public static bool Connect(bool OfflineMode = false) { bool result = false; try { FTPFile = IBMiUtils.GetLocalFile("QTEMP", "FTPLOG", DateTime.Now.ToString("MMddTHHmm"), "txt"); FtpTrace.AddListener(new TextWriterTraceListener(FTPFile)); FtpTrace.LogUserName = false; // hide FTP user names FtpTrace.LogPassword = false; // hide FTP passwords FtpTrace.LogIP = false; // hide FTP server IP addresses string password = Password.Decode(CurrentSystem.GetValue("password")); Client = new FtpClient(CurrentSystem.GetValue("system"), CurrentSystem.GetValue("username"), password); if (OfflineMode == false) { Client.UploadDataType = FtpDataType.ASCII; Client.DownloadDataType = FtpDataType.ASCII; //FTPES is configurable if (IBMi.CurrentSystem.GetValue("useFTPES") == "true") { Client.EncryptionMode = FtpEncryptionMode.Explicit; } //Client.DataConnectionType = FtpDataConnectionType.AutoPassive; //THIS IS THE DEFAULT VALUE Client.DataConnectionType = GetFtpDataConnectionType(CurrentSystem.GetValue("transferMode")); Client.SocketKeepAlive = true; Client.ConnectTimeout = 5000; Client.Connect(); //Change the user library list on connection RemoteCommand($"CHGLIBL LIBL({ CurrentSystem.GetValue("datalibl").Replace(',', ' ')}) CURLIB({ CurrentSystem.GetValue("curlib") })"); System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 60000; timer.Elapsed += new ElapsedEventHandler(KeepAliveFunc); timer.Start(); } result = true; } catch (Exception e) { MessageBox.Show("Unable to connect to " + CurrentSystem.GetValue("system") + " - " + e.Message, "Cannot Connect", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }
public static bool Connect(bool OfflineMode = false, string promptedPassword = "") { string[] remoteSystem; bool result = false; try { string password = ""; remoteSystem = IBMi.CurrentSystem.GetValue("system").Split(':'); if (promptedPassword == "") { password = Password.Decode(IBMi.CurrentSystem.GetValue("password")); } else { password = promptedPassword; } ClientDDM = DDMConnection.getConnection(remoteSystem[0], IBMi.CurrentSystem.GetValue("username"), password); result = true; if (OfflineMode == false) { // Ignore result as a new system may not have library list set correctly // We can store status if required. RemoteCommand($"CHGLIBL LIBL({ IBMi.CurrentSystem.GetValue("datalibl").Replace(',', ' ')}) CURLIB({ IBMi.CurrentSystem.GetValue("curlib") })", false); } } catch (Exception e) { MessageBox.Show("Unable to connect to " + IBMi.CurrentSystem.GetValue("system") + " - " + e.Message, "Cannot Connect", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } return(result); }
public static bool Connect() { bool result = false; try { string password = Password.Decode(CurrentSystem.GetValue("password")); Client = new FtpClient(CurrentSystem.GetValue("system"), CurrentSystem.GetValue("username"), password); Client.UploadDataType = FtpDataType.ASCII; Client.DownloadDataType = FtpDataType.ASCII; //FTPES is configurable if (IBMi.CurrentSystem.GetValue("useFTPES") == "true") { Client.EncryptionMode = FtpEncryptionMode.Explicit; } Client.ConnectTimeout = 5000; Client.Connect(); //Change the user library list on connection if (IBMi.CurrentSystem.GetValue("useuserlibl") != "true") { RemoteCommand($"CHGLIBL LIBL({ CurrentSystem.GetValue("datalibl").Replace(',', ' ')}) CURLIB({ CurrentSystem.GetValue("curlib") })"); } result = true; } catch (Exception e) { MessageBox.Show("Unable to connect to " + CurrentSystem.GetValue("system") + " - " + e.Message, "Cannot Connect", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(result); }