Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            foreach (DataGridViewRow irow in grdDataSync.Rows)
            {
                string ipAddress = irow.Cells[1].Value.ToString();
                string port      = irow.Cells[2].Value.ToString();
                irow.Cells[3].Value = machineData.CheckingConnectionStatus(ipAddress, port);
                // machineData.CheckingConnectionStatus(ipAddress, port);
            }

            btnPushData.Enabled = true;
            Cursor.Current      = Cursors.Default;
        }
Пример #2
0
        private void cmdCheck_Click(object sender, EventArgs e)
        {
            if (rdoMachineStatus.Checked)
            {
                richTextBox1.Text = "Please wait while checking status.......";

                IList <DeviceEntity> deviceEntities = deviceBLL.GetDynamic(" Where isActive=1", "");
                IList <DeviceEntity> deviceOnline   = new List <Entity.DeviceEntity>();
                string Error = string.Empty;
                #region Variables
                string   machineId = string.Empty;
                string   status    = string.Empty;
                string   ipAddress = string.Empty;
                int      port      = 0;
                DateTime dtFrom    = DateTime.Now;
                DateTime dtTo      = DateTime.Now;
                #endregion

                foreach (DeviceEntity deviceEntity in deviceEntities)
                {
                    machineId = deviceEntity.MachineId.ToString();
                    ipAddress = deviceEntity.IpAddress.ToString();
                    port      = int.Parse(deviceEntity.Port.ToString());
                    dtFrom    = DateTime.Now;
                    dtTo      = DateTime.Now;

                    status = machineData.CheckingConnectionStatus(ipAddress, port.ToString());
                    richTextBox1.AppendText("\r\n" + ipAddress + " : " + status);
                    richTextBox1.ScrollToCaret();
                }
            }
        }
Пример #3
0
        private void StartAttandanceService()
        {
            IList <DeviceEntity> deviceEntities = deviceBLL.GetDynamic(" Where isActive=1", "");
            IList <DeviceEntity> deviceOnline   = new List <DeviceEntity>();
            string Error = string.Empty;

            #region Variables
            string   machineId = string.Empty;
            string   status    = string.Empty;
            string   ipAddress = string.Empty;
            int      port      = 0;
            DateTime dtFrom    = DateTime.Now;
            DateTime dtTo      = DateTime.Now;
            #endregion
            foreach (DeviceEntity deviceEntity in deviceEntities)
            {
                machineId = deviceEntity.MachineId.ToString();
                ipAddress = deviceEntity.IpAddress.ToString();
                port      = int.Parse(deviceEntity.Port.ToString());
                dtFrom    = DateTime.Now;
                dtTo      = DateTime.Now;

                status = machineData.CheckingConnectionStatus(ipAddress, port.ToString());
                if (status != "Device Is Online")
                {
                    using (TextWriter tw = new StreamWriter("Error_" + DateTime.Now.ToString("yyyyMMddhh") + ".dat", true))
                    {
                        tw.WriteLine(status);
                    }
                }
                else
                {
                    deviceOnline.Add(deviceEntity);
                }
            }
            foreach (DeviceEntity deviceEntity in deviceOnline)
            {
                machineId = deviceEntity.MachineId.ToString();
                ipAddress = deviceEntity.IpAddress.ToString();
                port      = int.Parse(deviceEntity.Port.ToString());
                dtFrom    = DateTime.Now;
                dtTo      = DateTime.Now;

                Error = machineData.StartService(machineId, ipAddress, port, dtFrom, dtTo, "Device Is Online");
                if (Error == "Successfull")
                {
                    //Text File write
                }
                else
                {
                    using (TextWriter tw = new StreamWriter("Error" + DateTime.Now.ToString("yyyyMMddhh") + ".txt", true))
                    {
                        tw.WriteLine(Error);
                    }
                }
            }
        }
Пример #4
0
        private void StartAttandanceService(string _Zid)
        {
            try
            {
                IList <DeviceEntity> deviceEntities = deviceBLL.GetDynamic(" Where isActive=1 and Zid='" + _Zid + "'", "");
                IList <DeviceEntity> deviceOnline   = new List <DeviceEntity>();
                string FileLocation = ConfigurationManager.AppSettings["FileLocation"].ToString();
                string Error        = string.Empty;
                #region Variables
                string   machineId = string.Empty;
                string   status    = string.Empty;
                string   ipAddress = string.Empty;
                int      port      = 0;
                DateTime dtFrom    = DateTime.Now;
                DateTime dtTo      = DateTime.Now;
                #endregion
                foreach (DeviceEntity deviceEntity in deviceEntities)
                {
                    machineId = deviceEntity.MachineId.ToString();
                    ipAddress = deviceEntity.IpAddress.ToString();
                    port      = int.Parse(deviceEntity.Port.ToString());
                    dtFrom    = DateTime.Now;
                    dtTo      = DateTime.Now;

                    status = machineData.CheckingConnectionStatus(ipAddress, port.ToString());
                    if (status != "Device Is Online")
                    {
                        using (TextWriter tw = new StreamWriter(FileLocation + "Error_" + DateTime.Now.ToString("yyyyMMdd") + ".dat", true))
                        {
                            tw.WriteLine(status);
                        }
                    }
                    else
                    {
                        deviceOnline.Add(deviceEntity);
                    }
                }
                foreach (DeviceEntity deviceEntity in deviceOnline)
                {
                    machineId = deviceEntity.MachineId.ToString();
                    ipAddress = deviceEntity.IpAddress.ToString();
                    port      = int.Parse(deviceEntity.Port.ToString());
                    dtFrom    = DateTime.Now;
                    dtTo      = DateTime.Now;

                    Error = machineData.StartService(machineId, ipAddress, port, dtFrom, dtTo, "Device Is Online");
                    if (Error == "Successfull")
                    {
                        //Text File write
                    }
                    else
                    {
                        using (TextWriter tw = new StreamWriter(FileLocation + "Error_" + DateTime.Now.ToString("yyyyMMdd") + ".dat", true))
                        {
                            tw.WriteLine(Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string _FileLocation = ConfigurationManager.AppSettings["FileLocation"].ToString();
                string _Error        = string.Empty;
                using (TextWriter tw = new StreamWriter(_FileLocation + "TaskSceduleError_" + DateTime.Now.ToString("yyyyMMdd") + ".dat", true))
                {
                    tw.WriteLine(_Error);
                }
            }
            finally
            {
                Application.Exit();
            }
        }