Пример #1
0
        public ActionResult RegisterNewBuyer(BuyerRegistrationViewModel postModel)
        {
            if (ModelState.IsValid)
            {
                Mapper.CreateMap <BuyerRegistrationViewModel, Buyer>();
                Mapper.CreateMap <BuyerRegistrationViewModel, User>();
                Buyer buyer = Mapper.Map <BuyerRegistrationViewModel, Buyer>(postModel);
                User  user  = Mapper.Map <BuyerRegistrationViewModel, User>(postModel);

                UserComponent     userComponent = new UserComponent();
                ValidationResults vResult       = userComponent.CreateUser(user);
                postModel.ValidationResult = vResult;
                if (vResult.Success == true)
                {
                    BuyerComponent buyerComponent = new BuyerComponent();
                    vResult = buyerComponent.RegisterNewBuyer(buyer);
                    postModel.ValidationResult = vResult;
                }
            }
            else
            {
                ListComponent lstComponent = new ListComponent();
                postModel.Countries = lstComponent.GetListItemsById("Country");
                postModel.Cities    = lstComponent.GetListItemsById("City");
                postModel.AreBothAddressSameOptions = lstComponent.GetListItemsById("YesOrNo");
            }
            return(View("RegisterNewBuyer", postModel));
        }
Пример #2
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     if (txt_CurrentPassword.Text.Trim() != "" && txt_NewPassword.Text.Trim() != "" && txt_ConfirmNewPassword.Text.Trim() != "")
     {
         if (txt_CurrentPassword.Text == System.Text.Encoding.UTF8.GetString(Atiran.Connections.Operaions.UserOp.GetCurrentSysUser.Instance.UserPassWord))
         {
             if (txt_NewPassword.Text == txt_ConfirmNewPassword.Text)
             {
                 if (UserComponent.ChangePassword(GetCurrentSysUser.Instance.UserID, txt_Username.Text, txt_NewPassword.Text))
                 {
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "رمز عبور با موفقيت تغيير كرد");
                     Application.Restart();
                 }
             }
             else
             {
                 CustomMessageForm.CustomMessageBox.Show("پیغام", "کلمه عبور جدید و تکرار آن مشابه نمی باشند");
             }
         }
         else
         {
             CustomMessageForm.CustomMessageBox.Show("پیغام", "کلمه عبور فعلی اشتباه می باشد");
         }
     }
     else
     {
         CustomMessageForm.CustomMessageBox.Show("پیغام", "پر کردن کلمه عبور جاری، کلمه عبور جدید و تایید کلمه عبور جدید الزامی می باشد");
     }
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
      this.lblMessage.Text = "";

      //if (this.txtNewPassword.Text != this.txtNewPasswordConfirm.Text)
      //{
      //  this.lblMessage.Text = "新密码两次输入不一致,请确认!";
      //  return;
      //}

      //if (this.txtNewPassword.Text == "")
      //{
      //  this.lblMessage.Text = "必须输入密码!";
      //  return;
      //}

      Business.UserComponent uc = new UserComponent();
      if (this.txtPassword.Text.Trim().Length == 0 || !uc.VerifyPassword(this.lblUserID.Text, this.txtPassword.Text.Trim()))
      {
        this.lblMessage.Text = "当前密码输入错误,请重新输入!";
        return;
      }

      var user = uc.getUserById(this.hddId.Value);
      user.Psd = this.txtNewPassword.Text;
      if (uc.Update(user) > 0)
      {
        this.lblMessage.Text = "修改密码成功!";
      }
      else
      {
        this.lblMessage.Text = "修改密码失败,请稍后再试!";
      }
    }
    private void getUsers()
    {

      Business.UserComponent uc = new UserComponent();
      this.gvUserList.DataSource = uc.getUsers();
      this.gvUserList.DataBind();
    }
