public bool ResendCode()
        {
            var reg = User.Identity.GetUserName().Substring(6, 3);
            var id  = User.Identity.GetUserName().Substring(0, 6);

            var newMob = db.suppliermobileactivtions.FirstOrDefault(s => s.sid.Equals(id) && s.region.Equals(reg));

            if (newMob != null)
            {
                var sms = new xSms().GetCode(6);

                newMob.codesms      = sms;
                newMob.status       = "pending";
                newMob.datetimesent = string.Format("{0:dd-MM-yyyy hh:mm:ss}", DateTime.Now);

                db.SaveChanges();

                //new xSms().SendSMS("Requested an activation code " + sms + " for mobile registration.", newMob.mobile);

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        private void processValidation()
        {
            dnbmssqlEntities db = new dnbmssqlEntities();

            var smslist = db.suppliermobileactivtions.Distinct().ToList();

            foreach (var item in smslist.Where(s => s.status.Equals("pending")))
            {
                try
                {
                    var sms = new xSms().GetCode(6);

                    item.codesms      = sms;
                    item.datetimesent = string.Format("{0:dd-MM-yyyy hh:mm:ss}", DateTime.Now);

                    var msg = "Requested an activation code " + sms + " for mobile registration.";

                    var result = new SMS().SendSMS(msg, item.mobile);

                    if (result.Success)
                    {
                        RichTxt(rtBox, item.mobile + " : " + sms + " : success.", Color.Green);
                        item.status = "request";
                    }
                    else
                    {
                        RichTxt(rtBox, item.mobile + " : " + sms + " : error csms.", Color.Red);
                        item.status = "error";
                    }
                }
                catch
                {
                    RichTxt(rtBox, item.mobile + " : error.", Color.Red);
                }
            }

            db.SaveChanges();
        }