/// <summary>
        /// 批量删除操作
        /// </summary>
        public static void DoBatchDelete(params object[] args)
        {
            WorkflowTemplate[] tents = WorkflowTemplate.FindAll(Expression.In("ID", args));

            foreach (WorkflowTemplate tent in tents)
            {
                tent.DoDelete();
            }
        }
Пример #2
0
        public void StartFlow(string formId)
        {
            string code = this.RequestData.Get <string>("FlowKey");

            Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.FindAllByProperties(Aim.WorkFlow.WorkflowTemplate.Prop_Code, code)[0];
            //启动流程
            //表单路径,后面加上参数传入
            StockCheck scEnt   = StockCheck.Find(formId);
            string     formUrl = "/SaleManagement/StockCheckView.aspx?id=" + formId;
            Guid       guid    = Aim.WorkFlow.WorkFlow.StartWorkFlow(formId, formUrl, "盘点单【" + scEnt.StockCheckNo + "】申请人【" + scEnt.CreateName + "】", code, this.UserInfo.UserID, this.UserInfo.Name);

            //返回流程的Id
            this.PageState.Add("FlowId", guid.ToString());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            WorkflowTemplate ent = null;

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

            case RequestActionEnum.Custom:
                //启动流程
                if (this.RequestActionString.ToLower() == "startflow")
                {
                    Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.Find(this.RequestData["Id"].ToString());
                    //启动流程
                    string key = ne.Code;    // "NewsPub";
                    //表单路径,后面加上参数传入
                    string formUrl = "/WorkFlow/WorkFlowDefineEdit.aspx?op=u&&Id=" + ne.ID;
                    Aim.WorkFlow.WorkFlow.StartWorkFlow(ne.ID, formUrl, ne.TemplateName, key, this.UserInfo.UserID, this.UserInfo.Name);
                    PageState.Add("message", "启动成功");
                }
                break;

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

                    if (idList != null && idList.Count > 0)
                    {
                        WorkflowTemplate.DoBatchDelete(idList.ToArray());
                    }
                }
                else
                {
                    ents = WorkflowTemplateRule.FindAll(SearchCriterion);
                    this.PageState.Add("SysWorkFlowDefineList", ents);
                }
                break;
            }
        }
