Пример #1
0
        public override BizObject GetParent()
        {
            IEngineeringVolumeService _IEngineeringVolumeService = UnityContainerHelper.GetServer <IEngineeringVolumeService>();
            var vol = _IEngineeringVolumeService.Get(this.VolumeID);

            return(new EngineeringVolumeInfo(vol));
        }
Пример #2
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var _ITokenManager = UnityContainerHelper.GetServer <ITokenManager>();

            // 如果请求头中不包含 Authorization 内容,则抛出 401 异常,表明要访问的资源需要验证
            if (!actionContext.Request.Headers.Contains("Authorization"))
            {
                throw new Exception("请求头中未包含身份验证信息,拒绝访问");
            }

            // 获取请求头中的验证信息(即token)
            var jwtToken = actionContext.Request.Headers.GetValues("Authorization").First <string>();

            // 验证token
            HttpStatusCode statusCode = _ITokenManager.ValidateToken(jwtToken);

            // 验证通过(返回 http 200)则继续,否则抛出http错误
            if (statusCode == HttpStatusCode.OK)
            {
                base.OnActionExecuting(actionContext);
            }
            else
            {
                throw new Exception("身份验证失败,拒绝访问");
            }
        }
Пример #3
0
        public static ProcessInfo GetFlowInfo(string System, string Key, int ID)
        {
            var _IObjectProcessService      = UnityContainerHelper.GetServer <IObjectProcessService>(System);
            var _IUserTaskService           = UnityContainerHelper.GetServer <IUserTaskService>(System);
            var _IBPMProcessInstanceService = UnityContainerHelper.GetServer <IBPMProcessInstanceService>();

            var objProcess  = _IObjectProcessService.Get(Key, ID);
            var processInfo = _IBPMProcessInstanceService.Get(objProcess.ProcessID);

            var result = new ProcessInfo();

            result.ProcessStatus = processInfo.Status;
            result.ProcessID     = processInfo.ID.ToString();
            if (processInfo.Status != (int)ProcessStatus.Finish)
            {
                var userTask = _IUserTaskService.GetCurrentTask(objProcess.ProcessID);

                result.CurrentTaskID   = userTask.Identity.ToString();
                result.CurrentTaskName = userTask.Name;
                result.CurrentTaskUser = userTask.UserID;
                result.CurrentTaskTime = userTask.Time;
            }

            return(result);
        }
Пример #4
0
        public static FlowDetailInfo GetFlowDetail(string System, string ObjectKey, int ObjectID)
        {
            var _IObjectProcessService = UnityContainerHelper.GetServer <IObjectProcessService>(System);
            var objProcess             = _IObjectProcessService.Get(ObjectKey, ObjectID);

            return(GetFlowDetail(System, objProcess.ProcessID.ToString()));
        }
Пример #5
0
        public static Dictionary <string, Dictionary <string, Dictionary <string, string> > > GetFlowUser()
        {
            var _IBaseConfig = UnityContainerHelper.GetServer <IBaseConfig>();

            var nodes = _IBaseConfig.GetConfigNodes(c => c.Key.StartsWith("User.") && c.Key.EndsWith("Tasks"), "User.");

            var result = new Dictionary <string, Dictionary <string, Dictionary <string, string> > >();

            nodes.ForEach(user => {
                //  用户
                var users = new Dictionary <string, Dictionary <string, string> >();
                user.ChildNodes[0].ChildNodes.ForEach(spec => {
                    //  专业
                    var specs = new Dictionary <string, string>();
                    spec.ChildNodes[0].ChildNodes.ForEach(pro => {
                        //  流程
                        specs.Add(pro.NodeName, pro.ChildNodes[0].NodeValue);
                    });

                    users.Add(spec.NodeName, specs);
                });

                result.Add(user.NodeName, users);
            });

            return(result);
        }
