private static IEnumerable <IUser> AllElapsedOperators(object callerContext)
        {
            List <IUser> result = new List <IUser>();

            if (callerContext is WfConditionDescriptor)
            {
                WfConditionDescriptor condition = (WfConditionDescriptor)callerContext;

                if (condition.Owner != null)
                {
                    foreach (IWfActivity activity in condition.Owner.ProcessInstance.Activities)
                    {
                        if (activity.Status == WfActivityStatus.Completed)
                        {
                            if (OguUser.IsNotNullOrEmpty(activity.Operator))
                            {
                                if (result.NotExists(u => string.Compare(u.ID, activity.Operator.ID, true) == 0))
                                {
                                    result.Add(activity.Operator);
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private static WfProcessStartupParams PrepareStartWorkflowParams(IWfProcessDescriptor processDesp, WfSimulationContext simulationContext)
        {
            WfProcessStartupParams startupParams = new WfProcessStartupParams();

            startupParams.ProcessDescriptor = processDesp;
            startupParams.DefaultTaskTitle  = startupParams.ProcessDescriptor.DefaultTaskTitle;

            if (OguUser.IsNotNullOrEmpty(simulationContext.SimulationParameters.Creator))
            {
                startupParams.Creator = simulationContext.SimulationParameters.Creator;
            }
            else
            {
                if (DeluxePrincipal.IsAuthenticated)
                {
                    startupParams.Creator = DeluxeIdentity.CurrentUser;
                }
            }

            startupParams.Assignees.Add(startupParams.Creator);
            startupParams.ResourceID = UuidHelper.NewUuidString();

            MergeVariablesToApplicationRuntimeParameters(startupParams.ApplicationRuntimeParameters, simulationContext.SimulationParameters.Variables);

            return(startupParams);
        }
Exemplo n.º 3
0
        private IUser GetUser()
        {
            IUser user = new OguUser(Guid.NewGuid().ToString());


            return(user);
        }
Exemplo n.º 4
0
        private static WfActivityDescriptor PrepareServerActivity(string key)
        {
            WfActivityDescriptor actDesp = new WfActivityDescriptor(key, WfActivityType.InitialActivity);

            actDesp.Key  = key;
            actDesp.Name = key;

            actDesp.Condition.Expression = "Amount > 1000";
            actDesp.Variables.SetValue("ActKey", key);
            actDesp.Variables.SetValue("ActName", key);

            actDesp.Resources.Add(new WfUserResourceDescriptor((IUser)OguUser.CreateWrapperObject(ActivityConverterTest.UserID, SchemaType.Users)));
            actDesp.Resources.Add(new WfDepartmentResourceDescriptor((IOrganization)OguOrganization.CreateWrapperObject(ActivityConverterTest.OrganizationID, SchemaType.Organizations)));
            actDesp.Resources.Add(new WfGroupResourceDescriptor((IGroup)OguGroup.CreateWrapperObject(ActivityConverterTest.GroupID, SchemaType.Groups)));
            actDesp.Resources.Add(new WfRoleResourceDescriptor(new SOARole(ActivityConverterTest.RoleFullCodeName)));
            actDesp.Resources.Add(new WfActivityOperatorResourceDescriptor()
            {
                ActivityKey = ActivityConverterTest.ResActivityKey
            });
            actDesp.Resources.Add(new WfActivityAssigneesResourceDescriptor()
            {
                ActivityKey = ActivityConverterTest.ResActivityKey
            });
            actDesp.Resources.Add(new WfDynamicResourceDescriptor("ConditionResource", "Amount > 1000"));
            actDesp.BranchProcessTemplates.Add(BranchProcessTemplateConverterTest.PrepareServerBranchProcessTemplate());

            return(actDesp);
        }
Exemplo n.º 5
0
        protected override void OnPreRender(EventArgs e)
        {
            IUser testUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy")[0];

            testUser = (IUser)OguUser.CreateWrapperObject(testUser);

            this.ClientScript.RegisterHiddenField("userData", JSONSerializerExecute.Serialize(testUser));

            base.OnPreRender(e);
        }
Exemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            OguUser user = new OguUser("80f4464f-e912-40c9-9502-c369a0d935ee");

            OguDataCollection <IOguObject> list = new OguDataCollection <IOguObject>();

            list.Add(user);

            this.OuUserInputControl1.SelectedOuUserData = list;
            //}
        }
Exemplo n.º 7
0
 protected void moveToControl_ProcessChanged(IWfProcess process)
 {
     if (this.ViewData.Data.Amount >= 5000)
     {
         process.ApplicationRuntimeParameters["TempApprover"] =
             (IUser)OguUser.CreateWrapperObject(OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "quym").First());
     }
     else
     {
         process.ApplicationRuntimeParameters["TempApprover"] =
             (IUser)OguUser.CreateWrapperObject(OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy").First());
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// 是否是流程的查看者。本方法仅返回流程分类授权的信息,即使是流程环节中的人,也可能返回为False
        /// </summary>
        /// <param name="process"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        private static bool GetIsProcessViewer(IWfProcess process, string userID)
        {
            bool result = false;

            if (userID.IsNotEmpty())
            {
                OguUser user = new OguUser(userID);

                result = WfApplicationAuthAdapter.Instance.GetUserApplicationAuthInfo(user).Contains(
                    process.Descriptor.ApplicationName, process.Descriptor.ProgramName, WfApplicationAuthType.FormViewer);
            }

            return(result);
        }
Exemplo n.º 9
0
        private static void FillPersonTypeUsers(WfMatrixRowUsersCollection rowsUsers)
        {
            Dictionary <string, string> userIDs = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);

            foreach (WfMatrixRowUsers rowUsers in rowsUsers)
            {
                if (rowUsers.Row.OperatorType == WfMatrixOperatorType.Person)
                {
                    foreach (string id in rowUsers.ObjectIDs)
                    {
                        userIDs[id] = id;
                    }
                }
            }

            List <string> logonNames = new List <string>();

            foreach (KeyValuePair <string, string> kp in userIDs)
            {
                logonNames.Add(kp.Key);
            }

            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, logonNames.ToArray());

            if (WfRuntime.ProcessContext.CurrentProcess != null)
            {
                users = users.FilterUniqueSidelineUsers(WfRuntime.ProcessContext.CurrentProcess.OwnerDepartment);
            }

            Dictionary <string, IUser> userDicts = GenerateUserDictionary(users);

            foreach (WfMatrixRowUsers rowUsers in rowsUsers)
            {
                if (rowUsers.Row.OperatorType == WfMatrixOperatorType.Person)
                {
                    foreach (string id in rowUsers.ObjectIDs)
                    {
                        IUser user = null;
                        if (userDicts.TryGetValue(id, out user))
                        {
                            if (rowUsers.Users.Exists(u => string.Compare(u.ID, user.ID, true) == 0) == false)
                            {
                                rowUsers.Users.Add((IUser)OguUser.CreateWrapperObject(user));
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// 序列化OguOrganization
        /// </summary>
        /// <param name="obj">material对象</param>
        /// <param name="serializer">序列化器</param>
        /// <returns>属性集合</returns>
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            OguUser oguUser = (OguUser)obj;

            if (string.IsNullOrEmpty(oguUser.ID) == false)
            {
                dictionary.Add("id", oguUser.ID);
                dictionary.Add("logOnName", oguUser.LogOnName);
                dictionary.Add("displayName", oguUser.DisplayName);
            }

            return(dictionary);
        }
        private static WfAssignee DataRowToAssignee(DataRow row)
        {
            WfAssignee result = new WfAssignee();

            result.AssigneeType = (WfAssigneeType)Enum.Parse(typeof(WfAssigneeType), row["ASSIGNEE_TYPE"].ToString(), true);

            OguUser user = new OguUser();

            user.ID       = row["USER_ID"].ToString();
            user.Name     = row["USER_NAME"].ToString();
            user.FullPath = row["USER_PATH"].ToString();

            result.User = user;

            return(result);
        }
        protected internal override void FillUsers(OguDataCollection <IUser> users)
        {
            IWfActivity target = TargetActivity;

            if (target != null)
            {
                //如果该环节存在操作人,则使用操作人。否则使用候选人
                if (OguUser.IsNotNullOrEmpty(target.Operator))
                {
                    users.Add(target.Operator);
                }
                else
                {
                    target.Candidates.ForEach(a => users.Add(a.User));
                }
            }
        }
Exemplo n.º 13
0
        public void EnsureInUserList()
        {
            if (string.IsNullOrEmpty(UserID) == false)
            {
                if (UserList.Exists(u => string.Compare(u.ID, this.UserID, true) == 0) == false)
                {
                    OguUser user = (OguUser)OguUser.CreateWrapperObject(UserID, SchemaType.Users);

                    if (string.IsNullOrEmpty(UserDisplayName) == false)
                    {
                        user.Name        = UserDisplayName;
                        user.DisplayName = UserDisplayName;
                    }

                    UserList.Add(user);
                }
            }
        }
Exemplo n.º 14
0
        private static bool GetIsProcessAdmin(IWfProcess process, string userID)
        {
            bool result = false;

            if (userID.IsNotEmpty())
            {
                OguUser user = new OguUser(userID);

                result = RolesDefineConfig.GetConfig().IsCurrentUserInRoles(user, "ProcessAdmin");

                if (result == false)
                {
                    result = WfApplicationAuthAdapter.Instance.GetUserApplicationAuthInfo(user).Contains(
                        process.Descriptor.ApplicationName, process.Descriptor.ProgramName, WfApplicationAuthType.FormAdmin);
                }
            }

            return(result);
        }
        private void groupControl_LoadingObjectToTreeNode(UserOUGraphControl treeControl, IOguObject oguObj, DeluxeTreeNode newTreeNode, ref bool cancel)
        {
            if ((oguObj is IUser) == false)
            {
                newTreeNode.ChildNodesLoadingType = ChildNodesLoadingTypeDefine.LazyLoading;

                if (oguObj is IGroup)
                {
                    IGroup group = (IGroup)oguObj;

                    int count = GroupMemberSelectedCount(group, treeControl.SelectedOuUserData);

                    if (count > 0 && group.Members.Count == count)
                    {
                        newTreeNode.Checked = true;
                        treeControl.SelectedOuUserData.Add(group);
                    }
                }
            }
            else
            {
                OguUser user = (OguUser)oguObj;

                StringBuilder strB = new StringBuilder();

                foreach (IGroup group in user.MemberOf)
                {
                    if (strB.Length > 0)
                    {
                        strB.Append(",");
                    }

                    strB.Append(group.ID);
                }

                user.Tag = strB.ToString();
            }

            newTreeNode.ShowCheckBox = true;
        }
Exemplo n.º 16
0
        /// <summary>
        ///反序列化OguUser
        /// </summary>
        /// <param name="dictionary">对象类型</param>
        /// <param name="type">对象类型</param>
        /// <param name="serializer">JS序列化器</param>
        /// <returns>反序列化出的对象</returns>
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            object  id, logOnName, displayName;
            OguUser oguUser = null;

            if (dictionary.TryGetValue("id", out id))
            {
                oguUser = new OguUser((string)dictionary["id"]);

                if (dictionary.TryGetValue("logOnName", out logOnName))
                {
                    oguUser.LogOnName = (string)logOnName;
                }

                if (dictionary.TryGetValue("displayName", out displayName))
                {
                    oguUser.DisplayName = (string)displayName;
                }
            }

            return(oguUser);
        }
Exemplo n.º 17
0
        private CommandStateBase Controller_PrepareCommandState(IWfProcess process)
        {
            TemplateCommandState state = null;

            //从流程上下文中获取数据。在这里通过流程上下文保存表单数据,省去了单独建表存储的工作
            string appData = (string)process.RootProcess.Context["appData"];

            if (appData.IsNullOrEmpty())
            {
                TemplateData data = new TemplateData();
                data.ID = process.ResourceID;

                data.CostCenter         = "1001";
                data.AdministrativeUnit = "Group";

                state = new TemplateCommandState()
                {
                    Data = data
                };

                process.ApplicationRuntimeParameters["approval1"]          = OguUser.CreateWrapperObject(OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy").FirstOrDefault());
                process.ApplicationRuntimeParameters["Amount"]             = data.Amount;
                process.ApplicationRuntimeParameters["CostCenter"]         = data.CostCenter;
                process.ApplicationRuntimeParameters["AdministrativeUnit"] = data.AdministrativeUnit;
                process.ApplicationRuntimeParameters["TempApprover"]       =
                    (IUser)OguUser.CreateWrapperObject(OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy").First());

                process.GenerateCandidatesFromResources();
            }
            else
            {
                state             = (TemplateCommandState)SerializationHelper.DeserializeStringToObject(appData, SerializationFormatterType.Binary);
                state.Data.Loaded = true;
            }

            return(state);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 用户是否在Acl中
        /// </summary>
        /// <param name="process"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static bool IsUserInAcl(this IWfProcess process, IUser user)
        {
            bool result = false;

            if (OguUser.IsNotNullOrEmpty(user))
            {
                InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("RESOURCE_ID");

                inBuilder.AppendItem(process.ResourceID, process.ID);

                WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder();

                whereBuilder.AppendItem("OBJECT_TYPE", "Users");
                whereBuilder.AppendItem("OBJECT_ID", user.ID);

                ConnectiveSqlClauseCollection connective = new ConnectiveSqlClauseCollection(inBuilder, whereBuilder);

                WfAclItemCollection aclItems = WfAclAdapter.Instance.LoadByBuilder(connective);

                result = aclItems.Count > 0;
            }

            return(result);
        }
Exemplo n.º 19
0
        private object ProcessContext_EvaluateDynamicResourceCondition(string funcName, ParamObjectCollection arrParams, object callerContext)
        {
            object result = null;

            switch (funcName)
            {
            case "Requestor":
                List <IUser> users = new List <IUser>();

                users.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);
                users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);

                result = users;
                break;

            case "EmptyUser":
                OguUser user = new OguUser("FakeID");
                user.ID = string.Empty;
                result  = user;
                break;
            }

            return(result);
        }
        private static WfAssignee DataRowToAssignee(DataRow row)
        {
            WfAssignee result = new WfAssignee();

            result.AssigneeType = (WfAssigneeType)Enum.Parse(typeof(WfAssigneeType), row["ASSIGNEE_TYPE"].ToString(), true);

            OguUser user = new OguUser();
            user.ID = row["USER_ID"].ToString();
            user.Name = row["USER_NAME"].ToString();
            user.FullPath = row["USER_PATH"].ToString();

            result.User = user;

            return result;
        }
Exemplo n.º 21
0
 public WfUserResourceDescriptor(IUser user)
 {
     this._User = (IUser)OguUser.CreateWrapperObject(user);
 }
Exemplo n.º 22
0
        /// <summary>
        /// 得到被委托的人员
        /// </summary>
        /// <param name="sourceAssignees"></param>
        /// <returns></returns>
        private static WfAssigneeCollection GetDelegatedAssignees(WfAssigneeCollection sourceAssignees, IWfProcess process)
        {
            WfAssigneeCollection result = new WfAssigneeCollection();

            foreach (WfAssignee sourceAssignee in sourceAssignees)
            {
                WfDelegationCollection delegations = WfDelegationSettings.GetConfig().Reader.GetUserActiveDelegations(sourceAssignee.User, process);

                foreach (WfDelegation delegation in delegations)
                {
                    OguUser user = new OguUser(delegation.DestinationUserID);

                    user.DisplayName = delegation.DestinationUserName;
                    user.Name = delegation.DestinationUserName;

                    OguUser delegator = new OguUser(delegation.SourceUserID);
                    delegator.DisplayName = delegation.SourceUserName;
                    delegator.Name = delegation.SourceUserName;

                    WfAssignee assignee = new WfAssignee(user);

                    assignee.AssigneeType = WfAssigneeType.Delegated;
                    assignee.Delegator = delegator;

                    result.Add(assignee);
                }
            }

            return result;
        }
Exemplo n.º 23
0
        private void InnerStartWorkflow(string processDescKey, string appName, string programName,
                                        string relativeID, string relativeURL, bool isCloned, NameValueCollection relativeParams)
        {
            StartWorkflowControllerOperation operation = new StartWorkflowControllerOperation();

            operation.StartupParams.ProcessDescriptor = WfProcessDescriptorManager.GetDescriptor(processDescKey);

            if (operation.StartupParams.ProcessDescriptor.DefaultTaskTitle.IsNullOrEmpty())
            {
                operation.StartupParams.DefaultTaskTitle = operation.StartupParams.ProcessDescriptor.Name;
            }
            else
            {
                operation.StartupParams.DefaultTaskTitle = operation.StartupParams.ProcessDescriptor.DefaultTaskTitle;
            }

            operation.StartupParams.ResourceID = UuidHelper.NewUuidString();
            operation.StartupParams.ApplicationRuntimeParameters["ProcessRequestor"] = OguUser.CreateWrapperObject(DeluxeIdentity.CurrentUser);
            operation.ApplicationName           = appName;
            operation.ProgramName               = programName;
            operation.StartupParams.RelativeID  = relativeID;
            operation.StartupParams.RelativeURL = relativeURL;
            operation.StartupParams.Department  = DeluxeIdentity.CurrentUser.TopOU;
            operation.StartupParams.Assignees.Add(DeluxeIdentity.CurrentUser);
            operation.IsCloned = isCloned;

            operation.StartupParams.RelativeParams.CopyFrom(relativeParams);

            operation.NavigationCommand = CollectNavigationCommand(this.GetType());
            operation.SceneInfo         = CollectSceneInfo(this.GetType());

            OnInitOperation(operation);

            PerformanceMonitorHelper.GetDefaultMonitor().WriteExecutionDuration("DoStartWorkflowControllerOperation",
                                                                                () => operation.DoOperation());
        }
        private object ProcessContext_EvaluateDynamicResourceCondition(string funcName, ParamObjectCollection arrParams, object callerContext)
        {
            object result = null;

            switch (funcName)
            {
                case "Requestor":
                    List<IUser> users = new List<IUser>();

                    users.Add((IUser)OguObjectSettings.GetConfig().Objects["requestor"].Object);
                    users.Add((IUser)OguObjectSettings.GetConfig().Objects["approver1"].Object);

                    result = users;
                    break;
                case "EmptyUser":
                    OguUser user = new OguUser("FakeID");
                    user.ID = string.Empty;
                    result = user;
                    break;
            }

            return result;
        }
Exemplo n.º 25
0
 public WfAssignee(IUser user)
 {
     this._User = (IUser)OguUser.CreateWrapperObject(user);
 }