}//end of create_xml public void create_xml(string s, bool incontrol, string inxml_file_name, string sys_id) { DataSet ds_insertDB = new DataSet(); string sysid = sys_id, xml_file_name = ""; ArrayList element = new ArrayList(); ArrayList element_text = new ArrayList(); DirectoryInfo di = new DirectoryInfo(Server.MapPath(".") + "\\File\\" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString()); if (!di.Exists) { di.Create(); } /* * if( fi.Exists == true ) * { * sw = File.AppendText(Server.MapPath(".") + "\\log\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + DateTime.Now.ToString("yyyyMMdd") +".log"); * } * //*/ file xmlw = new file(); element.Add("EVENTID"); element_text.Add("AlarmReport"); element.Add("SYSTEMID"); element_text.Add(sysid); element.Add("EQPID"); element_text.Add(inxml_file_name); element.Add("ALARMID"); element_text.Add("MSG"); element.Add("ALARMTEXT"); element_text.Add(s); xml_file_name = sysid + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + inxml_file_name + ".xml"; // xmlw.Alarm_create_xml(Server.MapPath(".") + "\\File\\" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString(), xml_file_name, element, element_text); if (incontrol == true) { FTPFactory ff = new FTPFactory(); ff.setDebug(true); ff.setRemoteHost("172.16.12.78"); ff.setRemoteUser("CIMFTP"); ff.setRemotePass("ALCS_cim13579"); ff.login(); try { ff.upload(Server.MapPath(".") + "\\File\\" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString() + "/" + xml_file_name); sp.Send_mail("File Upload Success", "CIM CENTRAL MAIL SYSTEM<*****@*****.**>", "*****@*****.**", "", "[ARRAY_PH_WIP_Status]" + inxml_file_name + "-XML File Upload ALCS Success", 0, null); sw.WriteLine(DateTime.Now.ToString("u") + " " + inxml_file_name + " File Upload Success"); } catch (Exception ex) { sp.Send_mail("File Upload Fail" + ex.Message, "CIM CENTRAL MAIL SYSTEM<*****@*****.**>", "*****@*****.**", "[ARRAY_PH_WIP_Status]" + inxml_file_name + "-XML File Upload ALCS Fail", 0, null); sw.WriteLine(DateTime.Now.ToString("u") + " " + inxml_file_name + " File Upload Fail"); } } }//end of create_xml
}//end of create_xml private void create_xml(string s, bool incontrol, string inxml_file_name, string inUser_ID) { DataSet ds_insertDB = new DataSet(); string sysid = "ARY_HOLD_LOT", xml_file_name = ""; ArrayList element = new ArrayList(); ArrayList element_text = new ArrayList(); DirectoryInfo di = new DirectoryInfo(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString()); if (!di.Exists) { di.Create(); } file xmlw = new file(); element.Add("EVENTID"); element_text.Add("AlarmReport"); element.Add("SYSTEMID"); element_text.Add(sysid); element.Add("EQPID"); element_text.Add(inxml_file_name); element.Add("ALARMID"); element_text.Add("MSG"); element.Add("ALARMTEXT"); element_text.Add(s); xml_file_name = sysid + "_" + DateTime.Now.ToString("yyyyMMdd") + "_" + inxml_file_name + ".xml"; xmlw.Create_ALCS_xml(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString(), xml_file_name, element, element_text); if (incontrol == true) { FTPFactory ff = new FTPFactory(); ff.setDebug(true); ff.setRemoteHost("172.16.12.78"); ff.setRemoteUser("CIMFTP"); ff.setRemotePass("ALCS_cim13579"); ff.login(); try { ff.upload(Server.MapPath(".") + "/" + DateTime.Now.ToString("yyyyMMdd") + "_ALCS_" + DateTime.Now.Hour.ToString() + "/" + xml_file_name); //sp.Send_mail("File Upload Success","CIM CENTRAL MAIL SYSTEM<*****@*****.**>","*****@*****.**","[Array Hold Lot] XML File Upload ALCS Success",1,Server.MapPath(".")+"/"+ DateTime.Now.ToString("yyyyMMdd")+"_ALCS_" + DateTime.Now.Hour.ToString() + "/" + xml_file_name); string insertDB_phone = " begin insert into std_alarm_event_history@ods2stdman ( SYSTEM,TYPE,USER_ID,USER_LEVEL,PHONE_DTTM ) " + " values('Array_Hold_Lot','PHONE','" + inUser_ID + "','" + inxml_file_name + "',sysdate); commit; end;"; ds_insertDB = db.GetDataset(insertDB_phone, 1); } catch (Exception ex) { //sp.Send_mail("File Upload Fail"+ex.Message,"CIM CENTRAL MAIL SYSTEM<*****@*****.**>","*****@*****.**","[CIM REPORT MSG] :WeekendReport MSG:XML File Upload ALCS Fail",0,null); sp.Send_mail("File Upload Fail" + ex.Message, "CIM CENTRAL MAIL SYSTEM<*****@*****.**>", "*****@*****.**", "[Array Hold Lot] XML File Upload ALCS Fail", 0, null); } } }
public void Ftp_upload(string setRemoteHost, string setRemoteUser, string setRemotePass, string dir, string file_path) { FTPFactory ff = new FTPFactory(); ff.setRemoteHost(setRemoteHost); ff.setRemoteUser(setRemoteUser); ff.setRemotePass(setRemotePass); ff.login(); ff.chdir(dir); ff.setBinaryMode(true); ff.upload(file_path); ff.close(); }
static void Main(string[] args) { Console.WriteLine("This upload tester is fully automatic."); Console.WriteLine("Please wait for a line saying \"press [enter] to exit\""); Console.WriteLine(" "); FTPFactory ff = null; try { Console.WriteLine("Starting..."); ff = new FTPFactory(); ff.setDebug(true); ff.setRemoteHost("ftp.twofour.co.uk"); ff.setRemoteUser("ftp_bbcws"); ff.setRemotePass("Tw0four"); ff.ListMode = DirectoryListMode.PlatformList; ff.login(); Console.WriteLine(" ... I think I'm at: " + ff.pwd()); ff.ensureRemotePath("/test/test/", false); ff.chdir("/test/test/"); ff.ListMode = DirectoryListMode.NameList; string[] fileNames = ff.getFileList("*"); for (int i = 0; i < fileNames.Length; i++) { Console.WriteLine(fileNames[i]); } ff.setBinaryMode(true); try { ff.PassiveMode = false; ff.upload(@"C:\temp\test.txt"); Console.WriteLine("Uploaded Active"); } catch { ff.PassiveMode = true; ff.upload(@"C:\temp\test.txt"); Console.WriteLine("Uploaded Passive"); } try { ff.ShouldOverwrite = true; try { ff.PassiveMode = false; ff.upload(@"C:\temp\test2.txt"); ff.upload(@"C:\temp\test.txt", @"test2.txt", false); Console.WriteLine("Over-write: Uploaded Active"); } catch { ff.PassiveMode = true; ff.upload(@"C:\temp\test2.txt"); ff.upload(@"C:\temp\test.txt", @"test2.txt", false); Console.WriteLine("Over-write: Uploaded Passive"); } } catch { Console.WriteLine("Over-write DIDN'T work"); } try { ff.PassiveMode = false; ff.download("test.txt", @"C:\temp\test_result.txt"); Console.WriteLine("Downloaded Active"); } catch { ff.PassiveMode = true; ff.download("test.txt", @"C:\temp\test_result.txt"); Console.WriteLine("Downloaded Active"); } ff.close(); } catch (Exception e) { Console.WriteLine("Caught Error: " + e.Message); } Console.WriteLine(" "); Console.WriteLine("PRESS [ENTER] TO EXIT"); Console.ReadLine(); }
public override async Task <bool> Reserve(reserve reserve) { FTPFactory fTPFactory = InstanceFTPFactory(reserve.provider_id); return(await fTPFactory.Reserve(reserve)); }
private List <HistoricalOutput> GetHistoricalOutputs() { List <HistoricalOutput> historicalOutputs = new List <HistoricalOutput>(); try { foreach (HistoricalOutputElement element in HistoricalOutputConfiguration.GetConfigurationFromFile()) { if (element.FTPType == "SFTP") { historicalOutputs.Add(new HistoricalOutput(element.Name, element.FTPType, element.Directory, FTPFactory.CreateFTP(new FTPBuilder(element.FTPType, element.Host, element.Port, element.Username, Password.Decrypt(element.Password), element.PSFTPPath, element.BatchFilePath)))); Console.WriteLine("Added {0} historical outputs (SFTP).", historicalOutputs.Count); } else if (element.FTPType == "FTPS") { historicalOutputs.Add(new HistoricalOutput(element.Name, element.FTPType, element.Directory, FTPFactory.CreateFTP(new FTPBuilder(element.FTPType, element.Host, element.Port, element.Username, Password.Decrypt(element.Password))))); Console.WriteLine("Added {0} historical outputs (FTPS).", historicalOutputs.Count); } else { historicalOutputs.Add(new HistoricalOutput(element.Name, element.FTPType, element.Directory, FTPFactory.CreateFTP(new FTPBuilder(element.FTPType, element.Host, element.Port, element.Username, Password.Decrypt(element.Password))))); Console.WriteLine("Added {0} historical outputs.", historicalOutputs.Count); } } } catch (Exception exception) { MessageBox.Show(exception.Message, "FTP Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(historicalOutputs); }