Exemplo n.º 1
0
        public ActionResult Edit(FriendLinkModel model, int id = -1)
        {
            FriendLinkInfo friendLinkInfo = FriendLinks.GetFriendLinkById(id);

            if (friendLinkInfo == null)
            {
                return(PromptView("友情链接不存在"));
            }

            if (ModelState.IsValid)
            {
                friendLinkInfo.Name         = model.FriendLinkName;
                friendLinkInfo.Title        = model.FriendLinkTitle == null ? "" : model.FriendLinkTitle;
                friendLinkInfo.Logo         = model.FriendLinkLogo == null ? "" : model.FriendLinkLogo;
                friendLinkInfo.Url          = model.FriendLinkUrl;
                friendLinkInfo.Target       = model.Target;
                friendLinkInfo.DisplayOrder = model.DisplayOrder;

                FriendLinks.UpdateFriendLink(friendLinkInfo);
                AddAdminOperateLog("修改友情链接", "修改友情链接,友情链接ID为:" + id);
                return(PromptView("友情链接修改成功"));
            }

            Load();
            return(View(model));
        }
Exemplo n.º 2
0
 public static bool InsertURL(FriendLinks fl)
 {
     using (var db = new DataContext())
     {
         var result = db.FriendLinks.Add(fl);
         return(db.SaveChanges() > 0);
     }
 }
Exemplo n.º 3
0
        public void InsertURLTest()
        {
            FriendLinks friendLinks = new FriendLinks();

            friendLinks.FriendLinksId = SnowFlake_Net.GenerateSnowFlakeID();
            friendLinks.ThemeId       = SnowFlake_Net.GenerateSnowFlakeID();
            friendLinks.Title         = "标题1";
            friendLinks.Title         = "标题2";
            Assert.Fail();
        }
    protected void rpList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = int.Parse(e.CommandArgument.ToString());

        if (e.CommandName == "Delete")
        {
            FriendLinks.FriendLinkDelete(id);
        }
        BindLinks();
    }
Exemplo n.º 5
0
        //
        // GET: /FriendLink/

        /// <summary>
        /// 友情链接列表
        /// </summary>
        public ActionResult List()
        {
            FriendLinkListModel model = new FriendLinkListModel();

            model.FriendLinkList = FriendLinks.GetFriendLinkList();

            string[] sizeList = StringHelper.SplitString(WorkContext.SiteConfig.FriendLinkThumbSize);

            ViewData["size"] = sizeList[sizeList.Length / 2];
            SiteUtils.SetAdminRefererCookie(Url.Action("list"));
            return(View(model));
        }
Exemplo n.º 6
0
    void BindLinks()
    {
        int id = 0;

        try
        {
            id                    = int.Parse(Request.QueryString["id"]);
            lnk                   = FriendLinks.FriendLinkGet(id);
            txtTitle.Text         = lnk.Title;
            txtLink.Text          = lnk.Url;
            ddlRank.SelectedIndex = lnk.Rank - 1;
        }
        catch (Exception ex)
        {
            throw new HHException(ExceptionType.NoMasterError, ex.Message);
        }
    }
        string BindLinks()
        {
            List <FriendLink> links = FriendLinks.FriendLinkGet();

            if (links.Count == 0)
            {
                return("");
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (FriendLink fl in links)
                {
                    sb.AppendFormat("<a href='{0}' target='_blank'>{1}</a>", fl.Url, fl.Title);
                }
                return(sb.ToString());
            }
        }
Exemplo n.º 8
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        if (lnk == null)
        {
            throw new HHException(ExceptionType.NoMasterError, "无法完成信息修改!");
        }
        lnk.Title = txtTitle.Text.Trim();
        lnk.Url   = txtLink.Text.Trim();
        lnk.Rank  = int.Parse(ddlRank.SelectedValue);
        bool r = FriendLinks.FriendLinkUpdate(lnk);

        if (r)
        {
            base.ExecuteJs("msg('成功修改此友情链接信息!',true)", false);
        }
        else
        {
            base.ExecuteJs("msg('修改友情链接信息失败,请联系管理员!')", false);
        }
    }
