Ejemplo n.º 1
0
 private UserProxy CreateUserProxy(User user)
 {
     using (SecurityFreeSection.Activate())
     {
         return(UserProxy.Create(user));
     }
 }
Ejemplo n.º 2
0
        public static async Task <nAssembla.Cache.SpaceDataCache> GetSpaceDataCache(string spaceId)
        {
            var dataCache   = new nAssembla.Cache.SpaceDataCache();
            var space       = SpaceProxy.GetAsync(spaceId, true);
            var components  = TicketComponentProxy.GetListAsync(true);
            var fields      = CustomFieldProxy.GetListAsync(true);
            var custReports = CustomReportProxy.GetListAsync(true);
            var statuses    = CustomStatusProxy.GetListAsync(true);
            var milestones  = MilestoneProxy.GetListAsync(true);
            var tools       = SpaceToolProxy.GetListAsync(true);
            var users       = UserProxy.GetListAsync(true);
            var userRoles   = UserRoleProxy.GetListAsync(true);

#if NET4_5
            await Task.WhenAll(space, components, fields, statuses, milestones, tools, users, custReports, userRoles);
#else
            await TaskEx.WhenAll(space, components, fields, statuses, milestones, tools, users, custReports, userRoles);
#endif
            dataCache.Space          = space.Result;
            dataCache.Components     = components.Result;
            dataCache.CustomFields   = fields.Result;
            dataCache.CustomStatuses = statuses.Result;
            dataCache.Milestones     = milestones.Result;
            dataCache.Tools          = tools.Result;
            dataCache.Users          = users.Result;
            dataCache.CustomReports  = custReports.Result;
            dataCache.UserRoles      = userRoles.Result;

            return(dataCache);
        }
Ejemplo n.º 3
0
        internal void Initialize()
        {
            _top = new Dictionary <TopParam, SortedByValueDictionary <UserId, decimal> >
            {
                { TopParam.Gold, new SortedByValueDictionary <UserId, decimal>() },
                { TopParam.Monsters, new SortedByValueDictionary <UserId, decimal>() },
                { TopParam.Rooms, new SortedByValueDictionary <UserId, decimal>() },
                { TopParam.Level, new SortedByValueDictionary <UserId, decimal>() }
            };
            foreach (var userId in DatabaseConnection.GetUsersList())
            {
                var user = UserProxy.GetUnsafe(userId);
                _top[TopParam.Gold].Add(userId, user.Info.Gold);
                _top[TopParam.Monsters].Add(userId, user.Info.Statistics.MonsterCount);
                _top[TopParam.Rooms].Add(userId, user.Info.Statistics.RoomsCount);
                _top[TopParam.Level].Add(userId, PackLevel(user.Info.Level.Level, user.Info.Level.ExpirenceCollected));
            }

            UserLevel.OnChanged += (user, level) =>
            {
                _top[TopParam.Level].Add(user.Info.UserId,
                                         PackLevel(user.Info.Level.Level, user.Info.Level.ExpirenceCollected));
            };

            Statistics.OnChanged += user =>
            {
                _top[TopParam.Gold].Add(user.Info.UserId, user.Info.Gold);
                _top[TopParam.Monsters].Add(user.Info.UserId, user.Info.Statistics.MonsterCount);
                _top[TopParam.Rooms].Add(user.Info.UserId, user.Info.Statistics.RoomsCount);
            };
        }
Ejemplo n.º 4
0
        private void OnUserSetID(object sender, EventArgs e)
        {
            UserProxy user = (UserProxy)sender;

            lock (Users)
                Users[user.ID] = user;
        }
Ejemplo n.º 5
0
        private void OnUserSetRoleID(object sender, EventArgs e)
        {
            UserProxy user = (UserProxy)sender;

            lock (Roles)
                Roles[user.RoleID] = user;
        }
Ejemplo n.º 6
0
        public void Equals_OtherObject_False()
        {
            var proxy1 = UserProxy.Create(CreateUser());
            var proxy2 = UserProxy.Create(CreateUser());

            Assert.That(proxy1.Equals(proxy2), Is.False);
        }