Пример #6
0
        private async Task <HttpResponseMessage> getResponse2()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var file = new FileStream(attach.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

                // 判断是否大于64Md,如果大于就采用分段流返回,否则直接返回
                if (file.Length < MEMORY_SIZE)
                {
                    //Copy To Memory And Close.
                    byte[] bytes = new byte[file.Length];
                    await file.ReadAsync(bytes, 0, (int)file.Length);

                    file.Close();
                    MemoryStream ms = new MemoryStream(bytes);

                    response.Content = new ByteArrayContent(ms.ToArray());
                }
                else
                {
                    response.Content = new StreamContent(file);
                }

                if (attach.Type == (int)EnumAttachType.Excel)
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                }
                else if (attach.Type == (int)EnumAttachType.PPT)
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.presentationml.presentation");
                }
                else
                {
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
                }

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Пример #7
0
        public static async Task <UploadResponseModel> Upload(HttpRequestMessage Request, string Name)
        {
            if (Request.Content.IsMimeMultipartContent())
            {
                var uploadPath = System.Configuration.ConfigurationManager.AppSettings["UploadFilePath"];

                var date = DateTime.Now;

                var fullPath = Path.Combine(uploadPath, date.Year.ToString(), date.Month.ToString(), date.Day.ToString());

                if (!Directory.Exists(fullPath))
                {
                    Directory.CreateDirectory(fullPath);
                }

                var _IImageGetter  = UnityContainerHelper.GetServer <IImageGetter>();
                var response       = new UploadResponseModel();
                var streamProvider = new UploadStreamProvider(fullPath);
                var upResult       = await Request.Content.ReadAsMultipartAsync(streamProvider);

                foreach (var file in upResult.FileData)
                {
                    var stream = new FileStream(file.LocalFileName, FileMode.Open);
                    var md5Str = Md5.GetMd5Hash(stream);
                    stream.Close();

                    FileInfo fi     = new FileInfo(file.LocalFileName);
                    var      entity = _IImageGetter.SaveImage(streamProvider.FileName, streamProvider.MediaType, Name, md5Str, fi);

                    // 检查文件的MD5 如果有相同的MD5文件,则直接返回已有的文件ID
                    // var entity = _IImageGetter.Check(md5Str);
                    //if (entity == null)
                    //{
                    //    FileInfo fi = new FileInfo(file.LocalFileName);
                    //    entity = _IImageGetter.SaveImage(streamProvider.FileName, streamProvider.MediaType, Name, md5Str, fi);
                    //}

                    response.files.Add(new FileResponseModel()
                    {
                        id         = entity.ID,
                        name       = entity.Name,
                        size       = entity.Size,
                        error      = "",
                        mediaType  = streamProvider.MediaType,
                        type       = entity.Extension,
                        upDateTime = entity.UploadDate.ToString("yyyy-MM-dd hh:mm:ss")
                    });
                }

                return(response);
            }
            else
            {
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid Request!");
                throw new HttpResponseException(response);
            }
        }
Пример #8
0
        //public ProcessEngine()
        //{
        //    this._ProcessInstances = new Dictionary<string, ProcessInstance>();
        //    this.modelInstanceIDMaps = new Dictionary<string, string>();
        //}

        public string CreateProcessInstance(string Identity, int User, Dictionary <string, object> InputData = null)
        {
            // 获取流程模板
            var def = ProcessModelCache.Instance[Identity];

            // 获取流程的监听者
            var _Ob = UnityContainerHelper.GetServer <IObservation>(def.ProcessOb.Name);

            var pID = Guid.NewGuid().ToString();

            // 生成流程实例
            var pi = new ProcessInstance()
            {
                ID   = pID,
                Name = def.ID,
            };

            pi.StartDate  = DateTime.Now;
            pi.Version    = 1;
            pi.CreateUser = User;
            pi.InputData  = InputData;

            // 流程资源
            def.Resources.ForEach(r =>
            {
                var prs = new ProcessResouce()
                {
                    Key   = r.ID,
                    Users = new Dictionary <string, string>()
                };

                r.Users.ForEach(u =>
                {
                    prs.Users.Add(u.ID, u.Name);
                });

                pi.ProcessResouces.Add(r.ID, prs);
            });

            // 编译脚本代码
            if (!string.IsNullOrEmpty(def.ConditionCode))
            {
                pi.Compiled = ConditionExpression.Evaluator(def.ConditionCode, def.ID);
            }

            // 生成流程脚本实例
            pi.GeneratTasks(def, InputData, _Ob);

            // 缓存流程实例
            _ProcessInstances.Add(pID, pi);

            // 保存生成的流程实例
            BPMDBService.Create(pi);

            return(pID);
        }
Пример #9
0
        public async Task Next(string System, int ID, Dictionary <string, object> Datas)
        {
            var _IUserTaskService = UnityContainerHelper.GetServer <IUserTaskService>(System);

            var taskID = _IUserTaskService.Get(ID).Identity;

            Datas.Add("userTaskID", ID);

            await ProcessEngine.Instance.Continu(taskID.ToString(), int.Parse(base.User.Identity.Name), Datas);
        }
Пример #10
0
        public override List <BPMTaskInstanceEntity> GetTasks()
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();
            var _IObjectProcessService   = UnityContainerHelper.GetServer <IObjectProcessService>("System3");

            var processInfo = _IObjectProcessService.Get(base.ObjectKey, this.ID);

            this.Tasks = _IBPMTaskInstanceService.GetList(t => t.ProcessID == processInfo.ProcessID && t.Type == (int)TaskType.Manual && !t.IsDelete);

            return(this.Tasks);
        }
