Exemplo n.º 1
0
        public List <Model.UserCustomAttr> GetUserCustomAttrs()
        {
            CustomProfileCommon         profile = new CustomProfileCommon();
            List <Model.UserCustomAttr> list    = profile.UserCustomAttr.GetList();

            return(list);
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                rawUrl = Intelligencia.UrlRewriter.RewriterHttpModule.RawUrl;

                CustomProfileCommon profile = new CustomProfileCommon();
                string userName             = profile.GetUserName();

                string fileName = string.Format("~/App_Data/AdminData/{0}.xml", userName);
                string path     = Server.MapPath(VirtualPathUtility.GetDirectory(fileName));
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                userFile = Server.MapPath(fileName);
                if (!File.Exists(userFile))
                {
                    if (mnBll == null)
                    {
                        mnBll = new BLL.MenuNav();
                    }
                    mnBll.Create(userFile, "~/Admin/Default.aspx");
                }
                if (mnBll == null)
                {
                    mnBll = new BLL.MenuNav();
                }
                mnBll.RequestSave(Request.AppRelativeCurrentExecutionFilePath, rawUrl, userFile);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设为默认
        /// </summary>
        private void OnSetDefault()
        {
            string nId = hV.Value.Trim();

            if (!string.IsNullOrEmpty(nId))
            {
                CustomProfileCommon          profile = new CustomProfileCommon();
                List <Model.UserAddressInfo> list    = profile.UserAddress.GetList();
                foreach (Model.UserAddressInfo item in list)
                {
                    if (item.NumberID.ToString() == nId)
                    {
                        item.IsDefault = true;
                    }
                    else
                    {
                        item.IsDefault = false;
                    }
                }
                profile.Save();

                Bind();

                WebHelper.MessageBox.MessagerShow(this.Page, lbtnPostBack, "操作成功");
            }
        }
Exemplo n.º 4
0
        private void Bind()
        {
            Control ctl = this.LoadControl("~/WebUserControls/UCMenu.ascx");

            ctl.ID = "UCMenu";
            phUc.Controls.Add(ctl);

            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                var Profile         = new CustomProfileCommon();
                var userProfileInfo = JsonConvert.DeserializeObject <UserProfileInfo>(Profile.UserInfo);
                if (userProfileInfo != null)
                {
                    lbSiteTitle.InnerText = userProfileInfo.SiteTitle;
                    if (!string.IsNullOrWhiteSpace(userProfileInfo.SiteLogo))
                    {
                        imgLogo.Src     = userProfileInfo.SiteLogo;
                        imgLogo.Visible = true;
                    }
                    if (!string.IsNullOrWhiteSpace(userProfileInfo.CultureName) && userProfileInfo.CultureName.ToLower() == "en-us")
                    {
                        LoginStatus lsUser = lvUser.FindControl("lsUser") as LoginStatus;
                        lsUser.LogoutText = "[Sign Out]";
                        LoginName lnUser = lvUser.FindControl("lnUser") as LoginName;
                        lnUser.FormatString = "Welcome,{0}";
                    }
                    lbAppId.InnerText = userProfileInfo.SiteCode;
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 数据绑定
        /// </summary>
        private void Bind()
        {
            CustomProfileCommon profile = new CustomProfileCommon();

            rpData.DataSource = profile.UserAddress.GetList();
            rpData.DataBind();
        }
Exemplo n.º 6
0
        public void CreateSearchItem(ref StringBuilder sqlWhere, ref ParamsHelper parms)
        {
            if (HttpContext.Current.User.IsInRole("Administrators"))
            {
                return;
            }

            if (sqlWhere == null)
            {
                sqlWhere = new StringBuilder(500);
            }
            if (parms == null)
            {
                parms = new ParamsHelper();
            }

            CustomProfileCommon Profile = new CustomProfileCommon();
            var upi = JsonConvert.DeserializeObject <UserProfileInfo>(Profile.UserInfo);

            sqlWhere.Append("and AppCode = @AppCode ");
            var parm = new SqlParameter("@AppCode", SqlDbType.Char, 6);

            parm.Value = upi.SiteCode;
            parms.Add(parm);

            if (upi.SiteCode == "000000")
            {
                sqlWhere.Append("and UserId = @UserId ");
                parm       = new SqlParameter("@UserId", SqlDbType.UniqueIdentifier);
                parm.Value = WebCommon.GetUserId();
                parms.Add(parm);
            }
        }
Exemplo n.º 7
0
        private void OnEditAddress()
        {
            string numberId = hNId.Value.Trim();

            if (!string.IsNullOrEmpty(numberId))
            {
                if (profile == null)
                {
                    profile = new CustomProfileCommon();
                }
                UserAddressInfo model = profile.UserAddress.GetModel(Guid.Parse(numberId));
                if (!OnCheckForm(ref model))
                {
                    return;
                }

                if (model != null)
                {
                    profile.UserAddress.Update(model);

                    profile.Save();

                    BindAddress();

                    BindSelectAddress();

                    hOp.Value = "savaAddress";
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 去结算事件
        /// </summary>
        private void OnTopay()
        {
            //当前部门分配给用户
            RepeaterItemCollection ric = rpData.Items;

            if (ric.Count > 0)
            {
                bool hasQtyChange = false;
                if (profile == null)
                {
                    profile = new CustomProfileCommon();
                }
                ICollection <Model.CartItemInfo> list = profile.ShoppingCart.CartItems;
                foreach (RepeaterItem item in ric)
                {
                    HtmlInputCheckBox cb          = item.FindControl("cbItem") as HtmlInputCheckBox;
                    HtmlInputText     txtQuantity = item.FindControl("txtQuantity") as HtmlInputText;
                    if (cb != null)
                    {
                        string productId = cb.Value;
                        if (cb.Checked)
                        {
                            if (txtQuantity != null)
                            {
                                int quantity = 1;
                                int.TryParse(txtQuantity.Value.Trim(), out quantity);
                                if (quantity < 1)
                                {
                                    quantity = 1;
                                }
                                if (quantity > 1)
                                {
                                    foreach (Model.CartItemInfo model in list)
                                    {
                                        if (model.ProductId == productId)
                                        {
                                            profile.ShoppingCart.SetQuantity(productId, quantity);

                                            hasQtyChange = true;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            profile.ShoppingCart.Remove(productId);
                            hasQtyChange = true;
                        }
                    }
                }

                if (hasQtyChange)
                {
                    profile.Save();
                }

                Response.Redirect("../../Users/Order/AddOrder.aspx", true);
            }
        }
Exemplo n.º 9
0
        public string InsertUserCustomAttr(string attrName, string attrValue)
        {
            context = HttpContext.Current;
            CustomProfileCommon profile = new CustomProfileCommon();

            if (profile.UserCustomAttr.Count > 4)
            {
                return("已超过上限,最多保存5个自定义属性");
            }
            attrName  = attrName.Trim();
            attrValue = attrValue.Trim();
            if (string.IsNullOrEmpty(attrName) || string.IsNullOrEmpty(attrValue))
            {
                return("属性名称或属性值不能为空,请检查");
            }
            List <Model.UserCustomAttr> list = profile.UserCustomAttr.GetList();

            Model.UserCustomAttr oldModel = list.Find(delegate(Model.UserCustomAttr m)
            {
                return(m.AttrValue == attrValue);
            });
            if (oldModel != null)
            {
                return("已存在记录");
            }

            Model.UserCustomAttr model = new Model.UserCustomAttr();
            model.AttrName  = attrName;
            model.AttrValue = attrValue;
            profile.UserCustomAttr.Insert(model);
            profile.Save();

            return("操作成功");
        }
Exemplo n.º 10
0
        private void DelBatch()
        {
            if (profile == null)
            {
                profile = new CustomProfileCommon();
            }
            bool isNoCheck = true;

            RepeaterItemCollection rows = rpData.Items;

            //当前部门分配给用户
            foreach (RepeaterItem item in rows)
            {
                //找到CheckBox
                HtmlInputCheckBox cb = item.FindControl("cbItem") as HtmlInputCheckBox;
                if (cb != null && cb.Checked)
                {
                    if (isNoCheck)
                    {
                        isNoCheck = false;
                    }
                    profile.ShoppingCart.Remove(cb.Value);
                }
            }
            if (isNoCheck)
            {
                WebHelper.MessageBox.Messager(this.Page, Page.Controls[0], "请至少选中一行进行操作!", "操作错误", "error");
                return;
            }

            profile.Save();
            Bind();
        }
Exemplo n.º 11
0
        private void OnSaveAddress()
        {
            if (profile == null)
            {
                profile = new CustomProfileCommon();
            }
            if (profile.UserAddress.Count >= 5)
            {
                MessageBox.Messager(this.Page, lbtnSave, "当前地址数量已达上限(5个),若要继续添加新地址,请先删除部分收货地址。");
                return;
            }

            UserAddressInfo model = new UserAddressInfo();

            if (!OnCheckForm(ref model))
            {
                return;
            }

            model.NumberID = Guid.NewGuid();

            List <UserAddressInfo> list = profile.UserAddress.GetList();

            foreach (UserAddressInfo item in list)
            {
                item.IsDefault = false;
            }
            profile.UserAddress.Insert(model);
            profile.Save();

            BindAddress();

            BindSelectAddress();
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取当前客户端对应的菜单导航文件
        /// </summary>
        /// <returns></returns>
        private string GetMenuNavFile()
        {
            context = HttpContext.Current;
            CustomProfileCommon profile = new CustomProfileCommon();
            string userName             = profile.GetUserName();

            return(context.Server.MapPath(string.Format("~/App_Data/AdminData/{0}.xml", userName)));
        }
Exemplo n.º 13
0
        public List <Model.MenuNav> GetTabs()
        {
            BLL.MenuNav         mnBll   = new BLL.MenuNav();
            CustomProfileCommon profile = new CustomProfileCommon();
            string fileName             = string.Format("~/App_Data/AdminData/{0}.xml", profile.GetUserName());

            return(mnBll.GetList(Server.MapPath(fileName)));
        }
Exemplo n.º 14
0
 protected string GetCount()
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     return(profile.ShoppingCart.Count.ToString());
 }
Exemplo n.º 15
0
 protected string GetTotalPrice()
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     return(profile.ShoppingCart.TotalPrice.ToString());
 }
Exemplo n.º 16
0
        private void OnCommit()
        {
            bool hasSucceed = false;

            if (profile == null)
            {
                profile = new CustomProfileCommon();
            }
            if (!nId.Equals(Guid.Empty))
            {
                List <Model.UserAddressInfo> list = profile.UserAddress.GetList();
                Model.UserAddressInfo updateModel = list.Find(delegate(Model.UserAddressInfo m) { return(m.NumberID == nId); });
                if (updateModel != null)
                {
                    if (!OnCheckForm(ref updateModel))
                    {
                        return;
                    }
                    profile.UserAddress.Update(updateModel);
                    hasSucceed = true;
                }
            }
            else
            {
                if (profile.UserAddress.Count >= 5)
                {
                    WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "当前地址数量已达上限(5个),若要继续添加新地址,请先删除部分收货地址。", "操作错误", "error");
                    return;
                }
                List <Model.UserAddressInfo> list = profile.UserAddress.GetList();

                Model.UserAddressInfo model = new Model.UserAddressInfo();
                if (!OnCheckForm(ref model))
                {
                    return;
                }
                Model.UserAddressInfo model2 = list.Find(delegate(Model.UserAddressInfo m)
                {
                    return(m.Receiver == model.Receiver && m.ProvinceCity == model.ProvinceCity && m.Address == model.Address && m.Mobilephone == model.Mobilephone && m.Telephone == model.Telephone && m.Email == model.Email);
                });
                if (model2 != null)
                {
                    WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "已存在相同记录,请检查");
                    return;
                }

                model.NumberID = Guid.NewGuid();

                profile.UserAddress.Insert(model);
                hasSucceed = true;
            }

            if (hasSucceed)
            {
                profile.Save();
                WebHelper.MessageBox.Show(this.Page, lbtnPostBack, "操作成功", "ListAddress.aspx");
            }
        }
Exemplo n.º 17
0
 private void Bind()
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     rpData.DataSource = profile.ShoppingCart.CartItems;
     rpData.DataBind();
 }
Exemplo n.º 18
0
 private void Del(string productId)
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     profile.ShoppingCart.Remove(productId);
     profile.Save();
     Bind();
 }
Exemplo n.º 19
0
 /// <summary>
 /// 直接购买
 /// </summary>
 /// <param name="productId"></param>
 private void ToBuy(string productId)
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     profile.ShoppingCart.Add(productId);
     profile.Save();
     Response.Redirect("ShoppingCart/ListCart.aspx", true);
 }
Exemplo n.º 20
0
        public string DeleteUserCustomAttr(string attrName)
        {
            attrName = attrName.Trim();
            CustomProfileCommon         profile = new CustomProfileCommon();
            List <Model.UserCustomAttr> list    = profile.UserCustomAttr.GetList();

            Model.UserCustomAttr model = list.Find(delegate(Model.UserCustomAttr m) { return(m.AttrName.ToLower() == attrName.ToLower()); });
            profile.UserCustomAttr.Remove(model);
            profile.Save();

            return("操作成功");
        }
Exemplo n.º 21
0
        public void SetMigrateAnonymous()
        {
            var userId = WebCommon.GetUserId();
            IList <SiteMenusInfo> smis = new List <SiteMenusInfo>();
            UserProfileInfo       upi  = new UserProfileInfo();
            var menuBll = new SiteMenus();

            if (Roles.GetRolesForUser().Length == 0)
            {
                var      guestRole = new SiteRoles().GetAspnetModel(Membership.ApplicationName, "guest");
                string[] accessIds = { guestRole.Id.ToString() };
                smis = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds, false);
                upi  = new UserProfileInfo {
                    SiteCode = AppCode, SiteTitle = GlobalConfig.SiteTitle
                };
            }
            else
            {
                var accessIds = new List <string>();
                accessIds.Add(userId.ToString());
                var roleIds = new SiteRoles().GetAspnetRoleIds(Membership.ApplicationName, Roles.GetRolesForUser());
                foreach (var item in roleIds)
                {
                    accessIds.Add(item.ToString());
                }
                var    isAdmin = HttpContext.Current.User.IsInRole("Administrators");
                Task[] tasks   = new Task[2];
                tasks[0] = Task.Factory.StartNew(() =>
                {
                    var fuInfo = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        upi.SiteCode    = fuInfo.SiteCode;
                        upi.SiteTitle   = fuInfo.SiteTitle;
                        upi.SiteLogo    = string.IsNullOrWhiteSpace(fuInfo.SiteLogo) ? "" : WebCommon.GetSiteAppName() + fuInfo.SiteLogo;
                        upi.CultureName = fuInfo.CultureName;
                    }
                });

                tasks[1] = Task.Factory.StartNew(() =>
                {
                    smis = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds.ToArray(), isAdmin);
                });
                Task.WaitAll(tasks);
            }

            var Profile = new CustomProfileCommon();

            Profile.UserMenus = JsonConvert.SerializeObject(smis);
            Profile.UserInfo  = JsonConvert.SerializeObject(upi);

            Profile.Save();
        }
Exemplo n.º 22
0
        public static List <MenusInfo> GetUserMenus()
        {
            List <MenusInfo>    userMenuList = new List <MenusInfo>();
            CustomProfileCommon profile      = new CustomProfileCommon();
            var sUserMenu = profile.UserMenus;

            if (!string.IsNullOrEmpty(sUserMenu))
            {
                userMenuList = JsonConvert.DeserializeObject <List <MenusInfo> >(sUserMenu).FindAll(m => m.IsView && m.Descr != "hide");
            }

            return(userMenuList);
        }
Exemplo n.º 23
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            CustomProfileCommon profile          = new CustomProfileCommon();
            CustomProfileCommon anonymousProfile = profile.GetProfile(args.AnonymousID, false);

            profile.ShoppingCart = (BLL.Cart)anonymousProfile.GetPropertyValue("ShoppingCart");

            ProfileManager.DeleteProfile(args.AnonymousID);
            AnonymousIdentificationModule.ClearAnonymousIdentifier();

            profile.Save();

            // Delete the user row that was created for the anonymous user.
            Membership.DeleteUser(args.AnonymousID, true);
        }