Ejemplo n.º 7
0
        public void Test()
        {
            var proxy = new UserProxy(BaseAddress);
            var user = proxy.Get(new AppCredentialModel
            {
                Key = UserKey,
                AppId = AppId
            }).Result;
            Assert.AreEqual(UserId, user.Id);
            Assert.IsNotEmpty(Token);
            Assert.AreEqual(AppSettings, user.Settings);

            proxy.Update(new AppCredentialModel
            {
                Key = UserKey,
                AppId = AppId
            }, new UpdateCredentialModel
            {
                Key = "5"
            }).Wait();

            UserKey = "5";

            user = proxy.Get(new AppCredentialModel
            {
                Key = UserKey,
                AppId = AppId
            }).Result;
            Assert.AreEqual(UserId, user.Id);

        }
Ejemplo n.º 8
0
        public ActionResult AccessControl()
        {
            StringBuilder strData                  = new StringBuilder();
            AccessControlOverviewModel model       = new AccessControlOverviewModel();
            List <SiteMap>             siteMapList = new List <SiteMap>();


            model.SiteMapJsonList = new List <AccessControlOverviewModel.JsonSiteMap>();



            using (var proxy = new UserProxy())
            {
                siteMapList = proxy.GetSiteMapByApplicationId(1);
            }
            //Generate Site Map string.
            foreach (SiteMap siteMap in siteMapList.Where(f => f.MapPath.IndexOf("*", StringComparison.InvariantCultureIgnoreCase) == -1))
            {
                model.SiteMapJsonList.Add(new AccessControlOverviewModel.JsonSiteMap
                {
                    SiteMapId       = siteMap.SiteMapId,
                    ParentSiteMapId = siteMap.ParentId.HasValue ? siteMap.ParentId.Value : siteMap.SiteMapId,
                    SiteMapTitle    = siteMap.SiteMapTitle,
                    SiteMapUrl      = Url.Action(Constants.Controllers.User_ManageAccessControl, Constants.Controllers.User, new { id = siteMap.SiteMapId }),
                    Open            = Convert.ToString(false).ToLower()
                });
            }
            return(View(model));
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            // 实例化对象。
            IUserService userService = new UserService();
            //// 实例化装饰器类,并用上面的实例给构造方法传值。
            //var userDecorator = new UserDecorator(userService);
            //var user = new User { Name = "Charles", Password = "******" };
            //// 调用装饰器类的注册方法,相当于调用实例化对象的注册方法。
            //userDecorator.Register(user);

            //Console.ReadKey();



            //// 实例化对象
            //IUserService userService = new UserService();
            // 实例化装饰器类,并用上面的实例给构造方法传值
            var userProxy = new UserProxy();
            var user      = new User {
                Name = "Charles", Password = "******"
            };

            // 调用装饰器类的注册方法,相当于调用实例化对象的注册方法
            userProxy.Register(user);

            Console.ReadKey();
        }
Ejemplo n.º 10
0
    //监听事件
    private void Login()
    {
        //检查是否为空
        if (UserNameInput.text == "" || pwdInput.text == "")
        {
            Debug.Log("不能为空");
            return;
        }


        //检查非法字符



        //获取用户名密码



        //UserProxy login
        UserProxy userProxy = GetComponent <UserProxy>();

        UserVO user = new UserVO(UserNameInput.text, pwdInput.text);

        userProxy.Login(user);
    }
