private static void ReadSms() { HuaweiParser parser = new HuaweiParser(new HuaweiReader(config.Hostname).Read()); Smses smses = parser.Parse(); if (config.UnreadOnly) { smses.ClearRead(); } string result; if (config.HtmlOutput) { result = smses.HtmlReport; } else { result = smses.TxtReport; } if (config.SendEmail) { if (smses.Count == 0) { if (!config.IsQueit) { Console.WriteLine("There is no sms... exit"); } return; } string mailScript = config.MailCommand; string mailSubj = "\"" + config.MailSubject + "\""; string mailText = "\"" + result + "\""; new Bash(mailScript, $"{mailSubj} {mailText}").Execute(); } else if (config.SendTelegram) { if (smses.Count == 0) { if (!config.IsQueit) { Console.WriteLine("There is no sms... exit"); } return; } string telegramScript = config.TelegramCommand; new Bash(telegramScript, result).Execute(); } else { smses.Print(); } }
public Smses Parse() { Smses smses = new Smses(); XmlNodeList smsNodes = xmlDoc.SelectNodes("response/Messages/Message"); foreach (XmlNode smsNode in smsNodes) { int id = Convert.ToInt32(smsNode.SelectSingleNode("Index").InnerText); string phone = smsNode.SelectSingleNode("Phone").InnerText; string message = smsNode.SelectSingleNode("Content").InnerText; DateTime dateTime = Convert.ToDateTime(smsNode.SelectSingleNode("Date").InnerText); // int smstat = Convert.ToInt32(smsNode.SelectSingleNode("Smstat").InnerText); string sca = smsNode.SelectSingleNode("Sca").InnerText; int saveType = Convert.ToInt32(smsNode.SelectSingleNode("SaveType").InnerText); int priorityd = Convert.ToInt32(smsNode.SelectSingleNode("Priority").InnerText); int smsType = Convert.ToInt32(smsNode.SelectSingleNode("SmsType").InnerText); smses.Add(new Sms(id, phone, message, dateTime, smstat, sca, saveType, priorityd, smsType)); } return(smses); }