コード例 #1
0
 public void LogAndSendAlertPackage(AlertPackageType _AlertPackageType, string threadid)
 {
     _ManualResetEvent.WaitOne();
     try
     {
         //DumpLogMessage(new LogMessage(_ComponentPackageType.DeviceGUID, "Started Device Alert for " + threadid + " @ " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")));
         proxy.SendAlert(_AlertPackageType);
         //DumpLogMessage(new LogMessage(_ComponentPackageType.DeviceGUID, "Ended Device Alert for " + threadid + " @ " + System.DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt")));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
ファイル: wsdl.cs プロジェクト: pkb2917/TestWcfDeviceService
 public void SendAlert(AlertPackageType AlertPackage)
 {
     base.Channel.SendAlert(AlertPackage);
 }
コード例 #3
0
        private void SendSendAlertPackageForPerformance()
        {
            List<AlertPackageType> lstAlertPackageType = new List<AlertPackageType>();
            for (int i = 0; i <= nCurrentRow_SendAlert; i++)
            {
                if (this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_DEVICE_GUID].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_SNAPSHOT].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_ID].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_SERIAL_NO].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_DEVICE_TYPE].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_ALERT_REMOVED].Value != null &&
                    this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_MESSAGE].Value != null &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_DEVICE_GUID].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_SNAPSHOT].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_ID].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_SERIAL_NO].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_DEVICE_TYPE].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_ALERT_REMOVED].Value)) &&
                    !string.IsNullOrEmpty(Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_MESSAGE].Value)))
                {
                    AlertPackageType _alertPackageType = new AlertPackageType();
                    _alertPackageType.DeviceGUID = Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_DEVICE_GUID].Value);

                    DeviceStatusesType deviceStatusType = new DeviceStatusesType();
                    deviceStatusType.ServiceStatus = 1;
                    deviceStatusType.Status = 1;
                    deviceStatusType.StatusDate = DateTime.Now;

                    _alertPackageType.DeviceStatus = deviceStatusType;

                    RemoteAlertInstanceType _remoteAlertInstanceType = new RemoteAlertInstanceType();
                    _remoteAlertInstanceType.ComponentDeviceType = Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_DEVICE_TYPE].Value);
                    _remoteAlertInstanceType.ComponentSerialNumber = Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_COMPONENT_SERIAL_NO].Value);
                    _remoteAlertInstanceType.ID = Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_ID].Value);
                    _remoteAlertInstanceType.IsAlertRemoved = Convert.ToBoolean(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_ALERT_REMOVED].Value);
                    _remoteAlertInstanceType.Message = Convert.ToString(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_ALERT_MESSAGE].Value);
                    _alertPackageType.RemoteAlerts = new RemoteAlertsInstanceType();
                    _alertPackageType.RemoteAlerts.IsSnapShot = Convert.ToBoolean(this.dgv_Performance_SendAlert.Rows[i].Cells[GRD_IS_SNAPSHOT].Value);
                    _alertPackageType.RemoteAlerts.IsSnapShotSpecified = true;
                    _alertPackageType.RemoteAlerts.RemoteAlert = new RemoteAlertInstanceType[1];
                    _alertPackageType.RemoteAlerts.RemoteAlert[0] = _remoteAlertInstanceType;
                    try
                    {
                        lstAlertPackageType.Add(_alertPackageType);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return;
                    }
                }
            }

            try
            {
                int j = 0;
                foreach (var item in lstAlertPackageType)
                {
                    j = j + 1;
                    Thread SendAlertPackageType = new Thread(() => { proxy.SendAlert(item); });
                    SendAlertPackageType.Name = "Thread" + j.ToString();
                    SendAlertPackageType.Start();
                    System.Threading.Thread.Sleep(20);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            System.Threading.Thread.Sleep(2000);
            _ManualResetEvent.Set();
            System.Threading.Thread.Sleep(2000);
            _ManualResetEvent.Reset();
        }