public void RetrySend(string mobile, string msg, string logid) { string sender = ConfigurationSettings.AppSettings["ServiceMode"].ToString(); string SMSGatewaySever = ConfigurationSettings.AppSettings["SMSGatewaySever"].ToString(); int SMSGatewaySeverPort = Int32.Parse(ConfigurationSettings.AppSettings["SMSGatewaySeverPort"]); string url = ConfigurationSettings.AppSettings["SMSGatewaySever_url"].ToString(); //string SMSGatewaySever = "203.170.230.170"; //int SMSGatewaySeverPort = 2257; byte[] data = new byte[1024]; string str = string.Empty; string TRANSID = "BULK"; string FROM = "GasControl"; string TO = "66896213113"; string CONTENT = "Test from automation"; // MSG; string error = ""; OracleQuery2 cc2 = new OracleQuery2(); TO = CleanNumber(mobile); CONTENT = ConvertToHex(msg); if (!string.IsNullOrEmpty(TO)) { try { string _data = String.Format("TRANSID={0}&CMD=SENDMSG&FROM={1}&TO={2}&REPORT=Y&CHARGE=N&CODE=PTTNGV_BulkSMS&CTYPE=UNICODE&CONTENT={3}" , TRANSID, FROM, TO, CONTENT ); string response = SendPost(url, _data); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(response); string xpath = "XML"; var nodes = xDoc.SelectNodes(xpath); foreach (XmlNode childrenNode in nodes) { string status = childrenNode.SelectSingleNode("//STATUS").InnerText; string DETAIL = childrenNode.SelectSingleNode("//DETAIL").InnerText; string SMID = childrenNode.SelectSingleNode("//SMID").InnerText; LogToFile("LOGDATE:" + DateTime.Now + ": " + status + " " + DETAIL + " " + SMID + "," + TO); if (status == "OK") { cc2.UpdateLog(1, DETAIL, SMID, logid); } else { error += "fail:" + TO + ";"; cc2.UpdateLog(0, DETAIL, SMID, logid); } } //LogToFile( response+"," + TO); } catch (Exception e) { Console.WriteLine("Unable to connect to server." + e.ToString()); str = String.Format("{0}|ERR" + "|Connect server error||", e.Message.ToString()); LogToFile("LOGDATE:" + DateTime.Now + ": " + " Error connect " + str + " " + DateTime.Now); //เขียน event log เพิ่มเติมเ // this.LOG(stationid, str, ""); // turn off event log if (!System.Diagnostics.EventLog.SourceExists("SMS_Auto")) { System.Diagnostics.EventLog.CreateEventSource("SMS_Auto", "MyLog"); } // configure the event log instance to use this source name error += "fail:" + TO + ";"; //LogToFile(e.ToString() + " " + DateTime.Now); } } }