Пример #5
0
    public String readline()
    {
        UserComponent.controlled_print("About to read new line from buffer...");
        while (this.running)
        {
            lock (this.lock_object)
            {
                UserComponent.controlled_print("Waiting for input in buffer... len=" +
                                               input_buffer.Length + " " + input_buffer);

                if (this.input_buffer.Length > 0)
                {
                    String[] message_list = input_buffer.TrimStart(' ').TrimStart('$').TrimStart(' ').Split('$');

                    if (message_list.Length > 1)
                    {
                        String message = message_list[0];
                        input_buffer = input_buffer.TrimStart(' ').TrimStart('$').TrimStart(' ')
                                       .Substring(message.Length + 1);
                        UserComponent.controlled_print("Returning message: " + message);
                        return(message);
                    }
                }
            }

            Thread.Sleep(1);
        }

        return(null);
    }
Пример #6
0
        /// <summary>
        /// Retrieve general beatmap information.
        /// </summary>
        /// <param name="nameOrId">Specify a user or a username to return metadata from.</param>
        /// <param name="gameMode">Specify the game mode.</param>
        /// <param name="limitCount">Amount of results (1 - 500). Default value is 500.</param>
        /// <returns>Fetched beatmaps.</returns>
        public OsuBeatmap[] GetBeatmaps(
            UserComponent nameOrId       = null,
            ConvertibleGameMode gameMode = null,
            int?limitCount = null)
        {
            var sb = new StringBuilder(Key.CreateBeatmapLink());

            if (nameOrId != null)
            {
                AppendUser(nameOrId, sb);
            }
            if (gameMode != null)
            {
                AppendConvertibleGameMode(gameMode, sb);
            }
            if (limitCount != null)
            {
                AppendLimit(limitCount, sb);
            }

            string json = GetJson(sb);
            var    obj  = JsonConvert.DeserializeObject <OsuBeatmap[]>(json);

            return(obj);
        }
 public Entity AddUser(string newName, int newAge)
 {
     var component = new UserComponent();
     component.name = newName;
     component.age = newAge;
     return AddUser(component);
 }
Пример #8
0
        public void Test_SaveUserDetails_Failure()
        {
            UserComponent userComponent = new UserComponent();

            //Empty userDetails being passed.
            userComponent.SaveUserDetails(null);
        }
        public async Task <IActionResult> Login(UserModel model)
        {
            UserModel user = UserComponent.GetUser(model.UserName);

            if (UserComponent.CheckUser(user, model))
            {
                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject = new ClaimsIdentity(new Claim[]
                    {
                        new Claim("UserID", user.Id.ToString())
                    }),
                    Expires = DateTime.UtcNow.AddDays(1),
                };
                var tokenHandler  = new JwtSecurityTokenHandler();
                var securityToken = tokenHandler.CreateToken(tokenDescriptor);
                var token         = tokenHandler.WriteToken(securityToken);

                return(Ok(new { token }));
            }
            else
            {
                return(BadRequest(new { message = "Username or password is incorrect." }));
            }
        }
Пример #10
0
        /// <summary>
        /// Retrieve information about the top 100 scores of a specified beatmap.
        /// </summary>
        /// <param name="beatmapId">Specify a beatmap id to return score information from.</param>
        /// <param name="nameOrId">Specify a user id or a user name to return score information for.</param>
        /// <param name="gameMode">Specify the game mode. Default value is 0.</param>
        /// <param name="mods">Specify a mod or mod combination.</param>
        /// <param name="limitCount">Amount of results from the top (1 - 100). Default value is 50.</param>
        /// <returns>Fetched scores.</returns>
        public OsuPlayScore[] GetScores(
            BeatmapId beatmapId,
            UserComponent nameOrId = null,
            GameMode?gameMode      = null,
            Mod?mods       = null,
            int?limitCount = null)
        {
            var sb = new StringBuilder(Key.CreateScoreLink(beatmapId));

            if (nameOrId != null)
            {
                AppendUser(nameOrId, sb);
            }
            if (gameMode != null)
            {
                AppendGameMode(gameMode, sb);
            }
            if (mods != null)
            {
                sb.Append($"&mods={(int)mods.Value}");
            }
            if (limitCount != null)
            {
                AppendLimit(limitCount, sb);
            }

            string json = GetJson(sb);
            var    obj  = JsonConvert.DeserializeObject <OsuPlayScore[]>(json);

            return(obj);
        }
