Пример #1
0
        /// <summary>
        /// 查询所有工作流
        /// </summary>
        /// <returns></returns>
        public IEnumerable <WfProcess> GetWorkFlowList()
        {
            Drision.Framework.Entity.EntityCache cache = Drision.Framework.Entity.EntityCache.New();
            using (BizDataContext context = new BizDataContext())
            {
                var processList = context.Set <SysProcess>().Where(p => p.ProcessCategory != (int)ProcessCategory.FormApprove).ToList();
                foreach (var p in processList)
                {
                    p.ActivityEntity = cache.FindById <SysEntity>(p.ActivityEntityId); // context.FindById<SysEntity>(p.ActivityEntityId);
                    p.ProcessEntity  = cache.FindById <SysEntity>(p.EntityId);         // context.FindById<SysEntity>(p.EntityId);
                }

                return(processList.Select(p => new
                {
                    ActivityEntityName = p.ActivityEntity != null ? p.ActivityEntity.EntityName : "",
                    EntityName = p.ProcessEntity != null ? p.ProcessEntity.EntityName : "",
                    p.ProcessName,
                    p.ProcessId,
                    p.ProcessStatus,
                    p.ProcessCategory,
                    p.ProcessVersion,
                    CanDelete = p.ProcessStatus == (int)ProcessState.Created,
                }).ConvertTo <WfProcess>());
            }
        }
Пример #2
0
        /// <summary>
        /// 查询所有实体(含所有字段、引用实体、引用实体的字段)
        /// </summary>
        /// <returns></returns>
        public IEnumerable <WfEntity> GetEntityList()
        {
            Drision.Framework.Entity.EntityCache cache = Drision.Framework.Entity.EntityCache.New();
            //using (BizDataContext context = new BizDataContext())
            {
                //var entityList = context.Set<SysEntity>().OrderBy(p => p.DisplayText).ToList();
                var entityList = cache.SysEntity.OrderBy(p => p.DisplayText).ToList();
                //var fieldList = context.Set<SysField>().OrderBy(p => p.DisplayText).ToList();
                var fieldList = cache.SysField.OrderBy(p => p.DisplayText).ToList();
                //var relationList = context.FetchAll<SysOneMoreRelation>();
                var relationList = cache.SysOneMoreRelation;
                //var pageList = context.Where<SysPage>(p => p.PageType == (int)PageType.Activity || p.PageType == (int)PageType.Approve);
                var pageList = cache.SysPage.Where(p => p.PageType == (int)PageType.Activity || p.PageType == (int)PageType.Approve);

                //foreach (var page in pageList)
                //{
                //    var control = context.FindById<SysPageControl>(page.ControlId);
                //    page.EntityId = control.EntityId;
                //}

                //foreach (var entity in entityList)
                //{
                //    entity.ChildOneMoreRelations = relationList.Where(p => p.ChildEntityId == entity.EntityId).ToList();
                //    foreach (var relation in entity.ChildOneMoreRelations)
                //    {
                //        relation.ChildField = fieldList.FirstOrDefault(p => p.FieldId == relation.ChildFieldId);
                //        relation.ParentEntity = entityList.FirstOrDefault(p => p.EntityId == relation.ParentEntityId);
                //    }

                //    entity.Fields = fieldList.Where(p => p.EntityId == entity.EntityId).ToList();
                //}

                var result = entityList.Select(p => new WfEntity()
                {
                    EntityId     = p.EntityId,
                    EntityName   = p.DisplayText,
                    RelationList = p.ChildOneMoreRelations.Select(r => new WfRelation() //所有引用实体(关系)
                    {
                        RelationId       = r.RelationId,
                        RelationName     = r.ChildField.DisplayText,
                        ParentEntityId   = r.ParentEntity.EntityId,
                        ParentEntityName = r.ParentEntity.DisplayText,
                    }).ToList(),
                    FieldList = p.Fields.Select(f => new WfField() //所有字段
                    {
                        FieldId   = f.FieldId,
                        DataType  = f.DataType,
                        FieldName = f.DisplayText,
                    }).ToList(),
                    PageList = pageList.Where(i => i.EntityId == p.EntityId).Select(i => new WfPage()
                    {
                        PageId   = i.ControlId,
                        PageName = i.DisplayText,
                    }).ToList(),
                }).ToList();

                return(result);
            }
        }