private void btnDownload_Click(object sender, EventArgs e) { var client = new AgentSvcClient(); try { var stream = client.DownloadConfig(sessionID, new ConfigOptions()); if (stream == null) { MessageBox.Show(@"Download stream is null."); } else { var t0 = DateTime.UtcNow; var buf = new byte[1024]; using (var fileStream = File.Open(DefConfigArc, FileMode.Create, FileAccess.Write, FileShare.Read)) { stream.CopyTo(fileStream); } stream.Dispose(); MessageBox.Show(@"Done in " + (int)(DateTime.UtcNow - t0).TotalMilliseconds + @" ms"); } } finally { client.Close(); } }
private void btnCreateSession_Click(object sender, EventArgs e) { var client = new AgentSvcClient(); try { if (client.CreateSession(out sessionID)) { MessageBox.Show(@"Session created: " + sessionID); string encPwd = CryptoUtils.EncryptPassword("12345", sessionID, ScadaUtils.HexToBytes(SecretKey)); if (client.Login(sessionID, "admin", encPwd, "Default", out string errMsg)) { MessageBox.Show(@"Logged on."); } else { MessageBox.Show(errMsg); } } else { MessageBox.Show(@"Unable to create session."); } } finally { client.Close(); } }
private void button1_Click(object sender, System.EventArgs e) { AgentSvcClient client = new AgentSvcClient(); double sum = client.Sum(2, 2); client.Close(); MessageBox.Show(sum.ToString()); }
private void btnUpload_Click(object sender, EventArgs e) { var client = new AgentSvcClient(); try { var t0 = DateTime.UtcNow; using (var fileStream = File.Open(DefConfigArc, FileMode.Open, FileAccess.Read, FileShare.Read)) { client.UploadConfig(new ConfigOptions(), sessionID, fileStream); } MessageBox.Show(@"Done in " + (int)(DateTime.UtcNow - t0).TotalMilliseconds + @" ms"); } finally { client.Close(); } }