Пример #11
0
        public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope)
        {
            var    routeMsg = scope.RouteMessage;
            string userName = Decode(UserName);

            if (string.IsNullOrEmpty(userName))
            {
                return(routeMsg.ToSource(DefaultReply.ParamMissing));
            }

            BllUserRole      bllUserRole = new BllUserRole();
            OldSiteApiClient client      = new OldSiteApiClient();
            int userNum = client.GetUser(UserComponent.FromUserName(UserName), out var userObj);

            if (userNum == 0)
            {
                return(routeMsg.ToSource(DefaultReply.IdNotFound, true));
            }
            if (userNum > 1)
            {
                // ignored
            }

            var role = bllUserRole.GetUserRoleByQq(long.Parse(routeMsg.UserId));

            if (role.Count != 0)
            {
                if (role[0].CurrentUname == userObj.UserName)
                {
                    return(routeMsg.ToSource("我早就认识你啦.", true));
                }
                string msg = role[0].CurrentUname + ",我早就认识你啦. 有什么问题请找Mother Ship(扔锅)";
                return(routeMsg.ToSource(msg, true));
            }

            var newRole = new TableUserRole
            {
                UserId        = userObj.UserId,
                Role          = "creep",
                QQ            = long.Parse(routeMsg.UserId),
                LegacyUname   = "[]",
                CurrentUname  = userObj.UserName,
                IsBanned      = false,
                RepeatCount   = 0,
                SpeakingCount = 0,
                Mode          = 0,
            };
            var exist = bllUserRole.GetUserRoleByUid(userObj.UserId);

            if (exist != null && exist.Count > 0)
            {
                return(routeMsg.ToSource("这个账号已经被QQ: " + exist.First().QQ + "绑定啦,请联系妈船或对方QQ哦."));
            }
            int c = bllUserRole.InsertUserRole(newRole);

            return(c < 1
                ? routeMsg.ToSource("由于各种强大的原因,绑定失败..")
                : routeMsg.ToSource("明白了," + userObj.UserName + ",多好的名字呢."));
        }
Пример #12
0
        public Entity AddUser(string newName, int newAge)
        {
            var component = new UserComponent();

            component.name = newName;
            component.age  = newAge;
            return(AddUser(component));
        }
Пример #13
0
 public List <vw_KeyValue> GetAllJudges(int courtID)
 {
     return(UserComponent.GetUsersBasedOnType(courtID, SystemUserTypes.Judge).Select(user => new vw_KeyValue
     {
         ID = user.ID,
         Name = user.FullName
     }).ToList());
 }
        public void AddUser(string newName, int newAge)
        {
            var component = new UserComponent();

            component.name = newName;
            component.age  = newAge;
            AddUser(component);
        }
Пример #15
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_UserName.Text != "" && txt_Password.Text != "")
         {
             if (UserComponent.checkAtiranUserName(txt_UserName.Text) == 0)
             {
                 if (txt_Password.Text.Trim().Equals(txt_ConfPassword.Text.Trim()))
                 {
                     int result = 0;
                     result = UserComponent.InserToUser(txt_UserName.Text, txt_Password.Text);
                     if (result > 0)
                     {
                         txt_UserName.Text = "";
                         txt_Password.Text = "";
                         txt_ConfPassword.Clear();
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "ثبت اطلاعات با موفقیت انجام شد");
                         dataGridView1.DataSource = UserComponent.GetUsers();
                         setgridview();
                         // new by sharafzade
                         DialogResult x = Atiran.UI.WindowsForms.MessageBoxes.CustomMessageForm.CustomMessageBox.Show("پيغام", "آيا ميخواهيد براي كاربر تعريف شده، زير سيستم اختصاص دهيد؟", "w");
                         if (x == DialogResult.Yes)
                         {
                             ModuleAccessControl UAC    = new ModuleAccessControl(true, result);
                             UserControlLoader   loader = new UserControlLoader(UAC);
                         }
                     }
                     else
                     {
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ثبت اطلاعات");
                     }
                 }
                 else
                 {
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "كلمه هاي عبور وارد شده مطابقت ندارد", "e");
                     txt_Password.Clear();
                     txt_ConfPassword.Clear();
                     txt_Password.Focus();
                 }
             }
             else
             {
                 CustomMessageForm.CustomMessageBox.Show("پیغام", "نام کاربری تکراری می باشد، لطفا نام کاربری دیگری انتخاب نمایید.");
             }
         }
         else
         {
             CustomMessageForm.CustomMessageBox.Show("پیغام", "نام، نام خانوادگی، نام کاربری و کلمه عبور نمی تواند خالی باشد");
         }
     }
     catch (Exception ex)
     {
         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ثبت اطلاعات");
     }
 }