Пример #11
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IEngineeringSpecialtyService _IEngineeringSpecialtyService = UnityContainerHelper.GetServer <IEngineeringSpecialtyService>();
            IEngineeringResourceService  _IEngineeringResourceService  = UnityContainerHelper.GetServer <IEngineeringResourceService>();

            var specils  = _IEngineeringSpecialtyService.GetEngineeringSpecialtys(this.ID);
            var resource = _IEngineeringResourceService.GetEngineeringResource(this.ID);

            specils.AddRange(resource);

            return(specils);
        }
Пример #12
0
        public static FlowNodeInfo GetInitFlowNodeInfo(string FlowName, Dictionary <string, Object> Params = null)
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();

            var def = ProcessModelCache.Instance[FlowName];

            var node = new FlowNodeInfo();

            var list = getFlowTasks(def.Process).Take(2).ToList();

            node.CurrentTaskName = list.First().Name;

            if (list.Count == 2)
            {
                node.NextName       = list.Last().Name;
                node.NextIsJoinSign = list.Last().IsJoinSign;
                node.NextOwner      = list.Last().Owner;

                // 不是会签才取候选人
                if (!node.NextIsJoinSign)
                {
                    node.NextUsers = new List <int>();

                    var owner = list.Last().Owner;

                    def.Resources.ForEach(r =>
                    {
                        if (r.ID == owner)
                        {
                            if (r.IOwner != null)
                            {
                                var call = UnityContainerHelper.GetServer <IOwner>(r.IOwner.Name);

                                node.NextUsers = call.GetOwner("_" + list[1].DefID, Params);
                            }

                            node.NextUsers = node.NextUsers ?? new List <int>();

                            r.Users.ForEach(u =>
                            {
                                var id = int.Parse(u.ID);
                                if (!node.NextUsers.Contains(id))
                                {
                                    node.NextUsers.Add(id);
                                }
                            });
                        }
                    });
                }
            }

            return(node);
        }
Пример #13
0
        private async Task <HttpResponseMessage> downloadSingleFile()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var file = new FileStream(attach.Path, FileMode.Open, FileAccess.Read, FileShare.Read);

                // 判断是否大于64Md,如果大于就采用分段流返回,否则直接返回
                if (file.Length < MEMORY_SIZE)
                {
                    //Copy To Memory And Close.
                    byte[] bytes = new byte[file.Length];
                    await file.ReadAsync(bytes, 0, (int)file.Length);

                    file.Close();
                    MemoryStream ms = new MemoryStream(bytes);

                    response.Content = new ByteArrayContent(ms.ToArray());
                }
                else
                {
                    response.Content = new StreamContent(file);
                }

                //response.Content = new StreamContent(System.IO.File.OpenRead(attach.Path));
                response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attach");
                response.Content.Headers.ContentDisposition.FileName = attach.Name;


                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Пример #14
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IEngineeringVolumeService _IEngineeringVolumeService = UnityContainerHelper.GetServer <IEngineeringVolumeService>();

            var volumes = _IEngineeringVolumeService.GetSpecialtyVolumesV2(this.EngineeringID, this.SpecialtyID, PageParam != null && PageParam.FilterCondtion.ContainsKey("Task"));

            var result = new List <BizObject>();

            foreach (var item in volumes)
            {
                result.Add(item);
            }

            return(result);
        }
Пример #15
0
        public static int CreateChatGroup(ChatGroupInfo GroupInfo)
        {
            var _Context = new SystemContext();

            var entity = new ChatGroupEntity()
            {
                GroupName   = GroupInfo.GroupName,
                GroupDesc   = GroupInfo.GroupDesc,
                CreateDate  = DateTime.Now,
                CreateEmpID = GroupInfo.CreateEmpID,
                IsDelete    = false,
                IsPublic    = false
            };

            _Context.ChatGroupEntity.Add(entity);
            _Context.SaveChanges();

            // 将自己添加进组成员
            _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
            {
                GroupID = entity.GroupID,
                EmpID   = GroupInfo.CreateEmpID
            });

            foreach (var id in GroupInfo.Emps)
            {
                if (id != GroupInfo.CreateEmpID)
                {
                    _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
                    {
                        GroupID = entity.GroupID,
                        EmpID   = id
                    });
                }
            }

            _Context.SaveChanges();

            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 104
            });

            return(entity.GroupID);
        }
