private bool Validate() { bool status = true; if (ProtocolType.ToLower() != "tcp") { if (String.IsNullOrWhiteSpace(ucmod.txtRemoteIP.Text) || !Utils.IsValidIPv4(ucmod.txtRemoteIP.Text)) { ucmod.txtRemoteIP.Text = "0.0.0.0"; } if (String.IsNullOrWhiteSpace(ucmod.txtTCPPort.Text)) { ucmod.txtTCPPort.Text = "502"; } } //Check empty field's if (Utils.IsEmptyFields(ucmod.grpIED)) { MessageBox.Show("Fields cannot be empty!!!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //IED-UnitID should be unique... if (!IsUnitIDUnique(ucmod.txtUnitID.Text)) { MessageBox.Show("IED Unit ID must be unique!!!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //Check Remote IP... if (!Utils.IsValidIPv4(ucmod.txtRemoteIP.Text)) { MessageBox.Show("Invalid Remote IP.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } //Check TCP Port... if (!Utils.IsValidTCPPort(Int32.Parse(ucmod.txtTCPPort.Text))) { MessageBox.Show("Invalid TCP Port.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } return(status); }
private void refreshList() { int cnt = 0; ucmod.lvIEDList.Items.Clear(); //addListHeaders(); //Namrata: 25/11/2017 Utils.MODBUSMasteriedList.Clear(); foreach (IED ied in iedList) { string[] row = new string[7]; if (ied.IsNodeComment) { row[0] = "Comment..."; } else { row[0] = ied.UnitID; row[1] = ied.Device; if (ProtocolType.ToLower() == "tcp") { row[2] = ied.RemoteIP; row[3] = ied.TCPPort; } else { row[2] = "NA"; row[3] = "NA"; } row[4] = ied.Retries; row[5] = ied.TimeOutMS; row[6] = ied.Description; } ListViewItem lvItem = new ListViewItem(row); if (cnt++ % 2 == 0) { lvItem.BackColor = ColorTranslator.FromHtml(Globals.rowColour); } ucmod.lvIEDList.Items.Add(lvItem); } //Namrata: 20/11/2017 Utils.MODBUSMasteriedList.AddRange(iedList); }
public Boolean New_Session() { bool results = ParseProtocol(ProtocolType.ToLower()); SessionOptions sessionOptions = new SessionOptions { Protocol = protocol, //Protocol.Sftp, HostName = HostName, //hostname e.g. IP: 192.54.23.32, or mysftpsite.com UserName = UserName, Password = Password, PortNumber = PortNumber, SshHostKeyFingerprint = "ssh-rsa 2048 fa:cf:7d:2a:9d:bb:a0:92:11:22:02:5b:d4:21:2f:63" //test ftp }; session = new Session(); //global variable SessionStatus = true; LogData = string.Empty; //Session try { session.FileTransferred += OnFileTransferred; session.FileTransferProgress += OnFileTransferProgress; session.ExecutablePath = @"C:\Program Files\WinSCP\WinSCP.exe"; session.Open(sessionOptions); //TransferOptions transferOptions = new TransferOptions(); transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; transferOptions.FilePermissions = null; transferOptions.PreserveTimestamp = false; transferOptions.OverwriteMode = OverwriteMode.Overwrite; //transferOptions.ResmeSupport.State = TransferResumeSupportState.Off; } catch (Exception ex) { SessionStatus = false; } return(SessionStatus); }