예제 #1
0
 protected void DefaultProcessRequest(string delegateUserID)
 {
     if (string.IsNullOrEmpty(delegateUserID))
     {
         DefaultProcessRequest();
     }
     else
     {
         WfDelegationCollection delegation   = WfDelegationAdapter.Instance.Load(builder => builder.AppendItem("DESTINATION_USER_ID", delegateUserID));
         WfDelegation           wfDelegation = new WfDelegation();
         foreach (WfDelegation delegation1 in delegation)
         {
             wfDelegation.DestinationUserID   = delegation1.DestinationUserID;
             wfDelegation.DestinationUserName = delegation1.DestinationUserName;
             wfDelegation.StartTime           = delegation1.StartTime;
             wfDelegation.EndTime             = delegation1.EndTime;
             wfDelegation.SourceUserID        = delegation1.SourceUserID;
             wfDelegation.SourceUserName      = delegation1.SourceUserName;
         }
         if (delegation.Count > 0)
         {
             Data = wfDelegation;
             IOguObject oguObject =
                 OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.Guid, Data.DestinationUserID)[
                     0];
             DelegatedUserInput.SelectedOuUserData.Add(oguObject);
         }
     }
 }
예제 #2
0
        private void buttonConvert_Click(object sender, EventArgs e)
        {
            using (AD2DBInitialParams initParams = AD2DBInitialParams.GetParams())
            {
                textBoxLog.Text = string.Empty;

                ServiceLog log = new ServiceLog("ADToAccredit");

                log.AddTextBoxTraceListener(textBoxLog);

                initParams.Log = log;

                this._ProcessedObjectsCount = 0;

                OutputStatus();

                initParams.BeforeProcessADObject += new BeforeProcessADObjectDelegate(initParams_BeforeProcessADObject);

                AD2DBConvertion converter = new AD2DBConvertion(initParams);

                converter.DoConvert();

                OutputStatus();

                OguMechanismFactory.GetMechanism().RemoveAllCache();
                PermissionMechanismFactory.GetMechanism().RemoveAllCache();
            }
        }
예제 #3
0
        protected void DefaultProcessRequest(string fpath)
        {
            OguObjectCollection <IUser> user =
                OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.FullPath, fpath);

            foreach (IUser userObj in user)
            {
                UserInfoExtendCollection collection = UserInfoExtendDataObjectAdapter.Instance.Load(builder => builder.AppendItem("ID", userObj.ID));
                if (collection.Count > 0)
                {
                    Data = collection[0];
                }
                if (collection.Count == 0)
                {
                    Data = new UserInfoExtendDataObject()
                    {
                        ID = userObj.ID
                    }
                }
                ;
                Data.DisplayName = userObj.DisplayName;
                Data.FullPath    = userObj.FullPath;
                Data.LogonName   = userObj.LogOnName;
            }
        }
예제 #4
0
        private void GetApplicationRole()
        {
            List <AppRoles> allRoles = new List <AppRoles>();

            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, Data.ID);

            ExceptionHelper.FalseThrow(users.Count > 0, "不能找到ID为\"{0}\"的用户", Data.ID);

            ApplicationCollection result = PermissionMechanismFactory.GetMechanism().GetAllApplications();

            foreach (IApplication app in result)
            {
                RoleCollection roles = users[0].Roles[app.CodeName];
                if (roles.Count > 0)
                {
                    AppRoles ar = new AppRoles();

                    ar.AppName = app.Name;
                    ar.Roles   = GetRoleNames(roles);

                    allRoles.Add(ar);
                }
            }

            gridAppRoles.DataSource = allRoles;
            gridAppRoles.DataBind();
        }
        /// <summary>
        /// 准备权限中心的开始组织
        /// </summary>
        /// <param stringValue="startPath"></param>
        /// <returns></returns>
        private IOrganization PrepareStartOrganization(string startPath, string taskID)
        {
            IOrganization startOrg = null;

            SynchronizeContext.Current.WriteExceptionDBLogIfError("初始化", () =>
            {
                SynchronizeContext.Current.SynchronizeResult = ADSynchronizeResult.Running;
                SynchronizeContext.Current.SynchronizeID     = taskID;

                LogHelper.WriteEventLog("同步开始", "同步开始", LogPriority.Lowest, TraceEventType.Start);
                LogHelper.WriteSynchronizeDBLog("PermissionCenterServices", "PermissionCenterServices");

                SynchronizeContext.Current.ExtendLockTime();

                InitContext(startPath);

                SynchronizeContext.Current.ExtendLockTime();
                EnsureRecycleBin();               // 检查并创建回收站

                EnsureADTarget();                 // 确保AD中有对应节点

                SynchronizeContext.Current.ExtendLockTime();
                startOrg = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, SynchronizeContext.Current.StartPath).FirstOrDefault();

                EnsureRootOU(startOrg);                 //确保开始路径对应的机构的父节点都存在,如果不存在,则首先添加到变更列表里。
            });

            return(startOrg);
        }