Пример #16
0
        public static void UpdateChatGroup(int GroupID, ChatGroupInfo GroupInfo)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEntity.Find(GroupID);

            entity.GroupName = GroupInfo.GroupName;
            entity.GroupDesc = GroupInfo.GroupDesc;

            _Context.Entry(entity).State = System.Data.Entity.EntityState.Modified;

            // 先清空小组成员
            var items = _Context.ChatGroupEmpsEntity.Where(g => g.GroupID == GroupID);

            foreach (var item in items)
            {
                _Context.ChatGroupEmpsEntity.Remove(item);
            }

            // 重新生成小组成员
            _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
            {
                GroupID = entity.GroupID,
                EmpID   = entity.CreateEmpID
            });

            foreach (var id in GroupInfo.Emps)
            {
                if (id != GroupInfo.CreateEmpID)
                {
                    _Context.ChatGroupEmpsEntity.Add(new ChatGroupEmpsEntity()
                    {
                        GroupID = entity.GroupID,
                        EmpID   = id
                    });
                }
            }

            _Context.SaveChanges();
            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 104
            });
        }
Пример #17
0
        public static void ExitChatGroup(int GroupID, int UserID)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEmpsEntity.SingleOrDefault(g => g.GroupID == GroupID && g.EmpID == UserID);

            _Context.ChatGroupEmpsEntity.Remove(entity);

            _Context.SaveChanges();
            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                TargetUser  = UserID,
                MessageType = 106
            });
        }
Пример #18
0
        public static FlowDetailInfo GetFlowDetail(string System, string ProcessID)
        {
            var _IBPMTaskInstanceService = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();

            var _IUserTaskService = UnityContainerHelper.GetServer <IUserTaskService>(System);

            var tasks = _IBPMTaskInstanceService.GetList(t => t.ProcessID == new Guid(ProcessID) &&
                                                         !t.IsDelete && (t.Type == (int)TaskType.Manual || t.Type == (int)TaskType.Sign));


            var taskLog = _IUserTaskService.GetTaskLog(new Guid(ProcessID));

            return(new FlowDetailInfo()
            {
                Logs = taskLog,
                Tasks = tasks
            });
        }
Пример #19
0
        public static void RemoveChatGroup(int GroupID)
        {
            var _Context = new SystemContext();

            var entity = _Context.ChatGroupEntity.Find(GroupID);

            entity.IsDelete = true;

            _Context.Entry(entity).State = System.Data.Entity.EntityState.Modified;
            _Context.SaveChanges();

            var notifySrv = UnityContainerHelper.GetServer <WSHandler>();

            notifySrv.Send(new
            {
                TargetGroup = entity.GroupID,
                MessageType = 105
            });
        }
Пример #20
0
        private HttpResponseMessage downloadFiles()
        {
            if (!string.IsNullOrEmpty(FileIds))
            {
                var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();
                this.Attachs = _IImageGetter.GetAttachs(this.FileIds);
            }

            // 这里按照ID排序,以便生成的下载临时压缩文件的文件名ID有序
            this.Attachs = this.Attachs.OrderBy(a => a.ID).ToList();

            var zipContent = ZipFileHelp.ZipFileByCode(this.Attachs);
            var response   = new HttpResponseMessage();

            response.Content = new StreamContent(zipContent);
            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = DateTime.Now.ToFileTime().ToString() + ".zip";

            return(response);
        }
Пример #21
0
        public async Task <HttpResponseMessage> ExecuteAsync(CancellationToken cancellationToken)
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            //if (System.IO.File.Exists(filePath))
            //{
            //    HttpResponseMessage response = new HttpResponseMessage();
            //    response.Content = new StreamContent(System.IO.File.OpenRead(filePath));
            //    response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg");

            //    return await Task.FromResult(response);
            //}

            var attach = _IImageGetter.GetAttach(this.ImageID);

            HttpResponseMessage response = new HttpResponseMessage();

            if (attach != null && attach.Type == (int)EnumAttachType.Picture && System.IO.File.Exists(attach.Path))
            {
                response.Content = new StreamContent(System.IO.File.OpenRead(attach.Path));
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("image/" + attach.Extension.Trim('.'));

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", ImageID));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(await Task.FromResult(response));
        }
Пример #22
0
        private HttpResponseMessage getResponse()
        {
            var _IImageGetter = UnityContainerHelper.GetServer <IImageGetter>();

            var attach = _IImageGetter.GetAttach(this.FileId);

            var response = new HttpResponseMessage();

            if (attach != null && System.IO.File.Exists(attach.Path))
            {
                var stream = WordGenerator.ConvertHtml(attach.Path);

                // 把图片的绝对路径替换成网络路径
                var htmlStr = Encoding.UTF8.GetString(stream.ToArray());
                htmlStr = htmlStr.Replace(AppDomain.CurrentDomain.BaseDirectory, "http://localhost:8002/");
                byte[] bytes = Encoding.UTF8.GetBytes(htmlStr);

                response.Content = new ByteArrayContent(bytes);
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("text/html");

                // 设置缓存信息,该部分可以没有,该部分主要是用于与开始部分结合以便浏览器使用304缓存
                // Set Cache
                response.Content.Headers.Expires = new DateTimeOffset(DateTime.Now).AddHours(1);
                // 这里应该写入文件的存储日期
                response.Content.Headers.LastModified = new DateTimeOffset(DateTime.Now);
                response.Headers.CacheControl         = new CacheControlHeaderValue()
                {
                    Public = true, MaxAge = TimeSpan.FromHours(1)
                };
                // 设置Etag,这里就简单采用 Id
                response.Headers.ETag = new EntityTagHeaderValue(string.Format("\"{0}\"", FileId));

                response.StatusCode = HttpStatusCode.OK;
            }

            return(response);
        }
