예제 #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;
            }
        }
예제 #2
0
 private void DoSelect()
 {
     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");
     SetFormData(msg);
     PageState.Add("ReadStatus", (msg.ReadState + "").IndexOf(UserInfo.UserID));
 }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string  Id   = Request.QueryString["id"];
                ImgNews news = ImgNews.TryFind(Id);
                if (news == null)
                {
                    return;
                }

                if (news.State == "2")
                {
                    news.Ext1 = news.Ext1 == null ? "1" : (Convert.ToInt32(news.Ext1) + 1) + "";
                    news.DoUpdate();
                }

                if (news != null)
                {
                    this.lbltitle.InnerText        = news.Title;
                    this.lblPostDeptName.InnerText = news.PostDeptName;
                    this.lblAuthorName.InnerText   = news.CreateName;
                    this.lblPostTime.InnerText     = news.PostTime != null?news.PostTime.ToString() : "";

                    this.lblReadCount.InnerText = news.Ext1;

                    if ((news.Ext2 + "").Contains(UserInfo.UserID))
                    {
                        lblreadstate.Attributes.Add("style", "display:none");
                    }

                    ImgNewDetail[] imgdetails = ImgNewDetail.FindAllByProperty("PId", news.Id);
                    int            index      = 0;
                    foreach (ImgNewDetail ent in imgdetails)
                    {
                        litimg.Text     += "<img src='/Document/" + ent.ImgPath + "' width='780' height='570'/>";
                        litcontent.Text += "<p id='p" + index + "' style='margin-top:20px;'>" + ent.Content + "</p>";
                        litimgs.Text    += "<li><img src='/Document/" + ent.ImgPath + "'/><tt></tt></li>";
                        index++;
                    }

                    CollectionToUser[] cts = CollectionToUser.FindAllByProperties("MsgId", news.Id, "UserId", UserInfo.UserID);
                    hidcollection.Value = cts.Length > 0 ? "on" : "off";
                }
            }
        }
예제 #4
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);
            }
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");

            News ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Delete:
                ent = this.GetTargetData <News>();
                ent.Delete();
                this.SetMessage("删除成功!");
                break;

            case RequestActionEnum.Custom:
                IList <object> idList = RequestData.GetList <object>("IdList");

                if (idList != null && idList.Count > 0)
                {
                    if (RequestActionString == "batchdelete")
                    {
                        NewsRule.BatchRemoveByPrimaryKeys(idList);
                    }
                }

                if (this.RequestActionString.ToLower() == "submitnews")
                {
                    News ne = News.Find(this.RequestData["Id"].ToString());
                    ne.PostTime = DateTime.Now;
                    ne.State    = this.RequestData["state"].ToString();
                    ne.Save();
                    if (this.RequestData["state"].ToString() == "1")
                    {
                        PageState.Add("message", "发布成功");
                    }
                    else
                    {
                        PageState.Add("message", "撤销成功");
                    }
                    return;
                }
                else if (RequestActionString == "canelFavorite")
                {
                    //取消收藏
                    CollectionToUser[] Ctus = CollectionToUser.FindAll("from CollectionToUser where MsgId='" + RequestData["Id"] + "' and UserId='" + UserInfo.UserID + "'");
                    if (Ctus.Length > 0)
                    {
                        foreach (CollectionToUser ctu in Ctus)
                        {
                            ctu.DoDelete();
                        }
                    }
                }
                break;

            default:
                //ents = NewsRule.FindAll(SearchCriterion, Expression.Sql(" Id in (select MsgId from CollectionToUser where UserId='" + UserInfo.UserID + "' )"));

                string sql = @"select Id,Title,TypeId,PostUserName,PostTime,SaveTime,ExpireTime,[State], 'News' as NewType from News where Id in (select MsgId from CollectionToUser where UserId='" + UserInfo.UserID + "' ) " +
                             "union all " +
                             "select Id,Title,TypeId,PostUserName,PostTime,CreateTime,ExpireTime,[State], 'ImgNews' as NewType from ImgNews where Id in (select MsgId from CollectionToUser where UserId='" + UserInfo.UserID + "' ) " +
                             "union all " +
                             "select Id,Title,TypeId,PostUserName,PostTime,CreateTime,ExpireTime,[State], 'VideoNews' as NewType from VideoNews where Id in (select MsgId from CollectionToUser where UserId='" + UserInfo.UserID + "' )";

                this.PageState.Add("DataList", GetPageData(sql, SearchCriterion));
                break;
            }

            if (!IsAsyncRequest)
            {
                NewsType[] types = NewsType.FindAll();
                Dictionary <string, string> dt = new Dictionary <string, string>();

                foreach (NewsType type in types)
                {
                    dt.Add(type.Id, type.TypeName);
                }

                this.PageState.Add("EnumType", dt);
            }
        }
예제 #8
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);
                    }
                }
            }
        }