예제 #6
0
        private static IOrganization GetOrganization(UserGraphTreeParams requestParams)
        {
            IOrganization org = null;

            if (requestParams.ID.IsNotEmpty())
            {
                org = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.Guid, requestParams.ID).SingleOrDefault();

                (org != null).FalseThrow("不能找到ID为\"{0}\"的组织", requestParams.ID);
            }
            else
            {
                if (requestParams.FullPath.IsNotEmpty())
                {
                    org = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, requestParams.FullPath).SingleOrDefault();

                    (org != null).FalseThrow("不能找到路径为\"{0}\"的组织", requestParams.FullPath);
                }
                else
                {
                    org = OguMechanismFactory.GetMechanism().GetRoot();
                }
            }

            return(org);
        }
        private void signInControl_AfterSignIn(SignInContext context)
        {
            if (context.ResultType == SignInResultType.Success)
            {
                if (PassportSignInSettings.GetConfig().UseSimulateTime)
                {
                    context.SignInInfo.Properties["SimulateTime"] = this.simulateDate.Value;

                    IPersistTimePoint persister = TimePointSimulationSettings.GetConfig().Persister;

                    if (persister != null)
                    {
                        OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, context.SignInInfo.UserID);

                        if (users.Count > 0)
                        {
                            persister.SaveTimePoint(users[0].ID, this.simulateDate.Value);

                            TimePointContext tpc = new TimePointContext();

                            tpc.UseCurrentTime = this.simulateDate.Value == DateTime.MinValue;
                            tpc.SimulatedTime  = this.simulateDate.Value;

                            tpc.SaveToCookie();
                        }
                    }
                }
            }
        }
예제 #8
0
        public int DisplaceUserInProcessMatrix(string processDespKey, string userID, string[] displacingUserIDArray)
        {
            WfMatrix matrix = WfMatrixAdapter.Instance.LoadByProcessKey(processDespKey, true);

            IUser originalUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID).FirstOrDefault();
            OguObjectCollection <IUser> displacingUsers = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, displacingUserIDArray);

            string originalUserCodeName = originalUser != null ? originalUser.LogOnName : string.Empty;

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

            foreach (IUser user in displacingUsers)
            {
                if (desplacingUserCodeNames.Contains(user.LogOnName) == false)
                {
                    desplacingUserCodeNames.Add(user.LogOnName);
                }
            }

            int result = matrix.Rows.ReplcaeOperators(WfMatrixOperatorType.Person, originalUserCodeName, desplacingUserCodeNames.ToArray());

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                WfMatrixAdapter.Instance.Update(matrix);

                scope.Complete();
            }

            return(result);
        }
예제 #9
0
        private void InnerRefreshMembers(string auCodeName)
        {
            lock (this._RoleMembersSyncObject)
            {
                if (this._RoleMembers != null)
                {
                    if (this._RoleMembers.AUCodeName != auCodeName)
                    {
                        this._RoleMembers = null;
                    }
                }

                if (this._RoleMembers == null)
                {
                    ClientAURole role = GetAURoleObject(auCodeName);

                    if (role != null)
                    {
                        ClientSchemaMember[] members = AUCenterQueryService.Instance.GetMemberships(role.ID, UserSchemaType, true);

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

                        members.ForEach(m => userIDs.Add(m.ID));

                        IEnumerable <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userIDs.ToArray());

                        this._RoleMembers = new WrappedAURoleMembers(auCodeName, users);
                    }
                    else
                    {
                        this._RoleMembers = new WrappedAURoleMembers(auCodeName, new IUser[0]);
                    }
                }
            }
        }
예제 #10
0
        public int DisplaceUserInRoleMatrix(string roleID, string userID, string[] displacingUserIDArray)
        {
            IUser originalUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID).FirstOrDefault();
            OguObjectCollection <IUser> displacingUsers = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, displacingUserIDArray);

            string originalUserCodeName = originalUser != null ? originalUser.LogOnName : string.Empty;

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

            foreach (IUser user in displacingUsers)
            {
                if (desplacingUserCodeNames.Contains(user.LogOnName) == false)
                {
                    desplacingUserCodeNames.Add(user.LogOnName);
                }
            }

            SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.LoadByRoleID(roleID, null);

            int result = rows.ReplaceOperators(SOARoleOperatorType.User, originalUserCodeName, desplacingUserCodeNames.ToArray());

            SOARolePropertiesAdapter.Instance.Update(roleID, rows);

            return(result);
        }
 protected void DefaultProcessRequest()
 {
     Data = new WfDelegation();
     Data.SourceUserID   = DeluxeIdentity.CurrentUser.ID;
     Data.SourceUserName = DeluxeIdentity.CurrentUser.Name;
     DelegateSrc.SelectedOuUserData.Add(OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.Guid, Data.SourceUserID)[0]);
 }