Пример #23
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IFormChangeService _IFormChangeService = UnityContainerHelper.GetServer <IFormChangeService>();
            var result = _IFormChangeService.GetVolumeChanges(this.ID);

            IEngineeringVolumeCheckService _IEngineeringVolumeCheckService = UnityContainerHelper.GetServer <IEngineeringVolumeCheckService>();
            var checkList = _IEngineeringVolumeCheckService.GetVolumeCheckList(this.ID);

            if (checkList.Count > 0)
            {
                result.Add(new EngineeringVolumeCheckForm()
                {
                    ID         = this.ID,
                    ObjectText = "校审单",
                    VolumeID   = this.ID,
                    Checker    = this.Checker,
                    Designer   = this.Designer,
                    CheckItems = checkList
                });
            }

            return(result);
        }
Пример #24
0
        public static FlowNodeInfo GetFlowNodeInfo(int TaskID, string System, Dictionary <string, Object> Params = null)
        {
            var _IUserTaskService           = UnityContainerHelper.GetServer <IUserTaskService>(System);
            var _IBPMProcessInstanceService = UnityContainerHelper.GetServer <IBPMProcessInstanceService>();
            var _IBPMTaskInstanceService    = UnityContainerHelper.GetServer <IBPMTaskInstanceService>();

            var userTask = _IUserTaskService.Get(TaskID);
            var process  = _IBPMProcessInstanceService.Get(userTask.ProcessID.Value);

            var def = ProcessModelCache.Instance[process.Name];

            var node = new FlowNodeInfo();

            node.ProcessID = userTask.ProcessID.Value.ToString();

            if (!string.IsNullOrEmpty(userTask.Args))
            {
                node.Params = userTask.Args.Split(',').ToList();
            }

            var list = getFlowTasks(def.Process);

            var index = list.FindIndex(u => "_" + u.DefID == userTask.TaskModelID);

            node.CurrentTaskName = list[index].Name;

            if (index < list.Count - 1)
            {
                var nextTask = list[index + 1];
                node.NextName  = nextTask.Name;
                node.NextUsers = new List <int>();

                node.NextIsJoinSign = nextTask.IsJoinSign;
                node.NextOwner      = nextTask.Owner;

                // 如果下一个任务已执行过,既被退回重新提交
                var tasks = _IBPMTaskInstanceService.GetList(t => t.ProcessID == userTask.ProcessID &&
                                                             t.SourceID == "_" + nextTask.DefID &&
                                                             !t.IsDelete);

                if (tasks.Count == 1)
                {
                    if (tasks[0].Type == (int)TaskType.Manual)
                    {
                        node.NextUser = tasks[0].UserID;
                    }
                    else
                    {
                        node.NextJoinSignUsers = tasks[0].Users.Split(',');
                    }
                }

                var owner = list[index + 1].Owner;

                def.Resources.ForEach(r =>
                {
                    if (r.ID == owner)
                    {
                        if (r.IOwner != null)
                        {
                            var call = UnityContainerHelper.GetServer <IOwner>(r.IOwner.Name);

                            node.NextUsers = call.GetOwner("_" + nextTask.DefID, Params);
                        }

                        node.NextUsers = node.NextUsers ?? new List <int>();

                        if (!string.IsNullOrEmpty(r.Task))
                        {
                            var orgTask = _IBPMTaskInstanceService.GetList(t => t.ProcessID == userTask.ProcessID &&
                                                                           t.SourceID == r.Task &&
                                                                           !t.IsDelete);

                            if (orgTask != null && orgTask.Count > 0)
                            {
                                node.NextUsers.Add(orgTask.First().UserID);
                            }
                        }

                        r.Users.ForEach(u =>
                        {
                            var id = int.Parse(u.ID);
                            if (!node.NextUsers.Contains(id))
                            {
                                node.NextUsers.Add(id);
                            }
                        });
                    }
                });
            }

            return(node);
        }
Пример #25
0
        public override BizObject GetParent()
        {
            IEngineeringService _IEngineeringService = UnityContainerHelper.GetServer <IEngineeringService>();

            return(_IEngineeringService.Get(this.EngineeringID));
        }
Пример #26
0
        public override BizObject GetParent()
        {
            IProjectService _IProjectService = UnityContainerHelper.GetServer <IProjectService>();

            return(new ProjectInfo(_IProjectService.Get(this.ProjectID)));
        }
