コード例 #1
0
        public ResponseResult UpdateProcess([FromBody] ProcessEntity entity)
        {
            var result = ResponseResult.Default();

            try
            {
                var wfService     = new WorkflowService();
                var processEntity = wfService.GetProcessByVersion(entity.ProcessGUID, entity.Version);
                processEntity.ProcessName = entity.ProcessName;
                processEntity.ProcessCode = entity.ProcessCode;
                processEntity.XmlFileName = entity.XmlFileName;
                processEntity.AppType     = entity.AppType;
                processEntity.Description = entity.Description;
                processEntity.IsUsing     = entity.IsUsing;
                if (!string.IsNullOrEmpty(entity.XmlContent))
                {
                    processEntity.XmlContent = PaddingContentWithRightSpace(entity.XmlContent);
                }
                wfService.UpdateProcess(processEntity);

                result = ResponseResult.Success(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.updateprocess.success")
                                                );
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.updateprocess.error", ex.Message));
            }
            return(result);
        }
コード例 #2
0
        /// <summary>
        /// 解析XML文件
        /// </summary>
        /// <param name="xmlContent"></param>
        private bool CreateNewProcess(string xmlContent, out string message)
        {
            bool isUploaded = false;

            message = string.Empty;

            //xml package
            var xmlDocument = new XmlDocument();

            xmlDocument.LoadXml(xmlContent);
            var workflowNode = xmlDocument.DocumentElement.SelectSingleNode("WorkflowProcesses");

            if (workflowNode != null)
            {
                var processNode = workflowNode.SelectSingleNode("Process");
                if (processNode != null)
                {
                    var processName = XMLHelper.GetXmlAttribute(processNode, "name");
                    var processGUID = XMLHelper.GetXmlAttribute(processNode, "id");
                    var processCode = XMLHelper.GetXmlAttribute(processNode, "code");
                    //获取8位随机字符串和数字序列作为ProcessCode,保证唯一性
                    if (string.IsNullOrEmpty(processCode))
                    {
                        processCode = (new RandomSequenceGenerator()).GetRandomSequece();
                    }

                    if (!string.IsNullOrEmpty(processName) && !string.IsNullOrEmpty(processGUID))
                    {
                        var processEntity = new ProcessEntity
                        {
                            ProcessGUID     = processGUID,
                            ProcessName     = processName,
                            ProcessCode     = processCode,
                            Version         = "1",
                            IsUsing         = 1,
                            XmlContent      = xmlContent,
                            CreatedDateTime = System.DateTime.Now
                        };

                        var wfService = new WorkflowService();
                        wfService.ImportProcess(processEntity);
                        isUploaded = true;
                        message    = LocalizeHelper.GetDesignerMessage("fineuploadcontroller.importprocess.success");
                    }
                    else
                    {
                        message = LocalizeHelper.GetDesignerMessage("fineuploadcontroller.createnewprocess.warning");
                    }
                }
                else
                {
                    message = LocalizeHelper.GetDesignerMessage("fineuploadcontroller.createnewprocess.noxmlnode.warning");
                }
            }
            else
            {
                message = LocalizeHelper.GetDesignerMessage("fineuploadcontroller.createnewprocess.norootelement.warning");
            }
            return(isUploaded);
        }
コード例 #3
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);
        }
コード例 #4
0
        public ResponseResult <List <TaskViewEntity> > GetTaskDoneListTop()
        {
            var result = ResponseResult <List <TaskViewEntity> > .Default();

            try
            {
                var tm       = new TaskManager();
                var taskList = tm.GetTaskDoneListTop();
                result = ResponseResult <List <TaskViewEntity> > .Success(taskList);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <TaskViewEntity> > .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.gettaskdonelisttop.error", ex.Message));
            }
            return(result);
        }
コード例 #5
0
        public ResponseResult SetLang(string id)
        {
            var result = ResponseResult.Default();

            try
            {
                LangTypeEnum lang = EnumHelper.ParseEnum <LangTypeEnum>(id);
                LocalizeHelper.SetLang(ProjectTypeEnum.Designer, lang);
                LocalizeHelper.SetLang(ProjectTypeEnum.Engine, lang);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(LocalizeHelper.GetDesignerMessage("languagecontroller.setlang.error", ex.Message));
            }
            return(result);
        }
コード例 #6
0
        public ResponseResult <List <Role> > GetRoleAll()
        {
            var result = ResponseResult <List <Role> > .Default();

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

                result = ResponseResult <List <Role> > .Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <Role> > .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.getroleall.error", ex.Message));
            }
            return(result);
        }
