/// <summary>
        /// 切换客户
        /// </summary>
        /// <param name="groupID"></param>
        /// <param name="tenantCode"></param>
        public ActionResult ChangeCustomer(string tenantCode, string vehGroupID, string aVehGroupName)
        {
            ETenant tenant = ModelFacade.Platform.TenantModel.GetTenant(tenantCode);
            if (tenant == null)
            {
                return Json(new { result = 0, data = "切换客户失败,所选终端客户不存在!" });
            }

            EUser user = ModelFacade.Platform.UserModel.GetUser(tenant.RegisterUserCode);

            SelectedUserViewModel selUser = new SelectedUserViewModel();
            if (user != null)
            {
                selUser.UserCode = user.UserCode;
                selUser.UserName = user.UserName;                 
            }
            selUser.VehGroupID = vehGroupID;
            selUser.VehGroupName = aVehGroupName;
            selUser.TenantCode = tenant.TenantCode;
            selUser.TenantName = tenant.TenantName;


            ETenant superTenant = ModelFacade.Platform.TenantModel.GetTenant(tenant.SuperTenantID);
            selUser.SuperTenantCode = superTenant.TenantCode;
            selUser.SuperTenantName = superTenant.TenantName;
            this.SetSelectedUser(selUser);
         

            //写cookie,保存最后一次切换的TenantCode
            HttpCookie cookie = new HttpCookie("LastSelectTenantCode");

            //不区分大不写
            cookie.Values.Add("LoginUserName",Passport.UserName.ToLower());
            cookie.Values.Add("SelectTenantCode", tenant.TenantCode);
            cookie.Expires = DateTime.Now.AddDays(1);
            Response.Cookies.Add(cookie);

            return Json(new { result = 1, data = tenant.TenantName });
        }
Example #2
0
 public static void SetSelectedUser(SelectedUserViewModel selectedUser)
 {
     string s = new JavaScriptSerializer().Serialize(selectedUser);
     CacheDataManager.SetCookie("SelectedUserViewModel", s);
 }