Beispiel #1
0
        internal void AddInstanceData(SysWorkItem work_item, ApproveResultEnum approveResult, string approveComment)
        {
            SysApproveActivityData data = new SysApproveActivityData {
                DataId             = work_item.WorkItemId,
                ActivityInstanceId = work_item.ActivityInstanceId,
                AddingUserId       = work_item.AddingUserId,
                IsAdded            = work_item.IsAdded,
                IsProxy            = work_item.IsProxy,
                ProxyUserId        = work_item.ProxyUserId,
                WorkItemId         = new int?(work_item.WorkItemId),
                ApproveComment     = approveComment,
                ApproveGroupId     = work_item.ApproveGroupId,
                ApproveResult      = new int?((int)approveResult),
                ApproveTime        = new DateTime?(DateTime.Now),
                ApproveUserId      = work_item.OwnerId
            };

            this._piCacheFactory.AddApproveData(data);
        }
 public void AddApproveData(SysApproveActivityData data)
 {
     this._context.Insert(data);
 }
        private WfActivityEntityInstance GetApproveEntityData(BizDataContext context, SysApproveActivityData p)
        {
            WfActivityEntityInstance entity = new WfActivityEntityInstance()
            {
                ActivityEntityInstanceId = p.DataId,
            };
            var dic  = new Dictionary <string, WfActivityFieldData>();
            var list = context.Where <SysApproveActivityData>(i => i.ApproveGroupId == p.ApproveGroupId).OrderBy(i => i.ApproveTime).ToList();

            for (int i = 0; i < list.Count(); i++)
            {
                p = list.ElementAt(i);
                var user = context.FindById <T_User>(p.ApproveUserId);
                if (user != null)
                {
                    dic[(1 + 3 * i).ToString()] = new WfActivityFieldData()
                    {
                        DisplayText = "审核人", Value = user.User_Name
                    };
                }
                dic[(2 + 3 * i).ToString()] = new WfActivityFieldData()
                {
                    DisplayText = "审核时间", Value = Convert.ToString(p.ApproveTime)
                };
                dic[(3 + 3 * i).ToString()] = new WfActivityFieldData()
                {
                    DisplayText = "审核意见", Value = p.ApproveComment
                };
            }
            entity.ActivityEntityInstanceData = dic;

            return(entity);
        }
        /// <summary>
        /// 活动实体的内容
        /// </summary>
        /// <param name="process"></param>
        /// <param name="activityInstance"></param>
        /// <param name="data"></param>
        private void LoadActivityEntityData(BizDataContext context, SysProcess process, WfActivityInstance activityInstance, WfWorkflowInstanceData data)
        {
            //实体名
            string entityName = process.ActivityEntity.EntityName;

            var es = IEntitySchemaHelper.Get(entityName);

            //主键名
            string keyFieldName = es.KeyName;// process.ActivityEntity.GetKeyFieldName();

            //字段列表
            var fieldList = process.ActivityEntity.Fields.ToList();

            //签核流程
            bool isApprove = process.ProcessCategory == (int)ProcessCategory.Approve;

            if (isApprove)
            {
                SysApproveActivityData ad = context.FirstOrDefault <SysApproveActivityData>(p => p.ActivityInstanceId == activityInstance.ActivityInstanceId);
                if (ad != null)
                {
                    WfActivityEntityInstance entity = GetApproveEntityData(context, ad);
                    activityInstance.ActivityEntityInstance = entity;
                }
            }
            else
            {
                //标哥说普通流程活动实例ID和活动实体ID是一样的……
                int id = activityInstance.ActivityInstanceId;

                dynamic entityData = (new OrgManager(context)).GetEntity(entityName, id);

                if (entityData != null)
                {
                    Type entityType = entityData.GetType();

                    WfActivityEntityInstance entity = new WfActivityEntityInstance()
                    {
                        ActivityEntityInstanceId = id,
                    };

                    //属性的键值对
                    entity.ActivityEntityInstanceData = entityType.GetProperties()
                                                        .Where(i => i.Name != keyFieldName && !IgnoreList.Contains(i.Name))
                                                        .ToDictionary(i => i.Name, i =>
                    {
                        var pValue = new WfActivityFieldData();
                        try
                        {
                            pValue.Value = Convert.ToString(i.GetValue(entityData, null));
                        }
                        catch { }
                        return(pValue);
                    });


                    //加上DisplayText
                    foreach (var i in entity.ActivityEntityInstanceData)
                    {
                        var field = fieldList.FirstOrDefault(q => q.FieldName.Contains(i.Key));
                        if (field != null)
                        {
                            i.Value.DisplayText = field.DisplayText;
                        }
                        else
                        {
                            i.Value.DisplayText = i.Key;
                        }
                    }

                    activityInstance.ActivityEntityInstance = entity;
                }
            }
        }