protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            string link = RequestData.Get <string>("link");

            typeId = RequestData.Get <string>("TypeId", String.Empty);

            ImgNews ent = null;

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

            case RequestActionEnum.Custom:
                if (this.RequestActionString.ToLower() == "submitnews")
                {
                    ImgNews ne = ImgNews.Find(this.RequestData["Id"].ToString());
                    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 == "batchdelete")
                {
                    DoBatchDelete();
                }
                break;

            default:
                if (link == "home")
                {
                    string path = DataHelper.QueryValue("select g.Path from SysGroup g inner join sysusergroup ug on ug.GroupId=g.GroupId where UserId='" + UserInfo.UserID + "'") + "";
                    string sql  = @"select n.* from ImgNews n 
                                    inner join NewsType nt on nt.Id=n.TypeId
                                    where TypeId='{2}' 
                                    and State='2' and isnull(ExpireTime,'2099-01-01')>=getdate()
                                    and (charindex('{0}',n.CreateId)>0 or charindex('{0}',n.ReceiveUserId)>0 or charindex('{0}',nt.AllowQueryId)>0 or 
                                    exists (select Id from Competence c where c.Ext1=n.Id and charindex(PId,'{1}')>0)
                                    or exists (select Id from Competence c where c.Ext1=nt.Id and charindex(PId,'{1}')>0))";
                    sql = string.Format(sql, UserInfo.UserID, path, typeId);
                    PageState.Add("DataList", GetPageData(sql, SearchCriterion));
                }
                else
                {
                    string where = " and isnull(ExpireTime,'2099-01-01')>=getdate() ";
                    if (RequestData.Get <string>("Expire") == "true")
                    {
                        where = " and isnull(ExpireTime,'2099-01-01')<getdate() ";
                    }
                    foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches)
                    {
                        if (!String.IsNullOrEmpty(item.Value.ToString()))
                        {
                            switch (item.PropertyName)
                            {
                            default:
                                where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                                break;
                            }
                        }
                    }
                    SearchCriterion.SetSearch("TypeId", typeId);
                    ents = ImgNews.FindAll(SearchCriterion, Expression.Sql(" CreateId = '" + UserInfo.UserID + "' " + where)).OrderByDescending(o => o.CreateTime).ToArray();

                    this.PageState.Add("DataList", ents);
                }
                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);
            }
        }
예제 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op     = RequestData.Get <string>("op");
            typeId = RequestData.Get <string>("TypeId", String.Empty);
            ImgNews ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Delete:
                ent = this.GetTargetData <ImgNews>();
                ent.Delete();
                break;

            case RequestActionEnum.Custom:
                //启动流程
                if (this.RequestActionString.ToLower() == "startflow")
                {
                    ImgNews ne = ImgNews.Find(this.RequestData["Id"].ToString());
                    //启动流程
                    string key = "NewsPub";
                    //表单路径,后面加上参数传入
                    string formUrl = "/Modules/PubNews/NewsEdit.aspx?op=u&&Id=" + ne.Id;
                    Aim.WorkFlow.WorkFlow.StartWorkFlow(ne.Id, formUrl, ne.Title, key, this.UserInfo.UserID, this.UserInfo.Name);
                    PageState.Add("message", "启动成功");
                    return;
                }
                else if (RequestActionString == "batchdelete")
                {
                    DoBatchDelete();
                }
                else if (this.RequestActionString.ToLower() == "submitnews")
                {
                    ImgNews ne = ImgNews.Find(this.RequestData["Id"].ToString());
                    ne.PostTime = DateTime.Now;
                    ne.State    = this.RequestData["state"].ToString();
                    string state = this.RequestData["state"] + "";
                    if (state == "2")
                    {
                        ne.PostUserId   = UserInfo.UserID;
                        ne.PostUserName = UserInfo.Name;
                        ne.PostTime     = DateTime.Now;
                        PageState.Add("message", "发布成功");
                    }
                    else if (state == "0")
                    {
                        PageState.Add("message", "退回成功");
                    }
                    else
                    {
                        ne.PostUserId   = "";
                        ne.PostUserName = "";
                        ne.PostTime     = null;
                        PageState.Add("message", "撤销成功");
                    }
                    ne.Save();
                    return;
                }
                break;

            default:
                string where = " and isnull(ExpireTime,'2099-01-01')>=getdate() ";
                if (RequestData.Get <string>("Expire") == "true")
                {
                    where = " and isnull(ExpireTime,'2099-01-01')<getdate() ";
                }
                foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches)
                {
                    if (!String.IsNullOrEmpty(item.Value.ToString()))
                    {
                        switch (item.PropertyName)
                        {
                        default:
                            where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                            break;
                        }
                    }
                }
                SearchCriterion.SetSearch("TypeId", typeId);
                ents = ImgNews.FindAll(SearchCriterion, Expression.Sql(" (State='1' or State='2') " + where)).OrderByDescending(o => o.CreateTime).ToArray();

                this.PageState.Add("DataList", ents);
                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);
            }
        }