コード例 #1
0
ファイル: MainHub.cs プロジェクト: Lukpik/lukpiksignalr
        public void changeStorePassword(string phone, string oldpwd, string newpwd, string clientID)
        {
            try
            {
                // 1 - success
                // 0 - fail
                int storeID = GetStoreIDbyPhone(phone);
                MySQLBusinessLogic bl = new MySQLBusinessLogic();
                int result = bl.ChangePassword(storeID, phone, Encrypt(oldpwd), Encrypt(newpwd));
                if (result == 1)
                {
                    Clients.Client(clientID).changedPassword("1");
                    DataTable dt = new DataTable();
                    dt = bl.GetStoreOwnerName(storeID);
                    if (dt.Rows.Count == 1)
                    {
                        string loginRedirect = System.Configuration.ConfigurationManager.AppSettings.GetValues("LoginRedirect").FirstOrDefault().ToString();
                        string name = dt.Rows[0].ItemArray[0].ToString();// + " " + dt.Rows[0].ItemArray[0].ToString();
                        string email = dt.Rows[0].ItemArray[2].ToString();
                        string midText = "Dear " + name + ",<br> Your password was changed recently . The new password was sent to your phone number ending with XXXXXXX" + phone.Substring(7) + "<br>";
                        string body = AttachTexttoMailTemplate(midText, loginRedirect, "You Have Changed Your Password !", false);
                        string subject = "Lukpik - Password Changed ";
                        SendSMS("Hi " + name + ", Your password has been changed successfully. \nNew password : "******"*****@*****.**", email, subject, body);
                        SendEMail("*****@*****.**", "*****@*****.**", subject, body);
                        //Notification

                    }
                }
                else if (result == 2)
                {
                    Clients.Client(clientID).changedPassword("2");
                }
                else
                    Clients.Client(clientID).changedPassword("0");

            }
            catch (Exception ex)
            {
                Clients.Client(clientID).changedPassword("0");
            }
        }