コード例 #1
0
ファイル: ListCart.aspx.cs プロジェクト: qq283335746/ECShop
        /// <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);
            }
        }
コード例 #2
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();
        }
コード例 #3
0
 /// <summary>
 /// 加入购物车
 /// </summary>
 /// <param name="productId"></param>
 private void AddCart(string productId)
 {
     if (profile == null)
     {
         profile = new CustomProfileCommon();
     }
     profile.ShoppingCart.Add(productId);
     profile.Save();
     Response.Redirect("ShoppingCart/AddCartSucceed.aspx", true);
 }
コード例 #4
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, "操作成功");
            }
        }
コード例 #5
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("操作成功");
        }
コード例 #6
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");
            }
        }
コード例 #7
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("操作成功");
        }
コード例 #8
0
ファイル: Auth.cs プロジェクト: qq283335746/MyContentSystem
        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();
        }
コード例 #9
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);
        }
コード例 #10
0
ファイル: Global.asax.cs プロジェクト: qq283335746/Qdhtyy
        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 { }
        }
コード例 #11
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 {
            }
        }
コード例 #12
0
        /// <summary>
        /// 删除
        /// </summary>
        private void OnDelete()
        {
            string sItemsAppend = hV.Value.Trim();

            if (string.IsNullOrEmpty(sItemsAppend))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "请勾选一行或多行数据再进行操作", "操作错误", "error");
                return;
            }
            string[]            items      = sItemsAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            bool                hasChanged = false;
            CustomProfileCommon profile    = new CustomProfileCommon();

            foreach (string item in items)
            {
                profile.UserAddress.Remove(Guid.Parse(item));
                hasChanged = true;
            }
            if (hasChanged)
            {
                profile.Save();
                Bind();
            }
        }