public void RemoteCommandAsync(XDMExpress.Process.DeviceCommunicationProxy.RemoteCommandInstanceType remoteCommand) { //TdmServiceDeviceClient proxy = new TdmServiceDeviceClient(); if (remoteCommand != null) { TabControl tabControl = Application.OpenForms["frmTdmSimulator"].Controls.OfType <TabControl>().First(x => x.Name == "tabControl"); tabControl.Controls[1].Enabled = true; TextBox txtResult = tabControl.Controls[0].Controls.OfType <TextBox>().First(x => x.Name == "txtDetails"); txtResult.Enabled = true; XmlSerializer xsSubmit = new XmlSerializer(typeof(RemoteCommandInstanceType)); System.IO.StringWriter sww = new System.IO.StringWriter(); XmlWriter writer = XmlWriter.Create(sww); xsSubmit.Serialize(writer, remoteCommand); string text = sww.ToString(); txtResult.Text = text; } TdmServiceDeviceClient proxy = new TdmServiceDeviceClient(System.Configuration.ConfigurationManager.AppSettings["Endpoint"] as string); proxy.Endpoint.Behaviors.Add(new TestWcfDeviceService.Inspections.CustomBehavior()); RemoteCommandResultType result = new RemoteCommandResultType(); result.ID = remoteCommand.ID; result.InstanceID = remoteCommand.InstanceID; result.Message = "Command received"; result.Status = 2; proxy.RemoteCommandReply(result); //result = new RemoteCommandResultType(); //result.ID = remoteCommand.InstanceID; //result.InstanceID = Guid.NewGuid().ToString(); //result.Message = "In Progress"; //result.Status = 1; //proxy.RemoteCommandReply(result); //result = new RemoteCommandResultType(); //result.ID = remoteCommand.InstanceID; //result.InstanceID = Guid.NewGuid().ToString(); //result.Message = "Command Executed"; //result.Status = 2; //proxy.RemoteCommandReply(result); }
public void RemoteCommandAsync(XDMExpress.Process.DeviceCommunicationProxy.RemoteCommandInstanceType remoteCommand) { //TdmServiceDeviceClient proxy = new TdmServiceDeviceClient(); if (remoteCommand != null) { TabControl tabControl = Application.OpenForms["frmTdmSimulator"].Controls.OfType<TabControl>().First(x => x.Name == "tabControl"); tabControl.Controls[1].Enabled = true; TextBox txtResult = tabControl.Controls[0].Controls.OfType<TextBox>().First(x => x.Name == "txtDetails"); txtResult.Enabled = true; XmlSerializer xsSubmit = new XmlSerializer(typeof(RemoteCommandInstanceType)); System.IO.StringWriter sww = new System.IO.StringWriter(); XmlWriter writer = XmlWriter.Create(sww); xsSubmit.Serialize(writer, remoteCommand); string text = sww.ToString(); txtResult.Text = text; } TdmServiceDeviceClient proxy = new TdmServiceDeviceClient(System.Configuration.ConfigurationManager.AppSettings["Endpoint"] as string); proxy.Endpoint.Behaviors.Add(new TestWcfDeviceService.Inspections.CustomBehavior()); RemoteCommandResultType result = new RemoteCommandResultType(); result.ID = remoteCommand.ID; result.InstanceID = remoteCommand.InstanceID; result.Message = "Command received"; result.Status = 2; proxy.RemoteCommandReply(result); //result = new RemoteCommandResultType(); //result.ID = remoteCommand.InstanceID; //result.InstanceID = Guid.NewGuid().ToString(); //result.Message = "In Progress"; //result.Status = 1; //proxy.RemoteCommandReply(result); //result = new RemoteCommandResultType(); //result.ID = remoteCommand.InstanceID; //result.InstanceID = Guid.NewGuid().ToString(); //result.Message = "Command Executed"; //result.Status = 2; //proxy.RemoteCommandReply(result); }
public void RemoteCommandReply(RemoteCommandResultType RemoteCommandResultPackage) { base.Channel.RemoteCommandReply(RemoteCommandResultPackage); }
private void cmdRemoteCommandExecute_Click(object sender, EventArgs e) { List<DescribeDevicePackageType> describeDeviceColl = new List<DescribeDevicePackageType>(); List<RemoteCommandResultType> remoteCommandResltLst = new List<RemoteCommandResultType>(); for (int row = 0; row < dgvPendingRemoteCommands.Rows.Count; row++) { try { if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_CHK] != null && this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_CHK].Value != null && (bool)this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_CHK].Value == true && this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_ID].Value != null) { DescribeDevicePackageType describeDevice = new DescribeDevicePackageType(); if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DEVICEID].Value != null) { describeDevice.DeviceGUID = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DEVICEID].Value); } DeviceDescriptionType deviceDescriptionType = new DeviceDescriptionType(); if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DESC].Value != null) { deviceDescriptionType.Description = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DESC].Value); } deviceDescriptionType.DeviceGUID = describeDevice.DeviceGUID; if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_IP].Value != null) { deviceDescriptionType.IPAddress = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_IP].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_LOGICALID].Value != null) { deviceDescriptionType.LogicalDeviceID = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_LOGICALID].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MAC].Value != null) { deviceDescriptionType.MACAddress = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MAC].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MANF].Value != null) { deviceDescriptionType.Manufacturer = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MANF].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MODEL].Value != null) { deviceDescriptionType.Model = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_MODEL].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_SERIAL_NUMBER].Value != null) { deviceDescriptionType.SerialNumber = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_SERIAL_NUMBER].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_HOST].Value != null) { deviceDescriptionType.HostName = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_HOST].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_SW_VER].Value != null) { deviceDescriptionType.SoftwareVersion = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_SW_VER].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DEVICE_TYPE].Value != null) { deviceDescriptionType.Type = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_DEVICE_TYPE].Value); } describeDevice.DeviceDescription = deviceDescriptionType; DeviceStatusesType deviceStatusType = new DeviceStatusesType(); deviceStatusType.ServiceStatus = 0; deviceStatusType.Status = 4; deviceStatusType.StatusDate = DateTime.Now; describeDevice.DeviceStatus = deviceStatusType; describeDeviceColl.Add(describeDevice); RemoteCommandResultType resultType = new RemoteCommandResultType(); resultType.Status = 2; if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_ID].Value != null) { resultType.ID = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_ID].Value); } if (this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_INSTNCE_ID].Value != null) { resultType.InstanceID = Convert.ToString(this.dgvPendingRemoteCommands.Rows[row].Cells[GRD_RMCD_INSTNCE_ID].Value); } resultType.Message = "Reply send by simulator"; resultType.Status = 2; remoteCommandResltLst.Add(resultType); } } catch { } } //for (int i = 0; i < describeDeviceColl.Count; i++) //{ // RemoteCommandResultType _remoteCmdResult = new RemoteCommandResultType(); // _remoteCmdResult = remoteCommandResltLst[i]; // proxy.RemoteCommandReply(_remoteCmdResult); // DescribeDevicePackageType _describeDevicePkgType = new DescribeDevicePackageType(); // _describeDevicePkgType = describeDeviceColl[i]; // proxy.DescribeDevice(_describeDevicePkgType); //} try { int j = 0; foreach (var item in describeDeviceColl) { j = j + 1; Thread SenddescribeDevicePackageType = new Thread(() => { LogAndSendDescribeDevicePackage(item, "Thread" + j.ToString()); }); SenddescribeDevicePackageType.Name = "Thread" + j.ToString(); SenddescribeDevicePackageType.Start(); System.Threading.Thread.Sleep(20); } j = 0; foreach (var item in remoteCommandResltLst) { j = j + 1; Thread SendRemoteCommandResult = new Thread(() => { LogAndSendRemoteCommandReplyPackage(item, "Thread" + j.ToString()); }); SendRemoteCommandResult.Name = "Thread" + j.ToString(); SendRemoteCommandResult.Start(); System.Threading.Thread.Sleep(20); } } catch (Exception ex) { MessageBox.Show(ex.Message); } System.Threading.Thread.Sleep(4000); _ManualResetEvent.Set(); System.Threading.Thread.Sleep(4000); _ManualResetEvent.Reset(); }
public void LogAndSendRemoteCommandReplyPackage(RemoteCommandResultType _RemoteCommandResultType, string threadid) { _ManualResetEvent.WaitOne(); try { //DumpLogMessage(new LogMessage(_ComponentPackageType.DeviceGUID, "Started Device RemoteCommandReply for " + threadid + " @ " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"))); proxy.RemoteCommandReply(_RemoteCommandResultType); //DumpLogMessage(new LogMessage(_ComponentPackageType.DeviceGUID, "Ended Device RemoteCommandReply for " + threadid + " @ " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"))); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void HandleClient(TcpClient client) { _message.AppendLine("Getting local certificate"); X509Certificate certificate = new X509Certificate(GetCertificateName()); _message.AppendLine("received local certificate"); using (NetworkStream myNwStream = client.GetStream()) { BinaryFormatter formatter = new BinaryFormatter(); Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType Package = new Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType(); byte[] buffer = new byte[2048]; int bytes = -1; bytes = myNwStream.Read(buffer, 0, buffer.Length); MemoryStream ms = new MemoryStream(buffer); Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType mp = (Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType)formatter.Deserialize(ms); RemoteCommandResultType result = new RemoteCommandResultType(); result.ID = mp.ID; result.InstanceID = mp.InstanceID; result.Message = "Command received"; result.Status = 0; proxy.RemoteCommandReply(result); result = new RemoteCommandResultType(); result.ID = mp.ID; result.InstanceID = mp.InstanceID; result.Message = "In Progress"; result.Status = 1; proxy.RemoteCommandReply(result); result = new RemoteCommandResultType(); result.ID = mp.ID; result.InstanceID = mp.InstanceID; result.Message = "Command Executed"; result.Status = 2; proxy.RemoteCommandReply(result); ms.Close(); } //using (SslStream sslStream = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null)) //{ // sslStream.AuthenticateAsServer(certificate); // BinaryFormatter formatter = new BinaryFormatter(); // byte[] buffer = new byte[2048]; // int bytes = -1; // bytes = sslStream.Read(buffer, 0, buffer.Length); // if (bytes > 0) // { // _message.AppendLine(string.Format("Remote command received")); // MemoryStream ms = new MemoryStream(buffer); // Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType mp = (Xerox.XOS.RemoteDeviceManagement.RemoteCommandInstanceType)formatter.Deserialize(ms); // RemoteCommandResultType result = new RemoteCommandResultType(); // result.ID = mp.ID; // result.InstanceID = mp.InstanceID; // result.Message = "Command received"; // result.Status = 0; // proxy.RemoteCommandReply(result); // result = new RemoteCommandResultType(); // result.ID = mp.ID; // result.InstanceID = mp.InstanceID; // result.Message = "In Progress"; // result.Status = 1; // proxy.RemoteCommandReply(result); // result = new RemoteCommandResultType(); // result.ID = mp.ID; // result.InstanceID = mp.InstanceID; // result.Message = "Command Executed"; // result.Status = 2; // proxy.RemoteCommandReply(result); // ms.Close(); // _message.AppendLine(string.Format("Remote command reply has been called")); // } //} }