Пример #27
0
        /// <summary>
        /// 恢复流程实例
        /// </summary>
        /// <param name="TaskID"></param>
        /// <returns></returns>
        public static ProcessInstance BackUpInstance(string TaskID)
        {
            //var _IBPMProcessTaskIDMapService = UnityContainerHelper.GetServer<IBPMProcessTaskIDMapService>();
            //var _IBPMProcessInstanceService = UnityContainerHelper.GetServer<IBPMProcessInstanceService>();
            //var _IBPMTaskInstanceService = UnityContainerHelper.GetServer<IBPMTaskInstanceService>();

            var _IBPMProcessTaskIDMapService = new BPMProcessTaskIDMapService();
            var _IBPMProcessInstanceService  = new BPMProcessInstanceService();
            var _IBPMTaskInstanceService     = new BPMTaskInstanceService();

            var task    = _IBPMTaskInstanceService.Get(new Guid(TaskID));
            var tasks   = _IBPMTaskInstanceService.GetList(t => t.ProcessID == task.ProcessID);
            var process = _IBPMProcessInstanceService.Get(task.ProcessID);
            var idMaps  = _IBPMProcessTaskIDMapService.GetList(m => m.ProcessID == task.ProcessID);

            // 获取流程模板
            var def = ProcessModelCache.Instance[process.Name];

            // 获取流程的监听者
            var _Ob = UnityContainerHelper.GetServer <IObservation>(def.ProcessOb.Name);


            // 生成流程实例
            var pi = new ProcessInstance()
            {
                ID        = task.ProcessID.ToString(),
                Name      = def.Name,
                StartDate = process.StartDate,
                Version   = process.Version
            };

            // 编译脚本代码
            if (!string.IsNullOrEmpty(def.ConditionCode))
            {
                pi.Compiled = ConditionExpression.Evaluator(def.ConditionCode, def.ID);
            }

            // 流程资源
            def.Resources.ForEach(r =>
            {
                var prs = new ProcessResouce()
                {
                    Key   = r.ID,
                    Users = new Dictionary <string, string>()
                };

                r.Users.ForEach(u =>
                {
                    prs.Users.Add(u.ID, u.Name);
                });

                pi.ProcessResouces.Add(r.ID, prs);
            });

            pi.ModelInstanceIDMaps = new Dictionary <string, string>();

            idMaps.ForEach(m =>
            {
                pi.ModelInstanceIDMaps.Add(m.TaskKey, m.TaskID.ToString());
            });

            pi.OB = _Ob;

            // 生成流程脚本实例
            pi.BackUpTasks(def, tasks);

            return(pi);
        }
Пример #28
0
        public override List <BizObject> GetChildren(PageQueryParam PageParam)
        {
            IEngineeringService _IEngineeringService = UnityContainerHelper.GetServer <IEngineeringService>();

            return(_IEngineeringService.GetListByProjectID(this.ID, PageParam));
        }
