Exemplo n.º 1
0
        public JsonResult GetParticipants(string ActivityCode, string InstanceID)
        {
            return(ExecuteFunctionRun(() =>
            {
                if (!string.IsNullOrEmpty(ActivityCode) && !string.IsNullOrEmpty(InstanceID))
                {
                    //流程
                    Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceID);
                    if (InstanceContext != null)
                    {
                        //流程模板
                        WorkflowTemplate.PublishedWorkflowTemplate Template = this.Engine.WorkflowManager.GetPublishedTemplate(
                            InstanceContext.WorkflowCode,
                            InstanceContext.WorkflowVersion);
                        if (Template != null)
                        {
                            //活动信息
                            ClientActivityBase Activity = Template.GetActivityByCode(ActivityCode) as ClientActivityBase;

                            OThinker.H3.Instance.InstanceData InstanceData = new Instance.InstanceData(this.Engine, InstanceID, null);

                            string[] ParticipantIDs = Activity.ParseParticipants(InstanceData, this.Engine.Organization);
                            OThinker.Organization.Unit[] ParticipantUsers = this.Engine.Organization.GetUnits(ParticipantIDs).ToArray();

                            if (ParticipantUsers != null)
                            {
                                List <object> ParticipantUserNames = new List <object>();
                                foreach (OThinker.Organization.Unit u in ParticipantUsers)
                                {
                                    if (u != null && u.UnitType == OThinker.Organization.UnitType.User)
                                    {
                                        OThinker.Organization.User user = (OThinker.Organization.User)u;
                                        ParticipantUserNames.Add(new
                                        {
                                            Name = user.Name,
                                            Code = user.Code,
                                            ObjectID = user.ObjectID
                                        });
                                        //ParticipantUserNames.Add(u.Name + "[" + u.Code + "]");
                                    }
                                }
                                return Json(ParticipantUserNames, JsonRequestBehavior.AllowGet);
                            }
                        }
                    }
                }

                return Json(new string[] { }, JsonRequestBehavior.AllowGet);
            }));
        }
        /// <summary>
        /// 保存表单数据
        /// </summary>
        /// <param name="workItem"></param>
        /// <param name="user"></param>
        /// <param name="boolMatchValue"></param>
        /// <param name="paramValues"></param>
        private void SaveBizObject(OThinker.H3.WorkItem.WorkItem workItem, OThinker.Organization.User user, OThinker.Data.BoolMatchValue boolMatchValue, List<DataItemParam> paramValues)
        {
            Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(workItem.InstanceId);
            string bizObjectId = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;
            OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(InstanceContext.BizObjectSchemaCode);
            OThinker.H3.DataModel.BizObject bo = new OThinker.H3.DataModel.BizObject(this.Engine, schema, workItem.Participant);
            bo.ObjectID = bizObjectId;
            bo.Load();

            // 设置数据项的值
            foreach (DataItemParam param in paramValues)
            {
                OThinker.H3.DataModel.PropertySchema property = schema.GetProperty(param.ItemName);
                if (property.LogicType == DataLogicType.Comment)
                {// 审核意见
                    CommentParam comment = JSSerializer.Deserialize<CommentParam>(param.ItemValue + string.Empty);
                    this.Engine.BizObjectManager.AddComment(new Comment()
                    {
                        BizObjectId = bo.ObjectID,
                        BizObjectSchemaCode = schema.SchemaCode,
                        InstanceId = workItem.InstanceId,
                        TokenId = workItem.TokenId,
                        Approval = boolMatchValue,
                        Activity = workItem.ActivityCode,
                        DataField = property.Name,
                        UserID = user.ObjectID,
                        SignatureId = comment.SignatureId,
                        Text = comment.Text
                    });
                }
                else
                {
                    this.SetItemValue(bo, property, param.ItemValue);
                }
            }

            bo.Update();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 异常节点
        /// </summary>
        /// <param name="InstanceId"></param>
        /// <returns></returns>
        private List <string> ExceptionActivities(string InstanceId)
        {
            //异常活动
            List <string> lstExceptionActivities = new List <string>();

            Instance.InstanceContext  InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceId);
            Exceptions.ExceptionLog[] ExceptionLogs   = this.Engine.ExceptionManager.GetExceptionsByInstance(InstanceId);
            if (ExceptionLogs != null)
            {
                foreach (Exceptions.ExceptionLog ExceptionLog in ExceptionLogs)
                {
                    if (ExceptionLog.State == Exceptions.ExceptionState.Unfixed)
                    {
                        InstanceContext.State = Instance.InstanceState.Exceptional;
                        if (ExceptionLog.SourceType == Instance.RuntimeObjectType.Activity)
                        {
                            lstExceptionActivities.Add(ExceptionLog.SourceName);
                        }
                    }
                }
            }
            return(lstExceptionActivities);
        }
        private void AppendComment(WorkItem.WorkItem Item, OThinker.Data.BoolMatchValue Approval, string Comment)
        {
            WorkflowTemplate.PublishedWorkflowTemplate workflow = GetWorkflowTemplate(Item.WorkflowCode, Item.WorkflowVersion);
            // 审批字段
            string approvalDataItem = null;

            if (workflow != null)
            {
                PublishedWorkflowTemplate             workflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(Item.WorkflowCode, Item.WorkflowVersion);
                OThinker.H3.DataModel.BizObjectSchema schema           = GetSchema(workflowTemplate.BizObjectSchemaCode);
                approvalDataItem = workflow.GetDefaultCommentDataItem(schema, Item.ActivityCode);
            }
            if (approvalDataItem != null)
            {
                // 创建审批
                //TODO:此处待修改,Item.BizObjectId不存在,通过 OT_InstanceContext获取
                Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(Item.InstanceId);
                string BizObjectId = InstanceContext == null ? string.Empty : InstanceContext.BizObjectId;

                Data.Comment comment = new Data.Comment();
                comment.Activity    = Item.ActivityCode;
                comment.Approval    = Approval;
                comment.CreatedTime = System.DateTime.Now;
                comment.DataField   = approvalDataItem;
                comment.InstanceId  = Item.InstanceId;
                comment.OUName      = this.Engine.Organization.GetName(this.Engine.Organization.GetParent(Item.Participant));
                comment.Text        = Comment;
                comment.TokenId     = Item.TokenId;
                comment.UserID      = Item.Participant;
                comment.UserName    = Item.ParticipantName;
                //comment.BizObjectId = Item.BizObjectId;
                comment.BizObjectId         = BizObjectId;
                comment.BizObjectSchemaCode = Item.WorkflowCode;
                this.Engine.BizObjectManager.AddComment(comment);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 验证权限
        /// </summary>
        /// <param name="UserValidator"></param>
        /// <param name="SheetDataType"></param>
        /// <param name="IsOriginateMode"></param>
        /// <param name="SchemaCode"></param>
        /// <param name="BizObject"></param>
        /// <param name="SheetMode"></param>
        /// <param name="WorkflowCode"></param>
        /// <param name="WorkItem"></param>
        /// <param name="InstanceContext"></param>
        /// <returns></returns>
        public static bool ValidateAuthorization(
            UserValidator UserValidator,
            SheetDataType SheetDataType,
            bool IsOriginateMode,
            string SchemaCode,
            DataModel.BizObject BizObject,
            SheetMode SheetMode,
            string WorkflowCode,
            WorkItem.WorkItem WorkItem,
            WorkItem.CirculateItem CirculateItem,
            Instance.InstanceContext InstanceContext)
        {
            if (UserValidator.ValidateAdministrator())
            {
                return(true);
            }
            // 业务对象表单
            else if (SheetDataType == SheetDataType.BizObject)
            {
                if (IsOriginateMode)
                {
                    return(UserValidator.ValidateBizObjectAdd(SchemaCode, null, UserValidator.UserID));
                }
                else
                {
                    if (UserValidator.ValidateOrgAdmin(BizObject.OwnerId))
                    {
                        return(true);
                    }
                    return(UserValidator.ValidateBizObjectAdmin(SchemaCode, null, BizObject.OwnerId));
                }
            }
            else
            {
                switch (SheetMode)
                {
                case SheetMode.Originate:
                    return(UserValidator.ValidateCreateInstance(WorkflowCode));

                case SheetMode.View:
                case SheetMode.Print:
                    if (WorkItem != null &&
                        ValidateWorkItemAuth(WorkItem, UserValidator, UserValidator.Engine.AgencyManager))
                    {
                        return(true);
                    }
                    else if (CirculateItem != null && ValidateCirculateItemAuth(CirculateItem, UserValidator))
                    {
                        return(true);
                    }
                    else if (UserValidator.ValidateWFInsView(WorkflowCode, InstanceContext.Originator))
                    {
                        // 是否允许查看这个流程模板的所有实例
                        return(true);
                    }
                    else
                    {
                        // 判定用户是否参与过流程实例
                        string[] workItems = UserValidator.Engine.Query.QueryWorkItems(
                            new string[] { InstanceContext.InstanceId },
                            new string[] { UserValidator.UserID },
                            DateTime.Now.AddYears(-100),
                            DateTime.Now.AddDays(1),
                            H3.WorkItem.WorkItemState.Unspecified,
                            OThinker.H3.WorkItem.WorkItem.NullWorkItemID);
                        if (workItems != null && workItems.Length > 0)
                        {
                            return(true);
                        }
                        return(false);
                    }

                case SheetMode.Work:
                    if (WorkItem != null)
                    {
                        return(ValidateWorkItemAuth(WorkItem, UserValidator, UserValidator.Engine.AgencyManager));
                    }
                    else
                    {
                        return(ValidateCirculateItemAuth(CirculateItem, UserValidator));
                    }

                default:
                    throw new NotImplementedException();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 输出流程模板包、流程模板
        /// </summary>
        public JsonResult RegisterActivityTemplateConfigs(string WorkflowCode, int WorkflowVersion, string InstanceID)
        {
            return(ExecuteFunctionRun(() =>
            {
                WorkflowCode = Server.UrlDecode(WorkflowCode); //解决WorkflowCode为汉字的情景
                ActivityTemplateConfigsViewModel model = new ActivityTemplateConfigsViewModel();
                if ((WorkflowCode == null || WorkflowCode == "") && WorkflowVersion == -1)
                {
                    Instance.InstanceContext InstanceContext = this.Engine.InstanceManager.GetInstanceContext(InstanceID);
                    if (InstanceContext != null)
                    {
                        WorkflowCode = InstanceContext.WorkflowCode;
                        WorkflowVersion = InstanceContext.WorkflowVersion;
                        model.InstanceContext = InstanceContext;
                        model.ExceptionActivities = this.ExceptionActivities(InstanceID);
                    }
                }

                #region 是否锁定
                model.IsControlUsable = BizWorkflowPackageLockByID(WorkflowCode);
                #endregion

                #region 流程模板

                WorkflowDocument WorkflowTemplate = null;
                if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion)
                {
                    WorkflowTemplate = this.Engine.WorkflowManager.GetDraftTemplate(WorkflowCode);
                }
                else
                {
                    WorkflowTemplate = this.Engine.WorkflowManager.GetPublishedTemplate(WorkflowCode, WorkflowVersion);
                }

                #endregion

                #region 数据模型

                //数据项
                List <string> lstDataItems = new List <string>();
                //所有属性
                List <object> lstProperties = new List <object>();
                //输出到前台的数据项
                List <object> lstFrontDataItems = new List <object>();
                //允许设置权限的数据项
                List <string> lstPermissionDataItems = new List <string>();

                //参与者数据项
                List <string> lstUserDataItems = new List <string>();
                //逻辑型数据项
                List <string> lstBoolDataItems = new List <string>();

                //业务方法名称列表
                List <string> lstBizMethodNames = new List <string>();
                List <object> lstAllDataItems = new List <object>();//系统数据项,+流程数据项,流程设计选择时使用

                WorkflowClause Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                if (Clause != null && Clause.BizSchemaCode != null)
                {
                    //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "ClauseName", "var ClauseName=" + JSSerializer.Serialize(Clause.DisplayName + string.Empty) + ";", true);
                    model.ClauseName = Clause.WorkflowName + string.Empty;
                    //流程模板浏览页面地址
                    // ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "WorkflowViewUrl", "var WorkflowViewUrl=" + JSSerializer.Serialize(GetPortalRoot(this.Page) + ConstantString.PagePath_WorkflowDesigner) + ";", true);
                    model.WorkflowViewUrl = PortalRoot + ConstantString.PagePath_WorkflowDesigner;
                    DataModel.BizObjectSchema BizObject = this.Engine.BizObjectManager.GetDraftSchema(Clause.BizSchemaCode);
                    if (BizObject != null)
                    {
                        //流程包
                        object Package = new
                        {
                            SchemaCode = BizObject.SchemaCode
                        };
                        //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "Package", "var Package=" + JSSerializer.Serialize(Package) + ";", true);
                        model.Package = Package;

                        #region 页标签

                        if (Clause != null)
                        {
                            string TabName = string.IsNullOrEmpty(Clause.WorkflowName) ? Clause.WorkflowCode : Clause.WorkflowName;
                            if (WorkflowVersion != WorkflowDocument.NullWorkflowVersion)
                            {
                                TabName += "[" + WorkflowVersion + "]";
                            }
                            else
                            {
                                TabName += "[设计]";
                            }
                            //SetTabHeader(TabName);//前台执行
                            model.TabName = TabName;
                        }

                        #endregion

                        List <object> lstBizMethods = new List <object>();
                        //可选的业务方法
                        if (BizObject.Methods != null)
                        {
                            foreach (var Method in BizObject.Methods)
                            {
                                if (!DataModel.BizObjectSchema.IsDefaultMethod(Method.MethodName) && Method.MethodType == DataModel.MethodType.Normal)
                                {
                                    lstBizMethodNames.Add(Method.MethodName);
                                    lstBizMethods.Add(new { Text = Method.FullName, Value = Method.MethodName });
                                }
                            }
                        }
                        model.BizMethods = lstBizMethods;
                        //ScriptManager.RegisterClientScriptBlock(this.Page, Page.GetType(), "BizMethods", "var BizMethods=" + JSSerializer.Serialize(lstBizMethods.ToArray()) + ";", true);

                        #region  数据项、参与者、逻辑型数据项
                        //数据项、参与者、逻辑型数据项
                        if (BizObject.Properties != null)
                        {
                            List <Object> listNotifyCondition = new List <object>();
                            List <Object> listApprovalDataItem = new List <object>();
                            List <Object> listCommentDataItem = new List <object>();

                            listNotifyCondition.Add(new { Text = string.Empty, Value = string.Empty });
                            listApprovalDataItem.Add(new { Text = string.Empty, Value = string.Empty });
                            listCommentDataItem.Add(new { Text = string.Empty, Value = string.Empty });

                            foreach (DataModel.PropertySchema Property in BizObject.Properties)
                            {
                                //不显示保留数据项
                                if (!DataModel.BizObjectSchema.IsReservedProperty(Property.Name))
                                {
                                    lstDataItems.Add(Property.Name);
                                    lstProperties.Add(new
                                    {
                                        Text = Property.DisplayName,
                                        Value = Property.Name
                                    });

                                    lstFrontDataItems.Add(new
                                    {
                                        Text = Property.DisplayName,
                                        Value = Property.Name,
                                        //标记子表标题行
                                        ItemType = Property.LogicType == Data.DataLogicType.BizObjectArray ? "SubTableHeader" : string.Empty
                                    });
                                    lstPermissionDataItems.Add(Property.Name);



                                    //通知条件 TODO
                                    // sltNotifyCondition.Items.Add(new ListItem(Property.DisplayName, Property.Name));
                                    listNotifyCondition.Add(new { Text = Property.DisplayName, Value = Property.Name });

                                    //子表
                                    if ((Property.LogicType == Data.DataLogicType.BizObject || Property.LogicType == Data.DataLogicType.BizObjectArray) &&
                                        Property.ChildSchema != null && Property.ChildSchema.Properties != null)
                                    {
                                        foreach (DataModel.PropertySchema ChildProperty in Property.ChildSchema.Properties)
                                        {
                                            if (!DataModel.BizObjectSchema.IsReservedProperty(ChildProperty.Name))
                                            {
                                                lstFrontDataItems.Add(new
                                                {
                                                    Text = Property.DisplayName + "." + ChildProperty.DisplayName,
                                                    Value = Property.Name + "." + ChildProperty.Name
                                                });
                                                lstPermissionDataItems.Add(Property.Name + "." + ChildProperty.Name);
                                            }
                                        }
                                    }
                                    //参与者
                                    else if (Property.LogicType == Data.DataLogicType.SingleParticipant ||
                                             Property.LogicType == Data.DataLogicType.MultiParticipant)
                                    {
                                        lstUserDataItems.Add(Property.Name);
                                    }
                                    //逻辑型
                                    else if (Property.LogicType == Data.DataLogicType.Bool)
                                    {
                                        lstBoolDataItems.Add(Property.Name);
                                        //TODO
                                        listApprovalDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name });
                                    }
                                    //文本
                                    else if (Property.LogicType == Data.DataLogicType.String)
                                    {
                                        listCommentDataItem.Add(new { Text = Property.DisplayName, Value = Property.Name });
                                    }

                                    //else if (Property.LogicType == Data.DataLogicType.TimeSpan)
                                    //    sltAllowedTime.Items.Add(new ListItem(Property.DisplayName, Property.Name));
                                }
                            }
                            model.NotifyCondition = listNotifyCondition;
                            model.ApprovalDataItem = listApprovalDataItem;
                            model.CommentDataItem = listCommentDataItem;
                        }

                        #endregion

                        #region 关联对象权限

                        if (BizObject.Associations != null)
                        {
                            foreach (DataModel.BizObjectAssociation association in BizObject.Associations)
                            {
                                DataModel.BizObjectSchema AssociatedSchema = this.Engine.BizObjectManager.GetPublishedSchema(association.AssociatedSchemaCode);
                                if (AssociatedSchema != null && AssociatedSchema.Properties != null)
                                {
                                    lstFrontDataItems.Add(new
                                    {
                                        Text = association.DisplayName,
                                        Value = association.Name,
                                        //标记子表标题行
                                        ItemType = "SubTableHeader"
                                    });
                                    lstPermissionDataItems.Add(association.Name);

                                    foreach (DataModel.PropertySchema AssociatedChildProperty in AssociatedSchema.Properties)
                                    {
                                        if (!DataModel.BizObjectSchema.IsReservedProperty(AssociatedChildProperty.Name))
                                        {
                                            lstFrontDataItems.Add(new
                                            {
                                                Text = association.DisplayName + "." + AssociatedChildProperty.DisplayName,
                                                Value = association.Name + "." + AssociatedChildProperty.Name
                                            });
                                            lstPermissionDataItems.Add(association.Name + "." + AssociatedChildProperty.Name);
                                        }
                                    }
                                }
                            }
                        }

                        #endregion

                        #region 可选表单
                        //TODO
                        // sltSheetCodes.Items.Clear();
                        List <object> listSheetCodes = new List <object>();
                        Sheet.BizSheet[] Sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(Clause.BizSchemaCode);
                        if (Sheets != null)
                        {
                            foreach (Sheet.BizSheet Sheet in Sheets)
                            {
                                listSheetCodes.Add(new { Text = Sheet.DisplayName + "[" + Sheet.SheetCode + "]", Value = Sheet.SheetCode });
                            }
                        }
                        model.SheetCodes = listSheetCodes;
                        #endregion
                    }
                }
                model.DataItems = lstFrontDataItems;

                #endregion

                //设置可选的数据项 TODO 前台处理
                //SetDataItems(lstDataItems);

                #region 前置条件, Text前台需要解析多语言包
                // TODO
                List <object> listEntryCondition = new List <object>();
                listEntryCondition.Add(new { Text = "Designer.Designer_AnyOne", Value = (int)EntryConditionType.Any + string.Empty, Indext = 0 });
                listEntryCondition.Add(new { Text = "Designer.Designer_All", Value = (int)EntryConditionType.All + string.Empty, Index = 1 });
                model.EntryCondition = listEntryCondition;

                #endregion

                #region  步异步

                List <object> listSync = new List <object>();
                listSync.Add(new { Text = "Designer.Designer_Sync", Value = "true", Index = 0 });
                listSync.Add(new { Text = "Designer.Designer_Async", Value = "false", Index = 1 });
                model.SyncOrASync = listSync;
                #endregion

                #region 参与者策略
                //TODO
                List <object> listParAbNormalPolicy = GetParAbnormalPolicy();
                model.ParAbnormalPolicy = listParAbNormalPolicy;


                #endregion

                #region 发起者参与者策略
                List <object> listOriginatorParAbnormalPolicy = GetOriginatorParAbnormalPolicy();
                model.OriginatorParAbnormalPolicy = listOriginatorParAbnormalPolicy;
                #endregion

                #region 参与方式:单人/多人
                //TODO
                List <object> listParticipantMode = new List <object>();
                listParticipantMode.Add(new { Text = "Designer.Designer_Single", Value = (int)ActivityParticipateType.SingleParticipant + string.Empty, Index = 0 });
                listParticipantMode.Add(new { Text = "Designer.Designer_Mulit", Value = (int)ActivityParticipateType.MultiParticipants + string.Empty, Index = 1 });
                model.ParticipantMode = listParticipantMode;
                #endregion

                #region 可选参与方式:并行/串行
                //TODO
                List <object> listParticipateMethod = new List <object>();
                listParticipateMethod.Add(new { Text = "Designer.Designer_Parallel", Value = (int)ParticipateMethod.Parallel + string.Empty, Index = 0 });
                listParticipateMethod.Add(new { Text = "Designer.Designer_Serial", Value = (int)ParticipateMethod.Serial + string.Empty, Index = 1 });
                model.ParticipateMethod = listParticipateMethod;

                #endregion

                #region 提交时检查
                //TODO
                List <object> listSubmittingValidation = new List <object>();
                listSubmittingValidation.Add(new { Text = "Designer.Designer_NotCheck", Value = (int)SubmittingValidationType.None + string.Empty, Index = 0 });
                listSubmittingValidation.Add(new { Text = "Designer.Designer_CheckParticipant", Value = (int)SubmittingValidationType.CheckNextParIsNull + string.Empty, Index = 1 });
                model.SubmittingValidation = listSubmittingValidation;

                #endregion

                #region 子流程数据映射类型

                List <object> lstMapTypes = new List <object>();
                foreach (string WorkflowDataMapInOutType in Enum.GetNames(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType)))
                {
                    //不需要使用InOutAppend
                    if (WorkflowDataMapInOutType != OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType.InOutAppend.ToString())
                    {
                        lstMapTypes.Add(new
                        {
                            Text = WorkflowDataMapInOutType,
                            Value = (int)Enum.Parse(typeof(OThinker.H3.WorkflowTemplate.WorkflowDataMap.InOutType), WorkflowDataMapInOutType) + string.Empty
                        });
                    }
                }
                model.MapTypes = lstMapTypes;

                #endregion

                #region 表单锁
                //TODO

                List <object> listLockLevel = new List <object>();
                listLockLevel.Add(new { Text = "Designer.Designer_PopupManyPeople", Value = (int)LockLevel.Warning + string.Empty });
                listLockLevel.Add(new { Text = "Designer.Designer_ProhibitOneTime", Value = (int)LockLevel.Mono + string.Empty });
                listLockLevel.Add(new { Text = "Designer.Designer_CancelExclusive", Value = (int)LockLevel.CancelOthers + string.Empty });
                model.LockLevel = listLockLevel;

                #endregion

                #region 锁策略
                //TODO
                List <object> listLockPlicy = new List <object>();
                listLockPlicy.Add(new { Text = "Designer.Designer_NotLock", Value = (int)LockPolicy.None + string.Empty });
                listLockPlicy.Add(new { Text = "Designer.Designer_LockOpen", Value = (int)LockPolicy.Open + string.Empty });
                listLockPlicy.Add(new { Text = "Designer.Designer_LockRequest", Value = (int)LockPolicy.Request + string.Empty });
                model.LockPolicy = listLockPlicy;


                #endregion

                #region 超时策略
                //TODO
                List <object> listOvertimePolicy = new List <object>();
                listOvertimePolicy.Add(new { Text = "Designer.Designer_ExecuteStrategy", Value = (int)OvertimePolicy.None + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_Approval", Value = (int)OvertimePolicy.Approve + string.Empty });
                //超时审批拒绝,暂时关闭
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_ApprovalVote", Value = (int)OvertimePolicy.Disapprove + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_AutoComplete", Value = (int)OvertimePolicy.Finish + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy1", Value = (int)OvertimePolicy.Remind1 + string.Empty });
                listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy2", Value = (int)OvertimePolicy.Remind2 + string.Empty });
                //超时策略3,4在消息设置中去除,关闭
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy3", Value = (int)OvertimePolicy.Remind3 + string.Empty });
                //listOvertimePolicy.Add(new { Text = "Designer.Designer_RemindStrategy4", Value = (int)OvertimePolicy.Remind4 + string.Empty });
                model.OvertimePolicy = listOvertimePolicy;


                #endregion

                #region 数据项映射类型

                List <object> lstDataDisposalTypes = new List <object>();
                foreach (string DisposalTypeString in Enum.GetNames(typeof(DataDisposalType)))
                {
                    lstDataDisposalTypes.Add(new
                    {
                        Text = DisposalTypeString,
                        Value = (int)Enum.Parse(typeof(DataDisposalType), DisposalTypeString) + string.Empty
                    });
                }
                model.DataDisposalTypes = lstDataDisposalTypes;

                #endregion

                #region 初始化活动的数据权限

                if (WorkflowVersion == WorkflowDocument.NullWorkflowVersion && WorkflowTemplate != null && WorkflowTemplate.Activities != null)
                {//流程模板编码\显示名称
                    Dictionary <string, string> dicWorkflowNames = new Dictionary <string, string>();
                    //整理数据项权限
                    foreach (Activity Activity in WorkflowTemplate.Activities)
                    {
                        if (Activity is ParticipativeActivity)
                        {
                            ParticipativeActivity ParticipativeActivity = (ParticipativeActivity)Activity;

                            List <string> lstValidPermissionItemNames = new List <string>();
                            List <DataItemPermission> lstValidDataItemPermissions = new List <DataItemPermission>();
                            if (ParticipativeActivity.DataPermissions == null)
                            {
                                ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray();
                            }

                            if (ParticipativeActivity.DataPermissions != null)
                            {
                                foreach (DataItemPermission DataItemPermission in ParticipativeActivity.DataPermissions)
                                {
                                    if (lstPermissionDataItems.Contains(DataItemPermission.ItemName))
                                    {
                                        lstValidDataItemPermissions.Add(DataItemPermission);
                                        lstValidPermissionItemNames.Add(DataItemPermission.ItemName);
                                    }
                                }
                            }

                            foreach (string ItemName in lstPermissionDataItems)
                            {
                                if (!lstValidPermissionItemNames.Contains(ItemName))
                                {
                                    lstValidDataItemPermissions.Add(new DataItemPermission()
                                    {
                                        ItemName = ItemName,
                                        Visible = true,
                                        MobileVisible = true
                                    });
                                    lstValidPermissionItemNames.Add(ItemName);
                                }
                            }

                            ParticipativeActivity.DataPermissions = lstValidDataItemPermissions.ToArray();
                        }
                        //子流程:获取流程模板显示名称
                        else if (Activity is SubInstanceActivity)
                        {
                            string _SubWorkflowCode = ((SubInstanceActivity)Activity).WorkflowCode;
                            if (!string.IsNullOrEmpty(_SubWorkflowCode) && !dicWorkflowNames.ContainsKey(_SubWorkflowCode.ToLower()))
                            {
                                WorkflowClause _SubClause = this.Engine.WorkflowManager.GetClause(_SubWorkflowCode);
                                dicWorkflowNames.Add(_SubWorkflowCode.ToLower(), _SubClause == null ? _SubWorkflowCode : _SubClause.WorkflowName);
                            }
                        }
                    }
                    //流程模板编码\显示名称
                    model.WorkflowNames = dicWorkflowNames;
                }

                #endregion
                model.WorkflowTemplate = WorkflowTemplate;

                #region 数据项

                model.DataItemsSelect = GetALLDataItems(WorkflowCode);
                #endregion

                return Json(model, JsonRequestBehavior.AllowGet);
            }));
        }
Exemplo n.º 7
0
        //方法重写,区分推送和表单直接打开所存在的差异
        public JsonResult WorkItemSheetsNew(string paramString)
        {
            ActionResult result = new ActionResult(false, "");

            Dictionary <string, string> dicParams = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramString);
            bool   isMobile    = false;
            string LoginName   = string.Empty;
            string MobileToken = string.Empty;
            string WechatCode  = string.Empty;
            string EngineCode  = string.Empty;

            foreach (string key in dicParams.Keys)
            {
                if (key == Param_WorkItemID)
                {
                    WorkItemID = dicParams[key]; continue;
                }
                if (key == Param_Mode)
                {
                    SheetMode = (SheetMode)Enum.Parse(typeof(SheetMode), dicParams[key]); continue;
                }
                if (key == Param_IsMobile)
                {
                    bool.TryParse(dicParams[key], out isMobile);
                    IsMobile = isMobile;
                    continue;
                }
                if (key.ToLower() == "loginname")
                {
                    LoginName = dicParams[key];
                }
                if (key.ToLower() == "mobiletoken")
                {
                    MobileToken = dicParams[key];
                }
                if (key.ToLower() == "code")
                {
                    WechatCode = dicParams[key];
                }
                if (key.ToLower() == "state")
                {
                    EngineCode = dicParams[key];
                }
            }

            //APP打开表单验证
            if (!string.IsNullOrEmpty(LoginName) && !string.IsNullOrEmpty(MobileToken) && this.UserValidator == null)
            {
                if (!SSOopenSheet(LoginName, MobileToken))
                {
                    result = new ActionResult(false, "登录超时!", null, ExceptionCode.NoAuthorize);
                    return(Json(result, JsonRequestBehavior.AllowGet));
                }
            }
            else if (this.UserValidator == null)
            {
                result = new ActionResult(false, "登录超时!", null, ExceptionCode.NoAuthorize);
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            Instance.InstanceContext instanceContext = null;

            instanceContext = this.Engine.InstanceManager.GetInstanceContext(CurrentWorkItem.InstanceId);
            bool customAuthorized = SheetUtility.ValidateAuthorization(this.UserValidator,
                                                                       SheetDataType.Workflow,
                                                                       false,
                                                                       CurrentWorkItem.SheetCode,
                                                                       null,
                                                                       SheetMode.View,
                                                                       CurrentWorkItem.WorkflowCode,
                                                                       null,
                                                                       null,
                                                                       instanceContext);

            if (customAuthorized)
            {
                //验证关联关系流程权限
                MvcViewContext sheet = new MvcViewContext()
                {
                    Message = Configs.Global.ResourceManager.GetString("MvcController_Perission"),
                    Close   = true
                };
                result.Success = false;
                result.Message = sheet.Message;
                return(Json(result, JsonRequestBehavior.AllowGet));
            }

            // 解析Url地址
            if (SheetMode == SheetMode.Work)
            {
                if (CurrentWorkItem != null)
                {
                    url = this.GetWorkSheetUrl(
                        CurrentWorkItem,
                        WorkItemSheet,
                        IsMobile);
                }
                else
                {
                    url = this.GetViewCirculateItemSheetUrl(
                        CurrentCirculateItem,
                        WorkItemSheet,
                        SheetMode,
                        IsMobile);
                }
            }
            else
            {
                if (CurrentWorkItem != null)
                {
                    url = this.GetViewSheetUrl(
                        CurrentWorkItem,
                        WorkItemSheet,
                        SheetMode,
                        IsMobile);
                }
                else
                {
                    url = this.GetViewCirculateItemSheetUrl(
                        CurrentCirculateItem,
                        WorkItemSheet,
                        SheetMode,
                        IsMobile);
                }
            }
            // 将其中的数据参数做转换
            if (url.Contains(OThinker.H3.Math.Variant.VariablePrefix.ToString()))
            {
                url = InstanceData.ParseText(url);
            }
            // 处理缓存
            DateTime t = DateTime.Now;

            url += "&T=" + t.ToString("HHmmss") + WorkItemID.Substring(0, 8);
            if (SheetMode == SheetMode.Print)
            {
                url += "Print";
            }
            result.Success = true;
            result.Message = url;
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 打开流程表单
        /// </summary>
        /// <param name="paramString"></param>
        /// <returns></returns>
        public JsonResult InstanceSheets(string paramString)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(false, "");
                Dictionary <string, string> dicParams = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramString);
                bool isMobile = false;
                foreach (string key in dicParams.Keys)
                {
                    if (key == Param_InstanceId)
                    {
                        InstanceID = dicParams[key]; continue;
                    }
                    if (key == Param_IsMobile)
                    {
                        bool.TryParse(dicParams[key], out isMobile);
                        IsMobile = isMobile;
                        continue;
                    }
                }

                if (InstanceContext == null)
                {
                    result.Message = "InstanceSheets_InstanceNotExist";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                // 获取流程模板信息
                WorkflowTemplate.PublishedWorkflowTemplate workflow = this.Engine.WorkflowManager.GetPublishedTemplate(InstanceContext.WorkflowCode, InstanceContext.WorkflowVersion);
                if (workflow == null)
                {
                    result.Message = "InstanceSheets_WorkflowNotExist";
                    return Json(result, JsonRequestBehavior.AllowGet);
                }

                //WorkflowVersion,InstanceID,UserID
                DataTable dtWorkItem = this.GetItemTable(InstanceID);
                string activity, sheetCode;
                Dictionary <string, string> sheetWorkItemIds = new Dictionary <string, string>();
                //当前用户参与过流程时,则打开参与过的流程表单,否则打开系统流程表单
                if (dtWorkItem != null && dtWorkItem.Rows.Count > 0)
                {
                    foreach (DataRow row in dtWorkItem.Rows)
                    {
                        activity = row[WorkItem.WorkItem.PropertyName_ActivityCode] + string.Empty;
                        sheetCode = this.GetSheetCodeByActivity(((WorkflowTemplate.ClientActivity)workflow.GetActivityByCode(activity)));
                        if (!sheetWorkItemIds.ContainsKey(sheetCode))
                        {
                            sheetWorkItemIds.Add(sheetCode, row[WorkItem.WorkItem.PropertyName_ObjectID].ToString());
                        }
                    }
                }
                else
                { // 管理员,未参与过流程
                    foreach (WorkflowTemplate.Activity act in workflow.Activities)
                    {
                        if (act is WorkflowTemplate.ClientActivity)
                        {
                            sheetCode = this.GetSheetCodeByActivity(((WorkflowTemplate.ClientActivity)act));
                            if (!string.IsNullOrEmpty(sheetCode) && !sheetWorkItemIds.ContainsKey(sheetCode))
                            {
                                sheetWorkItemIds.Add(sheetCode, string.Empty);
                            }
                        }
                    }
                }
                if (sheetWorkItemIds.Count == 0)
                {
                    Instance.InstanceContext instanceContext = InstanceContext;
                    if (instanceContext != null)
                    {
                        // 未参与过流程,并且未设置默认表单,那么再获取默认表单
                        Sheet.BizSheet[] sheets = this.Engine.BizSheetManager.GetBizSheetBySchemaCode(instanceContext.BizObjectSchemaCode);
                        if (sheets != null && sheets.Length > 0)
                        {
                            foreach (Sheet.BizSheet sheet in sheets)
                            {
                                if (!string.IsNullOrEmpty(sheet.SheetCode) && !sheetWorkItemIds.ContainsKey(sheet.SheetCode))
                                {
                                    sheetWorkItemIds.Add(sheet.SheetCode, string.Empty);
                                }
                            }
                        }
                    }
                }
                WorkItem.WorkItem workItem = null;
                WorkItem.CirculateItem circulateItem = null;
                string url, workItemId;
                List <ListUrl> ListUrl = new List <ListUrl>();
                foreach (string key in sheetWorkItemIds.Keys)
                {
                    Sheet.BizSheet sheet = this.Engine.BizSheetManager.GetBizSheetByCode(key);
                    workItemId = sheetWorkItemIds[key];
                    if (workItemId == string.Empty)
                    {
                        url = this.GetViewSheetUrl(
                            sheet,
                            InstanceID,
                            SheetMode.View,
                            IsMobile);
                    }
                    else
                    {
                        workItem = this.Engine.WorkItemManager.GetWorkItem(workItemId);
                        if (workItem != null)
                        {
                            url = this.GetViewSheetUrl(
                                workItem,
                                sheet,
                                SheetMode.View,
                                this.IsMobile);
                        }
                        else
                        {
                            circulateItem = this.Engine.WorkItemManager.GetCirculateItem(workItemId);
                            if (circulateItem == null)
                            {
                                continue;
                            }
                            url = this.GetViewSheetUrl(
                                circulateItem,
                                sheet,
                                SheetMode.View,
                                this.IsMobile);
                        }
                    }
                    // 处理缓存
                    DateTime t = DateTime.Now;
                    url += "&T=" + t.ToString("HHmmss");
                    //只有一个表单直接跳转打开
                    if (sheetWorkItemIds.Count == 1)
                    {
                        result.Success = true;
                        result.Message = url;
                        result.Extend = "Redirect";
                        return Json(result, JsonRequestBehavior.AllowGet);
                    }
                    else //多个表单在界面上呈现连接选择打开
                    {
                        ListUrl.Add(new ListUrl
                        {
                            Title = "InstanceSheets_Sheet",
                            Text = string.Format("{0}[{1}]", sheet.DisplayName, key),
                            Url = url
                        });
                    }
                }
                result.Success = true;
                result.Message = "MultiSheets";
                result.Extend = ListUrl;
                return Json(result, JsonRequestBehavior.AllowGet);
            }));
        }