private void ProcessToEmployeeCardSync(ActiveMachine Machine) { MachineManagerLazyInitializer manager = null; ActiveMachine _activeMachine = null; List <Employeecarddata> getEmpcards = oCommonUtilities.CreateInstance().GetEmployeeCardPollingData(); try { _activeMachine = Machine as ActiveMachine; List <Employeecarddata> cards = getEmpcards.Where(emp => emp.Installation_No == _activeMachine.Installation_No).ToList(); EmployeeMasterCard empcard = new EmployeeMasterCard(); List <Employeecarddata> lstEmpPolling = empcard._emppollingCollection; foreach (Employeecarddata data in lstEmpPolling) { if (data.Installation_No == _activeMachine.Installation_No) { if (data.PollingStatus) { _activeMachine.Status = "Success"; oCommonUtilities.CreateInstance().UpdateEmployeecardPolling(cards[0].EmployeeCard, _activeMachine.Installation_No); } else { _activeMachine.Status = "Failed"; } } } if (lstEmpPolling.Count == 0) { _activeMachine.Status = "Failed"; } } catch (Exception Ex) { LogManager.WriteLog("ProcessToEmployeeCardSync: " + Ex.Message, LogManager.enumLogLevel.Info); ExceptionManager.Publish(Ex); } finally { if (manager != null) { try { manager.ReleaseMachineManager(); manager = null; } catch (Exception Ex) { LogManager.WriteLog("ProcessToEmployeeCardSync:ReleaseMachineManager " + Ex.Message, LogManager.enumLogLevel.Info);; } } } }
protected override void OnStart(string[] args) { //System.Diagnostics.Debugger.Break(); LogManager.WriteLog(string.Format("Starting Service ({0:D}).", Process.GetCurrentProcess().Id), LogManager.enumLogLevel.Info); IsStopRequested = false; try { //Get the connection string. _strConnectionString = DBBuilder.GetConnectionString(); } catch (Exception ex) { ExceptionManager.Publish(ex); } // Initialize application settings (App.config, setting table, etc...) this.InitSettings(); //ENABLE DISABLE if (Convert.ToBoolean(ConfigManager.Read("MachineConfig")) == true) { _EnableDisable = new EnableDisable(); } //TITO if (Convert.ToBoolean(ConfigManager.Read("TITO")) == true) { _TITO = new TITO(); } //AFTEnableDisable if (Convert.ToBoolean(ConfigManager.Read("AFTEnableDisable")) == true) { _enableDisableAFT = new AFTEnableDisable(); } //Employee Master card broadcast if (Convert.ToBoolean(ConfigManager.Read("EmployeecardBroadcast")) == true) { _empMastercard = new EmployeeMasterCard(); } //Instant Periodic Interval if (Convert.ToBoolean(ConfigManager.Read("InstantPeriodic")) == true) { _instantPeriodicInterval = new InstantPeriodicIntervalHandler(); } //Request/Response Wait Configuration NetworkServiceSettings.RequestWaitTime = Convert.ToInt32(ConfigManager.Read("RequestWaitMilliSeconds")); NetworkServiceSettings.DBHitWaitTime = Convert.ToInt32(ConfigManager.Read("DBHitWaitMilliSeconds")); LogManager.WriteLog("Started Service Successfully.", LogManager.enumLogLevel.Info); }