Exemplo n.º 9
0
    protected void btnPost_Click(object sender, EventArgs e)
    {
        FriendLink lnk = new FriendLink();

        lnk.Title      = txtTitle.Text.Trim();
        lnk.Url        = txtLink.Text.Trim();
        lnk.Rank       = int.Parse(ddlRank.SelectedValue);
        lnk.CreateUser = Profile.AccountInfo.UserID;
        lnk.CreateTime = DateTime.Now;
        bool r = FriendLinks.FriendLinkAdd(lnk);

        if (r)
        {
            base.ExecuteJs("msg('成功新增一条友情链接!',true)", false);
        }
        else
        {
            base.ExecuteJs("msg('新增友情链接失败,请联系管理员!')", false);
        }
    }
Exemplo n.º 10
0
        public ActionResult Add(FriendLinkModel model)
        {
            if (ModelState.IsValid)
            {
                FriendLinkInfo friendLinkInfo = new FriendLinkInfo()
                {
                    Name         = model.FriendLinkName,
                    Title        = model.FriendLinkTitle == null ? "" : model.FriendLinkTitle,
                    Logo         = model.FriendLinkLogo == null ? "" : model.FriendLinkLogo,
                    Url          = model.FriendLinkUrl,
                    Target       = model.Target,
                    DisplayOrder = model.DisplayOrder
                };

                FriendLinks.CreateFriendLink(friendLinkInfo);
                AddAdminOperateLog("添加友情链接", "添加友情链接,友情链接为:" + model.FriendLinkName);
                return(PromptView("友情链接添加成功"));
            }
            Load();
            return(View(model));
        }
Exemplo n.º 11
0
        public ActionResult Edit(int id = -1)
        {
            FriendLinkInfo friendLinkInfo = FriendLinks.GetFriendLinkById(id);

            if (friendLinkInfo == null)
            {
                return(PromptView("友情链接不存在"));
            }

            FriendLinkModel model = new FriendLinkModel();

            model.FriendLinkName  = friendLinkInfo.Name;
            model.FriendLinkTitle = friendLinkInfo.Title;
            model.FriendLinkLogo  = friendLinkInfo.Logo;
            model.FriendLinkUrl   = friendLinkInfo.Url;
            model.Target          = friendLinkInfo.Target;
            model.DisplayOrder    = friendLinkInfo.DisplayOrder;
            Load();

            return(View(model));
        }
