public void TITOProcessResponse(BMC.Business.NetworkService.TITOThreadDataResponse threadData) { lock (_lockRes) { if (dTITORequest.Count <= 0) { return; } } try { if (mEvent.WaitOne(NetworkServiceSettings.DBHitWaitTime)) { return; } lock (_lockRes) { if (dTITORequest.ContainsKey(threadData.MessageID)) { TITOThreadDataRequest Requestitem = dTITORequest[threadData.MessageID]; //Update DB and remove from both lists if (threadData.Ack == true) { int EnableCommand = Requestitem.Command == eCommand.Enable ? 1 : 0; DBBuilder.UpdatedTITOConfig(Requestitem.InstallationNo, Requestitem.SiteTITOEnabled, Requestitem.SiteNonCashEnabled, Requestitem.MachineTITOEnabled, Requestitem.MachineNonCashEnabled, EnableCommand); LogManager.WriteLog("TITOProcessResponse | ACK Received For Installation: " + Requestitem.InstallationNo.ToString() + ", Command: " + Requestitem.Command.ToString(), LogManager.enumLogLevel.Info); } else { LogManager.WriteLog("TITOProcessResponse | NACK Received For Installation: " + Requestitem.InstallationNo.ToString() + ", Command: " + Requestitem.Command.ToString(), LogManager.enumLogLevel.Info); } dTITORequest.Remove(threadData.MessageID); } } } catch (Exception ex) { LogManager.WriteLog("TITOProcessResponse | Exception Occured." + ex.Message, LogManager.enumLogLevel.Info); ExceptionManager.Publish(ex); } }
/// <summary> /// Entry Method for Enable/Disable Machines /// </summary> private void TITOConfig() { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { return; } try { DataTable getTITOConig; getTITOConig = DBBuilder.GetTITOConfig(); int TickerExpire = Convert.ToInt32(DBBuilder.GetSettingFromDB("TICKET_EXPIRE", "10")); LogManager.WriteLog("TITOConfig | Number of Installation to Process: " + getTITOConig.Rows.Count.ToString() , LogManager.enumLogLevel.Info); if (getTITOConig.Rows.Count > 0) { foreach (DataRow row in getTITOConig.Rows) { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { break; } TITOThreadDataRequest threadData = new TITOThreadDataRequest() { InstallationNo = Convert.ToInt32(row["Installation_No"]), TITOEnabled = Convert.ToInt32(row["TITOEnabled"]), SiteTITOEnabled = Convert.ToInt32(row["SiteTITOEnabled"]), SiteNonCashEnabled = Convert.ToInt32(row["SiteNonCashEnabled"]), MachineTITOEnabled = Convert.ToInt32(row["MachineTITOEnabled"]), MachineNonCashEnabled = Convert.ToInt32(row["MachineNonCashEnabled"]), TicketExpireDays = TickerExpire, }; if (threadData.TITOEnabled == 1) { threadData.Command = eCommand.Enable; int nMessageID; nMessageID = EnableTITO(threadData.InstallationNo); if (!dTITORequest.ContainsKey(nMessageID)) dTITORequest.Add(nMessageID, threadData); LogManager.WriteLog("TITOConfig | Request for Installation: " + threadData.InstallationNo.ToString() + " , Command:" + threadData.Command.ToString() + " , MessageID:" + nMessageID.ToString(), LogManager.enumLogLevel.Info); } else { threadData.Command = eCommand.Disable; int nMessageID; nMessageID = DisableTITO(threadData.InstallationNo); if (!dTITORequest.ContainsKey(nMessageID)) dTITORequest.Add(nMessageID, threadData); LogManager.WriteLog("TITOConfig | Request for Installation: " + threadData.InstallationNo.ToString() + " , Command:" + threadData.Command.ToString() + " , MessageID:" + nMessageID.ToString(), LogManager.enumLogLevel.Info); } } } } catch (Exception Ex) { LogManager.WriteLog("TITOConfig Error " + Ex.Message, LogManager.enumLogLevel.Info); ExceptionManager.Publish(Ex); } }
/// <summary> /// Entry Method for Enable/Disable Machines /// </summary> private void TITOConfig() { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { return; } try { DataTable getTITOConig; getTITOConig = DBBuilder.GetTITOConfig(); int TickerExpire = Convert.ToInt32(DBBuilder.GetSettingFromDB("TICKET_EXPIRE", "10")); LogManager.WriteLog("TITOConfig | Number of Installation to Process: " + getTITOConig.Rows.Count.ToString() , LogManager.enumLogLevel.Info); if (getTITOConig.Rows.Count > 0) { foreach (DataRow row in getTITOConig.Rows) { if (mEvent.WaitOne(NetworkServiceSettings.RequestWaitTime)) { break; } TITOThreadDataRequest threadData = new TITOThreadDataRequest() { InstallationNo = Convert.ToInt32(row["Installation_No"]), TITOEnabled = Convert.ToInt32(row["TITOEnabled"]), SiteTITOEnabled = Convert.ToInt32(row["SiteTITOEnabled"]), SiteNonCashEnabled = Convert.ToInt32(row["SiteNonCashEnabled"]), MachineTITOEnabled = Convert.ToInt32(row["MachineTITOEnabled"]), MachineNonCashEnabled = Convert.ToInt32(row["MachineNonCashEnabled"]), TicketExpireDays = TickerExpire, }; if (threadData.TITOEnabled == 1) { threadData.Command = eCommand.Enable; int nMessageID; nMessageID = EnableTITO(threadData.InstallationNo); if (!dTITORequest.ContainsKey(nMessageID)) { dTITORequest.Add(nMessageID, threadData); } LogManager.WriteLog("TITOConfig | Request for Installation: " + threadData.InstallationNo.ToString() + " , Command:" + threadData.Command.ToString() + " , MessageID:" + nMessageID.ToString(), LogManager.enumLogLevel.Info); } else { threadData.Command = eCommand.Disable; int nMessageID; nMessageID = DisableTITO(threadData.InstallationNo); if (!dTITORequest.ContainsKey(nMessageID)) { dTITORequest.Add(nMessageID, threadData); } LogManager.WriteLog("TITOConfig | Request for Installation: " + threadData.InstallationNo.ToString() + " , Command:" + threadData.Command.ToString() + " , MessageID:" + nMessageID.ToString(), LogManager.enumLogLevel.Info); } } } } catch (Exception Ex) { LogManager.WriteLog("TITOConfig Error " + Ex.Message, LogManager.enumLogLevel.Info); ExceptionManager.Publish(Ex); } }