예제 #12
0
        public static IUser QueryUser(string logonName)
        {
            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, logonName);

            ExceptionHelper.FalseThrow(users.Count != 0, "不能根据登录名'{0}'找到用户", logonName);

            return(users[0]);
        }
예제 #13
0
        private static IUser GetUserInfoFromID(string userID)
        {
            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID);

            ExceptionHelper.FalseThrow <AuthenticateException>(users.Count > 0, Resource.CanNotFindUser, userID);

            return(users[0]);
        }
예제 #14
0
        public static OguObjectCollection <IOguObject> QueryObjectByFullPath(string fullPath)
        {
            OguObjectCollection <IOguObject> objs = OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.FullPath, fullPath);

            ExceptionHelper.FalseThrow(objs.Count != 0, "不能根据FullPath'{0}'找到对象", fullPath);

            return(objs);
        }
예제 #15
0
        public static OguObjectCollection <IOguObject> QueryObjectByID(string objectID)
        {
            OguObjectCollection <IOguObject> objs = OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.Guid, objectID);

            ExceptionHelper.FalseThrow(objs.Count != 0, "不能根据ID'{0}'找到对象", objectID);

            return(objs);
        }
예제 #16
0
 protected void DefaultProcess(string id)
 {
     if (string.IsNullOrEmpty(id) == true)
     {
         id = OguMechanismFactory.GetMechanism().GetRoot().ID;
     }
     QueryCondition.DepartmentId = id;
     ExecQuery();
 }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string oguID = WebUtility.GetRequestQueryString("id", string.Empty);

            if (oguID.IsNotEmpty())
            {
                IOrganization org = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.Guid, oguID)[0];
                oguInfo.Text = HttpUtility.HtmlEncode(string.Format("部门ID为{0},名称为{1}", org.ID, org.DisplayName));
            }
        }
예제 #18
0
 protected void SetGroupRequest(string extUserId, string mappingUserId)
 {
     if (!string.IsNullOrEmpty(mappingUserId))
     {
         IOguObject oguObject =
             OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.Guid, mappingUserId)[
                 0];
         DelegatedUserInput.SelectedSingleData = oguObject;
     }
 }
예제 #19
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);
        }
예제 #20
0
        public int DisplaceUserInProcess(string processID, string userID, string[] displacingUserIDArray)
        {
            IUser originalUser = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, userID).FirstOrDefault();

            OguObjectCollection <IUser> displacingUsers = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, displacingUserIDArray);

            List <IUser> distinctUsers = new List <IUser>();

            foreach (IUser user in displacingUsers)
            {
                if (distinctUsers.Exists(u => u.ID == user.ID) == false)
                {
                    distinctUsers.Add(user);
                }
            }

            IWfProcess process = WfRuntime.GetProcessByProcessID(processID);

            int result = 0;

            foreach (IWfActivity activity in process.Activities)
            {
                bool needReplace = false;

                if (activity.Status != WfActivityStatus.Completed && activity.Status != WfActivityStatus.Aborted)
                {
                    if (activity.Status == WfActivityStatus.Running || activity.Status == WfActivityStatus.Pending)
                    {
                        needReplace = activity.Assignees.Contains(originalUser.ID);
                    }
                    else
                    {
                        needReplace = activity.Candidates.Contains(originalUser.ID);
                    }

                    if (needReplace)
                    {
                        WfReplaceAssigneesExecutor executor = new WfReplaceAssigneesExecutor(null, activity, originalUser, distinctUsers);

                        executor.ExecuteNotPersist();
                        result++;
                    }
                }
            }

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                WfReplaceAssigneesExecutor.DoUserTaskOperations();
                WfRuntime.PersistWorkflows();

                scope.Complete();
            }

            return(result);
        }
예제 #21
0
        public IOrganization GetOrganizationByPath(string rootPath)
        {
            OguObjectCollection <IOrganization> orgs = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, rootPath);

            if (orgs.Count == 0)
            {
                throw new ArgumentException(string.Format("不能找到路径为\"{0}\"的根组织", rootPath));
            }

            return(orgs[0]);
        }