Exemplo n.º 12
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);
            this.ValidateRequest = false;

            WorkContext.IsHttpAjax  = WebHelper.IsAjax();
            WorkContext.IP          = WebHelper.GetIP();
            WorkContext.RegionInfo  = Regions.GetRegionByIP(WorkContext.IP);
            WorkContext.RegionId    = WorkContext.RegionInfo.RegionId;
            WorkContext.Url         = WebHelper.GetUrl();
            WorkContext.UrlReferrer = WebHelper.GetUrlReferrer();

            //获得用户唯一标示符sid
            WorkContext.Sid = MallUtils.GetSidCookie();
            if (WorkContext.Sid.Length == 0)
            {
                //生成sid
                WorkContext.Sid = Sessions.GenerateSid();
                //将sid保存到cookie中
                MallUtils.SetSidCookie(WorkContext.Sid);
            }

            PartUserInfo partUserInfo;

            //获得用户id
            int uid = MallUtils.GetUidCookie();

            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                //获得保存在cookie中的密码
                string encryptPwd = MallUtils.GetCookiePassword();
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    encryptPwd   = string.Empty;
                    MallUtils.SetUidCookie(-1);
                    MallUtils.SetCookiePassword("");
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, MallUtils.DecryptCookiePassword(encryptPwd));
                    if (partUserInfo != null)
                    {
                        //发放登陆积分
                        Credits.SendLoginCredits(ref partUserInfo, DateTime.Now);
                    }
                    else//当会员的账号或密码不正确时,将用户置为游客
                    {
                        partUserInfo = Users.CreatePartGuest();
                        encryptPwd   = string.Empty;
                        MallUtils.SetUidCookie(-1);
                        MallUtils.SetCookiePassword("");
                    }
                }
                WorkContext.EncryptPwd = encryptPwd;
            }

            //设置用户等级
            if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now)
            {
                UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits);
                Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid);
                partUserInfo.UserRid = userRankInfo.UserRid;
            }

            //当用户被禁止访问时重置用户为游客
            if (partUserInfo.UserRid == 1)
            {
                partUserInfo           = Users.CreatePartGuest();
                WorkContext.EncryptPwd = string.Empty;
                MallUtils.SetUidCookie(-1);
                MallUtils.SetCookiePassword("");
            }

            WorkContext.PartUserInfo = partUserInfo;

            WorkContext.Uid             = partUserInfo.Uid;
            WorkContext.UserName        = partUserInfo.UserName;
            WorkContext.UserEmail       = partUserInfo.Email;
            WorkContext.UserMobile      = partUserInfo.Mobile;
            WorkContext.Password        = partUserInfo.Password;
            WorkContext.NickName        = partUserInfo.NickName;
            WorkContext.Avatar          = partUserInfo.Avatar;
            WorkContext.PayCreditName   = Credits.PayCreditName;
            WorkContext.PayCreditCount  = partUserInfo.PayCredits;
            WorkContext.RankCreditName  = Credits.RankCreditName;
            WorkContext.RankCreditCount = partUserInfo.RankCredits;

            WorkContext.UserRid      = partUserInfo.UserRid;
            WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid);
            WorkContext.UserRTitle   = WorkContext.UserRankInfo.Title;
            //设置用户商城管理员组
            WorkContext.MallAGid           = partUserInfo.MallAGid;
            WorkContext.MallAdminGroupInfo = MallAdminGroups.GetMallAdminGroupById(partUserInfo.MallAGid);
            WorkContext.MallAGTitle        = WorkContext.MallAdminGroupInfo.Title;

            //设置当前控制器类名
            WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower();
            //设置当前动作方法名
            WorkContext.Action  = RouteData.Values["action"].ToString().ToLower();
            WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action);

            WorkContext.ImageCDN  = WorkContext.MallConfig.ImageCDN;
            WorkContext.CSSCDN    = WorkContext.MallConfig.CSSCDN;
            WorkContext.ScriptCDN = WorkContext.MallConfig.ScriptCDN;

            //在线总人数
            WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount();
            //在线游客数
            WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount();
            //在线会员数
            WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount;
            //搜索词
            WorkContext.SearchWord = string.Empty;
            //购物车中商品数量
            WorkContext.CartProductCount = Carts.GetCartProductCountCookie();

            //设置导航列表
            WorkContext.NavList = Navs.GetNavList();
            //设置友情链接列表
            WorkContext.FriendLinkList = FriendLinks.GetFriendLinkList();
            //设置帮助列表
            WorkContext.HelpList = Helps.GetHelpList();
        }
Exemplo n.º 13
0
 public void AddFriendLinks(FriendLinks entity)
 {
     this.Add <FriendLinks>(entity);
 }
Exemplo n.º 14
0
 /// <summary>
 /// 删除友情链接
 /// </summary>
 public ActionResult Del(int[] idList)
 {
     FriendLinks.DeleteFriendLinkById(idList);
     AddAdminOperateLog("删除友情链接", "删除友情链接,友情链接ID为:" + CommonHelper.IntArrayToString(idList));
     return(PromptView("友情链接删除成功"));
 }
