Exemplo n.º 1
0
        public ResponseResult <ProcessEntity> CreateProcess([FromBody] ProcessFileEntity fileEntity)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                if (string.IsNullOrEmpty(fileEntity.ProcessName.Trim()) ||
                    string.IsNullOrEmpty(fileEntity.ProcessCode.Trim()) ||
                    string.IsNullOrEmpty(fileEntity.Version.Trim()))
                {
                    result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.warning"));

                    return(result);
                }

                //创建新流程,ProcessGUID默认赋值
                if (string.IsNullOrEmpty(fileEntity.ProcessGUID))
                {
                    fileEntity.ProcessGUID = Guid.NewGuid().ToString();
                }

                if (string.IsNullOrEmpty(fileEntity.Version))
                {
                    fileEntity.Version = "1";
                }

                //根据模板类型来创建流程
                ProcessEntity entity = null;
                if (fileEntity.TemplateType == ProcessTemplateType.Blank)
                {
                    entity = new ProcessEntity
                    {
                        ProcessGUID = fileEntity.ProcessGUID,
                        ProcessName = fileEntity.ProcessName,
                        ProcessCode = fileEntity.ProcessCode,
                        Version     = fileEntity.Version,
                        IsUsing     = fileEntity.IsUsing,
                        Description = fileEntity.Description,
                    };
                    var wfService = new WorkflowService();
                    var processID = wfService.CreateProcess(entity);
                    entity.ID = processID;
                }
                else
                {
                    //模板默认生成XML内容
                    //entity = ProcessTemplateFactory.CreateProcessByTemplateType(fileEntity);
                }
                result = ResponseResult <ProcessEntity> .Success(entity,
                                                                 LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.success")
                                                                 );
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.error", ex.Message));
            }
            return(result);
        }
Exemplo n.º 2
0
        public ResponseResult CreateProcess(ProcessEntity entity)
        {
            var result = ResponseResult.Default();

            try
            {
                var wfService = new WorkflowService();
                wfService.CreateProcess(entity);

                result = ResponseResult.Success();
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(string.Format("创建流程记录失败,错误:{0}", ex.Message));
            }
            return(result);
        }
Exemplo n.º 3
0
        public ResponseResult <ProcessEntity> CreateProcess([FromBody] ProcessEntity entity)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                var wfService = new WorkflowService();
                var processID = wfService.CreateProcess(entity);

                entity.ID = processID;

                result = ResponseResult <ProcessEntity> .Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(string.Format("创建流程记录失败,错误:{0}", ex.Message));
            }
            return(result);
        }
Exemplo n.º 4
0
        public ResponseResult <ProcessEntity> CreateProcess([FromBody] ProcessFileEntity fileEntity)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                if (string.IsNullOrEmpty(fileEntity.ProcessName.Trim()) ||
                    string.IsNullOrEmpty(fileEntity.ProcessCode.Trim()) ||
                    string.IsNullOrEmpty(fileEntity.Version.Trim()))
                {
                    result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.warning"));

                    return(result);
                }

                ProcessEntity entity = new ProcessEntity
                {
                    ProcessGUID = fileEntity.ProcessGUID,
                    ProcessName = fileEntity.ProcessName,
                    ProcessCode = fileEntity.ProcessCode,
                    Version     = fileEntity.Version,
                    IsUsing     = fileEntity.IsUsing,
                    Description = fileEntity.Description,
                };
                var wfService = new WorkflowService();
                var processID = wfService.CreateProcess(entity);
                entity.ID = processID;

                result = ResponseResult <ProcessEntity> .Success(entity,
                                                                 LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.success")
                                                                 );
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.crateprocess.error", ex.Message));
            }
            return(result);
        }
Exemplo n.º 5
0
        public ResponseResult <ProcessEntity> CreateProcess([FromBody] ProcessFileEntity fileEntity)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                ProcessEntity entity = null;
                //根据模板类型来创建流程
                if (fileEntity.TemplateType == ProcessTemplateType.Blank)
                {
                    entity = new ProcessEntity
                    {
                        ProcessGUID = fileEntity.ProcessGUID,
                        ProcessName = fileEntity.ProcessName,
                        ProcessCode = fileEntity.ProcessCode,
                        Version     = fileEntity.Version,
                        IsUsing     = fileEntity.IsUsing,
                        Description = fileEntity.Description,
                    };
                    var wfService = new WorkflowService();
                    var processID = wfService.CreateProcess(entity);
                    entity.ID = processID;
                }
                else
                {
                    //模板默认生成XML内容
                    entity = ProcessGraphFactory.CreateProcess(fileEntity);
                }
                result = ResponseResult <ProcessEntity> .Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(string.Format("创建流程记录失败,错误:{0}", ex.Message));
            }
            return(result);
        }