Пример #4
0
        public void GetNextUsers(string templateId, string instanctId, string nextName, string currentName)
        {
            Aim.WorkFlow.WorkflowInstance temp = Aim.WorkFlow.WorkflowInstance.Find(instanctId);
            Aim.WorkFlow.WorkflowTemplate tp   = Aim.WorkFlow.WorkflowTemplate.Find(temp.WorkflowTemplateID);
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(tp.XAML);
            XmlElement          root      = doc.DocumentElement;
            string              nameSpace = root.NamespaceURI;
            XmlNamespaceManager nsmgr     = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("ns", nameSpace);
            nsmgr.AddNamespace("x", "http://schemas.microsoft.com/winfx/2006/xaml");
            nsmgr.AddNamespace("bwa", "clr-namespace:BPM.WF.Activities;assembly=BPM.WF");

            string  current     = "ApprovalNode Name=\"" + currentName + "\"";
            XmlNode currentNode = root.SelectSingleNode("//*[contains(@ApprovalNodeConfig,'" + current + "')]", nsmgr);
            //XmlNode node = root.SelectSingleNode("//*[@x:Key='" + nextName + "']", nsmgr);
            XmlNode node                = currentNode.NextSibling.SelectSingleNode("ns:FlowSwitch/ns:FlowStep[@x:Key='" + nextName + "']", nsmgr);
            string  nextUserIds         = "";
            string  nextUserNames       = "";
            string  nextUserAccountType = "";
            string  nextNodeName        = "";
            string  content             = "ApprovalNode Name=\"" + nextName + "\"";

            if (node != null)//switch路由
            {
                node = node.SelectSingleNode("bwa:Approval_Node", nsmgr);
                if (node != null)
                {
                    string config = System.Web.HttpUtility.HtmlDecode(node.Attributes["ApprovalNodeConfig"].InnerXml);
                    SetNextUsers(config, ref nextUserIds, ref nextUserNames, ref nextUserAccountType, ref nextNodeName);
                }
            }
            else if (root.SelectSingleNode("//*[contains(@ApprovalNodeConfig,'" + content + "')]", nsmgr) != null)//直接路由
            {
                string config = System.Web.HttpUtility.HtmlDecode(root.SelectSingleNode("//*[contains(@ApprovalNodeConfig,'" + content + "')]", nsmgr).Attributes["ApprovalNodeConfig"].InnerXml);
                SetNextUsers(config, ref nextUserIds, ref nextUserNames, ref nextUserAccountType, ref nextNodeName);
            }
            //如果是打回的情况
            XmlNode nextNode = root.SelectSingleNode("//*[contains(@ApprovalNodeConfig,'" + nextName + "')]", nsmgr);

            if (currentNode.ParentNode.SelectSingleNode("ns:FlowStep.Next/ns:FlowSwitch/x:Reference/x:Key", nsmgr) != null)//switch情况的打回
            {
                if (currentNode.ParentNode.SelectSingleNode("ns:FlowStep.Next/ns:FlowSwitch/x:Reference[x:Key/text()='" + nextName + "']", nsmgr) != null)
                {
                    string reference = currentNode.ParentNode.SelectSingleNode("ns:FlowStep.Next/ns:FlowSwitch/x:Reference[x:Key/text()='" + nextName + "']", nsmgr).ChildNodes[0].InnerText;
                    nextNode = root.SelectSingleNode("//*[@x:Name='" + reference + "']", nsmgr);
                    string      config = System.Web.HttpUtility.HtmlDecode(nextNode.SelectSingleNode("bwa:Approval_Node", nsmgr).Attributes["ApprovalNodeConfig"].InnerXml);
                    XmlDocument docC   = new XmlDocument();
                    docC.LoadXml(config);
                    nextNodeName = docC.DocumentElement.Attributes["Name"].InnerText.ToString();
                    SetNextUsers(instanctId, nextNodeName, ref nextUserIds, ref nextUserNames, ref nextUserAccountType);
                }
            }
            else if (currentNode.SelectSingleNode("parent::*/ns:FlowStep.Next/x:Reference", nsmgr) != null)//正常路由打回
            {
                string refer = currentNode.SelectSingleNode("parent::*/ns:FlowStep.Next/x:Reference", nsmgr).InnerText;
                if (refer == nextNode.ParentNode.Attributes["x:Name"].Value)
                {
                    SetNextUsers(instanctId, nextName, ref nextUserIds, ref nextUserNames, ref nextUserAccountType);
                }
                nextNodeName = nextName;
            }
            this.PageState.Add("NextUserIds", nextUserIds.TrimEnd(','));
            this.PageState.Add("NextUserNames", nextUserNames.TrimEnd(','));
            this.PageState.Add("NextUserType", nextUserAccountType);
            this.PageState.Add("NextNodeName", nextNodeName);
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            V_Task ent = null;

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

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

                    if (idList != null && idList.Count > 0)
                    {
                        Aim.WorkFlow.Task.DoBatchDelete(idList.ToArray());
                    }
                }
                else if (this.RequestActionString.ToLower() == "startflow")
                {
                    //启动流程

                    /*string key = "FirstFlow";
                     * //表单路径,后面加上参数传入
                     * string formUrl = "/EPC/PrjBasic/PrjBasicEdit.aspx?op=u";
                     * Aim.WorkFlow.WorkFlow.StartWorkFlow("", formUrl, "流程的标题", key, this.UserInfo.UserID, this.UserInfo.Name);*/
                    string key = this.RequestData.Get <string>("flowkey");
                    Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.FindAllByProperty("Code", key)[0];
                    //启动流程
                    //表单路径,后面加上参数传入
                    string formUrl = "/WorkFlow/flowdemo.htm";
                    Aim.WorkFlow.WorkFlow.StartWorkFlow(ne.ID, formUrl, ne.TemplateName, key, this.UserInfo.UserID, this.UserInfo.Name);
                    PageState.Add("message", "启动成功");
                }
                else
                {
                    if (int.Parse(this.RequestData["Status"].ToString()) == 1)
                    {
                        SearchCriterion.SetSearch("Status", 4);
                        SearchCriterion.SetSearch(V_Task.Prop_FlowStatus, "Processing");
                    }
                    else if (int.Parse(this.RequestData["Status"].ToString()) == 4)
                    {
                        SearchCriterion.SetSearch("Status", 4);
                        SearchCriterion.SetSearch(V_Task.Prop_FlowStatus, "Completed");
                    }
                    else
                    {
                        SearchCriterion.SetSearch("Status", int.Parse(this.RequestData["Status"].ToString()));
                    }
                    SearchCriterion.SetSearch("OwnerId", this.UserInfo.UserID);
                    SearchCriterion.SetOrder("CreatedTime", false);
                    string dateFlag = this.RequestData["Date"] == null ? "3" : this.RequestData["Date"].ToString();
                    switch (dateFlag)
                    {
                    case "3":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-3), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "7":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-7), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "14":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-14), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "30":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddMonths(-1), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "31":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddMonths(-1), SearchModeEnum.LessThanEqual);
                        break;

                    case "100":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddMonths(100), SearchModeEnum.LessThanEqual);
                        break;
                    }
                    if (int.Parse(this.RequestData["Status"].ToString()) == 0)
                    {
                        //                            string sql = @"select * from (
                        //select ID,Title,WorkFlowInstanceId,WorkFlowName,ApprovalNodeName,CreatedTime,FinishTime,
                        //'' RelateName,'' System,'' Type,'' ExecUrl,'' RelateType,'' OwnerUserId from Task where status=0 and OwnerId='{0}') a
                        //union
                        //select * from (
                        //select Id,TaskName Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,FinishTime,RelateName,System,Type,
                        //ExecUrl,RelateType,OwnerUserId from BJKY_BeAdmin..WfWorkList where (State='New') and IsSign='{0}') b";

                        string sql = @"select * from (
select ID,Title,WorkFlowInstanceId,WorkFlowName,ApprovalNodeName,CreatedTime,FinishTime,
'' RelateName,'' System,'' Type,'' ExecUrl,'' RelateType,'' OwnerUserId from Task where status=0 and OwnerId='{0}') a";
                        sql = string.Format(sql, this.UserInfo.UserID);
                        this.PageState.Add("SysWorkFlowTaskList", GetPageData(sql, SearchCriterion));
                    }
                    else
                    {
                        ents = V_Task.FindAll(SearchCriterion);
                        this.PageState.Add("SysWorkFlowTaskList", ents);
                    }
                }
                break;
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (RequestActionString.ToLower())
            {
            case "startflow":
                //启动流程

                /*string key = "FirstFlow";
                 * //表单路径,后面加上参数传入
                 * string formUrl = "/EPC/PrjBasic/PrjBasicEdit.aspx?op=u";
                 * Aim.WorkFlow.WorkFlow.StartWorkFlow("", formUrl, "流程的标题", key, this.UserInfo.UserID, this.UserInfo.Name);*/
                string key = this.RequestData.Get <string>("flowkey");
                Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.FindAllByProperty("Code", key)[0];
                //启动流程
                //表单路径,后面加上参数传入
                string formUrl = "/WorkFlow/flowdemo.htm";
                Aim.WorkFlow.WorkFlow.StartWorkFlow(ne.ID, formUrl, ne.TemplateName, key, this.UserInfo.UserID, this.UserInfo.Name);
                PageState.Add("message", "启动成功");
                break;

            default:

                foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches)
                {
                    if (!String.IsNullOrEmpty(item.Value.ToString()))
                    {
                        switch (item.PropertyName)
                        {
                        case "BeginDate":
                            where += " and ReceiveDate>='" + item.Value + "' ";
                            break;

                        case "EndDate":
                            where += " and ReceiveDate<='" + (item.Value.ToString()).Replace(" 0:00:00", " 23:59:59") + "' ";
                            break;

                        default:
                            where += " and " + item.PropertyName + " like '%" + item.Value + "%' ";
                            break;
                        }
                    }
                }
                if (int.Parse(RequestData["Status"].ToString()) == 0)
                {
                    sql = @"select * from (
                            select Id,(WorkFlowName+'--'+ApprovalNodeName) Title,WorkFlowInstanceId,WorkFlowName,ApprovalNodeName,CreatedTime as CreateTime,
                            '综合办公' RelateName,'' System,'' Type,'' ExecUrl,'' RelateType,'' OwnerUserId from Task where status=0 and OwnerId='{0}'  
                            union
                            select Id,(FlowName+'--'+TaskName) Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,'综合办公' RelateName,System,Type,
                            ExecUrl,RelateType,OwnerUserId from BJKY_BeAdmin..WfWorkList where State='New'and isnull(OwnerUserId,'')<>'' and IsSign='{0}'
                            union 
                            select Id,Title,'' WorkFlowInstanceId,'' WorkFlowName,'' ApprovalNodeName,CreateTime,'问卷调查' Relatename,'' System,'Questionare' Type,'' ExecUrl,
                            '' RelateType,'' OwnerUserId from BJKY_IntegratedManage..SurveyQuestion c
                            where state='1' and (select count(1) from BJKY_IntegratedManage..SurveyCommitHistory t where t.SurveyId=c.Id and t.SurveyedUserId='{0}')=0
                            and (isnull(StatisticsPower,'')='' or PatIndex('%{0}%',StatisticsPower)>0)             
                            union 
                            select Id,(FlowName+'--'+TaskName) Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,System as RelateName,System,'MiddleDB' Type,
                            ExecUrl,RelateType,OwnerUserId from BJKY_MiddleDB..TaskMiddle where (State='New' or State='0') and OwnerUserId='{0}'           
                            ) b where 1=1 " + where;
                }
                if (int.Parse(RequestData["Status"].ToString()) == 1)
                {
                    sql = @"select * from (
                            select Id,(WorkFlowName+'--'+ApprovalNodeName) Title,WorkFlowInstanceId,WorkFlowName,ApprovalNodeName,CreatedTime as CreateTime,
                            '综合办公' RelateName,'' System,'' Type,'' ExecUrl,'' RelateType,'' OwnerUserId from Task where status<>0 and OwnerId='{0}'  
                            union
                            select Id,(FlowName+'--'+TaskName) Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,'综合办公' as RelateName,System,Type,
                            ExecUrl,RelateType,OwnerUserId from BJKY_BeAdmin..WfWorkList where isnull(State,'')<>'New'and isnull(OwnerUserId,'')<>'' and IsSign='{0}'
                            union 
                            select Id,Title,'' WorkFlowInstanceId,'' WorkFlowName,'' ApprovalNodeName,CreateTime,'问卷调查' RelateName,'' System,'Questionare' Type,'' ExecUrl,
                            '' RelateType,'' OwnerUserId from BJKY_IntegratedManage..SurveyQuestion c where
                            (select count(1) from BJKY_IntegratedManage..SurveyCommitHistory t where t.SurveyId=c.Id and t.SurveyedUserId='{0}')>0 and (isnull(StatisticsPower,'')='' or PatIndex('%{0}%',StatisticsPower)>0)             
                            union 
                            select Id,(FlowName+'--'+TaskName) Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,System as RelateName,System,'MiddleDB' Type,
                            ExecUrl,RelateType,OwnerUserId from BJKY_MiddleDB..TaskMiddle where isnull(State,'')<>'New' and isnull(State,'')<>'0' 
                            and OwnerUserId='{0}' and System!='科研管理系统'
                            union 
                            select Id,(FlowName+'--'+TaskName) Title,FlowId WorkFlowInstanceId,FlowName WorkFlowName,TaskName ApprovalNodeName,CreateTime,System as RelateName,System,'MiddleDB' Type,
                            ExecUrl,RelateType,OwnerUserId from BJKY_MiddleDB..TaskFinishMiddle where OwnerUserId='{0}' and System='科研管理系统'     
                            ) b where datediff(month,CreateTime,getdate())<=6 " + where;
                }
                sql = string.Format(sql, UserInfo.UserID);
                PageState.Add("SysWorkFlowTaskList", GetPageData(sql, SearchCriterion));
                break;
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Aim.WorkFlow.Task ent = null;
            switch (this.RequestAction)
            {
            case RequestActionEnum.Delete:
                ent = this.GetTargetData <Aim.WorkFlow.Task>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                break;

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

                    if (idList != null && idList.Count > 0)
                    {
                        Aim.WorkFlow.Task.DoBatchDelete(idList.ToArray());
                    }
                }
                else if (this.RequestActionString.ToLower() == "startflow")
                {
                    //启动流程

                    /*string key = "FirstFlow";
                     * //表单路径,后面加上参数传入
                     * string formUrl = "/EPC/PrjBasic/PrjBasicEdit.aspx?op=u";
                     * Aim.WorkFlow.WorkFlow.StartWorkFlow("", formUrl, "流程的标题", key, this.UserInfo.UserID, this.UserInfo.Name);*/
                    Aim.WorkFlow.WorkflowTemplate ne = Aim.WorkFlow.WorkflowTemplate.FindAllByProperty("Code", "audit")[0];
                    //启动流程
                    string key = "audit";
                    //表单路径,后面加上参数传入
                    string formUrl = "/EPC/PrjBasic/PrjBasicEdit.aspx?op=u";
                    Aim.WorkFlow.WorkFlow.StartWorkFlow(ne.ID, formUrl, ne.TemplateName, key, this.UserInfo.UserID, this.UserInfo.Name);
                    PageState.Add("message", "启动成功");
                }
                else
                {
                    SearchCriterion.SetSearch("Status", int.Parse(this.RequestData["Status"].ToString()));
                    SearchCriterion.SetSearch("OwnerId", this.UserInfo.UserID);
                    SearchCriterion.SetOrder("CreatedTime", false);
                    string dateFlag = this.RequestData["Date"] == null ? "3" : this.RequestData["Date"].ToString();
                    switch (dateFlag)
                    {
                    case "3":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-3), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "7":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-7), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "14":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddDays(-14), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "30":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddMonths(-1), SearchModeEnum.GreaterThanEqual);
                        break;

                    case "31":
                        SearchCriterion.SetSearch("CreatedTime", DateTime.Now.AddMonths(-1), SearchModeEnum.LessThanEqual);
                        break;
                    }
                    ents = Aim.WorkFlow.TaskRule.FindAll(SearchCriterion);
                    this.PageState.Add("SysWorkFlowTaskList", ents);
                }
                break;
            }
        }