private bool InitService() { bool isInitDone = false; try { // Get Reader Group Details iReaderGroupID = int.Parse(ConfigurationManager.AppSettings["ReaderGroupID"]); ReaderGroupDA rdrGrpDataAccess = new ReaderGroupDA(); currentGroup = rdrGrpDataAccess.GetReaderGroup(iReaderGroupID); if (!int.TryParse(ConfigurationManager.AppSettings["PollCycle"], out pollCycle)) pollCycle = 10000; //ReaderPulseMonitor_InMin if (!int.TryParse(ConfigurationManager.AppSettings["ReaderPulseMonitor_InMin"], out readerPulseMonitor_InMin)) readerPulseMonitor_InMin = 30; // Initialize all readers Parallel.ForEach(currentGroup.Readers, rdr => { RFIDMotorolaReader rdrObject = null; try { rdrObject = new RFIDMotorolaReader(rdr, 1000, readerPulseMonitor_InMin); rdrObject.Connect(pollCycle, true); } catch { //Log Reader is offline } rdr.IsOnline = false; } lock (objLock) { dicReaders[rdr.ReaderId] = rdrObject; } }); monitoringTimer = new System.Timers.Timer(5000); monitoringTimer.Elapsed += MonitoringTimer_Elapsed; monitoringTimer.Start(); isInitDone = true; } catch (Exception ex) { isInitDone = false; LoggerAgent.Error("Error in init reader service.", ex); } finally { LoggerAgent.Trace("Leaving..."); } return isInitDone; }
public void LoadReaderGroups() { ReaderGroupDA rdrGrpDataObj = new ReaderGroupDA(); var dic = rdrGrpDataObj.GetAllReaderGroup(); lstReaderGroups = dic.ToDictionary(x => x.ReaderGroupID, x => x); dicReaderGrpEndpoints = lstReaderGroups.ToDictionary(x => x.Key, x => x.Value.ReaderWCFConnectionString); lstNodes.Clear(); GetReaderGroup(); frmMain.frmMainObj.RefreshReaderTreeVw(); }