Exemplo n.º 24
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                BindMenuNav();

                //绑定菜单导航
                BindCategory();
            }

            if (profile == null)
            {
                profile = new CustomProfileCommon();
            }
            lbCartCount.InnerText = profile.ShoppingCart.Count.ToString();
        }
Exemplo n.º 25
0
        /// <summary>
        /// 导出存放地点
        /// </summary>
        /// <param name="context"></param>
        private void OnExportProduct(HttpContext context)
        {
            var sqlWhere = new StringBuilder(100);
            var parms    = new ParamsHelper();
            var Profile  = new CustomProfileCommon();

            if (!(HttpContext.Current.User.IsInRole("Administrators") && HttpContext.Current.User.IsInRole("Administrators")) && !string.IsNullOrEmpty(Profile.UserRule))
            {
                sqlWhere.Append("and CHARINDEX(convert(varchar(36),p.DepmtId),'" + Profile.UserRule + "') > 0 ");
            }
            var bll = new Product();
            var ds  = bll.GetExportData(sqlWhere.ToString(), parms.ToArray());
            var dt  = ds.Tables[0];

            HttpClientHelper.Export(context, dt);
        }
Exemplo n.º 26
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            AnonymousIdentificationModule.ClearAnonymousIdentifier();

            try
            {
                var userId    = WebCommon.GetUserId();
                var menuBll   = new SiteMenus();
                var accessIds = new List <string>();
                accessIds.Add(userId.ToString());
                Task[] tasks = new Task[3];
                tasks[0] = Task.Factory.StartNew(() =>
                {
                    var roleIds = new SiteRoles().GetAspnetRoleIds(Roles.GetRolesForUser());
                    foreach (var item in roleIds)
                    {
                        accessIds.Add(item.ToString());
                    }
                });
                var userProfileInfo = new UserProfileInfo();
                tasks[1] = Task.Factory.StartNew(() =>
                {
                    var fuInfo = new FeatureUser().GetModel(userId, "UserProfile");
                    if (fuInfo != null)
                    {
                        userProfileInfo.SiteCode    = fuInfo.SiteCode;
                        userProfileInfo.SiteTitle   = fuInfo.SiteTitle;
                        userProfileInfo.SiteLogo    = string.IsNullOrWhiteSpace(fuInfo.SiteLogo) ? "" : WebCommon.GetSiteAppName() + fuInfo.SiteLogo;
                        userProfileInfo.CultureName = fuInfo.CultureName;
                    }
                });
                IList <SiteMenusInfo> maList = new List <SiteMenusInfo>();
                tasks[2] = Task.Factory.StartNew(() =>
                {
                    maList = menuBll.GetMenusAccess(Membership.ApplicationName, accessIds.ToArray(), User.IsInRole("Administrators"));
                });
                Task.WaitAll(tasks);

                var Profile = new CustomProfileCommon();
                Profile.UserMenus = JsonConvert.SerializeObject(maList);
                Profile.UserInfo  = JsonConvert.SerializeObject(userProfileInfo);

                Profile.Save();
            }
            catch { }
        }
