private void AddMissingGroupSetting() { if (!_groupSettings.Exists(x => x.GroupName == Operator.MTC)) { var settings = new XmlGroupSettings(); settings.GroupName = Operator.MTC; settings.WaitAnswer = 25; settings.DoubleCheckOnTimeout = true; settings.SmsRecipient = "7422"; settings.SmsText = "%PHONE%"; _groupSettings.Add(settings); } if (!_groupSettings.Exists(x => x.GroupName == Operator.Life)) { var settings = new XmlGroupSettings(); settings.GroupName = Operator.Life; settings.WaitAnswer = 35; settings.DoubleCheckOnTimeout = false; settings.SmsRecipient = "1470"; settings.SmsText = "38%PHONE%"; _groupSettings.Add(settings); } if (!_groupSettings.Exists(x => x.GroupName == Operator.Kievstar)) { var settings = new XmlGroupSettings(); settings.GroupName = Operator.Kievstar; settings.WaitAnswer = 15; settings.DoubleCheckOnTimeout = true; settings.UssdText = "*143*%PHONE%#"; settings.NotificationType = NotificationType.USSD; _groupSettings.Add(settings); } }
private void FromXmlElements(XmlNodeList elems, IList <XmlGroupSettings> groupSettings) { if (elems != null) { foreach (XmlElement elem in elems) { var newGroupSettings = new XmlGroupSettings(); FromXmlElement(elem, newGroupSettings); groupSettings.Add(newGroupSettings); } } AddMissingGroupSetting(); }
private void FromXmlElement(XmlElement elem, XmlGroupSettings groupSettings) { if (elem == null) { return; } groupSettings.GroupName = elem.GetAttribute("GroupName"); var waitAnswerElem = (XmlElement)elem.SelectSingleNode("tn:WaitAnswer", _namespaceManager); if (waitAnswerElem == null) { waitAnswerElem = (XmlElement)elem.SelectSingleNode("WaitAnswer"); } if (waitAnswerElem != null) { groupSettings.WaitAnswer = Int32.Parse(waitAnswerElem.InnerText); } var doubleCheckOnTimeoutElem = (XmlElement)elem.SelectSingleNode("tn:DoubleCheckOnTimeout", _namespaceManager); if (doubleCheckOnTimeoutElem == null) { doubleCheckOnTimeoutElem = (XmlElement)elem.SelectSingleNode("DoubleCheckOnTimeout"); } if (doubleCheckOnTimeoutElem != null) { groupSettings.DoubleCheckOnTimeout = Boolean.Parse(doubleCheckOnTimeoutElem.InnerText); } var smsRecipientElem = (XmlElement)elem.SelectSingleNode("tn:SMSRecipient", _namespaceManager); if (smsRecipientElem == null) { smsRecipientElem = (XmlElement)elem.SelectSingleNode("SMSRecipient"); } if (smsRecipientElem != null) { groupSettings.SmsRecipient = smsRecipientElem.InnerText; } var smsTextElem = (XmlElement)elem.SelectSingleNode("tn:SMSText", _namespaceManager); if (smsTextElem == null) { smsTextElem = (XmlElement)elem.SelectSingleNode("SMSText"); } if (smsTextElem != null) { groupSettings.SmsText = smsTextElem.InnerText; } var ussdTextElem = (XmlElement)elem.SelectSingleNode("tn:USSDText", _namespaceManager); if (ussdTextElem == null) { ussdTextElem = (XmlElement)elem.SelectSingleNode("USSDText"); } if (ussdTextElem != null) { groupSettings.UssdText = ussdTextElem.InnerText; } var notificationTypeElem = (XmlElement)elem.SelectSingleNode("tn:NotificationType", _namespaceManager); if (notificationTypeElem == null) { notificationTypeElem = (XmlElement)elem.SelectSingleNode("NotificationType"); } if (notificationTypeElem != null) { groupSettings.NotificationType = (NotificationType)Enum.Parse(typeof(NotificationType), notificationTypeElem.InnerText); } }