Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pls combine two programs for me. new program name: AuditDell850.java

Status
Not open for further replies.

ansiboyd

MIS
Aug 14, 2002
1
US
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:eek:dbc:FairCom2");
conn=DriverManager.getConnection("jdbc:eek: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+&quot;\\&quot;+ls);

in = new BufferedReader(new FileReader(fileIn));

while ((str=in.readLine()) != null)
{
if (str.startsWith(&quot;BEG&quot;))
{
pono=str.substring(10,21);
// System.out.println(&quot;Looking for PO:&quot;+pono+&quot; in Cove&quot;);
line=new StringBuffer(str.substring(10,21));
line= line.append(&quot;|&quot;+ls);
// out.write(line+&quot;\n&quot;);
// System.out.println(line);
////

//try
//{
queryValue=&quot;'&quot; + pono + &quot;'&quot;;
// stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(&quot;SELECT * FROM sohead WHERE PO_NO = &quot;+queryValue);

//rs.next();
//String s=rs.getString(&quot;CODE&quot;);
//System.out.println(s);

//int numUpdated=stmt.executeUpdate(&quot;Update progstatus SET status='running' where programname = 'Dell997Loader'&quot;);
//System.out.println(&quot;Updated:&quot;+numUpdated);

poMissing=true;

while (rs.next())
{

String s=rs.getString(&quot;PO_NO&quot;);
if (s.indexOf(pono) >-1 )
{
poMissing=false;
}
// String status=rs.getString(&quot;status&quot;);
//System.out.println(&quot;Found PO:&quot;+s);
}

if ( poMissing )
{
line=line.append(&quot; Missing&quot;);
}

out.write(line+&quot;\n&quot;);
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(&quot;Start Auditing Dell PO Status..&quot;);
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=&quot;z:\\dell\\850in\\archive&quot;;
public static final String pipeChar=&quot;|&quot;;

public static void main(String[] args)
{
if ( args.length < 1 ) {
System.out.println(&quot;Usage: archiveDell850in <filename>&quot;);
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(&quot;File Not Found: &quot;+args[0]+&quot; in &quot;+archiveDir);
System.exit(1);
}

int i=-1;

try
{
BufferedReader in = new BufferedReader(new FileReader(f));

while ((str=in.readLine()) != null )
{
if (!str.endsWith(&quot;Missing&quot;))
{
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=&quot;jan&quot;;
break;
case 2:
month=&quot;feb&quot;;
break;
case 3:
month=&quot;mar&quot;;
break;
case 4:
month=&quot;apr&quot;;
break;
case 5:
month=&quot;may&quot;;
break;
case 6:
month=&quot;jun&quot;;
break;
case 7:
month=&quot;jul&quot;;
break;
case 8:
month=&quot;aug&quot;;
break;
case 9:
month=&quot;sept&quot;;
break;
case 10:
month=&quot;oct&quot;;
break;
case 11:
month=&quot;nov&quot;;
break;
case 12:
month=&quot;dec&quot;;
break;
default:
System.out.println(&quot;No such month&quot;);
System.exit(1);
}

archiveDirbyMonth = (archiveDir + &quot;\\&quot;+month+yy);


f2 = new File(archiveDirbyMonth,s);
f1.renameTo(f2);
System.out.println(&quot;Move &quot;+f1.getName()+ &quot; To &quot;+archiveDirbyMonth);
}
}
}
}
}
}
catch( IOException e )
{
System.err.println(e);
}
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top