Пример #16
0
 private void btn_Edit_Click(object sender, EventArgs e)
 {
     try
     {
         if (txt_EditUserName.Text != "" && txt_EditPassword.Text != "")
         {
             if (user != txt_EditUserName.Text)
             {
                 if (UserComponent.checkAtiranUserName(txt_EditUserName.Text.ToString()) == 0)
                 {
                     bool result;
                     result = UserComponent.EditUser(USERID, txt_EditUserName.Text, txt_EditPassword.Text);
                     if (result == true)
                     {
                         panel3.Visible = false;
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "ویرایش اطلاعات با موفقیت انجام شد");
                         dataGridView1.DataSource = UserComponent.GetUsers();
                         setgridview();
                     }
                     else
                     {
                         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ویرایش اطلاعات");
                     }
                 }
                 else
                 {
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "نام کاربری تکراری می باشد، لطفا نام کاربری دیگری انتخاب نمایید.");
                 }
             }
             else
             {
                 bool result;
                 result = UserComponent.EditUser(USERID, txt_EditUserName.Text, txt_EditPassword.Text);
                 if (result == true)
                 {
                     panel3.Visible = false;
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "ویرایش اطلاعات با موفقیت انجام شد");
                     dataGridView1.DataSource = UserComponent.GetUsers();
                     setgridview();
                 }
                 else
                 {
                     CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ویرایش اطلاعات");
                 }
             }
         }
         else
         {
             CustomMessageForm.CustomMessageBox.Show("پیغام", "نام کاربری تکراری می باشد، لطفا نام کاربری دیگری انتخاب نمایید.");
         }
     }
     catch (Exception)
     {
         CustomMessageForm.CustomMessageBox.Show("پیغام", "خطا در ویرایش اطلاعات");
     }
 }
Пример #17
0
        #pragma warning disable
        static void userComponent(GameContext context, UserComponent component)
        {
            var e    = context.userEntity;
            var name = context.user.name;
            var has  = context.hasUser;

            context.SetUser("John", 42);
            context.ReplaceUser("Max", 24);
            context.RemoveUser();
        }
Пример #18
0
 private void InitComponents()
 {
     User      = new UserComponent(this);
     Chat      = new ChatComponent(this);
     Broadcast = new BroadcastComponent(this);
     Search    = new SearchComponent(this);
     Songs     = new SongsComponent(this);
     Queue     = new QueueComponent(this);
     Remora    = new RemoraComponent(this);
 }
Пример #19
0
        #pragma warning disable
        static void userComponent(Pool pool, UserComponent component)
        {
            var e    = pool.userEntity;
            var name = pool.user.name;
            var has  = pool.hasUser;

            pool.SetUser("John", 42);
            pool.ReplaceUser("Max", 24);
            pool.RemoveUser();
        }
Пример #20
0
 public UserStatus UpdateUser(int id, vw_UserData userData)
 {
     try
     {
         return(UserComponent.UpdateUser(id, userData));
     }catch (Exception ex)
     {
         HandleException(ex);
         return(UserStatus.Failed);
     }
 }