Пример #29
0
        public void GeneratTasks(Definitions def, Dictionary <string, object> InputData = null, IObservation Ob = null)
        {
            this.OB = Ob;

            var startID = generatIds(def.Process.StartEvent.ID);

            this.StartTask = new StartTaskInstance()
            {
                Name     = def.Process.StartEvent.Name,
                SourceID = def.Process.StartEvent.ID,
                ID       = startID,
                To       = generatIds(def.Process.StartEvent.OutGoing),
                Status   = TaskStatus.Empty,
                Type     = TaskType.Start
            };

            // 开始节点
            this.Tasks.Add(startID, this.StartTask);

            // 用户手工任务
            def.Process.UserTasks.ForEach(t =>
            {
                var taskID = generatIds(t.ID);
                var fromID = generatIds(t.Incoming);
                var toID   = generatIds(t.OutGoing);

                var mTask = new ManualTaskInstance()
                {
                    Name     = t.Name,
                    ID       = taskID,
                    SourceID = t.ID,
                    To       = toID,
                    From     = fromID,
                    Status   = TaskStatus.Empty,
                    Type     = TaskType.Manual,
                    Owner    = t.PotentialOwner
                };

                if (mTask.Owner != null && !string.IsNullOrEmpty(mTask.Owner.Name))
                {
                    if (mTask.Owner.Name == "ProcessUser")
                    {
                        mTask.UserID = this.CreateUser;
                    }
                    else if (InputData.ContainsKey(mTask.Owner.Name))
                    {
                        mTask.UserID = int.Parse(InputData[mTask.Owner.Name].ToString());
                    }
                    else if (this.ProcessResouces.ContainsKey(mTask.Owner.Name) && this.ProcessResouces[mTask.Owner.Name].Users.Count == 1)
                    {
                        mTask.UserID = int.Parse(this.ProcessResouces[mTask.Owner.Name].Users.First().Key);
                    }
                }

                if (Ob != null)
                {
                    mTask.SetObservation(Ob);
                }

                this.Tasks.Add(taskID, mTask);
            });

            // 自动调用Api任务
            def.Process.AutoTasks.ForEach(t =>
            {
                var taskID = generatIds(t.ID);
                var fromID = generatIds(t.Incoming);
                var toID   = generatIds(t.OutGoing);

                this.Tasks.Add(taskID, new AutoTaskInstance(UnityContainerHelper.GetServer <IAutoTaskExcute>(t.Name))
                {
                    Name     = t.Name,
                    ID       = taskID,
                    SourceID = t.ID,
                    To       = toID,
                    From     = fromID,
                    Status   = TaskStatus.Empty,
                    Type     = TaskType.CallApi
                });
            });

            // 会签任务
            def.Process.JointlySigns.ForEach(t =>
            {
                var taskID = generatIds(t.ID);
                var fromID = generatIds(t.Incoming);
                var toID   = generatIds(t.OutGoing);

                var mTask = new JointlySignTaskInstance()
                {
                    Name     = t.Name,
                    ID       = taskID,
                    SourceID = t.ID,
                    To       = toID,
                    From     = fromID,
                    Status   = TaskStatus.Empty,
                    Type     = TaskType.Sign,
                    Owner    = t.PotentialOwner
                };

                if (mTask.Owner != null && !string.IsNullOrEmpty(mTask.Owner.Name))
                {
                    if (InputData.ContainsKey(mTask.Owner.Name))
                    {
                        mTask.Users = InputData[mTask.Owner.Name].ToString();
                    }
                    else if (this.ProcessResouces.ContainsKey(mTask.Owner.Name) && this.ProcessResouces[mTask.Owner.Name].Users.Count == 1)
                    {
                        mTask.Users = this.ProcessResouces[mTask.Owner.Name].Users.First().Key;
                    }
                }

                if (Ob != null)
                {
                    mTask.SetObservation(Ob);
                }

                this.Tasks.Add(taskID, mTask);
            });

            // 连接线
            def.Process.SequenceFlows.ForEach(s =>
            {
                var taskID = generatIds(s.ID);
                var fromID = generatIds(s.SourceRef);
                var toID   = generatIds(s.TargetRef);

                this.Sequences.Add(taskID, new SequenceInstance()
                {
                    Name      = s.ID,
                    ID        = taskID,
                    To        = toID,
                    From      = fromID,
                    Condition = s.Condition
                });
            });

            // 独立网关
            def.Process.ExclusiveGateways.ForEach(g =>
            {
                var gid = generatIds(g.ID);

                this.Gateways.Add(gid, new ExclusiveGatewayInstance()
                {
                    ID      = gid,
                    Froms   = generatIds(g.Incoming),
                    Tos     = generatIds(g.Outgoing),
                    Type    = GatewayType.Exclusive,
                    Default = generatIds(g.Default)
                });
            });

            // 并行网关
            def.Process.ParallelGateways.ForEach(g =>
            {
                var gid = generatIds(g.ID);

                this.Gateways.Add(gid, new ParallelGatewayInstance()
                {
                    ID    = gid,
                    Froms = generatIds(g.Incoming),
                    Tos   = generatIds(g.Outgoing),
                    Type  = GatewayType.Parallel,
                    IsJointlySignBegin = g.Type != null && g.Type.Equals("JointlySignBegin"),
                    IsJointlySignEnd   = g.Type != null && g.Type.Equals("JointlySignEnd")
                });
            });

            var endId     = generatIds(def.Process.EndEvent.ID);
            var endFromID = generatIds(def.Process.EndEvent.Incoming);

            // 结束任务
            this.Tasks.Add(endId, new EndTaskInstance()
            {
                Name     = def.Process.EndEvent.Name,
                ID       = endId,
                SourceID = def.Process.EndEvent.ID,
                From     = endFromID,
                Status   = TaskStatus.Empty,
                Type     = TaskType.End
            });
        }
