Exemple #1
0
        private void LongJob(LoginModel model)
        {

            //some initilizations

            //base.UpdateDatabase(model.UserName);

            //you can also set the parameter here
            //AsyncManager.Parameters.Add("redirect", false);


            //if we want to wait the end
            //            AsyncManager.OutstandingOperations.Decrement();
        }
Exemple #2
0
 public ActionResult LoginCompleted(LoginModel model, string returnUrl, bool redirect)
 {
     if (redirect)
     {
         if (returnUrl == String.Empty)
         {
             TempData["welcomeMessage"] = true;
             // return RedirectToAction("Index", "Home", new { area = "" });
             return Json(new { redirectUrl = Url.Action("Index", "Home", new { area = "" }) });
         }
         else
         {
             return Redirect(returnUrl);
         }
     }
     return PartialView("_Login", model);
 }
Exemple #3
0
        public void LoginAsync(LoginModel model, string returnUrl)
        {
            TempData["errorMessage"] = false;
            if (ModelState.IsValid)
            {
                var xx = Membership.GetUser(model.UserName);


                System.Web.HttpContext.Current.Session["artsSession"] = null;
                System.Web.HttpContext.Current.Session["tsksSession"] = null;



                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    //   base.UpdateDatabase(model.UserName);


                    profDataRep.SyncroModules(model.UserName);
                    var prof = profDataRep.GetSingle(model.UserName);
                    this.CheckModuleRole(prof);

                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (Url.IsLocalUrl(returnUrl))
                    {
                        AsyncManager.Parameters.Add("returnUrl", returnUrl);
                    }
                    else
                    {
                        AsyncManager.Parameters.Add("returnUrl", "");
                    }

                    AsyncManager.Parameters.Add("redirect", true);
                    AsyncManager.Parameters.Add("model", model);

                    try
                    {
                        warehouseRepository.SetDbName(model.UserName);
                        var wList = warehouseRepository.GetWarehouseList();
                        warehouseRepository.Save();
                    }
                    catch (Exception)
                    {
                    }
                    //AsyncManager.OutstandingOperations.Increment(1);
                    System.Threading.Tasks.Task.Factory.StartNew(() => LongJob(model));
                }
                else
                {
                    AsyncManager.Parameters.Add("redirect", false);
                    AsyncManager.Parameters.Add("model", model);
                    AsyncManager.Parameters.Add("returnUrl", returnUrl);

                    ModelState.AddModelError("PersError", "LoginMessageError");
                }
            }

        }