Пример #21
0
 public int GetUser(UserComponent nameOrId, out OsuUser user)
 {
     OsuUser[] list = GetUserList(nameOrId);
     if (list.Length == 0)
     {
         user = null;
         return(0);
     }
     user = list[0];
     return(list.Length);
 }
Пример #22
0
        public OsuBeatmapSet[] GetBeatmapSetsByCreator(UserComponent creator)
        {
            var grouping = _client
                           .GetBeatmaps(creator)
                           .GroupBy(k => k.BeatmapSetId);

            return(grouping
                   .Select(s => s.ToList())
                   .Select(beatmaps => new OsuBeatmapSet(beatmaps))
                   .ToArray());
        }
Пример #23
0
        public Entity SetUser(UserComponent component)
        {
            if (hasUser)
            {
                throw new SingleEntityException(Matcher.User);
            }
            var entity = CreateEntity();

            entity.AddUser(component);
            return(entity);
        }
Пример #24
0
        public void Test_SaveUserDetails_Success()
        {
            UserComponent userComponent = new UserComponent();
            UserDetails   userDetails   = new UserDetails()
            {
                FirstName = "Shivangi",
                LastName  = "Garg",
                Age       = 25
            };

            userComponent.SaveUserDetails(userDetails);
        }
Пример #25
0
        public void Can_Filter_By_DisplayName_And_Email()
        {
            // Arrange .. instantiate the component under test
            Mock<IUserRepository> mockRepo = new Mock<IUserRepository>();
            _component = new UserComponent(mockRepo.Object);

            // Act .. call the actual filter method
            var filterResults = _component.Filter(c => c.DisplayName == "galilyou1");

            // Assert .. verify that filter has been called
            mockRepo.Verify(c => c.Filter(It.IsAny<Expression<Func<User, bool>>>()), Times.Once());
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {

            this.lblMessage.Text = "";

            string userName = this.txtUserID.Text;

            MyPrincipal principal;

            HttpContext.Current.Session.Clear();

            UserComponent uc = new UserComponent();

            if (uc.VerifyPassword(userName, txtPassword.Text))
            {


                principal = new MyPrincipal(userName);

                System.Threading.Thread.CurrentPrincipal = principal;

                HttpContext.Current.Session["JMPrincipal"] = principal;

                HttpContext.Current.User = (MyPrincipal)(HttpContext.Current.Session["JMPrincipal"]);

                try
                {
                    //登陆系统
                    Page.Response.Redirect("Main.aspx");

                    //string url = FormsAuthentication.GetRedirectUrl(userName, true);

                    //Response.Redirect(url);
                    //FormsAuthentication.RedirectFromLoginPage(userName, false);

                }
                catch (Exception ex)
                {
                    throw ex;
                }

                
            }
            else
            {
                this.txtPassword.Text = "";
                this.txtUserID.Text = "";

                this.lblMessage.Text = "用户名或密码输入错误!";

            }
        }
Пример #27
0
        private OsuBeatmapSet[] GetBeatmapSets(UserComponent user)
        {
            _client.GetUser(user, out var userObj);

            //OsuBeatmapSet[] mapsets = NewSiteApiClient
            //    .SearchAllBeatmaps(mapperName, new BeatmapsetsSearchOptions { Status = BeatmapStatus.Qualified })
            //    .Union(
            //        NewSiteApiClient.SearchAllBeatmaps(
            //            mapperName,
            //            new BeatmapsetsSearchOptions { Status = BeatmapStatus.PendingWip }
            //        )
            //    )
            //    .ToArray()
            //    .Union(NewSiteApiClient.SearchAllBeatmaps(mapperName))
            //    .ToArray();
            OsuBeatmapSet[] mapsets = _client
                                      .GetBeatmapSetsByCreator(user)
                                      .ToArray();
            mapsets = mapsets
                      .Where(i => i.Creator == userObj.UserName)
                      .Where(i =>
                             (i.Status == BeatmapApprovedState.Qualified ||
                              i.Status == BeatmapApprovedState.Ranked ||
                              i.Status == BeatmapApprovedState.Loved) &&
                             i.RankedDate != null &&
                             DateTime.UtcNow - i.RankedDate < RangeTime /*||
                                                                         * (i.Status == "pending" || i.Status == "wip") &&
                                                                         * DateTime.UtcNow - i.SubmittedDate < RangeTime*/).ToArray();

            // 先从今日已提醒中筛选此mapper的图 IEnumerable<SlimBeatmapsets>
            var todayThisCreatorSet = _todaySets.Where(k => k.CreatorId == userObj.UserId);
            // 从总集合中筛选未提醒过的图 IEnumerable<OsuBeatmapSet>
            var mapsetsNormal = mapsets.Where(set =>
                                              !todayThisCreatorSet.Select(todaySet => todaySet.Id).Contains(set.Id));

            // 从总集合中筛选提醒过,但是状态改变了的图
            OsuBeatmapSet[] mapsetsStatusChanged = mapsets.Where(set =>
            {
                var matchedSet = todayThisCreatorSet.FirstOrDefault(k => k.Id == set.Id);
                return(matchedSet != null && matchedSet.Status != set.Status);
            }).ToArray();
            // 若状态改变,删除之前的已保存信息
            if (mapsetsStatusChanged.Length > 0)
            {
                _todaySets.RemoveAll(s => mapsetsStatusChanged.Select(k => k.Id).Contains(s.Id));
                SaveTodaySettings();
            }

            // 重新集合
            mapsets = mapsetsNormal.Union(mapsetsStatusChanged).ToArray();
            return(mapsets);
        }
Пример #28
0
 public static string CreateUserParameter(this UserComponent user)
 {
     if (user.IdType != UserComponent.Type.Auto)
     {
         return(string.Format("u={0}&type={1}",
                              user.IdOrName,
                              user.IdType == UserComponent.Type.Id ? "id" : "string"));
     }
     else
     {
         return($"u={user.IdOrName}");
     }
 }
 public Entity ReplaceUser(string newName, int newAge)
 {
     UserComponent component;
     if (hasUser) {
         WillRemoveComponent(ComponentIds.User);
         component = user;
     } else {
         component = new UserComponent();
     }
     component.name = newName;
     component.age = newAge;
     return ReplaceComponent(ComponentIds.User, component);
 }
Пример #30
0
        void userComponent(EntityRepository repo, UserComponent component)
        {
            var e    = repo.userEntity;
            var name = repo.user.name;
            var has  = repo.hasUser;

            repo.SetUser("John", 42);
            repo.SetUser(component);

            repo.ReplaceUser("Max", 24);

            repo.RemoveUser();
        }
Пример #31
0
        public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope)
        {
            var              routeMsg = scope.RouteMessage;
            string           id;
            string           uname;
            OldSiteApiClient client = new OldSiteApiClient();

            if (UserName == null)
            {
                BllUserRole          bllUserRole = new BllUserRole();
                List <TableUserRole> userInfo    = bllUserRole.GetUserRoleByQq(long.Parse(routeMsg.UserId));
                if (userInfo.Count == 0)
                {
                    return(routeMsg.ToSource(DefaultReply.IdNotBound, true));
                }

                id    = userInfo[0].UserId.ToString();
                uname = userInfo[0].CurrentUname;
            }
            else
            {
                int userNum = client.GetUser(UserComponent.FromUserName(UserName), out var userObj);
                if (userNum == 0)
                {
                    return(routeMsg.ToSource(DefaultReply.IdNotFound, true));
                }
                if (userNum > 1)
                {
                    // ignored
                }

                id    = userObj.UserId.ToString();
                uname = userObj.UserName;
            }

            var eloInfo = EloApiClient.GetEloByUid(long.Parse(id));

            switch (eloInfo.Result.ToLower())
            {
            case "fail" when eloInfo.Message.ToLower() == "unranked":
                return(routeMsg.ToSource(uname + "大概没有参加什么mapping赛事..所以没有数据..",
                                         true));

            case "fail":
                return(routeMsg.ToSource("未知错误..查询不到..", true));

            default:
                return(routeMsg.ToSource(
                           $"{eloInfo.User.Name},有elo点{Math.Round(eloInfo.User.Elo, 2)},当前#{eloInfo.User.Ranking}.", true));
            }
        }