Exemplo n.º 15
0
 public void DeleteFriendLink(FriendLinks entity)
 {
     this.Delete <FriendLinks>(entity);
 }
        public void ProcessRequest(HttpContext context)
        {
            string msg = string.Empty;
            bool   suc = false;

            try
            {
                string curUser = string.Empty;
                if (context.Profile.IsAnonymous)
                {
                    curUser = context.Profile.UserName;
                }
                else
                {
                    curUser = Users.GetUniqueId(context.Profile.UserName).ToString();
                }
                NameValueCollection req = context.Request.QueryString;
                string action           = req["action"];
                switch (action)
                {
                case "getFriendLinks":
                    try
                    {
                        suc = true;
                        msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(FriendLinks.FriendLinkGet());
                    }
                    catch (Exception ex)
                    {
                        suc = false;
                        msg = ex.Message;
                    }
                    break;

                case "addShopcart":
                    int      pid    = int.Parse(req["d"]);
                    int      amount = int.Parse(req["c"]);
                    int      mid    = int.Parse(req["m"]);
                    Shopping shop   = new Shopping()
                    {
                        CreateTime   = DateTime.Now,
                        UpdateTime   = DateTime.Now,
                        ModelID      = mid,
                        ProductID    = pid,
                        Quantity     = amount,
                        ShoppingMemo = string.Empty,
                        UserID       = curUser
                    };
                    suc = Shoppings.ShoppingAdd(shop);
                    break;

                case "getPSuggestion":
                    string        v  = req["value"];
                    List <string> sw = WordSearchManager.GetWordSuggest(v, 10);
                    suc = true;
                    msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(sw);
                    break;

                case "getStatistic":
                    List <WordStatistic> wss = WordSearchManager.GetStatistic(GlobalSettings.MinValue, GlobalSettings.MaxValue);
                    wss = wss.GetRange(0, Math.Min(10, wss.Count));
                    suc = true;
                    msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(wss);
                    break;

                case "batchDelete":
                    int i1 = Products.BatchOperation(req["ids"], 2, int.Parse(curUser));
                    if (i1 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchPublish":
                    int i2 = Products.BatchOperation(req["ids"], 1, int.Parse(curUser));
                    if (i2 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchCopy":
                    int i3 = Products.BatchOperation(req["ids"], 3, int.Parse(curUser));
                    if (i3 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchTruncate":
                    int i4 = Products.BatchOperation(req["ids"], 4, int.Parse(curUser));
                    if (i4 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;
                }

                context.Response.Write("{msg:'" + msg + "',suc:" + suc.ToString().ToLower() + "}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{msg:'" + ex.Message + "',suc:false}");
            }
        }
Exemplo n.º 17
0
 void BindLinks()
 {
     rpList.DataSource = FriendLinks.FriendLinkGet();
     rpList.DataBind();
 }
Exemplo n.º 18
0
        public bool InsertURL(FriendLinks fl)
        {
            var result = dataContext.FriendLinks.Add(fl);

            return(dataContext.SaveChanges() > 0);
        }
Exemplo n.º 19
0
 public void UpdateFriendLink(FriendLinks entity)
 {
     this.Update <FriendLinks>(entity);
 }
Exemplo n.º 20
0
        protected override void Initialize(RequestContext requestContext)
        {
            base.Initialize(requestContext);


            //WorkContext.IsHttpAjax = WebHelper.IsAjax();
            WorkContext.IP = WebHelper.GetIP();
            //WorkContext.RegionInfo = Regions.GetRegionByIP(WorkContext.IP);
            //WorkContext.RegionId = WorkContext.RegionInfo.RegionId;
            WorkContext.Url         = WebHelper.GetUrl();
            WorkContext.UrlReferrer = WebHelper.GetUrlReferrer();

            //获得用户唯一标示符sid
            WorkContext.Sid = SiteUtils.GetSidCookie();
            if (WorkContext.Sid.Length == 0)
            {
                //生成sid
                WorkContext.Sid = Sessions.GenerateSid();
                //将sid保存到cookie中
                SiteUtils.SetSidCookie(WorkContext.Sid);
            }

            PartUserInfo partUserInfo;

            //获得用户id
            int uid = SiteUtils.GetUidCookie();

            if (uid < 1)//当用户为游客时
            {
                //创建游客
                partUserInfo = Users.CreatePartGuest();
            }
            else//当用户为会员时
            {
                //获得保存在cookie中的密码
                string encryptPwd = SiteUtils.GetCookiePassword();
                //防止用户密码被篡改为危险字符
                if (encryptPwd.Length == 0 || !SecureHelper.IsBase64String(encryptPwd))
                {
                    //创建游客
                    partUserInfo = Users.CreatePartGuest();
                    encryptPwd   = string.Empty;
                    SiteUtils.SetUidCookie(-1);
                    SiteUtils.SetCookiePassword("");
                }
                else
                {
                    partUserInfo = Users.GetPartUserByUidAndPwd(uid, SiteUtils.DecryptCookiePassword(encryptPwd));
                    //if (partUserInfo != null)
                    //{
                    //    //发放登陆积分
                    //    Credits.SendLoginCredits(ref partUserInfo, DateTime.Now);
                    //}
                    //else//当会员的账号或密码不正确时,将用户置为游客
                    //{
                    //    partUserInfo = Users.CreatePartGuest();
                    //    encryptPwd = string.Empty;
                    //    ShopUtils.SetUidCookie(-1);
                    //    ShopUtils.SetCookiePassword("");
                    //}
                }
                WorkContext.EncryptPwd = encryptPwd;
            }

            ////设置用户等级
            //if (UserRanks.IsBanUserRank(partUserInfo.UserRid) && partUserInfo.LiftBanTime <= DateTime.Now)
            //{
            //    UserRankInfo userRankInfo = UserRanks.GetUserRankByCredits(partUserInfo.PayCredits);
            //    Users.UpdateUserRankByUid(partUserInfo.Uid, userRankInfo.UserRid);
            //    partUserInfo.UserRid = userRankInfo.UserRid;
            //}

            WorkContext.PartUserInfo = partUserInfo;

            WorkContext.Uid        = partUserInfo.UserID;
            WorkContext.UserName   = partUserInfo.UserName;
            WorkContext.UserEmail  = partUserInfo.Email;
            WorkContext.UserMobile = partUserInfo.Mobile;
            WorkContext.Password   = partUserInfo.Password;
            WorkContext.NickName   = partUserInfo.NickName;
            //WorkContext.Avatar = partUserInfo.Avatar;
            //WorkContext.PayCreditName = Credits.PayCreditName;
            //WorkContext.PayCreditCount = partUserInfo.PayCredits;
            //WorkContext.RankCreditName = Credits.RankCreditName;
            //WorkContext.RankCreditCount = partUserInfo.RankCredits;

            //WorkContext.UserRid = partUserInfo.UserRid;
            //WorkContext.UserRankInfo = UserRanks.GetUserRankById(partUserInfo.UserRid);
            //WorkContext.UserRTitle = WorkContext.UserRankInfo.Title;
            ////设置用户管理员组
            //WorkContext.AdminGid = partUserInfo.AdminGid;
            //WorkContext.AdminGroupInfo = AdminGroups.GetAdminGroupById(partUserInfo.AdminGid);
            //WorkContext.AdminGTitle = WorkContext.AdminGroupInfo.Title;

            //设置当前控制器类名
            WorkContext.Controller = RouteData.Values["controller"].ToString().ToLower();
            //设置当前动作方法名
            WorkContext.Action  = RouteData.Values["action"].ToString().ToLower();
            WorkContext.PageKey = string.Format("/{0}/{1}", WorkContext.Controller, WorkContext.Action);

            //当前商城主题名称
            WorkContext.ThemeName = WorkContext.SysConfig.ThemeName;
            //设置图片目录
            WorkContext.ImageDir = string.Format("{0}/themes/{1}/images", WorkContext.SiteConfig.ImageCDN, WorkContext.ThemeName);
            //设置css目录
            WorkContext.CSSDir = string.Format("{0}/themes/{1}/css", WorkContext.SiteConfig.CSSCDN, WorkContext.ThemeName);
            //设置脚本目录
            WorkContext.ScriptDir = string.Format("{0}/themes/{1}/scripts", WorkContext.SiteConfig.ScriptCDN, WorkContext.ThemeName);

            ////在线总人数
            //WorkContext.OnlineUserCount = OnlineUsers.GetOnlineUserCount();
            ////在线游客数
            //WorkContext.OnlineGuestCount = OnlineUsers.GetOnlineGuestCount();
            ////在线会员数
            //WorkContext.OnlineMemberCount = WorkContext.OnlineUserCount - WorkContext.OnlineGuestCount;
            ////搜索词
            //WorkContext.SearchWord = string.Empty;

            //设置导航列表
            WorkContext.NavList = ArticleClass.GetToTalNavList();
            //分类列表
            WorkContext.ClassList = ArticleClass.GetList();
            //设置友情链接列表
            WorkContext.FriendLinkList = FriendLinks.GetFriendLinkList();
            ////设置帮助列表
            //WorkContext.HelpList = Helps.GetHelpList();
        }