/// <summary> /// 当前供应商用户 /// </summary> /// <param name="user"></param> /// <returns></returns> public static Lebi_Supplier_User CurrentSupplierUser(Lebi_User user) { Lebi_Supplier_User model = null; string supplierid_ = CookieTool.GetCookieString("supplier"); int supplierid = 0; int.TryParse(supplierid_, out supplierid); if (supplierid > 0) { model = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011"); } if (model == null) { model = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", "").FirstOrDefault(); } if (model == null) { model = new Lebi_Supplier_User(); } return(model); }
protected override void OnLoad(EventArgs e) { if (!Shop.LebiAPI.Service.Instanse.Check("plugin_gongyingshang")) { Response.Redirect(WebPath + "/"); Response.End(); return; } PageLoadCheck(); //页面载入检查 #region 当前用户信息 int selectsupplierid = RequestTool.RequestInt("selectsupplierid"); if (selectsupplierid > 0) { //切换超级账号 string msg = ""; EX_Supplier.Login(CurrentUser, "", selectsupplierid, out msg); CurrentSupplierUser = B_Lebi_Supplier_User.GetModel("User_id = " + CurrentUser.id + " and Supplier_id=" + selectsupplierid + " and Type_id_SupplierUserStatus=9011"); } if (CurrentSupplierUser == null) { CurrentSupplierUser = EX_Supplier.CurrentSupplierUser(CurrentUser); } if (CurrentSupplierUser.id == 0) { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } CurrentSupplier = B_Lebi_Supplier.GetModel(CurrentSupplierUser.Supplier_id); if (CurrentSupplier.Type_id_SupplierStatus != 442) { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } CurrentSupplierUserGroup = B_Lebi_Supplier_UserGroup.GetModel(CurrentSupplierUser.Supplier_UserGroup_id); if (CurrentSupplierUserGroup == null) { CurrentSupplierUserGroup = new Lebi_Supplier_UserGroup(); } if (CurrentSupplier != null) { CurrentSupplierGroup = B_Lebi_Supplier_Group.GetModel(CurrentSupplier.Supplier_Group_id); if (CurrentSupplierGroup == null) { CurrentSupplierGroup = new Lebi_Supplier_Group(); } } else { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } DateTime LastDate = CurrentSupplier.Time_This; TimeSpan ts = System.DateTime.Now - LastDate; int NewEventTimes = 0; int.TryParse(SYS.NewEventTimes, out NewEventTimes); LeftNewEventTimes = Convert.ToInt32(ts.TotalSeconds % (NewEventTimes / 1000)); LeftNewEventTimes = NewEventTimes - (LeftNewEventTimes * 1000); #endregion #region 配合前台主题 string themecode = ""; int siteid = 0; var nv = CookieTool.GetCookie("ThemeStatus"); if (!string.IsNullOrEmpty(nv.Get("theme"))) { themecode = nv.Get("theme"); } if (!string.IsNullOrEmpty(nv.Get("site"))) { int.TryParse(nv.Get("site"), out siteid); } if (siteid == 0) { siteid = ShopCache.GetMainSite().id; } LoadTheme(themecode, siteid, CurrentLanguage.Code, "", true); #endregion #region 处理菜单 MenuType = Shop.Tools.CookieTool.GetCookieString("Menu"); if (MenuType == "") { MenuType = "Index"; } string menu_ids = ""; if (CurrentSupplierUserGroup != null && CurrentSupplierUser.User_id != CurrentSupplier.User_id) { menu_ids = CurrentSupplierUserGroup.Menu_ids; } else { CurrentSupplierGroup = B_Lebi_Supplier_Group.GetModel(CurrentSupplier.Supplier_Group_id); if (CurrentSupplierGroup != null) { menu_ids = CurrentSupplierGroup.Menu_ids; } } //lebi菜单 if (!Shop.LebiAPI.Service.Instanse.Check("managelicenese")) { lbmenu = "<ul class=\"tool\"><li><span><a href=\"" + site.AdminPath + "/?desk=1\">" + Tag("桌面") + "</a></span></li></ul>"; string license = "Copyright 2003-" + DateTime.Now.Year + " <a href=\"http://www.lebi.cn/\" target=\"_blank\" class=\"footcopy\">Lebi.cn</a> , All Rights Reserved. Powered by <a href=\"http://www.lebi.cn/support/license/?url=" + Request.ServerVariables["SERVER_NAME"] + "\" target=\"_blank\" title=\"LebiShop\" class=\"footcopy\">LebiShop</a> V<a href=\"" + site.AdminPath + "/config/version.aspx\">" + SYS.Version + "." + SYS.Version_Son + "</a>"; try { Label LBLicense = (Label)this.Page.FindControl("LBLicense"); LBLicense.Text = license; } catch { string strscript = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><script language='javascript'>"; strscript += "document.onreadystatechange = loadlicense;"; strscript += "function loadlicense(){"; strscript += "if(document.readyState == \"complete\"){"; strscript += "if ($(\"#lebicopy\")[0] == undefined) {alert('页面布局异常')}"; strscript += "$('#lebicopy').html('" + license + "')"; strscript += "}}</script>"; Response.Write(strscript); } } else { lbmenu = "<ul class=\"tool\"><li><span><a href=\"" + site.AdminPath + "/?desk=1\">" + Tag("桌面") + "</a></ul>"; } //处理菜单 desk = RequestTool.RequestInt("desk", 0); AllMenus = new List <Lebi_Supplier_Menu>(); List <Lebi_Supplier_Menu> All = B_Lebi_Supplier_Menu.GetList("Isshow=1", "Sort desc"); string currentgroupmenu = "," + menu_ids + ","; foreach (Lebi_Supplier_Menu m in All) { if (currentgroupmenu.Contains("," + m.id + ",")) { AllMenus.Add(m); } } TopMenus = (from m in AllMenus where m.parentid == 0 select m).ToList(); if (desk != 1) { try { var temp = from m in AllMenus where reqPage.Contains(m.URL.ToLower()) && m.parentid > 0 && m.URL != "" select m; //if (temp == null) // CurrentLeftMenu = new Lebi_Menu(); //else //{ CurrentLeftMenu = temp.ToList().FirstOrDefault(); CurrentTopMenu = (from m in AllMenus where m.id == CurrentLeftMenu.parentid select m).ToList().FirstOrDefault(); CurrentTopMenu = (from m in TopMenus where m.id == CurrentTopMenu.parentid select m).ToList().FirstOrDefault(); ////写入cookie NameValueCollection nvs = new NameValueCollection(); nvs.Add("top", CurrentTopMenu.id.ToString()); nvs.Add("left", CurrentLeftMenu.id.ToString()); CookieTool.WriteCookie("sMenu", nvs, 365); //} } catch (NullReferenceException) { var menu = CookieTool.GetCookie("sMenu"); int tid = 0; int lid = 0; int.TryParse(menu.Get("top"), out tid); int.TryParse(menu.Get("left"), out lid); CurrentTopMenu = (from m in TopMenus where m.id == tid select m).ToList().FirstOrDefault(); CurrentLeftMenu = (from m in AllMenus where m.id == lid select m).ToList().FirstOrDefault(); } } else { //写入cookie NameValueCollection nvs = new NameValueCollection(); nvs.Add("top", "0"); nvs.Add("left", "0"); CookieTool.WriteCookie("sMenu", nvs, 365); } if (CurrentTopMenu == null) { CurrentTopMenu = new Lebi_Supplier_Menu(); desk = 1; } #endregion Suppliers = GetSuppliers(); base.OnLoad(e); }
//public static bool CheckPower(string code, string name) //{ // if (!Power(code, name)) // { // NoPower(); // return false; // } // return true; //} //public static void NoPower() //{ // HttpContext.Current.Response.Write("{\"msg\":\"权限不足\"}"); // HttpContext.Current.Response.End(); //} #endregion /// <summary> /// 供应商账号登录 /// </summary> /// <param name="user"></param> /// <param name="type">账号类型</param> /// <param name="supplierid"></param> /// <param name="msg"></param> /// <returns></returns> public static bool Login(Lebi_User user, string type, int supplierid, out string msg, int adminlogin = 0) { msg = "OK"; Lebi_Supplier_User supplieruser = null; Lebi_Supplier supplier = null; if (supplierid == 0) { string supplierid_ = CookieTool.GetCookieString("supplier"); //int supplierid = 0; int.TryParse(supplierid_, out supplierid); } //string and = ""; //if (type != "") //{ // and = " and Supplier_id in (select id from [Lebi_Supplier] where Supplier_Group_id in (select id from [Lebi_Supplier_Group] where type='" + type + "'))"; //} if (supplierid > 0) { supplier = B_Lebi_Supplier.GetModel(supplierid); if (supplier != null) { Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id); if (group.type == type || type == "") { supplieruser = B_Lebi_Supplier_User.GetModel("User_id = " + user.id + " and Supplier_id=" + supplierid + " and Type_id_SupplierUserStatus=9011"); } } } if (supplieruser == null) { List <Lebi_Supplier_User> users = B_Lebi_Supplier_User.GetList("User_id = " + user.id + " and Type_id_SupplierUserStatus=9011", ""); if (type == "") { foreach (Lebi_Supplier_User u in users) { supplier = B_Lebi_Supplier.GetModel(u.Supplier_id); if (supplier != null) { supplieruser = u; break; } } //supplieruser = users.FirstOrDefault(); //if (supplieruser == null) //{ // msg = "User_id = " + user.id + " and Type_id_SupplierUserStatus=9011"; // return false; //} //supplier = B_Lebi_Supplier.GetModel(supplieruser.Supplier_id); } else { foreach (Lebi_Supplier_User u in users) { supplier = B_Lebi_Supplier.GetModel(u.Supplier_id); if (supplier == null) { continue; } Lebi_Supplier_Group group = B_Lebi_Supplier_Group.GetModel(supplier.Supplier_Group_id); if (group.type == type) { supplieruser = u; break; } } } } if (supplieruser == null) { Log.Add("登陆失败", "Login", "", supplier, "账号:" + user.UserName); msg = "登陆失败"; return(false); } if (supplier == null) { Log.Add("登陆失败:账号不存在或不可用", "Login", "", supplier, "账号:" + user.UserName); msg = "账号不存在或不可用"; return(false); } if (supplier.Type_id_SupplierStatus != 442) { Log.Add("登陆失败:供应商账号不可用", "Login", "", supplier, "账号:" + user.UserName); msg = "供应商账号不可用"; return(false); } supplier.Time_Last = supplier.Time_This; supplier.Time_This = DateTime.Now; supplier.Count_Login++; supplier.IP_Last = supplier.IP_This; supplier.IP_This = RequestTool.GetClientIP(); Shop.Tools.CookieTool.SetCookieString("supplier", supplier.id.ToString(), 60 * 24); B_Lebi_Supplier.Update(supplier); if (adminlogin == 0) { Log.Add("登陆系统", "Login", "", supplier, "账号:" + user.UserName); } return(true); }
protected override void OnLoad(EventArgs e) { if (!Shop.LebiAPI.Service.Instanse.Check("plugin_gongyingshang")) { Response.Write(""); Response.End(); return; } PageLoadCheck(); //页面载入检查 #region 当前用户信息 int selectsupplierid = RequestTool.RequestInt("selectsupplierid"); if (selectsupplierid > 0) { //切换超级账号 string msg = ""; EX_Supplier.Login(CurrentUser, "", selectsupplierid, out msg); CurrentSupplierUser = B_Lebi_Supplier_User.GetModel("User_id = " + CurrentUser.id + " and Supplier_id=" + selectsupplierid + " and Type_id_SupplierUserStatus=9011"); } if (CurrentSupplierUser == null) { CurrentSupplierUser = EX_Supplier.CurrentSupplierUser(CurrentUser); } if (CurrentSupplierUser.id == 0) { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } CurrentSupplier = B_Lebi_Supplier.GetModel(CurrentSupplierUser.Supplier_id); if (CurrentSupplier.Type_id_SupplierStatus != 442) { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } CurrentSupplierUserGroup = B_Lebi_Supplier_UserGroup.GetModel(CurrentSupplierUser.Supplier_UserGroup_id); if (CurrentSupplierUserGroup == null) { CurrentSupplierUserGroup = new Lebi_Supplier_UserGroup(); } if (CurrentSupplier != null) { CurrentSupplierGroup = B_Lebi_Supplier_Group.GetModel(CurrentSupplier.Supplier_Group_id); if (CurrentSupplierGroup == null) { CurrentSupplierGroup = new Lebi_Supplier_Group(); } } else { Response.Redirect(Shop.Bussiness.Site.Instance.SupplierPath + "/Login.aspx"); return; } #endregion #region 配合前台主题 string themecode = ""; int siteid = 0; var nv = CookieTool.GetCookie("ThemeStatus"); if (!string.IsNullOrEmpty(nv.Get("theme"))) { themecode = nv.Get("theme"); } if (!string.IsNullOrEmpty(nv.Get("theme"))) { int.TryParse(nv.Get("site"), out siteid); } if (siteid == 0) { siteid = ShopCache.GetMainSite().id; } LoadTheme(themecode, siteid, CurrentLanguage.Code, "", true); #endregion Suppliers = GetSuppliers(); base.OnLoad(e); }