private void DoBatchDelete()
        {
            IList <object> idList = RequestData.GetList <object>("IdList");

            if (idList != null && idList.Count > 0)
            {
                foreach (object obj in idList)
                {
                    ImgNewDetail.DeleteAll(" PId='" + obj + "' ");
                }
                VideoNews.DoBatchDelete(idList.ToArray());
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op     = RequestData.Get <string>("op");
            typeId = RequestData.Get <string>("TypeId", String.Empty);
            switch (RequestActionString)
            {
            case "batchdelete":
                IList <object> idList = RequestData.GetList <object>("IdList");
                if (idList != null && idList.Count > 0)
                {
                    NewsRule.BatchRemoveByPrimaryKeys(idList);
                    foreach (object obj in idList)
                    {
                        ImgNewDetail.DeleteAll(" PId='" + obj + "' ");
                        VideoNewDetail.DeleteAll(" PId='" + obj + "' ");

                        string delsql = "delete WorkflowInstance where RelateId='" + obj + "' delete Task where EFormName like '%" + obj + "%'";
                        DataHelper.ExecSql(delsql);
                    }
                    ImgNews.DoBatchDelete(idList.ToArray());
                    VideoNews.DoBatchDelete(idList.ToArray());
                }
                break;

            case "submitnews":
                object news     = null;
                string NewsType = RequestData.Get <string>("NewsType");
                if (NewsType == "视频")
                {
                    ne       = VideoNews.Find(this.RequestData["Id"].ToString());
                    ne.State = this.RequestData["state"].ToString();
                    ne.Save();
                    news = ne;
                }
                else if (NewsType == "图片")
                {
                    imgnew       = ImgNews.Find(this.RequestData["Id"].ToString());
                    imgnew.State = this.RequestData["state"].ToString();
                    imgnew.Save();
                    news = imgnew;
                }
                else
                {
                    ent       = News.Find(this.RequestData["Id"].ToString());
                    ent.State = this.RequestData["state"].ToString();
                    ent.Save();
                    news = ent;
                }

                if (this.RequestData["state"].ToString() == "1")
                {
                    PageState.Add("message", "提交成功");
                }
                else
                {
                    string nid = "";
                    if (news is News)
                    {
                        ent          = news as News;
                        ent.WFState  = "";
                        ent.WFResult = "";
                        ent.Update();
                        nid = ent.Id;
                    }
                    else if (news is ImgNews)
                    {
                        ImgNews imgent = news as ImgNews;
                        imgent.WFState  = "";
                        imgent.WFResult = "";
                        imgent.Update();
                        nid = imgent.Id;
                    }
                    else if (news is VideoNews)
                    {
                        VideoNews videoent = news as VideoNews;
                        videoent.WFState  = "";
                        videoent.WFResult = "";
                        videoent.Update();
                        nid = videoent.Id;
                    }

                    string delsql = "delete WorkflowInstance where RelateId='" + nid + "' delete Task where EFormName like '%" + nid + "%'";
                    DataHelper.ExecSql(delsql);
                    PageState.Add("message", "收回成功");
                }
                break;

            case "submit":
                StartFlow(RequestData.Get <string>("id"));
                break;

            case "autoexecute":
                Task[] tasks = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"));
                if (tasks.Length == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                    tasks = Task.FindAllByProperties(Task.Prop_WorkflowInstanceID, this.RequestData.Get <string>("FlowId"));
                }
                if (tasks.Length > 0)
                {
                    this.PageState.Add("TaskId", tasks[0].ID);
                    string AuditUserId   = RequestData.Get <string>("AuditUserId");
                    string AuditUserName = RequestData.Get <string>("AuditUserName");

                    if (!string.IsNullOrEmpty(AuditUserId))
                    {
                        Aim.WorkFlow.WorkFlow.AutoExecute(tasks[0], new string[] { AuditUserId, AuditUserName });
                    }
                    else
                    {
                        PageState.Add("error", "自动提交申请人失败,请手动提交");
                    }
                }
                else
                {
                    PageState.Add("error", "自动提交申请人失败,请手动提交");
                }
                break;

            case "CancelFlow":
                string id  = RequestData.Get <string>("id");
                string NId = "";
                ent = News.TryFind(id);
                if (ent != null)
                {
                    NId = ent.Id;
                }
                else
                {
                    imgnew = ImgNews.TryFind(id);
                    if (imgnew != null)
                    {
                        NId = imgnew.Id;
                    }
                }
                if (DataHelper.QueryDataTable("Select Id from Task where EFormName like '%" + NId + "%' and OwnerId='" + this.UserInfo.UserID + "' and Status=0 ").Rows.Count == 0)
                {
                    PageState.Add("error", "单据未打回给您或未启动流程,不能作废!");
                }
                else
                {
                    if (ent != null)
                    {
                        ent.WFState  = "";
                        ent.WFResult = "已撤销";
                        ent.Update();
                    }
                    else if (imgnew != null)
                    {
                        imgnew.WFState  = "";
                        imgnew.WFResult = "已撤销";
                        imgnew.Update();
                    }
                    string delsql = "delete WorkflowInstance where RelateId='" + NId + "' delete Task where EFormName like '%" + NId + "%'";
                    DataHelper.ExecSql(delsql);
                }
                break;

            default:
                PageState.Add("WorkFlowState", SysEnumeration.GetEnumDict("WorkFlowState"));
                if (op == "r")
                {
                    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.Id, n.TypeId, n.BelongDeptId, n.Title, n.KeyWord, n.Content, n.ContentType, n.AuthorName, n.PostUserId, n.PostUserName, n.PostDeptId, n.PostDeptName, n.ReceiveDeptId, n.ReceiveDeptName, n.ReceiveUserId, n.ReceiveUserName, n.PostTime, n.ExpireTime, n.SaveTime, n.Pictures, n.Attachments, n.MHT, n.State, n.ImportantGrade, n.ReadCount, n.HomePagePopup, n.LinkPortalImage, n.Class, n.PopupIds, n.Grade, n.AuthorId, n.CreateTime, n.CreateId, n.CreateName, n.Type, n.ReleaseState, n.PId, n.SubmitState, n.NewType, n.ReadState, n.RemindDays, n.RdoType, n.FileType, n.MhtFile from News 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.ReceiveUserId)>0 or charindex('{0}',n.AuthorId)>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)) {3}";
                    //合并老系统的新闻和公告
                    if (typeId == "fa67b910-a692-4df7-83a2-50711ba4bfa5" || typeId == "eb9db227-6adc-4dd1-8783-467aadc2d11b")
                    {
                        if (typeId == "fa67b910-a692-4df7-83a2-50711ba4bfa5")
                        {
                            sql += @" union all select [Id],'fa67b910-a692-4df7-83a2-50711ba4bfa5' [CatalogId],[BelongDeptId],[Title],[KeyWord],[Content],[ContentType]
                                 ,[AuthorName],[PostUserId],[PostUserName],[PostDeptId],[PostDeptName]
                                 ,[ReceiveDeptId],[ReceiveDeptName],[ReceiveUserId],[ReceiveUserName]
                                 ,[PostTime],[ExpireTime],[SaveTime],[Pictures],[Attachments],[MHT]
                                 ,2,[ImportantGrade],[ReadCount],[HomePagePopup],[LinkPortalImage],
                                 '' s,[PopupIds],[Grade],'' authorid,null createtime,null createid,null t,class,null a,null b,null c,null d,null e,null f,null g,null h,null i from BJKY_BeOfficeAuto..PublicInformation WHERE CatalogId = 'OPIC0020' and state=1 {3}";
                        }
                        else
                        {
                            sql += @" union all select [Id],'eb9db227-6adc-4dd1-8783-467aadc2d11b' [CatalogId],[BelongDeptId],[Title],[KeyWord],[Content],[ContentType]
                              ,[AuthorName],[PostUserId],[PostUserName],[PostDeptId],[PostDeptName]
                              ,[ReceiveDeptId],[ReceiveDeptName],[ReceiveUserId],[ReceiveUserName]
                              ,[PostTime],[ExpireTime],[SaveTime],[Pictures],[Attachments],[MHT]
                              ,2,[ImportantGrade],[ReadCount],[HomePagePopup],[LinkPortalImage],
                              '' s,[PopupIds],[Grade],'' authorid,null createtime,null createid,null t,class,null a,null b,null c,null d,null e,null f,null g,null h,null i from BJKY_BeOfficeAuto..PublicInformation WHERE CatalogId = 'OPIC0021' and state=1 {3}";
                        }
                    }
                    string where = "";
                    foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches)
                    {
                        if (item.Value + "" != "")
                        {
                            where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                        }
                    }
                    sql = string.Format(sql, UserInfo.UserID, path, typeId, where);
                    PageState.Add("SysUserList", 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 (item.Value + "" != "")
                        {
                            where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                        }
                    }
                    if (!string.IsNullOrEmpty(typeId))
                    {
                        SearchCriterion.SetSearch("TypeId", typeId);
                        News[] ents = NewsRule.FindAll(SearchCriterion, Expression.Sql(" AuthorId = '" + UserInfo.UserID + "' " + where)).OrderByDescending(o => o.SaveTime).ToArray();
                        this.PageState.Add("SysUserList", ents);
                    }    //图片新闻、视频新闻 不需要过滤(不同的页面)
                    else
                    {
                        string sql = @"select * from (select Id, TypeId, Title, AuthorId, AuthorName, PostDeptId,ReadCount, PostDeptName, PostTime, ExpireTime, SaveTime, [State],'普通' as NewsType, AuditUserId, AuditUserName, WFState, WFResult,
                            (select top 1 ApprovalNodeName from task where [Status]='0' and EFormName like '%'+News.Id+'%') as WFCurrentNode from News
                             union all 
                            select Id, TypeId, Title, CreateId,CreateName, PostDeptId,Ext1, PostDeptName, PostTime, ExpireTime, CreateTime, [State],'图片', AuditUserId, AuditUserName, WFState, WFResult,
                            (select top 1 ApprovalNodeName from task where [Status]='0' and EFormName like '%'+ImgNews.Id+'%') as WFCurrentNode from ImgNews
                            union all 
                            select Id, TypeId, Title, CreateId,CreateName, PostDeptId,Ext1, PostDeptName, PostTime, ExpireTime, CreateTime, [State],'视频', AuditUserId, AuditUserName, WFState, WFResult,
                           (select top 1 ApprovalNodeName from task where [Status]='0' and EFormName like '%'+VideoNews.Id+'%') as WFCurrentNode from VideoNews) t ";
                        this.PageState.Add("SysUserList", GetPageData(sql + " where AuthorId = '" + UserInfo.UserID + "' " + where, 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);
                }
                PageState.Add("EnumType", dt);
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op     = RequestData.Get <string>("op");
            typeId = RequestData.Get <string>("TypeId", String.Empty);
            News ent = null;

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

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

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

                        foreach (object obj in idList)
                        {
                            ImgNewDetail.DeleteAll(" PId='" + obj + "' ");
                            VideoNewDetail.DeleteAll(" PId='" + obj + "' ");
                        }
                        ImgNews.DoBatchDelete(idList.ToArray());
                        VideoNews.DoBatchDelete(idList.ToArray());
                    }
                }
                else if (this.RequestActionString.ToLower() == "submitnews")
                {
                    string NewsType = RequestData.Get <string>("NewsType");
                    if (NewsType == "视频")
                    {
                        VideoNews ne = VideoNews.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();
                    }
                    else if (NewsType == "图片")
                    {
                        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();
                    }
                    else
                    {
                        News ne = News.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>("checkstate") == "0")
                {
                    where += " and State='1' ";
                }
                else
                {
                    where += " and State='2' ";
                }

                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;
                        }
                    }
                }

                if (RequestData.Get <string>("checktype") == "Dept")
                {
                    string sql = @"select top 1 [Path] from View_SysUserGroup where UserId='" + UserInfo.UserID + "' order by Type desc";
                    where += " and '" + (DataHelper.QueryValue(sql) + "") + "' like '%'+PostDeptId+'%'";
                }

                if (!string.IsNullOrEmpty(typeId))
                {
                    SearchCriterion.SetSearch("TypeId", typeId);
                    ents = NewsRule.FindAll(SearchCriterion, Expression.Sql(" (State='1' or State='2') " + where)).OrderByDescending(o => o.SaveTime).ToArray();

                    this.PageState.Add("SysUserList", ents);
                }    //图片新闻、视频新闻 不需要过滤(不同的页面)
                else
                {
                    string sql = @"select * from (select Id, TypeId, Title, AuthorName, PostDeptId,ReadCount, PostDeptName, PostTime, ExpireTime, SaveTime, [State],'普通' as NewsType from News
                                            union all 
                                            select Id, TypeId, Title, CreateName, PostDeptId,Ext1, PostDeptName, PostTime, ExpireTime, CreateTime, [State],'图片' from ImgNews
                                            union all 
                                            select Id, TypeId, Title, CreateName, PostDeptId,Ext1, PostDeptName, PostTime, ExpireTime, CreateTime, [State],'视频' from VideoNews) t ";

                    this.PageState.Add("SysUserList", GetPageData(sql + " where 1=1 " + where, 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);
            }
        }