public ResultObject ModifyReader(ReaderInfo objReaderInfo) { ResultObject objRes = new ResultObject(); objRes.MethodInfo = "ReaderService.ModifyReader "; try { //param validation if (objReaderInfo == null) { objRes.IsSuccess = false; objRes.ErrorMessage = "ModifyReader Error : Invalid ReaderInfo object supplied."; objRes.ErrorMessageInternal = string.Empty; objRes.TimeStampString = DateTime.Now.ToString(); return objRes; } if (objReaderInfo.ReaderId <= 0) { objRes.IsSuccess = false; objRes.ErrorMessage = "ModifyReader Error : ReaderId is invalid. Invalid ReaderInfo object supplied."; objRes.ErrorMessageInternal = string.Empty; objRes.TimeStampString = DateTime.Now.ToString(); return objRes; } ReaderDA objReaderDA = new ReaderDA(); objRes = objReaderDA.ModifyReader(objReaderInfo); } catch (Exception ex) { objRes.IsSuccess = false; objRes.ErrorMessage = "Failed to modify reader " + objReaderInfo.ReaderId.ToString(); objRes.ErrorMessageInternal = "Error : " + ex.ToString(); } objRes.TimeStampString = DateTime.Now.ToString(); //reset the methodinfo objRes.MethodInfo = "ReaderService.ModifyReader "; LoggerAgent.Info("Result status = " + ResultObject.GetLogString(objRes)); LoggerAgent.Trace("Leaving..."); return objRes; }
public ResultObject AddReader(ReaderInfo objReaderInfo) { lock (objLock) { LoggerAgent.Trace("Entering..."); ResultObject objRes = new ResultObject(); objRes.MethodInfo = "ReaderService.AddReader "; try { // -- Adding reader to DB ---- ReaderDA objReaderDA = new ReaderDA(); objRes = objReaderDA.AddReader(objReaderInfo); if (objRes.IsSuccess == false) { return objRes; } // --- Connecting to actual reader --- RFIDMotorolaReader rdrObject = null; try { rdrObject = new RFIDMotorolaReader(objReaderInfo, 1000, readerPulseMonitor_InMin); objRes.IsSuccess = rdrObject.Connect(pollCycle, true); } catch (Exception ex) { objRes.IsSuccess = false; objRes.ErrorMessage = "Unable to connect to Reader. IP Address " + objReaderInfo.IPAddress; objRes.ErrorMessageInternal = "Error : " + ex.ToString(); } //Reader-Service collection will cache actual reader. dicReaders[objReaderInfo.ReaderId] = rdrObject; //Set result object: - /*set online status*/ objReaderInfo.IsOnline = objRes.IsSuccess; //Set readerInfo in result object // NOTE: ReaderId key is already SET by DAL call. // objRes.ResultData["ReaderInfo"] = objReaderInfo; objRes.MethodInfo = "ReaderService.AddReader "; objRes.TimeStampString = DateTime.Now.ToString(); LoggerAgent.Debug("Reader status: " + " Reader IP:Port = " + rdrObject.ReaderInfo.IPAddress + ":" + rdrObject.ReaderInfo.PortNo.ToString() + ", IsOnline = " + rdrObject.ReaderInfo.IsOnline.ToString() ); } catch (Exception ex) { objRes.IsSuccess = false; objRes.ErrorMessage = "Unable to Add Reader. IP Address " + objReaderInfo.IPAddress; objRes.ErrorMessageInternal = "Error : " + ex.ToString(); LoggerAgent.Error("Error : Failed to AddReader. " + objRes.ErrorMessage, ex); } finally { LoggerAgent.Trace("Leaving..."); } LoggerAgent.Info("Result status = " + ResultObject.GetLogString(objRes)); return objRes; } }
private void ProcessTags(string tagIdsWithCommas) { try { string readerTypeBL = string.Empty; ReaderDA objReaderDA = new ReaderDA(); objReaderDA.ExeSP(this.ReaderInfo.ReaderId, tagIdsWithCommas); } catch(Exception ex) { LoggerAgent.Fatal("Failed to save reader tag info into database, ProcessTags failed to exeSP.", ex); } }