コード例 #1
0
        public void ReceiveSMS(string from, string to, string content, string transID)
        {
            SCGSMSService = (ISCGSMSService)ContextRegistry.GetContext().GetObject("SCGSMSService");

            if (from.Length > 9)
            {
                int startIndex = from.Length - 9;
                from = from.Substring(startIndex, 9);
                from = from.PadLeft(10, '0');
            }


            if (content.Length != 7)
            {
                //แจ้งเตือนกรณีใส่ข้อมูลการ approve มาผิด format
                long smsLogID = AddSMSLog(DateTime.Now, from, "Receive", content, transID);
                SCGSMSService.SendSMS07(content, from, true);
            }
            else
            {
                string ReplyApproveFlag = content.Equals(string.Empty) ? "" : content.Substring(content.Length - 1, 1);


                if (ReplyApproveFlag.ToUpper().Equals("Y") || ReplyApproveFlag.ToUpper().Equals("N"))
                {
                    //format การ approve ถูกต้องจะต้องมี 7 หลักเท่านั้น แล้วทำการ process ในการเรียก work flow

                    SMSApproveProcess(from, content, transID);
                }
                else
                {
                    //แจ้งเตือนกรณีใส่ข้อมูลการ approve มาผิด format ไม่ต้อบเป็น Y หรือ N
                    long smsLogID = AddSMSLog(DateTime.Now, from, "Receive", content, transID);
                    SCGSMSService.SendSMS07(content, from, true);
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Request.Form["TRANSID"] == null ||
                    Request.Form["FROM"] == null ||
                    Request.Form["TO"] == null ||
                    Request.Form["CONTENT"] == null
                    )
                {
                    //Respone failed
                    string ResponseError = string.Empty;
                    if (Request.Form["TRANSID"] == null)
                    {
                        ResponseError = string.Format(ResponeERR, "Parameter TRANSID is null");
                    }
                    else if (Request.Form["FROM"] == null)
                    {
                        ResponseError = string.Format(ResponeERR, "Parameter FROM is null");
                    }
                    else if (Request.Form["TO"] == null)
                    {
                        ResponseError = string.Format(ResponeERR, "Parameter TO is null");
                    }
                    else if (Request.Form["CONTENT"] == null)
                    {
                        ResponseError = string.Format(ResponeERR, "Parameter CONTENT is null");
                    }
                    else
                    {
                        ResponseError = string.Format(ResponeERR, "Parameter is null");
                    }

                    Response.ClearHeaders();
                    Response.Clear();
                    Response.Write(ResponseError);
                    Response.End();
                }
                else
                {
                    TRANSID = Request.Form["TRANSID"] == null ? string.Empty : Request.Form["TRANSID"].Trim();
                    FROM    = Request.Form["FROM"] == null ? string.Empty : Request.Form["FROM"].Trim();
                    TO      = Request.Form["TO"] == null ? string.Empty : Request.Form["TO"].Trim();
                    CONTENT = Request.Form["CONTENT"] == null ? string.Empty : Request.Form["CONTENT"].Trim();


                    if (FROM.Length > 9)
                    {
                        int startIndex = FROM.Length - 9;
                        FROM = FROM.Substring(startIndex, 9);
                        FROM = FROM.PadLeft(10, '0');
                    }


                    if (Request.Form["CONTENT"].Trim().Length > 6 || Request.Form["CONTENT"].Trim().Length < 6)
                    {
                        //แจ้งเตือนกรณีใส่ข้อมูลการ approve มาผิด format
                        long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                        SCGSMSService.SendSMS07(CONTENT, FROM, true);
                    }
                    else if (Request.Form["CONTENT"].Trim().Length == 6)
                    {
                        string ReplyApproveFlag = CONTENT.Equals(string.Empty) ? "" : CONTENT.Substring(CONTENT.Length - 1, 1);


                        if (ReplyApproveFlag.ToUpper().Equals("Y") || ReplyApproveFlag.ToUpper().Equals("N"))
                        {
                            //format การ approve ถูกต้องจะต้องมี 6 หลักเท่านั้น แล้วทำการ process ในการเรียก work flow

                            SMSApproveProcess(FROM, CONTENT);
                        }
                        else
                        {
                            //แจ้งเตือนกรณีใส่ข้อมูลการ approve มาผิด format ไม่ต้อบเป็น Y หรือ N
                            long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                            SCGSMSService.SendSMS07(CONTENT, FROM, true);
                        }
                    }

                    //Respone OK ให้ทาง AIS ทราบว่าเราได้รับ message เรียบร้อยแล้ว
                    Response.ClearHeaders();
                    Response.Clear();
                    Response.Write(ResponeOK);
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                Utilities.WriteLogs(ex.Message, "smslog", "Logs", "txt");
            }
        }