import java.io.*;
import java.io.FilenameFilter;
import java.io.File;
import java.util.Calendar;
import javax.activation.*;
import java.util.Date;
import java.util.Vector;
import java.sql.*;
class auditDell850in extends Thread
{
public static final String archiveDir="z:\\dell\\850in\\archive";
File fdir;
Calendar cal1=Calendar.getInstance();
FilenameFilter filter=new extinFilter();
String[] ls;
boolean missingDir=false;
File fileIn;
File auditFile;
FileWriter out;
BufferedReader in;
String str;
String queryValue;
StringBuffer line=new StringBuffer(100);
String pono;
protected static Connection conn=null;
protected static Statement stmt=null;
boolean poMissing=false;
public void run()
{
fdir=new File(archiveDir);
if (!fdir.exists())
{
missingDir=true;
}
else if (!fdir.isDirectory()){
missingDir=true;
}
if ( missingDir ) {
System.out.println("Missing Directory:"+archiveDir);
System.exit(1);
}
auditFile= new File(archiveDir+"\\"+"check.txt"
;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
;
//conn=DriverManager.getConnection("jdbc
dbc:FairCom2"
;
conn=DriverManager.getConnection("jdbc
dbc:FairCom"
;
stmt=conn.createStatement();
ls = fdir.list(filter);
if (ls.length>0)
{
try
{
out = new FileWriter(auditFile);
for (int i=0; i<ls.length; i++ )
{
fileIn = new File(archiveDir+"\\"+ls);
in = new BufferedReader(new FileReader(fileIn));
while ((str=in.readLine()) != null)
{
if (str.startsWith("BEG"
)
{
pono=str.substring(10,21);
// System.out.println("Looking for PO:"+pono+" in Cove"
;
line=new StringBuffer(str.substring(10,21));
line= line.append("|"+ls);
// out.write(line+"\n"
;
// System.out.println(line);
////
//try
//{
queryValue="'" + pono + "'";
// stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM sohead WHERE PO_NO = "+queryValue);
//rs.next();
//String s=rs.getString("CODE"
;
//System.out.println(s);
//int numUpdated=stmt.executeUpdate("Update progstatus SET status='running' where programname = 'Dell997Loader'"
;
//System.out.println("Updated:"+numUpdated);
poMissing=true;
while (rs.next())
{
String s=rs.getString("PO_NO"
;
if (s.indexOf(pono) >-1 )
{
poMissing=false;
}
// String status=rs.getString("status"
;
//System.out.println("Found PO:"+s);
}
if ( poMissing )
{
line=line.append(" Missing"
;
}
out.write(line+"\n"
;
System.out.println(line);
//}
//catch (SQLException sqle) {System.err.println(sqle);
//}
} //if
} //while
in.close();
} //for
out.flush();
out.close();
conn.close();
} //try
catch (FileNotFoundException e ) {System.err.println(e);}
catch (IOException e) {System.err.println(e);}
}//if
}
catch (ClassNotFoundException cnfe) {System.err.println(cnfe);}
catch (SQLException sqle) {System.err.println(sqle);}
}
}
public class Dell850Audit
{
public static void main(String[] args)
{
System.out.println("Start Auditing Dell PO Status.."
;
Thread auditSession;
auditSession=new auditDell850in();
auditSession.start();
}
}
import java.io.*;
import java.io.FilenameFilter;
import java.io.File;
import java.util.Vector;
public class archiveDell850in
{
public static final String archiveDir="z:\\dell\\850in\\archive";
public static final String pipeChar="|";
public static void main(String[] args)
{
if ( args.length < 1 ) {
System.out.println("Usage: archiveDell850in <filename>"
;
System.exit(0);
}
Vector v = new Vector();
String s;
String str;
String destDir;
String archiveDirbyMonth;
File f=new File(archiveDir,args[0]); // outputfile produced by Dell850Audit
Object target;
File f1,f2 ;
String yy;
String month;
Integer mm;
int m;
if ( !f.exists() )
{
System.out.println("File Not Found: "+args[0]+" in "+archiveDir);
System.exit(1);
}
int i=-1;
try
{
BufferedReader in = new BufferedReader(new FileReader(f));
while ((str=in.readLine()) != null )
{
if (!str.endsWith("Missing"
)
{
i=str.indexOf(pipeChar);
if ( i > -1)
{
s = str.substring(++i);
target = (Object) s;
if ( v.indexOf(target) == -1 ) {
v.addElement(target);
f1 = new File(archiveDir,s);
if ( f1.exists() )
{
yy=s.substring(0,2);
month=s.substring(2,4);
mm = new Integer(month);
m = mm.intValue();
switch (m)
{
case 1 :
month="jan";
break;
case 2:
month="feb";
break;
case 3:
month="mar";
break;
case 4:
month="apr";
break;
case 5:
month="may";
break;
case 6:
month="jun";
break;
case 7:
month="jul";
break;
case 8:
month="aug";
break;
case 9:
month="sept";
break;
case 10:
month="oct";
break;
case 11:
month="nov";
break;
case 12:
month="dec";
break;
default:
System.out.println("No such month"
;
System.exit(1);
}
archiveDirbyMonth = (archiveDir + "\\"+month+yy);
f2 = new File(archiveDirbyMonth,s);
f1.renameTo(f2);
System.out.println("Move "+f1.getName()+ " To "+archiveDirbyMonth);
}
}
}
}
}
}
catch( IOException e )
{
System.err.println(e);
}
}
}
import java.io.FilenameFilter;
import java.io.File;
import java.util.Calendar;
import javax.activation.*;
import java.util.Date;
import java.util.Vector;
import java.sql.*;
class auditDell850in extends Thread
{
public static final String archiveDir="z:\\dell\\850in\\archive";
File fdir;
Calendar cal1=Calendar.getInstance();
FilenameFilter filter=new extinFilter();
String[] ls;
boolean missingDir=false;
File fileIn;
File auditFile;
FileWriter out;
BufferedReader in;
String str;
String queryValue;
StringBuffer line=new StringBuffer(100);
String pono;
protected static Connection conn=null;
protected static Statement stmt=null;
boolean poMissing=false;
public void run()
{
fdir=new File(archiveDir);
if (!fdir.exists())
{
missingDir=true;
}
else if (!fdir.isDirectory()){
missingDir=true;
}
if ( missingDir ) {
System.out.println("Missing Directory:"+archiveDir);
System.exit(1);
}
auditFile= new File(archiveDir+"\\"+"check.txt"
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"
//conn=DriverManager.getConnection("jdbc
conn=DriverManager.getConnection("jdbc
stmt=conn.createStatement();
ls = fdir.list(filter);
if (ls.length>0)
{
try
{
out = new FileWriter(auditFile);
for (int i=0; i<ls.length; i++ )
{
fileIn = new File(archiveDir+"\\"+ls);
in = new BufferedReader(new FileReader(fileIn));
while ((str=in.readLine()) != null)
{
if (str.startsWith("BEG"
{
pono=str.substring(10,21);
// System.out.println("Looking for PO:"+pono+" in Cove"
line=new StringBuffer(str.substring(10,21));
line= line.append("|"+ls);
// out.write(line+"\n"
// System.out.println(line);
////
//try
//{
queryValue="'" + pono + "'";
// stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM sohead WHERE PO_NO = "+queryValue);
//rs.next();
//String s=rs.getString("CODE"
//System.out.println(s);
//int numUpdated=stmt.executeUpdate("Update progstatus SET status='running' where programname = 'Dell997Loader'"
//System.out.println("Updated:"+numUpdated);
poMissing=true;
while (rs.next())
{
String s=rs.getString("PO_NO"
if (s.indexOf(pono) >-1 )
{
poMissing=false;
}
// String status=rs.getString("status"
//System.out.println("Found PO:"+s);
}
if ( poMissing )
{
line=line.append(" Missing"
}
out.write(line+"\n"
System.out.println(line);
//}
//catch (SQLException sqle) {System.err.println(sqle);
//}
} //if
} //while
in.close();
} //for
out.flush();
out.close();
conn.close();
} //try
catch (FileNotFoundException e ) {System.err.println(e);}
catch (IOException e) {System.err.println(e);}
}//if
}
catch (ClassNotFoundException cnfe) {System.err.println(cnfe);}
catch (SQLException sqle) {System.err.println(sqle);}
}
}
public class Dell850Audit
{
public static void main(String[] args)
{
System.out.println("Start Auditing Dell PO Status.."
Thread auditSession;
auditSession=new auditDell850in();
auditSession.start();
}
}
import java.io.*;
import java.io.FilenameFilter;
import java.io.File;
import java.util.Vector;
public class archiveDell850in
{
public static final String archiveDir="z:\\dell\\850in\\archive";
public static final String pipeChar="|";
public static void main(String[] args)
{
if ( args.length < 1 ) {
System.out.println("Usage: archiveDell850in <filename>"
System.exit(0);
}
Vector v = new Vector();
String s;
String str;
String destDir;
String archiveDirbyMonth;
File f=new File(archiveDir,args[0]); // outputfile produced by Dell850Audit
Object target;
File f1,f2 ;
String yy;
String month;
Integer mm;
int m;
if ( !f.exists() )
{
System.out.println("File Not Found: "+args[0]+" in "+archiveDir);
System.exit(1);
}
int i=-1;
try
{
BufferedReader in = new BufferedReader(new FileReader(f));
while ((str=in.readLine()) != null )
{
if (!str.endsWith("Missing"
{
i=str.indexOf(pipeChar);
if ( i > -1)
{
s = str.substring(++i);
target = (Object) s;
if ( v.indexOf(target) == -1 ) {
v.addElement(target);
f1 = new File(archiveDir,s);
if ( f1.exists() )
{
yy=s.substring(0,2);
month=s.substring(2,4);
mm = new Integer(month);
m = mm.intValue();
switch (m)
{
case 1 :
month="jan";
break;
case 2:
month="feb";
break;
case 3:
month="mar";
break;
case 4:
month="apr";
break;
case 5:
month="may";
break;
case 6:
month="jun";
break;
case 7:
month="jul";
break;
case 8:
month="aug";
break;
case 9:
month="sept";
break;
case 10:
month="oct";
break;
case 11:
month="nov";
break;
case 12:
month="dec";
break;
default:
System.out.println("No such month"
System.exit(1);
}
archiveDirbyMonth = (archiveDir + "\\"+month+yy);
f2 = new File(archiveDirbyMonth,s);
f1.renameTo(f2);
System.out.println("Move "+f1.getName()+ " To "+archiveDirbyMonth);
}
}
}
}
}
}
catch( IOException e )
{
System.err.println(e);
}
}
}