Пример #30
0
        public void BackUpTasks(Definitions def, List <BPMTaskInstanceEntity> DBTasks)
        {
            #region Tasks

            foreach (var task in DBTasks)
            {
                TaskInstance taskInstance = null;
                var          taskID       = task.ID.ToString().ToUpper();

                switch (task.Type)
                {
                case (int)TaskType.Start:
                {
                    taskInstance = new StartTaskInstance()
                    {
                        Name     = task.Name,
                        ID       = taskID,
                        SourceID = task.SourceID,
                        From     = task.Source.ToString().ToUpper(),
                        To       = task.Target.ToString().ToUpper(),
                        Status   = (TaskStatus)task.Status,
                        Type     = TaskType.Start
                    };
                    break;
                }

                case (int)TaskType.CallApi:
                {
                    taskInstance = new AutoTaskInstance(UnityContainerHelper.GetServer <IAutoTaskExcute>(task.Name))
                    {
                        Name     = task.Name,
                        ID       = taskID,
                        SourceID = task.SourceID,
                        From     = task.Source.ToString().ToUpper(),
                        To       = task.Target.ToString().ToUpper(),
                        Status   = (TaskStatus)task.Status,
                        Type     = TaskType.CallApi
                    };

                    break;
                }

                case (int)TaskType.Manual:
                {
                    var mTask = new ManualTaskInstance()
                    {
                        Name     = task.Name,
                        ID       = taskID,
                        SourceID = task.SourceID,
                        From     = task.Source.ToString().ToUpper(),
                        To       = task.Target.ToString().ToUpper(),
                        Status   = (TaskStatus)task.Status,
                        Type     = TaskType.Manual,
                        UserID   = task.UserID
                    };

                    mTask.IsDone = mTask.Status == TaskStatus.Done;

                    foreach (var item in this.ModelInstanceIDMaps)
                    {
                        if (item.Value.ToUpper() == taskID)
                        {
                            mTask.Owner = def.Process.UserTasks.SingleOrDefault(t => t.ID == item.Key).PotentialOwner;
                            break;
                        }
                    }

                    if (this.OB != null)
                    {
                        mTask.SetObservation(this.OB);
                    }

                    taskInstance = mTask;
                    break;
                }

                case (int)TaskType.Sign:
                {
                    var mTask = new JointlySignTaskInstance()
                    {
                        Name     = task.Name,
                        ID       = taskID,
                        SourceID = task.SourceID,
                        From     = task.Source.ToString().ToUpper(),
                        To       = task.Target.ToString().ToUpper(),
                        Status   = (TaskStatus)task.Status,
                        Type     = TaskType.Manual,
                        UserID   = task.UserID,
                        Users    = task.Users
                    };

                    mTask.IsDone = mTask.Status == TaskStatus.Done;

                    foreach (var item in this.ModelInstanceIDMaps)
                    {
                        if (item.Value.ToUpper() == taskID)
                        {
                            mTask.Owner = def.Process.JointlySigns.SingleOrDefault(t => t.ID == item.Key).PotentialOwner;
                            break;
                        }
                    }

                    if (this.OB != null)
                    {
                        mTask.SetObservation(this.OB);
                    }

                    taskInstance = mTask;
                    break;
                }

                case (int)TaskType.Empty:
                {
                    break;
                }

                case (int)TaskType.End:
                {
                    taskInstance = new EndTaskInstance()
                    {
                        Name     = task.Name,
                        ID       = taskID,
                        SourceID = task.SourceID,
                        From     = task.Source.ToString().ToUpper(),
                        To       = task.Target.ToString().ToUpper(),
                        Status   = (TaskStatus)task.Status,
                        Type     = TaskType.End
                    };
                    break;
                }
                }

                if (taskInstance.Status == TaskStatus.Waiting)
                {
                    var token = new TaskToken();
                    taskInstance.Token = token;
                    this.Tokens.Add(token);
                }

                this.Tasks.Add(taskID, taskInstance);
            }
            #endregion

            // 连接线
            def.Process.SequenceFlows.ForEach(s =>
            {
                var taskID = generatIds(s.ID);
                var fromID = generatIds(s.SourceRef);
                var toID   = generatIds(s.TargetRef);

                this.Sequences.Add(taskID, new SequenceInstance()
                {
                    Name      = s.ID,
                    ID        = taskID,
                    To        = toID,
                    From      = fromID,
                    Condition = s.Condition
                });
            });

            // 独立网关
            def.Process.ExclusiveGateways.ForEach(g =>
            {
                var gid = generatIds(g.ID);

                this.Gateways.Add(gid, new ExclusiveGatewayInstance()
                {
                    ID      = gid,
                    Froms   = generatIds(g.Incoming),
                    Tos     = generatIds(g.Outgoing),
                    Default = generatIds(g.Default),
                    Type    = GatewayType.Exclusive
                });
            });

            // 并行网关
            def.Process.ParallelGateways.ForEach(g =>
            {
                var gid = generatIds(g.ID);

                this.Gateways.Add(gid, new ParallelGatewayInstance()
                {
                    ID    = gid,
                    Froms = generatIds(g.Incoming),
                    Tos   = generatIds(g.Outgoing),
                    Type  = GatewayType.Parallel,
                    IsJointlySignBegin = g.Type != null && g.Type.Equals("JointlySignBegin"),
                    IsJointlySignEnd   = g.Type != null && g.Type.Equals("JointlySignEnd")
                });
            });
        }