Ejemplo n.º 11
0
        public ActionResult ManageUserAccountData(UserDetailModel model)
        {
            // Validate
            if (ModelState.IsValid)
            {
                User  user          = null;
                int[] selectedUGIds = null;
                using (var proxy = new UserProxy())
                {
                    user = proxy.GetUserById(model.UserId);
                    User userInfo = @Utilities.GetCurrentUserInfo();
                    if (user != null)
                    {
                        user = new User()
                        {
                            CreatedDate       = user.CreatedDate,
                            UpdatedBy         = Convert.ToString(userInfo.UserName),
                            UpdatedDate       = DateTime.Now,
                            CreatedBy         = user.CreatedBy,
                            Email             = model.Email,
                            Organisation_GUID = model.OrganizationGUID,
                            MobileNumber      = model.OfficeNumber,
                            UserName          = model.UserName,
                            Language          = model.BlastManagerWebSettingID,
                            GUID_User         = user.GUID_User,
                            IsDeptAdmin       = Convert.ToString(model.IsDeptAdmin),
                            IsActive          = Convert.ToByte(model.IsActive),
                            UserDisplayName   = user.UserDisplayName,
                        };

                        model.SelectedUserGroupIdList += string.Join(";", user.UserRoles.Select(p => p.UserRoleId).ToArray());


                        if (!string.IsNullOrWhiteSpace(model.SelectedUserGroupIdList))
                        {
                            user.UserRoles = new List <UserRole>();
                            selectedUGIds  = model.SelectedUserGroupIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Distinct().Select(p => NumericHelper.ParseInt(p).Value).ToArray();
                            foreach (var ugId in selectedUGIds)
                            {
                                user.UserRoles.Add(new UserRole()
                                {
                                    UserRoleId = ugId
                                });
                            }
                        }
                        proxy.UpdateUser(user);

                        model.ShowSuccessMessage   = true;
                        model.SuccessDirectionPath = StringHelper.Format("{0}/{1}", Constants.Controllers.User, Constants.Controllers.User_UserAccount);
                        model.SuccessMessage       = Convert.ToString(Resources.Res.RES_Success);
                    }
                    else
                    {
                        return(HttpNotFound());
                    }
                }
            }

            return(View("ManageUserAccount", model));
        }
Ejemplo n.º 12
0
        private async Task AddUserItems(string key)
        {
            Debug.WriteLine("current screen name: " + key);
            if (String.IsNullOrEmpty(key))
            {
                await DispatcherHelper.UIDispatcher.InvokeAsync(() => this._items.Clear());

                return;
            }
            var items = (await UserProxy.GetUsersFastAsync(key, 1000))
                        .Select(t => t.Item2)
                        .ToArray();
            // re-ordering
            var ordered = items.Where(s => s.StartsWith(key))
                          .OrderBy(s => s)
                          .Concat(items.Where(s => !s.StartsWith(key))
                                  .OrderBy(s => s))
                          .Select(s => new SuggestItemViewModel("@" + s))
                          .ToArray();
            await DispatcherHelper.UIDispatcher.InvokeAsync(
                () =>
            {
                this._items.Clear();
                ordered.ForEach(s => this._items.Add(s));
                this.SelectSuitableItem("@" + key);
            });
        }
Ejemplo n.º 13
0
        public override void Process()
        {
            UserProxy user = (UserProxy)Session;

            user.SetRoleID(RoleID);
            base.Process();
        }
Ejemplo n.º 14
0
        public override void Process()
        {
            UserProxy user = (UserProxy)Session;

            user.InitS2C(ClientKey.RawData());
            base.Process();
        }
Ejemplo n.º 15
0
        public void Equals_Null_False()
        {
            var user   = CreateUser();
            var proxy1 = UserProxy.Create(user);

            Assert.That(proxy1.Equals(null), Is.False);
        }
Ejemplo n.º 16
0
        internal static void NotifyRetweetFavorited(TwitterUser source, TwitterUser target, TwitterStatus status)
        {
            if (MuteBlockManager.IsBlocked(source) || MuteBlockManager.IsOfficialMuted(source))
            {
                return;
            }
            if (!NotificationLatch.CheckSetPositive(NotificationLatchTarget.Favorite, source.Id, status.Id))
            {
                return;
            }
            var original = status.RetweetedStatus;

            if (original == null)
            {
                return;
            }
            Task.Run(() => UserProxy.StoreUser(source));
            Task.Run(() => StatusModel.UpdateStatusInfo(
                         original.Id,
                         model => model.AddFavoritedUser(source), _ =>
            {
                StatusProxy.AddFavoritor(original.Id, source.Id);
                StatusBroadcaster.Republish(original);
            }));
            Head.NotifyRetweetFavorited(source, target, status);
        }
Ejemplo n.º 17
0
 public override void OnRegister()
 {
     Debug.Log("UserListMediator.OnRegister()");
     base.OnRegister();
     userProxy = Facade.RetrieveProxy(UserProxy.NAME) as UserProxy;
     View.LoadUsers(userProxy.Users);
 }