Exemplo n.º 27
0
        private void OnChangeAddress()
        {
            string numberId = hNId.Value.Trim();

            if (!string.IsNullOrEmpty(numberId))
            {
                if (profile == null)
                {
                    profile = new CustomProfileCommon();
                }
                UserAddressInfo selectModel = profile.UserAddress.GetModel(Guid.Parse(numberId));
                if (selectModel != null)
                {
                    ltrHasAddress.Text = string.Format("<p>{3} &nbsp; {2} &nbsp;  &nbsp; <br />{1} &nbsp; {0} </p>", selectModel.Address, selectModel.ProvinceCity.Replace("-", " "), selectModel.Mobilephone + " " + selectModel.Telephone, selectModel.Receiver);
                }
            }
        }
Exemplo n.º 28
0
        protected void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            AnonymousIdentificationModule.ClearAnonymousIdentifier();
            Membership.DeleteUser(args.AnonymousID, true);

            try
            {
                string[] userRoles          = Roles.GetRolesForUser();
                var      menuBll            = new Menus();
                var      userMenuAccessList = menuBll.GetUserMenuAccessList(WebCommon.GetUserId(), userRoles);

                CustomProfileCommon profile = new CustomProfileCommon();
                profile.UserMenus = JsonConvert.SerializeObject(userMenuAccessList);
                profile.Save();
            }
            catch {
            }
        }
