Exemplo n.º 1
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            id = RequestData.Get <string>("id");
            if (!string.IsNullOrEmpty(id))
            {
                msg = News.Find(id);
            }
            switch (RequestActionString)
            {
            case "batchcollection":
                //收藏
                try
                {
                    //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) };
                    CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + RequestData["Id"] + "' and UserId='" + UserInfo.UserID + "'");
                    if (Ctus.Length == 0)
                    {
                        CollectionToUser Ctu = new CollectionToUser();
                        Ctu.MsgId      = RequestData["Id"] + "";
                        Ctu.UserId     = UserInfo.UserID;
                        Ctu.CreateId   = UserInfo.UserID + "";
                        Ctu.CreateName = UserInfo.Name + "";

                        Ctu.DoSave();
                        this.PageState.Add("result", "已收藏");
                    }
                    else
                    {
                        CollectionToUser.DoBatchDelete(Ctus[0].Id);
                        this.PageState.Add("result", "已取消收藏");
                    }
                }
                catch (Exception ex)
                {
                    this.PageState.Add("result", ex.Message);
                }
                break;

            case "readstate":
                //标记为已阅状态
                if (!string.IsNullOrEmpty(msg.ReadState))
                {
                    msg.ReadState += "," + UserInfo.UserID;
                }
                else
                {
                    msg.ReadState = UserInfo.UserID;
                }
                msg.DoUpdate();
                break;

            default:
                DoSelect();
                break;
            }
        }
Exemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (this.Request["Id"] != null)
            {
                if (this.Request["Id"].Length == 8)
                {
                    var _link = Aim.Common.ConfigurationHosting.SystemConfiguration.AppSettings["GoodwayPortalUrl"].Replace("/portal/Portal.aspx", "");
                    _link += "/officeauto/PubInfo/InformView.aspx?FuncType=View&Id=" + this.Request["Id"] + "&PassCode=" + Session["PassCode"];
                    Response.Redirect(_link);
                }
                News msg = News.Find(this.Request["Id"]);
                if (msg.State == "2")
                {
                    msg.ReadCount = msg.ReadCount == null ? 1 : msg.ReadCount.Value + 1;
                    msg.Save();
                }

                if (msg.PostTime != null && msg.PostTime.HasValue)
                {
                    msg.CreateName = ((DateTime)msg.PostTime).ToString("yyyy-MM-dd HH:mm");
                }
                CollectionToUser[] cts = CollectionToUser.FindAllByProperties("MsgId", msg.Id, "UserId", UserInfo.UserID);
                PageState.Add("collection", cts.Length > 0 ? "on" : "off");
                this.SetFormData(msg);
            }

            if (RequestActionString == "batchcollection")
            {
                //收藏
                try
                {
                    //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) };
                    CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + RequestData["Id"] + "' and UserId='" + UserInfo.UserID + "'");
                    if (Ctus.Length == 0)
                    {
                        CollectionToUser Ctu = new CollectionToUser();
                        Ctu.MsgId      = RequestData["Id"] + "";
                        Ctu.UserId     = UserInfo.UserID;
                        Ctu.CreateId   = UserInfo.UserID + "";
                        Ctu.CreateName = UserInfo.Name + "";

                        Ctu.DoSave();
                        this.PageState.Add("result", "已收藏");
                    }
                    else
                    {
                        CollectionToUser.DoBatchDelete(Ctus[0].Id);
                        this.PageState.Add("result", "已取消收藏");
                    }
                }
                catch (Exception ex)
                {
                    this.PageState.Add("result", ex.Message);
                }
            }
            else if (RequestActionString == "readstate")
            {
                News msg = News.Find(this.RequestData["Id"]);

                //添加阅读状态
                msg.ReadState = (msg.ReadState + "").Contains(UserInfo.UserID) ? msg.ReadState : msg.ReadState + UserInfo.UserID + ",";
                msg.DoUpdate();
            }
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (this.Request["Id"] != null)
            {
                VideoNews msg = VideoNews.Find(this.Request["Id"]);
                if (msg != null)
                {
                    if (msg.State == "2")
                    {
                        msg.Ext1 = msg.Ext1 == null ? "1" : (Convert.ToInt32(msg.Ext1) + 1) + "";
                        msg.Save();
                    }

                    if (msg.PostTime != null && msg.PostTime.HasValue)
                    {
                        msg.CreateName = ((DateTime)msg.PostTime).ToString("yyyy-MM-dd HH:mm");
                    }
                    CollectionToUser[] cts = CollectionToUser.FindAllByProperties("MsgId", msg.Id, "UserId", UserInfo.UserID);
                    PageState.Add("collection", cts.Length > 0 ? "on" : "off");
                    this.SetFormData(msg);

                    VideoNewDetail[] imgdetails = VideoNewDetail.FindAllByProperty("PId", msg.Id);
                    if (imgdetails.Length > 0)
                    {
                        Url = imgdetails[0].ImgPath.TrimEnd(',');
                        for (int i = 0; i < imgdetails.Length; i++)
                        {
                            litcontent.Text += "<p id='p" + i + "' style='margin-top: 20px;' tag='" + imgdetails[i].ImgPath + "'>" + imgdetails[i].Content + "</p>";
                            litimgs.Text    += "<li><img src='" + imgdetails[i].Ext1 + "' /><tt></tt></li>";
                        }
                    }
                }
            }

            if (RequestActionString == "batchcollection")
            {
                //收藏
                try
                {
                    //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) };
                    CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + RequestData["Id"] + "' and UserId='" + UserInfo.UserID + "'");
                    if (Ctus.Length == 0)
                    {
                        CollectionToUser Ctu = new CollectionToUser();
                        Ctu.MsgId      = RequestData["Id"] + "";
                        Ctu.UserId     = UserInfo.UserID;
                        Ctu.CreateId   = UserInfo.UserID + "";
                        Ctu.CreateName = UserInfo.Name + "";

                        Ctu.DoSave();
                        this.PageState.Add("result", "已收藏");
                    }
                    else
                    {
                        CollectionToUser.DoBatchDelete(Ctus[0].Id);
                        this.PageState.Add("result", "已取消收藏");
                    }
                }
                catch (Exception ex)
                {
                    this.PageState.Add("result", ex.Message);
                }
            }
            else if (RequestActionString == "readstate")
            {
                VideoNews msg = VideoNews.Find(this.RequestData["Id"]);

                //添加阅读状态
                msg.Ext2 = (msg.Ext2 + "").Contains(UserInfo.UserID) ? msg.Ext2 : msg.Ext2 + UserInfo.UserID + ",";
                msg.DoUpdate();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Request["Id"] != null)
            {
                News msg = News.Find(this.Request["Id"]);

                if (msg.State == "2")
                {
                    msg.ReadCount = msg.ReadCount == null ? 1 : msg.ReadCount.Value + 1;
                    msg.Save();
                }

                if (msg.PostTime != null && msg.PostTime.HasValue)
                {
                    msg.CreateName = ((DateTime)msg.PostTime).ToString("yyyy-MM-dd HH:mm");
                }

                CollectionToUser[] cts = CollectionToUser.FindAllByProperties("MsgId", msg.Id, "UserId", UserInfo.UserID);
                PageState.Add("collection", cts.Length > 0 ? "on" : "off");
                this.SetFormData(msg);
            }

            if (RequestActionString == "batchcollection")
            {
                //收藏
                try
                {
                    //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) };
                    CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + RequestData["Id"] + "' and UserId='" + UserInfo.UserID + "'");
                    if (Ctus.Length == 0)
                    {
                        CollectionToUser Ctu = new CollectionToUser();
                        Ctu.MsgId      = RequestData["Id"] + "";
                        Ctu.UserId     = UserInfo.UserID;
                        Ctu.CreateId   = UserInfo.UserID + "";
                        Ctu.CreateName = UserInfo.Name + "";

                        Ctu.DoSave();
                        this.PageState.Add("result", "已收藏");
                    }
                    else
                    {
                        CollectionToUser.DoBatchDelete(Ctus[0].Id);
                        this.PageState.Add("result", "已取消收藏");
                    }
                }
                catch (Exception ex)
                {
                    this.PageState.Add("result", ex.Message);
                }
            }
            else if (RequestActionString == "readstate")
            {
                News msg = News.Find(this.RequestData["Id"]);

                //添加阅读状态
                msg.ReadState = (msg.ReadState + "").Contains(UserInfo.UserID) ? msg.ReadState : msg.ReadState + UserInfo.UserID + ",";
                msg.Save();
            }
            //在线预览
            if (RequestActionString == "View")
            {
                string fileName = RequestData["fileName"] + "";
                string type     = RequestData["type"] + "";

                string path = "/Document/" + fileName;

                this.PageState.Add("filepath", path);
                this.PageState.Add("type", type);
            }
        }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            if (context.Request["opera"] == "batchcollection")
            {
                string Id = context.Request["id"];
                if (!string.IsNullOrEmpty(Id))
                {
                    //收藏
                    try
                    {
                        //object[] pram = { new SqlParameter("MsgId", RequestData["Id"]), new SqlParameter("UserId", UserInfo.UserID) };
                        CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + Id + "' and UserId='" + UserInfo.UserID + "'");
                        if (Ctus.Length == 0)
                        {
                            CollectionToUser Ctu = new CollectionToUser();
                            Ctu.MsgId      = Id + "";
                            Ctu.UserId     = UserInfo.UserID;
                            Ctu.CreateId   = UserInfo.UserID;
                            Ctu.CreateName = UserInfo.Name;

                            Ctu.DoSave();
                            context.Response.Write("已收藏");
                        }
                        else
                        {
                            CollectionToUser.DoBatchDelete(Ctus[0].Id);
                            context.Response.Write("已取消收藏");
                        }
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write(ex.Message);
                    }
                }
            }
            else if (context.Request["opera"] == "readstate")
            {
                string Id = context.Request["id"];
                if (!string.IsNullOrEmpty(Id))
                {
                    try
                    {
                        ImgNews news = ImgNews.TryFind(Id);
                        if (news != null)
                        {
                            if ((news.Ext2 + "").Contains(UserInfo.UserID))
                            {
                                return;
                            }
                            news.Ext2 += UserInfo.UserID;
                            news.DoUpdate();
                            context.Response.Write("标记成功!");
                        }
                    }
                    catch (Exception ex)
                    {
                        context.Response.Write(ex.Message);
                    }
                }
            }
        }