예제 #22
0
        public Dictionary <string, IEnumerable <IOrganization> > QueryObjectsParents(params string[] ids)
        {
            Dictionary <string, IEnumerable <IOrganization> > result = new Dictionary <string, IEnumerable <IOrganization> >();

            OguObjectCollection <IOguObject> objs = OguMechanismFactory.GetMechanism().GetObjects <IOguObject>(SearchOUIDType.Guid, ids);

            foreach (IOguObject obj in objs)
            {
                result[obj.ID] = GetAllParents(obj);
            }

            return(result);
        }
예제 #23
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());
     }
 }
예제 #24
0
        private OguDataCollection <IOguObject> InnerCheckInputOuUser(string chkString)
        {
            //ServiceBrokerContext.Current.Timeout = QueryUserTimeout;

            IOrganization dept = OguMechanismFactory.GetMechanism().GetObjects <IOrganization>(SearchOUIDType.FullPath, OguPermissionSettings.GetConfig().RootOUPath)[0];

            OguDataCollection <IOguObject> users       = QueryChildrenBySelectMask(dept, chkString);
            OguDataCollection <IOguObject> forSelected = new OguDataCollection <IOguObject>();

            for (int i = 0; i < users.Count; i++)
            {
                forSelected.Add(OguBase.CreateWrapperObject(users[i]));
            }

            if (dept.DisplayName.IndexOf(chkString) == 0)
            {
                forSelected.Add(OguBase.CreateWrapperObject(dept));
            }

            IOrganization root = OguMechanismFactory.GetMechanism().GetRoot();

            foreach (OguBase obj in forSelected)
            {
                string path = string.Empty;
                if (obj.Parent != null)
                {
                    path = obj.Parent.FullPath;
                }

                if (path.IndexOf(root.FullPath) == 0)
                {
                    path = path.Substring(root.FullPath.Length);
                    path = path.Trim('\\');
                }

                if (obj is IUser)
                {
                    ((OguUser)obj).Description = string.Format("{0} {1}", ((OguUser)obj).Occupation, path);
                }
                else if (obj is OguOrganization)
                {
                    ((OguOrganization)obj).Description = path;
                }
                else
                {
                    ((OguUser)obj).Description = path;
                }
            }

            return(forSelected);
        }
예제 #25
0
        private bool AuthenticateUser(LogOnIdentity loi)
        {
            bool result = false;

            try
            {
                result = OguMechanismFactory.GetMechanism().AuthenticateUser(loi);
            }
            catch (System.Exception)
            {
            }

            return(result);
        }
예제 #26
0
        public override void OnThreadTaskStart()
        {
            using (AD2DBInitialParams initParams = AD2DBInitialParams.GetParams())
            {
                initParams.Log = this.Params.Log;

                AD2DBConvertion converter = new AD2DBConvertion(initParams);

                converter.DoConvert();

                OguMechanismFactory.GetMechanism().RemoveAllCache();
                PermissionMechanismFactory.GetMechanism().RemoveAllCache();
            }
        }
예제 #27
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));
                            }
                        }
                    }
                }
            }
        }
예제 #28
0
        /// <summary>
        /// 根据童虎的不变ID,得到用户的登录名
        /// </summary>
        /// <param name="consistentID"></param>
        /// <returns></returns>
        public string GetUserLogonName(string consistentID)
        {
            consistentID.CheckStringIsNullOrEmpty("consistentID");

            OguObjectCollection <IUser> users = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, consistentID);

            string result = string.Empty;

            if (users.Count > 0)
            {
                result = users[0].LogOnName;
            }

            return(result);
        }
예제 #29
0
        private bool AuthenticateUser(LogOnIdentity loi)
        {
            return(OguMechanismFactory.GetMechanism().AuthenticateUser(loi));
            //bool result = false;

            //try
            //{
            //    result = OguMechanismFactory.GetMechanism().AuthenticateUser(loi);
            //}
            //catch (System.Exception ex)
            //{
            //    ExceptionHelper.DoSilentAction(() => EventLog.WriteEntry("PassportService", ex.ToString()));
            //}

            //return result;
        }
예제 #30
0
        /// <summary>
        /// 转化为附件对象
        /// </summary>
        /// <returns>附件对象</returns>
        public Material ConvertToMaterial()
        {
            ExceptionHelper.TrueThrow <ArgumentNullException>(this == null, "MaterialModifyObject");

            Material m = new Material();

            m.ID = this.id;
            m.RelativeFilePath = this.relativeFilePath;
            m.OriginalName     = this.originalName;
            m.Title            = this.title;
            m.SortID           = this.sortID;
            m.WfActivityID     = this.wfActivityID;
            m.WfProcessID      = this.wfProcessID;
            m.Creator          = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.FullPath, this.creatorFullPath)[0];

            return(m);
        }