private void Timer1_Tick(object sender, ElapsedEventArgs e) { string processFlow = ""; string type = ""; try { Timer1.Stop(); oNode = oSetting.SystemSettingsXML; processFlow = oNode.SelectSingleNode("processflow").InnerXml; type = oNode.SelectSingleNode("smssettings/type").InnerXml; //ErrMrg.LogMessage(type + " Inbound Process Starting.", EventLogEntryType.Information); if (processFlow == "Inbound") { Factory.Inbound.InboundProcess inboundProcess = new Factory.Inbound.InboundProcess(); inboundProcess.GetInboundProcess(type, smsComponent); } else if (processFlow == "Outbound") { Factory.Outbound.OutboundProcess outboundProcess = new Factory.Outbound.OutboundProcess(); outboundProcess.GetOutBoundProcess(type); } } catch (Exception ex) { ErrMrg.LogMessage(ex.Message, EventLogEntryType.Error); } finally { Timer1.Start();// = true; } }
protected override void OnStart(string[] args) { try { String cInstance = ""; String type = ""; oSetting = Entity.Config.GetConfig(); oNode = oSetting.SystemSettingsXML; cInstance = oNode.SelectSingleNode("environment").InnerXml; ErrMrg.LogMessage(cInstance + " Service Started", EventLogEntryType.Information); type = oNode.SelectSingleNode("smssettings/type").InnerXml; if (type == "Receiver" || type == "Sender") { smsComponent = Entity.Config.GetSMSComponent(); smsComponent.InitializeModem(); smsComponent.OpenPort(); } Timer1 = new Timer(); this.Timer1.Interval = 1000; this.Timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.Timer1_Tick); Timer1.Start(); GC.KeepAlive(Timer1); } catch (Exception ex) { ErrMrg.LogMessage(ex.Message, EventLogEntryType.Error); this.startWin(); } }
private void DecodeMessage(String SMSMessage, SMSComponent smsComponent) { try { Array ValCollection; String value = ""; String findStr = "CMGL:"; Int32 strIndex = 0; Int64 counter = 0; if (SMSMessage.Contains(findStr)) { strIndex = SMSMessage.IndexOf("+" + findStr, 1); if (strIndex != -1) { SMSMessage = SMSMessage.Substring(strIndex - 1); ErrMrg.LogMessage("SMSContent:" + SMSMessage, EventLogEntryType.Information); while (SMSMessage != "") { value = ""; if (SMSMessage.IndexOf(findStr, 1) > 0) { SMSMessage = SMSMessage.Substring(SMSMessage.IndexOf(findStr, 1), SMSMessage.Length - SMSMessage.IndexOf(findStr, 1)).Trim(); if (SMSMessage.IndexOf(findStr, 1) > 0) { value = SMSMessage.Substring(6, SMSMessage.IndexOf(findStr, 1) - 7).Trim(); } else { value = SMSMessage.Substring(6, SMSMessage.Length - 6).Trim(); SMSMessage = ""; if (counter > 15) { value = ""; } } if (value != "") { ValCollection = value.Split((char)13); if (ValCollection.Length >= 2) { ParseMessage(smsComponent, ValCollection.GetValue(0).ToString().Trim() + " " + ValCollection.GetValue(1).ToString().Trim()); counter += 1; } } else { SMSMessage = ""; } } } } } } catch (Exception ex) { throw ex; } }
protected override void OnStop() { String cInstance = ""; oSetting = Entity.Config.GetConfig(); oNode = oSetting.SystemSettingsXML.SelectSingleNode("environment"); cInstance = oNode.InnerXml; smsComponent.ClosePort(); ErrMrg.LogMessage(cInstance + " Service Stoped", EventLogEntryType.Information); }