Пример #32
0
        public void User_Add_shall_be_notified_to_dashboard()
        {
            IDashboard dashboard = new Dashboard();

            UserComponent user = new UserComponent(dashboard);

            user.AddUser(new UserModel {
                Name = "MyName", LastName = "MyLastName", BirthDate = new DateTime(1982, 03, 11)
            });


            Assert.Contains("Adding User", dashboard.RecentOperations.Last());
            Assert.Contains("MyLastName", dashboard.RecentOperations.Last());
        }
Пример #33
0
        /// <summary>
        /// Retrieve information about replay data of the specified user's score on a map.
        /// </summary>
        /// <param name="gameMode">The mode the score was played in.</param>
        /// <param name="nameOrId">The user that has played the beatmap.</param>
        /// <param name="beatmapId">The beatmap ID in which the replay was played.</param>
        /// <returns>Fetched replay data.</returns>
        public OsuReplay GetReplay(
            GameMode gameMode,
            UserComponent nameOrId,
            BeatmapId beatmapId)
        {
            string    replay = Key.CreateReplayLink(gameMode, beatmapId, nameOrId);
            string    json   = GetJson(replay);
            OsuReplay obj    = JsonConvert.DeserializeObject <OsuReplay>(json);

            return(obj);
            // Note that the binary data you get when you decode above base64-string is not the contents of an .osr-file.
            // It is the LZMA stream referred to by the osu-wiki here:
            // The remaining data contains information about mouse movement and key presses in an wikipedia:LZMA stream
            // https://osu.ppy.sh/wiki/Osr_(file_format)#Format
        }
