Exemplo n.º 1
0
        public string NewActivity(string defineID, string guid, string name, string type)
        {
            string result = "T";

            try
            {
                var flowDefine = entities.S_WF_DefFlow.Where(c => c.ID == defineID).SingleOrDefault();

                if (flowDefine == null)
                {
                    throw new Exception("指定的工作流定义未找到");
                }

                S_WF_DefStep step = new S_WF_DefStep();
                step.ID        = guid.ToString();
                step.Type      = type;
                step.Name      = name;
                step.SortIndex = flowDefine.S_WF_DefStep.Count;
                step.DefFlowID = defineID;
                if (type == "Completion")
                {
                    step.Phase = "End";
                }
                else
                {
                    step.Phase = "Processing";
                }
                step.CooperationMode        = TaskCooperationMode.Single.ToString();
                step.AllowDoBackFirst       = "1";
                step.AllowDoBackFirstReturn = "0";
                if (type == "Inital")
                {
                    step.HideAdvice = "1";
                }
                entities.S_WF_DefStep.Add(step);
                entities.SaveChanges();


                result = "T:" + guid;
            }
            catch (Exception exp)
            {
                LogWriter.Error(exp);

                if (exp.InnerException != null)
                {
                    result = "F:" + guid + ":" + exp.InnerException.Message;
                }
                else
                {
                    result = "F:" + guid + ":" + exp.Message;
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public string NewActivity(string defineID, string name, string type)
        {
            string result = "";
            string guid   = FormulaHelper.CreateGuid();

            try
            {
                var flowDefine = entities.Set <S_WF_DefFlow>().Where(c => c.ID == defineID).SingleOrDefault();

                if (flowDefine == null)
                {
                    throw new Exception("指定的工作流定义未找到");
                }

                S_WF_DefStep step = new S_WF_DefStep();
                step.ID        = guid.ToString();
                step.Type      = type;
                step.Name      = name;
                step.NameEN    = type == "Completion" ? "End" : type == "Inital" ? "Start" : "Node";
                step.SortIndex = flowDefine.S_WF_DefStep.Count;
                step.DefFlowID = defineID;
                if (type == "Completion")
                {
                    step.Phase = "End";
                }
                else
                {
                    step.Phase = "Processing";
                }
                step.CooperationMode        = TaskCooperationMode.Single.ToString();
                step.AllowDoBackFirst       = "1";
                step.AllowDoBackFirstReturn = "0";
                entities.Set <S_WF_DefStep>().Add(step);
                entities.SaveChanges();


                result = guid;
            }
            catch (Exception exp)
            {
                LogWriter.Error(exp);

                result = "Error";
            }
            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 克隆流程定义
        /// </summary>
        /// <returns></returns>
        public S_WF_DefFlow Clone()
        {
            var newDefFlow = new S_WF_DefFlow();

            try
            {
                FormulaHelper.UpdateModel(newDefFlow, this);
                newDefFlow.ID = GetInsIDs(this.ID);

                //环节
                foreach (var step in this.S_WF_DefStep)
                {
                    S_WF_DefStep newStep = new S_WF_DefStep();
                    FormulaHelper.UpdateModel(newStep, step);
                    newStep.ID             = GetInsIDs(step.ID);
                    newStep.DefFlowID      = GetInsIDs(step.DefFlowID);
                    newStep.WaitingStepIDs = GetInsIDs(step.WaitingStepIDs);
                    newStep.SubFormID      = GetInsIDs(step.SubFormID);
                    newDefFlow.S_WF_DefStep.Add(newStep);
                }

                //路由
                foreach (var routing in this.S_WF_DefRouting)
                {
                    S_WF_DefRouting newRouting = new S_WF_DefRouting();
                    FormulaHelper.UpdateModel(newRouting, routing);
                    newRouting.EndID                    = GetInsIDs(routing.EndID);
                    newRouting.ID                       = GetInsIDs(routing.ID);
                    newRouting.DefFlowID                = GetInsIDs(routing.DefFlowID);
                    newRouting.DefStepID                = GetInsIDs(routing.DefStepID);
                    newRouting.UserIDsFromStep          = GetInsIDs(routing.UserIDsFromStep);
                    newRouting.UserIDsFromStepSender    = GetInsIDs(routing.UserIDsFromStepSender);
                    newRouting.UserIDsFromStepExec      = GetInsIDs(routing.UserIDsFromStepExec);
                    newRouting.MsgUserIDsFromStep       = GetInsIDs(routing.MsgUserIDsFromStep);
                    newRouting.MsgUserIDsFromStepSender = GetInsIDs(routing.MsgUserIDsFromStepSender);
                    newRouting.MsgUserIDsFromStepExec   = GetInsIDs(routing.MsgUserIDsFromStepExec);

                    newDefFlow.S_WF_DefRouting.Add(newRouting);
                }

                //子表单
                foreach (var subForm in this.S_WF_DefSubForm)
                {
                    S_WF_DefSubForm newSubForm = new S_WF_DefSubForm();
                    FormulaHelper.UpdateModel(newSubForm, subForm);
                    newSubForm.ID        = GetInsIDs(newSubForm.ID);
                    newSubForm.DefFlowID = GetInsIDs(newSubForm.DefFlowID);
                    newDefFlow.S_WF_DefSubForm.Add(newSubForm);
                }


                //更新流程图
                string flowView = newDefFlow.ViewConfig;
                foreach (string id in idDic.Keys)
                {
                    flowView = flowView.Replace(id, idDic[id]);
                }
                newDefFlow.ViewConfig = flowView;

                return(newDefFlow);
            }
            catch (Exception ex)
            {
                throw new FlowException(ex.Message);
            }
        }