コード例 #7
0
        public ResponseResult <List <TransitionImage> > QueryCompletedTransitionInstance([FromBody] TransitionInstanceQuery query)
        {
            var result = ResponseResult <List <TransitionImage> > .Default();

            try
            {
                var wfService = new WorkflowService();
                var itemList  = wfService.GetTransitionInstanceList(query).ToList();

                result = ResponseResult <List <TransitionImage> > .Success(itemList);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <TransitionImage> > .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.querycompletedtransitioninstance.error", ex.Message));
            }
            return(result);
        }
コード例 #8
0
        public ResponseResult <ProcessValidateResult> ValidateProcess([FromBody] ProcessValidateEntity entity)
        {
            var result = ResponseResult <ProcessValidateResult> .Default();

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

                result = ResponseResult <ProcessValidateResult> .Success(validateResult, LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.validateprocess.success"));
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessValidateResult> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.validateprocess.error", ex.Message));
            }
            return(result);
        }
コード例 #9
0
        public ResponseResult <ProcessEntity> GetProcess([FromBody] ProcessQuery query)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                var wfService = new WorkflowService();
                var entity    = wfService.GetProcessUsing(query.ProcessGUID);

                result = ResponseResult <ProcessEntity> .Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.queryprocess.error", ex.Message));
            }
            return(result);
        }
コード例 #10
0
        public ResponseResult <List <ActivityInstanceEntity> > QueryReadyActivityInstance([FromBody] TaskQuery query)
        {
            var result = ResponseResult <List <ActivityInstanceEntity> > .Default();

            try
            {
                var wfService = new WorkflowService();
                var itemList  = wfService.GetRunningActivityInstance(query).ToList();


                result = ResponseResult <List <ActivityInstanceEntity> > .Success(itemList);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <ActivityInstanceEntity> > .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.queryreadyactivityinstance.error", ex.Message));
            }
            return(result);
        }
コード例 #11
0
        public ResponseResult SaveProcessFilePool([FromBody] ProcessFilePool entity)
        {
            var result = ResponseResult.Default();

            try
            {
                var wfService = new WorkflowService();
                entity.XmlContent = PaddingContentWithRightSpace(entity.XmlContent);
                wfService.SaveProcessFilePool(entity);

                result = ResponseResult.Success(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.saveprocessfile.success"));
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.saveprocessfile.error", ex.Message));
            }
            return(result);
        }
コード例 #12
0
        public ResponseResult DeleteProcess([FromBody] ProcessEntity entity)
        {
            var result = ResponseResult.Default();

            try
            {
                var wfService = new WorkflowService();
                wfService.DeleteProcess(entity.ProcessGUID, entity.Version);

                result = ResponseResult.Success(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.deleteprocess.success")
                                                );
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.deleteprocess.error", ex.Message));
            }
            return(result);
        }
コード例 #13
0
        public ResponseResult <ProcessEntity> CheckProcessFile([FromBody] ProcessEntity query)
        {
            var result = ResponseResult <ProcessEntity> .Default();

            try
            {
                var wfService = new WorkflowService();
                var entity    = wfService.GetProcessByName(query.ProcessName, query.Version);
                if (entity == null)
                {
                    entity = wfService.GetProcessByCode(query.ProcessCode, query.Version);
                }
                result = ResponseResult <ProcessEntity> .Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <ProcessEntity> .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.queryprocessfile.error", ex.Message)
                                                               );
            }
            return(result);
        }
コード例 #14
0
        public ResponseResult <List <TaskViewEntity> > QueryCompletedTasks([FromBody] TaskQuery query)
        {
            var result = ResponseResult <List <TaskViewEntity> > .Default();

            try
            {
                var taskList  = new List <TaskViewEntity>();
                var wfService = new WorkflowService();
                var itemList  = wfService.GetCompletedTasks(query);

                if (itemList != null)
                {
                    taskList = itemList.ToList();
                }
                result = ResponseResult <List <TaskViewEntity> > .Success(taskList);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult <List <TaskViewEntity> > .Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.querycompletedtasks.error", ex.Message));
            }
            return(result);
        }
コード例 #15
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);
        }
コード例 #16
0
        public ResponseResult UpgradeProcess([FromBody] ProcessEntity entity)
        {
            var result = ResponseResult.Default();

            try
            {
                var wfService  = new WorkflowService();
                var process    = wfService.GetProcessByID(entity.ID);
                int newVersion = 1;
                var parsed     = int.TryParse(process.Version, out newVersion);
                if (parsed == true)
                {
                    newVersion = newVersion + 1;
                }
                wfService.UpgradeProcess(process.ProcessGUID, process.Version, newVersion.ToString());

                result = ResponseResult.Success(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.upgradeprocess.success"));
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(LocalizeHelper.GetDesignerMessage("wf2xmlcontroller.upgradeprocess.error", ex.Message));
            }
            return(result);
        }