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();
                        }
                    }
                }
            }
        }
 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]);
 }
Exemplo n.º 3
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]);
                    }
                }
            }
        }
Exemplo n.º 4
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);
        }
        /// <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);
        }
Exemplo n.º 6
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;
            }
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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]);
        }
Exemplo n.º 11
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]);
        }
Exemplo n.º 12
0
 protected void DefaultProcess(string id)
 {
     if (string.IsNullOrEmpty(id) == true)
     {
         id = OguMechanismFactory.GetMechanism().GetRoot().ID;
     }
     QueryCondition.DepartmentId = id;
     ExecQuery();
 }
Exemplo n.º 13
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.º 14
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;
     }
 }
Exemplo n.º 15
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));
            }
        }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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]);
        }
Exemplo n.º 18
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.º 19
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);
        }
Exemplo n.º 20
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);
        }
Exemplo n.º 21
0
        private bool AuthenticateUser(LogOnIdentity loi)
        {
            bool result = false;

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

            return(result);
        }
Exemplo n.º 22
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();
            }
        }
Exemplo n.º 23
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.º 24
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);
        }
Exemplo n.º 25
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;
        }
Exemplo n.º 26
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);
        }
        private static Dictionary <string, object> PrepareBasicDictionary()
        {
            Dictionary <string, object> result = new Dictionary <string, object>();

            result.Add("Name", "Shen Zheng");
            result.Add("Age", (DateTime.Now.Year - 1972));
            result.Add("Salary", (Decimal)10000.00);
            result.Add("Birthday", new DateTime(1972, 4, 26));
            result.Add("IsMale", true);

            IUser user = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "wanhw").FirstOrDefault();

            result.Add("Owner", user);
            result.Add("OwnerDepartment", user.Parent);

            IGroup group = OguMechanismFactory.GetMechanism().GetObjects <IGroup>(SearchOUIDType.FullPath, "机构人员\\远洋地产\\全体党员").FirstOrDefault();

            result.Add("Group", group);

            OguDataCollection <IUser> multiUsers = new OguDataCollection <IUser>();

            multiUsers.Add(user);

            result.Add("MultiUsers", multiUsers);

            OguDataCollection <IOrganization> multiOrgs = new OguDataCollection <IOrganization>();

            multiOrgs.Add(user.Parent);

            result.Add("MultiOrgs", multiOrgs);

            OguDataCollection <IGroup> multiGroups = new OguDataCollection <IGroup>();

            multiGroups.Add(group);

            result.Add("MultiGroups", multiGroups);

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

            multiObjs.Add(user);
            multiObjs.Add(user.Parent);

            result.Add("MultiObjs", multiObjs);

            return(result);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 根据登录名得到用户不变的ID
        /// </summary>
        /// <param name="logonName"></param>
        /// <returns></returns>
        public string GetUserConsistentID(string logonName)
        {
            logonName.CheckStringIsNullOrEmpty("logonName");

            LogOnIdentity loi = new LogOnIdentity(logonName, string.Empty);

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

            string result = string.Empty;

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

            return(result);
        }
Exemplo n.º 29
0
        public void OperatorBelongToRoleMatrixTest()
        {
            IRole role = GetTestRole();

            SOARole soaRole = SOARoleHelper.PrepareSOARole(role);

            IUser user = OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.LogOnName, "fanhy").First();

            List <string> roleIDs = SOARolePropertiesAdapter.Instance.OperatorBelongToRoleIDsDirectly(user.ID);

            foreach (string roleID in roleIDs)
            {
                SOARolePropertyRowCollection rows = SOARolePropertiesAdapter.Instance.GetByRoleID(roleID);

                Output(rows);
            }
        }
        /// <summary>
        /// 得到某一级组织下人员(带兼职)的详细信息。
        /// 权限中心的Organization的Children属性,仅仅返回子对象的基本属性,这个方法是通过再查询一次权限中心,继而得到完整的属性
        /// </summary>
        /// <param stringValue="allOguChildren"></param>
        /// <returns></returns>
        private static IList <IUser> GetUserDetailInfo(OguObjectCollection <IOguObject> allOguChildren)
        {
            List <string> childrenIDs = new List <string>();

            foreach (IOguObject child in allOguChildren)
            {
                if (child is IUser)
                {
                    if (SynchronizeContext.Current.IsRealObject(child))
                    {
                        childrenIDs.Add(child.ID);
                    }
                }
            }

            return(OguMechanismFactory.GetMechanism().GetObjects <IUser>(SearchOUIDType.Guid, childrenIDs.ToArray()).ToList());
        }