Exemplo n.º 1
0
        private static bool CheckCondition(string StrStartActive, string StrEndActive, WF311_WorkFlowRulesRuleConditionsCondition conditionItem, string BussinessObj, ref  List<WFCondition> ConditionList)
        {
            bool flag = false;
            var ConditionCode = conditionItem.CompAttr;
            var ConditoinOperate = conditionItem.Operate;
            var conditionValue = conditionItem.CompareValue;
            var conditionType = conditionItem.DataType;

            WFCondition condition = new WFCondition();
            condition.StrEndActive = StrEndActive;
            condition.StrStartActive = StrStartActive;
            condition.ConditoinOperate = ConditoinOperate;
            condition.conditionValue = conditionValue;
            condition.conditionType = conditionType;

            var alreadItem = (from ent in ConditionList
                              where ent.ConditionCode == ConditionCode
                              && ent.ConditoinOperate == ConditoinOperate
                              && ent.StrStartActive == StrStartActive
                              select ent).FirstOrDefault();
            if (alreadItem != null)
            {
                switch (ConditoinOperate)
                {
                    case ">":
                    case ">=":
                        if (objToDecimal(conditionValue) > objToDecimal(alreadItem.conditionValue))
                        {
                            ConditionList.Remove(alreadItem);
                            ConditionList.Add(condition);
                        }
                        else
                        {
                            condition = alreadItem;
                        }
                        break;
                    case "<":
                    case "<=":
                        if (objToDecimal(conditionValue) < objToDecimal(alreadItem.conditionValue))
                        {
                            ConditionList.Remove(alreadItem);
                            ConditionList.Add(condition);
                        }
                        else
                        {
                            condition = alreadItem;
                        }
                        break;
                    case "like":
                    case "=":
                        break;
                }
            }
            else
            {
                ConditionList.Add(condition);
            }
            flag = CheckBussinessObj(BussinessObj, condition.ConditionCode, condition.ConditoinOperate, condition.conditionValue, condition.conditionType);
            return flag;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据XML定义文件创建流程
        /// </summary>
        /// <param name="strFlowXml"></param>
        /// <returns></returns>
        public static WF1_WorkFlow CreateWFInstanceFromXmlDefine(string strFlowXml)
        {
            WF1_WorkFlow workflowInstanc = new WF1_WorkFlow();
            XElement FlowDefine = XDocument.Parse(strFlowXml).Root;

            var FlowDefineActivitys = (from ent in FlowDefine.Elements()
                                        where ent.Name == "Activitys"
                                   select ent).ToList();

            foreach(var item in FlowDefineActivitys.Elements())
            {
                WF2_WorkFlowActivitysActivity acivity= new WF2_WorkFlowActivitysActivity();
                acivity.Name = item.Attribute("Name").Value;
                acivity.X = item.Attribute("X").Value;
                acivity.Y = item.Attribute("Y").Value;
                acivity.RoleName = item.Attribute("RoleName").Value;
                acivity.UserType = item.Attribute("UserType").Value;
                acivity.IsOtherCompany = item.Attribute("IsOtherCompany").Value;
                acivity.OtherCompanyID = item.Attribute("OtherCompanyID").Value;
                acivity.OtherCompanyName = item.Attribute("OtherCompanyName").Value;
                acivity.Remark = item.Attribute("Remark").Value;

                var CountersignsList = from ent in item.Elements()
                                         where ent.Name == "Countersigns"
                                                   select ent;
                if (CountersignsList.Count() > 0)
                {
                    foreach (var CountersignsItem in CountersignsList)
                    {
                        WF21_WorkFlowActivitysActivityCountersigns Countersigns = new WF21_WorkFlowActivitysActivityCountersigns();
                        Countersigns.CountersignType = CountersignsItem.Attribute("CountersignType").Value;
                        var CountersignChildList = from ent in CountersignsItem.Elements()
                                               where ent.Name == "Countersign"
                                               select ent;
                        if(CountersignChildList.Count()>0)
                        {
                            foreach(var CountersignChild in CountersignChildList)
                            {
                                WF211_WorkFlowActivitysActivityCountersignsCountersign Countersign = new             WF211_WorkFlowActivitysActivityCountersignsCountersign();
                                Countersign.StateType = CountersignChild.Attribute("StateType").Value;
                                Countersign.RoleName = CountersignChild.Attribute("RoleName").Value;
                                Countersign.IsOtherCompany = CountersignChild.Attribute("IsOtherCompany").Value;
                                Countersign.OtherCompanyID = CountersignChild.Attribute("OtherCompanyID").Value;
                                Countersign.OtherCompanyName = CountersignChild.Attribute("OtherCompanyName").Value;
                                Countersign.UserType = CountersignChild.Attribute("UserType").Value;
                                Countersign.UserTypeName = CountersignChild.Attribute("UserTypeName").Value;
                                //添加会签角色子节点
                                Countersigns.Countersign.Add(Countersign);
                            }
                        }
                        //添加会签节点
                        acivity.Countersigns.Add(Countersigns);
                    }
                }
                //添加活动节点
                workflowInstanc.Activitys.Add(acivity);
            }

            //workflowInstanc.Activitys

            var FlowDefineRules = (from ent in FlowDefine.Elements()
                                     where ent.Name == "Rules"
                                                select ent).ToList();
            foreach (var item in FlowDefineRules.Elements())
            {
                WF3_WorkFlowRulesRule role = new WF3_WorkFlowRulesRule();
                role.Name = item.Attribute("Name").Value;
                role.Remark = item.Attribute("Remark").Value;
                role.StrStartActive = item.Attribute("StrStartActive").Value;
                role.StrEndActive = item.Attribute("StrEndActive").Value;

                var conditionList = from ent in item.Elements()
                                    where ent.Name=="Conditions"
                                 select ent;
                if (conditionList.Count() > 0)
                {
                    foreach (var conditionItem in conditionList)
                    {
                        WF31_WorkFlowRulesRuleConditions condition = new WF31_WorkFlowRulesRuleConditions();
                        condition.Name = conditionItem.Attribute("Name").Value;
                        condition.Object = conditionItem.Attribute("Object").Value;
                        condition.CodiCombMode = conditionItem.Attribute("CodiCombMode").Value;
                        //condition.Condition = conditionItem.Attribute("Condition").Value;
                          var conditionChildList = from ent in conditionItem.Elements()
                                                   where ent.Name=="Condition"
                                                   select ent;
                        if(conditionChildList.Count()>0)
                        {
                            foreach(var ChildConditionItem in conditionChildList)
                            {
                                WF311_WorkFlowRulesRuleConditionsCondition
                                conditionChild = new WF311_WorkFlowRulesRuleConditionsCondition();
                                conditionChild.Name = ChildConditionItem.Attribute("Name").Value;
                                conditionChild.Description = ChildConditionItem.Attribute("Description").Value;
                                conditionChild.CompAttr = ChildConditionItem.Attribute("CompAttr").Value;
                                conditionChild.DataType = ChildConditionItem.Attribute("DataType").Value;
                                conditionChild.Operate = ChildConditionItem.Attribute("Operate").Value;
                                conditionChild.CompareValueMark = ChildConditionItem.Attribute("CompareValueMark").Value;
                                conditionChild.CompareValue = ChildConditionItem.Attribute("CompareValue").Value;
                                //添加子条件描述至条件中
                                condition.Condition.Add(conditionChild);
                            }
                        }
                        //添加条件描述至roles
                        role.Conditions.Add(condition);
                    }
                }
                //添加活动连线规则
                workflowInstanc.Rules.Add(role);
              }
            return workflowInstanc;
        }