Пример #1
0
        private void SMSApproveProcess(string FROM, string CONTENT)
        {
            string ReplyApproveFlag = CONTENT.Equals(string.Empty) ? "" : CONTENT.Substring(CONTENT.Length - 1, 1);
            string ReplyTokenResult = CONTENT.Equals(string.Empty) ? "" : CONTENT.TrimEnd(new Char[] { 'Y', 'N', 'y', 'n' });


            if (ReplyApproveFlag.ToUpper().Equals("Y"))
            {
                ReplyApproveFlag = "Approve"; //Accept
            }
            else if (ReplyApproveFlag.ToUpper().Equals("N"))
            {
                ReplyApproveFlag = "Reject"; //Decline
            }
            long userID = 0;
            IList <WorkFlowResponseToken> responseTokens = WorkFlowQueryProvider.WorkFlowResponseTokenQuery.FindByTokenCode(ReplyTokenResult);

            foreach (WorkFlowResponseToken responseToken in responseTokens)
            {
                userID = responseToken.UserID;
                break;
            }
            //1. SignIn by UserName (From)

            if (userID == 0)
            {
                //แจ้งเตือนในกรณีที่มีการ approved ผ่านมือถือ แต่ว่า approve อีกรอบจะทำให้ tokencode หาย
                long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                SCGSMSService.SendSMS08(CONTENT, FROM, true);
            }
            else
            {
                SuUser userAccount = SS.SU.Query.QueryProvider.SuUserQuery.FindByIdentity(userID);
                if (userAccount != null && userAccount.MobilePhoneNo == FROM)
                {
                    string userName = userAccount.UserName;

                    UserEngine.SignIn(userName);
                    UserAccount.CurrentLanguageID  = ParameterServices.SMSDefaultLanguageID;
                    UserAccount.CurrentProgramCode = this.ProgramCode;


                    long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);

                    bool approveFalg = CallWorkFlow(ReplyTokenResult, ReplyApproveFlag, FROM);
                }
                else
                {
                    //แจ้งเตือนในกรณีที่มีการ approved ผ่านมือถือคนอื่นที่ไม่ใช่เครื่องที่รับ message นั้น
                    long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                    SCGSMSService.SendSMS10(CONTENT, FROM, true);
                }
            }
        }
Пример #2
0
        private void SMSApproveProcess(string FROM, string CONTENT, string TRANSID)
        {
            IWorkFlowResponseTokenQuery WorkFlowResponseTokenQuery = (IWorkFlowResponseTokenQuery)ContextRegistry.GetContext().GetObject("WorkFlowResponseTokenQuery");

            string ReplyApproveFlag = CONTENT.Equals(string.Empty) ? "" : CONTENT.Substring(CONTENT.Length - 1, 1);
            string ReplyTokenResult = CONTENT.Equals(string.Empty) ? "" : CONTENT.TrimEnd(new Char[] { 'Y', 'N', 'y', 'n' });


            if (ReplyApproveFlag.ToUpper().Equals("Y"))
            {
                ReplyApproveFlag = "Approve"; //Accept
            }
            else if (ReplyApproveFlag.ToUpper().Equals("N"))
            {
                ReplyApproveFlag = "Reject"; //Decline
            }
            long userID = 0;
            IList <WorkFlowResponseToken> responseTokens = WorkFlowResponseTokenQuery.FindByTokenCode(ReplyTokenResult);

            foreach (WorkFlowResponseToken responseToken in responseTokens)
            {
                userID = responseToken.UserID;
                break;
            }
            //1. SignIn by UserName (From)

            if (userID == 0)
            {
                //แจ้งเตือนในกรณีที่มีการ approved ผ่านมือถือ แต่ว่า approve อีกรอบจะทำให้ tokencode หาย
                long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                SCGSMSService.SendSMS08(CONTENT, FROM, true);
            }
            else
            {
                try
                {
                    UserEngine = (IUserEngine)ContextRegistry.GetContext().GetObject("UserEngine");
                    ISuUserQuery      SuUserQuery      = (ISuUserQuery)ContextRegistry.GetContext().GetObject("SuUserQuery");
                    IDbParameterQuery DbParameterQuery = (IDbParameterQuery)ContextRegistry.GetContext().GetObject("DbParameterQuery");

                    SuUser user = SuUserQuery.FindByIdentity(userID);
                    if (user != null && user.MobilePhoneNo == FROM)
                    {
                        string userName = user.UserName;

                        UserEngine.SignIn(userName);

                        UserAccount = (IUserAccount)ContextRegistry.GetContext().GetObject("UserAccount");
                        string smsDefaultLanguageID = DbParameterQuery.GetParameterByName("SMSDefaultLanguageID");
                        UserAccount.CurrentLanguageID  = string.IsNullOrEmpty(smsDefaultLanguageID) ? (short)1 : Convert.ToInt16(smsDefaultLanguageID);
                        UserAccount.CurrentProgramCode = "SmsWcfService";


                        long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);

                        bool approveFalg = CallWorkFlow(ReplyTokenResult, ReplyApproveFlag, FROM);
                    }
                    else
                    {
                        //แจ้งเตือนในกรณีที่มีการ approved ผ่านมือถือคนอื่นที่ไม่ใช่เครื่องที่รับ message นั้น
                        long smsLogID = AddSMSLog(DateTime.Now, FROM, "Receive", CONTENT, TRANSID);
                        SCGSMSService.SendSMS10(CONTENT, FROM, true);
                    }
                }
                catch (Exception ex)
                {
                    Utilities.WriteLogs(ex.Message, "smslog", "Logs", "txt");
                    // error = ex.Message;
                }
            }
        }