private static List <GridViewColumn> GetColumnsListByController(string controllerName, string gridViewName, IReportService reportService) { ECOMUserModel_Login userlogin = HttpSession.GetFromSession <ECOMUserModel_Login>(); string reportCode = string.Empty; List <GridViewColumn> result = new List <GridViewColumn>(); if (reportService != null) { result = reportService.GetColumnsInfo(GetReportCode(controllerName)).ToList(); } else { switch (gridViewName) { case "grdOffice": if (userlogin.RoleID == (int)EnumUtility.ROLE.admin || userlogin.RoleID == (int)EnumUtility.ROLE.supervisor) { result = GetOfficeListColumnsAdmin(); } else { result = GetOfficeListColumns(); } break; case "grdBranch": if (userlogin.RoleID == (int)EnumUtility.ROLE.admin || userlogin.RoleID == (int)EnumUtility.ROLE.supervisor) { result = GetBranchListColumnsAdmin(); } else { result = GetBranchListColumns(); } break; case "grdAgent": if (userlogin.RoleID == (int)EnumUtility.ROLE.admin || userlogin.RoleID == (int)EnumUtility.ROLE.supervisor) { result = GetAgentListColumnsAdmin(); } else { result = GetAgentListColumns(); } break; case "grdSubAgent": result = GetSubAgentListColumns(); break; case "grdCustomer": result = GetCustomerListColumns(); break; default: break; } } return(result); }
private bool CheckLogin(string userName, string password, bool rememberMe = true) { bool result = false; int branchID = 0, agentID = 0, subAgentID = 0, vendorID = 0, carrierID = 0; int partnerID = 0, profileType = 0, parentID = 0, customerID = 0; string partnerCode = "", partnerName = ""; try { var userMembership = _ecomMembershipService.Login(userName, password); if (userMembership != null) { var userInfo = _ecomUserService.FindByUserName(userName); var roleInfo = _ecomRoleService.FindByRoleID(userInfo.RoleID); var ePartnerInfo = _ecomPartnerService.FindByPartnerID_Login(userInfo.PartnerID); if (ePartnerInfo != null) { parentID = ePartnerInfo.PartnerID; partnerID = ePartnerInfo.PartnerID; branchID = ePartnerInfo.BranchID; agentID = ePartnerInfo.AgentID; subAgentID = ePartnerInfo.SubAgentID; if (userInfo.RoleID == (int)EnumUtility.ROLE.customer) { customerID = ePartnerInfo.PartnerID; } else { customerID = 0; } partnerCode = ePartnerInfo.PartnerCode; partnerName = ePartnerInfo.PartnerName; } var modelUser = new ECOMUserModel_Login() { UserName = userMembership.UserName, FullName = userInfo.FullName, UserID = userInfo.UserID, RoleID = roleInfo.RoleID, RoleName = roleInfo.RoleName, PartnerID = partnerID, PartnerCode = partnerCode, PartnerName = partnerName, AddressID = userInfo.AddressID, Email = userMembership.Email, ProfileType = profileType, OfficePartnerID = 1, OfficeUserID = 1, ParentID = parentID, BranchID = branchID, AgentID = agentID, SubAgentID = subAgentID, VendorID = vendorID, CarrierID = carrierID, CustomerID = customerID }; HttpSession.SetSession(modelUser); } if (rememberMe) { int CookieExpires = int.Parse(ConfigurationManager.AppSettings["CookieExpires"]); var ticket = new FormsAuthenticationTicket(2015, userName.Trim(), DateTime.Now, DateTime.Now.AddDays(CookieExpires), true, password.Trim()); var encryptedTicket = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(CommonFunction.DaikinInvRptCookieName, encryptedTicket); cookie.Expires = DateTime.Now.AddDays(CookieExpires); Response.Cookies.Add(cookie); } FormsAuthentication.SetAuthCookie(userName, true); result = true; } catch (ECOMException ex) { ModelState.AddModelError("", ex.Message); //Log here } catch (Exception ex) { ModelState.AddModelError("", ECOM.Resources.ECOMResource.User_LoginFailed); //Log here } return(result); }