Пример #34
0
        protected override void Awake()
        {
            base.Awake();

            LobbyServer.ActionUpdateCubeLv += (payloader) =>
            {
                payloader.Callback(
                    success: (data) =>
                {
                    userComponent?.Upsert();
                });
            };

            userComponent = GetUIComponent <UserComponent>();
        }
Пример #35
0
        public Entity ReplaceUser(string newName, int newAge)
        {
            UserComponent component;

            if (hasUser)
            {
                WillRemoveComponent(ComponentIds.User);
                component = user;
            }
            else
            {
                component = new UserComponent();
            }
            component.name = newName;
            component.age  = newAge;
            return(ReplaceComponent(ComponentIds.User, component));
        }
Пример #36
0
        public void Can_Not_Add_User_With_No_Email()
        {
            // Arrange .. instantiate the component under test
            Mock<IUserRepository> mockRepo = new Mock<IUserRepository>();
            _component = new UserComponent(mockRepo.Object);

            // Arrange .. user object to be added
            var user = new User();
            user.DisplayName = "galilyou";
            user.Url = @"http://galilyou.blogspot.com";

            // Act ..
            _component.Add(user);

            // Assert .. verify the call to Add never happend
            mockRepo.Verify(c=> c.Add(user), Times.Never());
        }
Пример #37
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         panel3.Visible = true;
         USERID         = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
         var find = UserComponent.GetUserInformation(USERID);
         foreach (var item in find)
         {
             txt_EditPassword.Text = System.Text.Encoding.UTF8.GetString(item.UserPassWord);
             user = txt_EditUserName.Text = item.UserName;
         }
         panel3.Visible = true;
         txt_EditUserName.Focus();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
    protected void Button2_Click(object sender, EventArgs e)
    {
      this.lblMessage.Text = "";

      string mId = string.Empty;


      for (int i = 0; i <= gvUserList.Rows.Count - 1; i++)
      {
        CheckBox cb1 = (CheckBox)gvUserList.Rows[i].FindControl("cb1");
        if (cb1.Checked)
        {
          mId = mId + gvUserList.DataKeys[i].Value + ",";
        }
      }

      mId = mId.Substring(0, mId.Length - 1);
      Business.UserComponent uc = new UserComponent();
      uc.DeleteUser(mId);
      getUsers();
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
      this.lblMessage.Text = "";

      if (this.txtConfirmPassword.Text != this.txtPassword.Text)
      {
        this.lblMessage.Text = "密码不匹配,请确认!";
        return;
      }

      if (this.lblId.Text == "")
      {
        if (this.txtPassword.Text == "")
        {
          this.lblMessage.Text = "新建用户,必须输入密码!";
          return;
        }

      }



      JMReports.Entities.User user1 = new Entities.User();
      user1.UserId = this.txtUserId.Text.Trim();
      user1.RoleId = int.Parse(this.ddlRole.SelectedItem.Value);
      user1.Title = this.txtTitle.Text.Trim();
      user1.Email = this.txtEmail.Text.Trim();
      user1.Psd = this.txtPassword.Text.Trim();


      Business.UserComponent uc = new UserComponent();

      if (this.lblId.Text == "")
      {
        user1 = uc.Create(user1);
        if (user1.Id != 0)
        {
          this.lblMessage.Text = "用户新增成功!";
          getUsers();

          this.txtUserId.Text = "";
          this.txtEmail.Text = "";
          this.txtTitle.Text = "";
          this.txtPassword.Text = "";
          this.txtConfirmPassword.Text = "";
          this.ddlRole.SelectedValue = "";

          this.lblId.Text = "";

        }
      }
      else
      {
        user1.Id = int.Parse(this.lblId.Text);

        int i = uc.Update(user1);
        if (i > 0)
        {
          this.lblMessage.Text = "用户修改成功!";
          getUsers();

          this.txtUserId.Text = "";
          this.txtEmail.Text = "";
          this.txtTitle.Text = "";
          this.txtPassword.Text = "";
          this.txtConfirmPassword.Text = "";
          this.ddlRole.SelectedValue = "";

          this.lblId.Text = "";
        }
      }
    }
 public Entity AddUser(UserComponent component)
 {
     return AddComponent(ComponentIds.User, component);
 }
 public Entity SetUser(UserComponent component)
 {
     if (hasUser) {
         throw new SingleEntityException(Matcher.User);
     }
     var entity = CreateEntity();
     entity.AddUser(component);
     return entity;
 }