Ejemplo n.º 18
0
        private void ValidateUser(UserProxy user)
        {
            if (user == null)
            {
                ThrowHttp.BadRequest(ErrorMessage.USER_REQUIRED);
            }

            var emailError = _emailValidator.Validate(user.Email);

            if (emailError != null)
            {
                ThrowHttp.BadRequest(emailError);
            }

            var passwordError = _passwordValidator.Validate(user.Password);

            if (passwordError != null)
            {
                ThrowHttp.BadRequest(passwordError);
            }

            if (string.IsNullOrWhiteSpace(user.FirstName))
            {
                ThrowHttp.BadRequest(ErrorMessage.FIRST_NAME_REQUIRED);
            }

            if (string.IsNullOrWhiteSpace(user.LastName))
            {
                ThrowHttp.BadRequest(ErrorMessage.LAST_NAME_REQUIRED);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="startIndex"></param>
 /// <param name="pageSize"></param>
 /// <returns></returns>
 public IList <UserProxy> GetAllByPage(int startIndex, int pageSize)
 {
     try
     {
         IDataAccess dataAccess = new BUser();
         int         userCount  = 0;
         //decimal[] arr = dataAccess.GetAccessiblePersonByDepartment().ToArray();
         IList <User>      list  = userRepository.GetAllByPage(BUser.CurrentUser.ID, startIndex, pageSize);
         IList <UserProxy> users = new List <UserProxy>();
         for (int i = 0; i < list.Count; i++)
         {
             User      user  = list[i];
             UserProxy proxy = new UserProxy(user);
             if (proxy.Active && !Utility.IsEmpty(user.Person.EndEmploymentDate))
             {
                 proxy.Active = DateTime.Now > user.Person.EndEmploymentDate ? false : true;
             }
             users.Add(proxy);
         }
         return(users);
     }
     catch (Exception ex)
     {
         LogException(ex, "BUser", "GetAllUsers");
         throw ex;
     }
 }
        ///<summary>
        /// Prepare the Model.
        ///</summary>
        override public void Execute(INotification notification)
        {
            // Create User Proxy,
            UserProxy userProxy = new UserProxy();

            //Populate it with dummy data
            userProxy.AddItem(new UserVo {
                Username = "******", Fname = "Larry", Lname = "Stooge", Email = "*****@*****.**", Password = "******", Department = DeptEnum.ACCT
            });
            userProxy.AddItem(new UserVo {
                Username = "******", Fname = "Curly", Lname = "Stooge", Email = "*****@*****.**", Password = "******", Department = DeptEnum.SALES
            });
            userProxy.AddItem(new UserVo {
                Username = "******", Fname = "Moe", Lname = "Stooge", Email = "*****@*****.**", Password = "******", Department = DeptEnum.PLANT
            });

            // register it
            Facade.RegisterProxy(userProxy);

            // Create Role Proxy
            RoleProxy roleProxy = new RoleProxy();

            //Populate it with dummy data
            RoleEnum[] lstoogeRoles = { RoleEnum.PAYROLL, RoleEnum.EMP_BENEFITS };
            roleProxy.AddItem(new RoleVo("lstooge", new ObservableCollection <RoleEnum>(lstoogeRoles)));

            RoleEnum[] cstoogeRoles = { RoleEnum.ACCT_PAY, RoleEnum.ACCT_RCV, RoleEnum.GEN_LEDGER };
            roleProxy.AddItem(new RoleVo("cstooge", new ObservableCollection <RoleEnum>(cstoogeRoles)));

            RoleEnum[] mstoogeRoles = { RoleEnum.INVENTORY, RoleEnum.PRODUCTION, RoleEnum.SALES, RoleEnum.SHIPPING };
            roleProxy.AddItem(new RoleVo("mstooge", new ObservableCollection <RoleEnum>(mstoogeRoles)));

            // register it
            Facade.RegisterProxy(roleProxy);
        }
Ejemplo n.º 21
0
        public override void Process()
        {
            UserProxy user = (UserProxy)Session;

            user.InitC2S(ServerKey.RawData());
            base.Process();
        }
Ejemplo n.º 22
0
        public UserProxy GetCurrentUser()
        {
            UserProxy user = TSAuthentication.GetUser(TSAuthentication.GetLoginUser()).GetProxy();

            user.CryptedPassword = string.Empty;
            return(user);
        }
Ejemplo n.º 23
0
        public void Insert_ActiveTest2()
        {
            try
            {
                puser_testObject.Active          = true;
                puser_testObject.UserName        = "******";
                puser_testObject.Password        = "******";
                puser_testObject.ConfirmPassword = "******";
                puser_testObject.RoleID          = ADORole2.ID;
                puser_testObject.PersonID        = ADOPerson1.ID;

                decimal id = busUser.InsertUser(puser_testObject);
                ClearSession();
                user_testObject = busUser.GetByID(id);
                Assert.AreEqual(true, user_testObject.Active);
                ClearSession();
                UserProxy p = busUser.GetAllByPageBySearch(UserSearchKeys.Username, "TestUser22", 0, 10).First();
                Assert.AreEqual(true, p.Active);
            }
            catch (UIValidationExceptions ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                ClearSession();
                busUser.SaveChanges(user_testObject, UIActionType.DELETE);
            }
        }
        private void DoWork(object state)
        {
            try
            {
                var clearDate = new Age(startDate);
                if (clearDate.Months >= 1)
                {
                    startDate = DateTime.Now;
                    this.states.Clear();
                }

                using (IServiceScope scope = _serviceProvider.CreateScope())
                {
                    IUserService userService =
                        scope.ServiceProvider.GetRequiredService <IUserService>();

                    var administrator = UserProxy.GetAdministratorProxy(null, userService);
                    var kims          = administrator.GetAllKIM().Result;

                    foreach (var item in kims.Where(x => x.Expired != ExpireStatus.Expire))
                    {
                        ProccessKIM(item, states.Where(x => x.Id == item.Id).FirstOrDefault());
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.LogInformation($"{ex.Message}");
            }
        }
Ejemplo n.º 25
0
        internal static void NotifyRetweetRetweeted(TwitterUser source, TwitterUser target, TwitterStatus status)
        {
            if (MuteBlockManager.IsBlocked(source) || MuteBlockManager.IsOfficialMuted(source))
            {
                return;
            }
            if (!Setting.NotifyBackfilledTweets.Value && status.CreatedAt < App.StartupDateTime)
            {
                // backfilled tweets
                return;
            }
            var original = status.RetweetedStatus;

            if (original == null)
            {
                return;
            }
            Task.Run(() => UserProxy.StoreUser(source));
            Task.Run(() => StatusModel.UpdateStatusInfo(
                         original.Id,
                         model => model.AddRetweetedUser(source), _ =>
            {
                StatusProxy.AddRetweeter(original.Id, source.Id);
                StatusBroadcaster.Republish(original);
            }));
            Head.NotifyRetweetRetweeted(source, target, status);
        }
Ejemplo n.º 26
0
        private async Task InitializeCollection()
        {
            Task <IEnumerable <long> > reader;

            switch (_type)
            {
            case RelationDataType.Following:
                reader = UserProxy.GetFollowingsAsync(_parent.AccountId);
                break;

            case RelationDataType.Follower:
                reader = UserProxy.GetFollowersAsync(_parent.AccountId);
                break;

            case RelationDataType.Blocking:
                reader = UserProxy.GetBlockingsAsync(_parent.AccountId);
                break;

            case RelationDataType.NoRetweets:
                reader = UserProxy.GetNoRetweetsAsync(_parent.AccountId);
                break;

            case RelationDataType.Mutes:
                reader = UserProxy.GetMutesAsync(_parent.AccountId);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            await AddAsync(await reader.ConfigureAwait(false)).ConfigureAwait(false);
        }
 /// <summary>
 /// Populate the user role id to UserRole entity dictionary
 /// </summary>
 public void SetUserRoleList(int roleType)
 {
     UserRoleDropdownList.Add(new SelectListItem()
     {
         Value = "", Text = "Please select user group", Selected = true
     });
     using (var proxy = new UserProxy())
     {
         List <UserRole> List = proxy.GetAllUserGroupList().Where(ud => ud.RoleType <= roleType).ToList();
         foreach (UserRole item in List)
         {
             UserRoleDropdownList.Add(new SelectListItem()
             {
                 Value = StringHelper.ToString(item.UserRoleId), Text = item.RoleName
             });
             DicUserRole.Add(StringHelper.ToString(item.UserRoleId), item);
         }
     }
     using (var proxy = new UserProxy())
     {
         OrganizationDropdownList = new List <SelectListItem>();
         OrganizationDropdownList.Add(new SelectListItem()
         {
             Value = "", Text = "Please select Organisation", Selected = true
         });
         List <Organisation> List = proxy.GetAllOrganizationList().ToList();
         foreach (Organisation item in List)
         {
             OrganizationDropdownList.Add(new SelectListItem()
             {
                 Value = Convert.ToString(item.Organisation_GUID), Text = item.OrganisationName
             });
         }
     }
 }
Ejemplo n.º 28
0
        public override void Process()
        {
            UserProxy user = (UserProxy)Session;

            user.SetLocalsid(Localsid);
            user.SetID(UserID);
            base.Process();
        }
Ejemplo n.º 29
0
        public void SerializesCache()
        {
            var deserialized = Serializer.SerializeAndDeserialize(Tuple.Create(_principal, _principal.User));
            SecurityManagerPrincipal deserialziedSecurityManagerPrincipal = deserialized.Item1;
            UserProxy deserialziedUser = deserialized.Item2;

            Assert.That(deserialziedSecurityManagerPrincipal.User, Is.SameAs(deserialziedUser));
        }
Ejemplo n.º 30
0
    /// <summary>
    /// retrieve the user and role proxies and delete the user
    /// and his roles. then send the USER_DELETED notification
    /// </summary>
    /// <param name="notification"></param>
    public override void Execute(INotification notification)
    {
        UserVO    user      = (UserVO)notification.Body;
        UserProxy userProxy = (UserProxy)Facade.RetrieveProxy(UserProxy.NAME);

        userProxy.AddItem(user);
        SendNotification(EventsEnum.USER_ADDED, user);
    }
Ejemplo n.º 31
0
        protected override async Task DoReceive()
        {
            var user = await this._account.ShowUserAsync(this._account.Id);

            this._account.UnreliableScreenName   = user.ScreenName;
            this._account.UnreliableProfileImage = user.ProfileImageUri.ChangeImageSize(ImageSize.Original);
            UserProxy.StoreUser(user);
        }
Ejemplo n.º 32
0
        public UserProxy(string id, string name, string password, UserRole? role)
            : this()
        {
            ID = id;
            Name = name;
            Password = password;
            Role = role;

            _original = new UserProxy() { ID = id, Name = name, Password = password, Role = role };
        }
Ejemplo n.º 33
0
        private void Login()
        {
            IsBusy = true;
            WorkInBackground((s, e) =>
            {
                try
                {
                    IUserProxy userProxy = new UserProxy();
                    KmtConstants.LoginUser = userProxy.Login(LoginId, Password);
                    if (KmtConstants.LoginUser != null)
                    {
                        MessageLogger.LogOperation(KmtConstants.LoginUser.LoginId, "Logged in.");

                        IConfigProxy configProxy = new ConfigProxy(KmtConstants.LoginUser);
                        KmtConstants.OldTimeline = configProxy.GetOldTimeline();

                        IHeadQuarterProxy headQuarterProxy = new HeadQuarterProxy();

                        var headQuarters = headQuarterProxy.GetHeadQuarters(KmtConstants.LoginUser);
                        if (headQuarters.Count > 0)
                        {
                            KmtConstants.CurrentHeadQuarter = headQuarters.Single(
                               hq => hq.UserHeadQuarters.First().IsDefault);
                        }

                        Dispatch(() =>
                        {
                            Thread.CurrentThread.CurrentUICulture = KmtConstants.CurrentCulture;
                            Thread.CurrentThread.CurrentCulture = KmtConstants.CurrentCulture;
                            MainWindow mainWindow = new MainWindow();
                            View.Close();
                            mainWindow.Show();
                        });
                    }
                    IsBusy = false;
                }
                catch (Exception ex)
                {
                    IsBusy = false;
                    ex.ShowDialog();
                    ExceptionHandler.HandleException(ex);
                }
            });
        }