Beispiel #1
0
        public ResponseResult DeleteProcess(ProcessEntity entity)
        {
            var result = ResponseResult.Default();
            try
            {
                var wfService = new WorkflowService();
                wfService.DeleteProcess(entity.ProcessGUID, entity.Version);

                result = ResponseResult.Success();
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(string.Format("删除流程记录失败,错误:{0}", ex.Message));
            }
            return result;
        }
Beispiel #2
0
 public void Insert(ProcessEntity entity)
 {
     IDbSession session = SessionFactory.CreateSession();
     try
     {
         Repository.Insert<ProcessEntity>(session.Connection, entity, session.Transaction);
         session.Commit();
     }
     catch (System.Exception)
     {
         session.Rollback();
         throw;
     }
     finally
     {
         session.Dispose();
     }
 }
        public ResponseResult<ProcessEntity> CreateProcess(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;
        }
        public ResponseResult UpdateProcess(ProcessEntity entity)
        {
            var result = ResponseResult.Default();
            try
            {
                var wfService = new WorkflowService();
                var processEntity = wfService.GetProcessByVersion(entity.ProcessGUID, entity.Version);
                processEntity.ProcessName = entity.ProcessName;
                processEntity.XmlFileName = entity.XmlFileName;
                processEntity.AppType = entity.AppType;
                processEntity.Description = entity.Description;

                wfService.UpdateProcess(processEntity);

                result = ResponseResult.Success();
            }
            catch (System.Exception ex)
            {
                result = ResponseResult.Error(string.Format("更新流程记录失败,错误:{0}", ex.Message));
            }
            return result;
        }
 public void RemoveProcess(ProcessEntity entity)
 {
     ProcessManager pm = new ProcessManager();
     pm.Delete(entity.ProcessGUID, entity.Version);
 }
 public void UpdateProcess(ProcessEntity obj)
 {
     ProcessManager pm = new ProcessManager();
     pm.Update(obj);
 }
 public void InsertProcess(ProcessEntity obj)
 {
     ProcessManager pm = new ProcessManager();
     pm.Insert(obj);
 }
        /// <summary>
        /// 创建流程定义记录
        /// </summary>
        /// <param name="entity"></param>
        public void CreateProcess(ProcessEntity entity)
        {
            var processManager = new ProcessManager();
            entity.ProcessGUID = Guid.NewGuid().ToString();
            entity.CreatedDateTime = DateTime.Now;
            entity.XmlFilePath = string.Format("{0}\\{1}", entity.AppType, entity.XmlFileName);

            var session = SessionFactory.CreateSession();
            try
            {
                session.BeginTrans();
                processManager.Insert(session.Connection, entity, session.Transaction);

                //创建xml文件到本地目录
                var serverPath = ConfigHelper.GetAppSettingString("WorkflowFileServer");
                var physicalFileName = string.Format("{0}\\{1}", serverPath, entity.XmlFilePath);

                //判断目录是否存在,否则创建
                var pathName = Path.GetDirectoryName(physicalFileName);
                if (!Directory.Exists(pathName))
                    Directory.CreateDirectory(pathName);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml("<Package/>");
                XmlDeclaration xmldecl = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

                //Add the new node to the document.
                XmlElement root = xmlDoc.DocumentElement;
                xmlDoc.InsertBefore(xmldecl, root);

                XmlElement workflowNode = xmlDoc.CreateElement("WorkflowProcess");
                XmlElement processNode = xmlDoc.CreateElement("Process");
                processNode.SetAttribute("name", entity.ProcessName);
                processNode.SetAttribute("id", entity.ProcessGUID);

                XmlElement descriptionNode = xmlDoc.CreateElement("Description");
                descriptionNode.InnerText = entity.Description;
                processNode.AppendChild(descriptionNode);

                workflowNode.AppendChild(processNode);
                root.AppendChild(workflowNode);

                xmlDoc.Save(physicalFileName);

                session.Commit();
            }
            catch (System.Exception ex)
            {
                session.Rollback();
            }
            finally
            {
                session.Dispose();
            }
        }
 /// <summary>
 /// 更新流程定义记录
 /// </summary>
 /// <param name="entity"></param>
 public void UpdateProcess(ProcessEntity entity)
 {
     var processManager = new ProcessManager();
     processManager.Update(entity);
 }
Beispiel #10
0
 public void Delete(IDbConnection conn, ProcessEntity entity, IDbTransaction trans)
 {
     Repository.Delete<ProcessEntity>(conn, entity, trans);
 }
Beispiel #11
0
 public void Insert(IDbConnection conn, ProcessEntity entity, IDbTransaction trans)
 {
     Repository.Insert<ProcessEntity>(conn, entity, trans);
 }
Beispiel #12
0
        public ResponseResult<ProcessEntity> GetProcessByVersion(ProcessEntity obj)
        {
            var result = ResponseResult<ProcessEntity>.Default();
            try
            {
                var wfService = new WorkflowService();
                var entity = wfService.GetProcessByVersion(obj.ProcessGUID, obj.Version);

                result = ResponseResult<ProcessEntity>.Success(entity);
            }
            catch (System.Exception ex)
            {
                result = ResponseResult<ProcessEntity>.Error(
                    string.Format("获取流程基本信息失败!{0}", ex.Message)
                );
            }
            return result;
        }
 /// <summary>
 /// 读取方法,比如数据库或远程方式等
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public XmlDocument Read(ProcessEntity entity)
 {
     throw new NotImplementedException();
 }
        /// <summary>
        /// 根据流程定义,创建新的流程实例
        /// </summary>
        /// <param name="processID">流程定义ID</param>
        /// <returns>流程实例的ID</returns>
        internal ProcessInstanceEntity CreateNewProcessInstanceObject(WfAppRunner runner,
            ProcessEntity processEntity,
            ProcessInstanceEntity parentProcessInstance,
            ActivityInstanceEntity subProcessNode)
        {
            ProcessInstanceEntity entity = new ProcessInstanceEntity();
            entity.ProcessGUID = processEntity.ProcessGUID;
            entity.ProcessName = processEntity.ProcessName;
            entity.Version = processEntity.Version;
            entity.AppName = runner.AppName;
            entity.AppInstanceID = runner.AppInstanceID;
            entity.ProcessState = (int)ProcessStateEnum.Running;
            if (parentProcessInstance != null)
            {
                //流程的Parent信息
                entity.ParentProcessInstanceID = parentProcessInstance.ID;
                entity.ParentProcessGUID = parentProcessInstance.ProcessGUID;
                entity.InvokedActivityInstanceID = subProcessNode.ID;
                entity.InvokedActivityGUID = subProcessNode.ActivityGUID;
            }
            entity.CreatedByUserID = runner.UserID;
            entity.CreatedByUserName = runner.UserName;
            entity.CreatedDateTime = System.DateTime.Now;
            entity.LastUpdatedByUserID = runner.UserID;
            entity.LastUpdatedByUserName = runner.UserName;
            entity.LastUpdatedDateTime = System.DateTime.Now;

            return entity;
        }