Exemplo n.º 29
0
        private void BindSelectAddress()
        {
            if (profile == null)
            {
                profile = new CustomProfileCommon();
            }
            List <UserAddressInfo> list = profile.UserAddress.GetList();

            if (list != null && list.Count > 0)
            {
                UserAddressInfo selectModel = list.Find(delegate(UserAddressInfo m) { return(m.IsDefault == true); });
                if (selectModel == null)
                {
                    selectModel = list.Find(delegate(UserAddressInfo m) { return(m.LastUpdatedDate == list.Max(mi => mi.LastUpdatedDate)); });
                }

                ltrHasAddress.Text = string.Format("<p>{3} &nbsp; {2} &nbsp;  &nbsp; <br />{1} &nbsp; {0} </p>", selectModel.Address, selectModel.ProvinceCity.Replace("-", " "), selectModel.Mobilephone + " " + selectModel.Telephone, selectModel.Receiver);
                hNId.Value         = selectModel.NumberID.ToString();
            }
        }
Exemplo n.º 30
0
 private void Bind()
 {
     if (!nId.Equals(Guid.Empty))
     {
         if (profile == null)
         {
             profile = new CustomProfileCommon();
         }
         Model.UserAddressInfo model = profile.UserAddress.GetModel(nId);
         if (model != null)
         {
             txtReceiver.Value     = model.Receiver;
             txtProvinceCity.Value = model.ProvinceCity;
             txtAddress.Value      = model.Address;
             txtMobilephone.Value  = model.Mobilephone;
             txtTelephone.Value    = model.Telephone;
             txtEmail.Value        = model.Email;
         }
     }
 }