Пример #42
0
        #pragma warning disable
        static void userComponent(Context context, UserComponent component) {
            var e = context.userEntity;
            var name = context.user.name;
            var has = context.hasUser;

            context.SetUser("John", 42);
            context.ReplaceUser("Max", 24);
            context.RemoveUser();
        }
Пример #43
0
        static void userComponent(Pool pool, UserComponent component)
        {
            var e = pool.userEntity;
            var name = pool.user.name;
            var has = pool.hasUser;

            pool.SetUser("John", 42);
            pool.SetUser(component);

            pool.ReplaceUser("Max", 24);

            pool.RemoveUser();
        }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
      this.lblMessage.Text = "";

      string mId = string.Empty;

      for (int i = 0; i <= gvUserList.Rows.Count - 1; i++)
      {
        CheckBox cb1 = (CheckBox)gvUserList.Rows[i].FindControl("cb1");
        if (cb1.Checked)
        {
          mId = mId + gvUserList.DataKeys[i].Value + ",";
        }
      }

      if (mId == string.Empty)
      {
        this.lblMessage.Text = "请选择一位用户";
        return;
      }


      mId = mId.Substring(0, mId.Length - 1);
      string[] ii = mId.Split(',');

      if (ii.Length > 1)
      {
        this.alertClient("请选择一位用户");
        return;
      }


      Business.UserComponent uc = new UserComponent();

      JMReports.Entities.User user1 = uc.getUserById(mId);

      this.txtUserId.Text = user1.UserId;
      this.txtEmail.Text = user1.Email;
      this.txtTitle.Text = user1.Title;
      this.txtPassword.Text = user1.Psd;
      this.txtConfirmPassword.Text = user1.Psd;
      this.ddlRole.SelectedValue = user1.RoleId.ToString();
      this.lblId.Text = user1.Id.ToString();

      this.divUser.Visible = true;
    }