public async Task HandleWithValidCreateRequestCallSaveAsExpectedResultAsync() { // Arrange var userModel = new UserModel { Id = 1, FirstName = "Thirumalai" }; var config = new MapperConfiguration(m => { m.CreateMap <UserDetail, UserModel>(); }); var mapper = new Mapper(config); var userDetail = new UserDetail { Id = 1, FirstName = "Thirumalai" };; repository = new Mock <IRepository>(); repository.Setup(m => m.Get <UserDetail>(It.IsAny <int>())) .Returns(userDetail); underTest = new GetUserInfo(repository.Object, mapper); request = new GetUserInfoRequest(userModel.Id); // Act CancellationToken cancellationToken; var result = await underTest.Handle(request, cancellationToken); // Assert Assert.NotNull(result); Assert.Equal(userModel.Id, result.Id); Assert.Equal(userModel.FirstName, result.FirstName); }
public void GetRooms() { try { NetworkClient.Start(); Plugin.log.Debug($"Creating message..."); NetOutgoingMessage outMsg = NetworkClient.CreateMessage(); Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; byte[] version = new byte[4] { (byte)assemblyVersion.Major, (byte)assemblyVersion.Minor, (byte)assemblyVersion.Build, (byte)assemblyVersion.Revision }; outMsg.Write(version); new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID()).AddToMessage(outMsg); Plugin.log.Debug($"Connecting to {channelInfos[0].ip}:{channelInfos[0].port}..."); NetworkClient.Connect(channelInfos[0].ip, channelInfos[0].port, outMsg); } catch (Exception e) { ChannelException?.Invoke(this, e); Abort(); } }
public ActionResult ChangePasswordConfirmed(ChangePasswordViewModel input) { if (ModelState.IsValid) { if (input.NewPassword != input.RepeatPassword) { TempData["error"] = "تکرار کلمه عبور صحیح نمی باشد."; return(View(input)); } User user = GetUserInfo.GetUser(); if (user.Password != input.OldPassword) { TempData["error"] = "کلمه عبور پیشین صحیح نمی باشد."; return(View(input)); } user.Password = input.NewPassword; user.LastModifiedDate = DateTime.Now; TempData["suucess"] = "تغییرات با موفقیت انجام شد"; db.SaveChanges(); } return(View(input)); }
public static async Task InitializeUserInfo() { UserInfo userInfo = await GetUserInfo.GetUserAsync(); _username = userInfo.userName + ""; _userID = userInfo.platformUserId; }
/// <summary> /// 1成功,0过期,-1非法 /// </summary> /// <param name="token"></param> /// <returns></returns> public int TokenCheck(string token) { try { if (token == "Shangweiji") { return(1); } IJsonSerializer serializer = new JsonNetSerializer(); IDateTimeProvider provider = new UtcDateTimeProvider(); IJwtValidator validator = new JwtValidator(serializer, provider); IBase64UrlEncoder urlEncoder = new JwtBase64UrlEncoder(); IJwtDecoder decoder = new JwtDecoder(serializer, validator, urlEncoder); var json = decoder.Decode(token, "UTF-8", verify: true);//token为之前生成的字符串 var userId = json.Split(',')[0].Split('"')[3]; DataConnection pclsCache = new DataConnection(); GetUserInfo a = userInfoMethod.MstUserGetUserInfo(pclsCache, userId, 0, 0, 0, 0, 0, 0, 1, 0, 0); if (a.Token == token) { return(1); } else { return(0); } } catch (TokenExpiredException) { return(0); } catch (SignatureVerificationException) { return(-1); } }
public object Any(GetUserInfo request) { var user = Db.Single <CustomUserAuth>(x => x.UserName == request.UserName); if (user == null) { throw HttpError.NotFound("User not found"); } var techStacks = Db.Select(Db.From <TechnologyStack>() .Where(x => x.CreatedBy == request.UserName) .OrderByDescending(x => x.Id)); var favStacks = Db.Select( Db.From <TechnologyStack>() .Join <UserFavoriteTechnologyStack>() .Where <UserFavoriteTechnologyStack>(u => u.UserId == user.Id.ToString())); favStacks.Each(x => x.Details = null); //lighten payload var favTechs = Db.Select( Db.From <Technology>() .Join <UserFavoriteTechnology>() .Where <UserFavoriteTechnology>(u => u.UserId == user.Id.ToString())); return(new GetUserInfoResponse { Created = DateTime.UtcNow, UserName = user.UserName, AvatarUrl = user.DefaultProfileUrl ?? "/img/no-profile64.png", TechStacks = techStacks, FavoriteTechStacks = favStacks, FavoriteTechnologies = favTechs, }); }
public ActionResult SupervisorIndex() { User user = GetUserInfo.GetUser(); List <Project> projects = new List <Project>(); if (user != null) { var projectDetails = db.ProjectDetails.Where(c => c.UserId == user.Id).Select(c => new { c.ProjectId, c.UserId }); foreach (var projectDetail in projectDetails) { if (projects.All(c => c.Id != projectDetail.ProjectId)) { projects.Add(db.Projects.Find(projectDetail.ProjectId)); } } } return(View(projects)); }
/// <summary> /// 拉取用户信息 /// </summary> /// <param name="obj"></param> /// <returns></returns> public AuthInfo UserInfo([FromBody] GetUserInfo obj) { if (obj.auth != null) { string secureKey = System.Configuration.ConfigurationManager.AppSettings["SecureKey"]; AuthInfo authInfo = JWT.JsonWebToken.DecodeToObject <AuthInfo>(obj.auth, secureKey); if (authInfo != null) { string username = authInfo.UserName; Users temp = user.FindByUserName(username); //找到token对应的用户 if (temp != null) { Role r = role.FindAuthByID(new Guid(temp.RoleID.ToString()));//找到用户对应的role auth列表 if (r != null) { string str = string.Join(",", authInfo.Roles); if (r.ID != authInfo.RoleID || r.RoleAuthName != str) { authInfo.code = 401; //如果用户角色或者角色本身信息发生改变,返回401标识码清空cookie token } else { authInfo.Roles = r.RoleAuthName.Split(',').ToList(); authInfo.RealName = temp.RealName; authInfo.code = 200; // 成功拉取用户信息 } } } } return(authInfo); } return(new AuthInfo()); }
public WorksSSOHelper(string server_id, string privateKey, string token_domain, string token_url, string consumerkey, string api_id, string domainId, string client_id, string client_secret) { ssoUtil = new GetSSOResultUtil(client_id, client_secret); userInfo = new GetUserInfo(server_id, privateKey, token_domain, token_url, consumerkey); this.api_id = api_id; this.domainId = domainId; }
public object Any(GetUserInfo request) { using (var db = DbFactory.OpenDbConnection()) { return(db.Single <UserAuth>(x => x.UserName == request.UserName).ConvertTo <UserLocal>()); } }
protected override System.IAsyncResult BeginExecuteCore(System.AsyncCallback callback, object state) { System.Globalization.CultureInfo oCultureInfo = new System.Globalization.CultureInfo("fa-IR"); System.Threading.Thread.CurrentThread.CurrentCulture = oCultureInfo; System.Threading.Thread.CurrentThread.CurrentUICulture = oCultureInfo; User user = GetUserInfo.GetUser(); if (user != null) { ViewBag.Name = user.FullName; ViewBag.avatar = user.AvatarImageUrl; ViewBag.Role = user.Role.Title; ViewBag.RoleName = user.Role.Name; if (string.IsNullOrEmpty(user.AvatarImageUrl)) { ViewBag.avatar = "/assets/images/avatars/avatar_default.jpg"; } } return(base.BeginExecuteCore(callback, state)); }
public void Connect(string IP, int Port) { ip = IP; port = Port; NetworkClient.Start(); Misc.Logger.Info($"Creating message..."); NetOutgoingMessage outMsg = NetworkClient.CreateMessage(); Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; byte[] version = new byte[4] { (byte)assemblyVersion.Major, (byte)assemblyVersion.Minor, (byte)assemblyVersion.Build, (byte)assemblyVersion.Revision }; outMsg.Write(version); playerInfo = new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID()); playerInfo.AddToMessage(outMsg); Misc.Logger.Info($"Connecting to {ip}:{port} with player name \"{playerInfo.playerName}\" and ID {playerInfo.playerId}"); InRadioMode = false; InRoom = false; NetworkClient.Connect(ip, port, outMsg); }
public void GetRooms() { try { Task.Run(() => { NetworkClient.Start(); Plugin.log.Info($"Creating message..."); NetOutgoingMessage outMsg = NetworkClient.CreateMessage(); Version assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version; byte[] version = new byte[4] { (byte)assemblyVersion.Major, (byte)assemblyVersion.Minor, (byte)assemblyVersion.Build, (byte)assemblyVersion.Revision }; outMsg.Write(version); new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID()).AddToMessage(outMsg); Plugin.log.Info($"Connecting to {ip}:{port}..."); NetworkClient.Connect(ip, port, outMsg); }).ConfigureAwait(false); } catch (Exception e) { ServerHubException?.Invoke(this, e); Abort(); } }
private void Form3_Load(object sender, EventArgs e) { listBox1.Items.Clear(); foreach (string name in GetUserInfo.Getgroups(out name)) { listBox1.Items.Add(name); } }
public Task <GetUserInfoResponse> GetUserInfo( CancellationToken cancellationToken = default) { var function = new GetUserInfo(); return(CallApi <GetUserInfoParams, GetUserInfoResponse>(function, cancellationToken)); }
public async Task TestEmailMissing() { Dictionary <string, StringValues> parameters = new Dictionary <string, StringValues>(); var request = CreateHttpRequest(parameters); var response = (JsonResult)await GetUserInfo.Run(request, logger); Assert.Equal(400, response.StatusCode); }
private void MenuSceneLoadedFresh() { ModelSaberAPI.HashAllAvatars(); PluginUI.OnLoad(); InGameOnlineController.OnLoad(); SpectatingController.OnLoad(); GetUserInfo.UpdateUserInfo(); }
public void TestMethod4() { CAuthorizationCode code = ssoUtil.GetAuthorzationCodeWithLogin(user_email, user_password).FromJSON <CAuthorizationCode>(); CAccessToken token = ssoUtil.GetAccessToken(code.code).FromJSON <CAccessToken>(); CExternalKey externalkey = ssoUtil.GetExternalKey(token.access_token).FromJSON <CExternalKey>(); userInfo = new GetUserInfo(server_id, privateKey, token_domain, token_url, consumerkey); Console.WriteLine(userInfo.GetUsersInfo(api_id, domainId, externalkey.user_id)); }
/// <summary> /// Окно отправки заявки ИТ-отделу /// </summary> /// <param name="mounters">Список монтажников</param> /// <param name="servicemans">Список техников</param> public OrdersForITViewModel(List <NewMounterExtensionBase> mounters, List <NewServicemanExtensionBase> servicemans) { EnableButton = true; TextButton = "Закрыть"; Mounters = mounters; Servicemans = servicemans; GetUserInfo.Execute(null); CloseOrSendImage = IconName("close"); }
/// <summary> /// 空间被载入后发生事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserControl_Loaded(object sender, RoutedEventArgs e) { if (uInfo != null) { this.UserNameText.Text = uInfo["name"].ToString(); this.PoliceTypeText.Text = uInfo["pType"].ToString(); if (!String.IsNullOrEmpty(uInfo["age"].ToString())) { TimeSpan nowTick = new TimeSpan(DateTime.Now.Ticks); TimeSpan birTick = new TimeSpan(Convert.ToDateTime(uInfo["age"].ToString()).Ticks); TimeSpan diffTick = nowTick.Subtract(birTick).Duration(); this.AgeText.Text = Math.Floor((diffTick.TotalDays / 365)).ToString(); } if (uInfo["sex"].ToString() == "1") { this.SexText.Text = "男"; } else { this.SexText.Text = "女"; } this.AreaText.Text = uInfo["area"].ToString(); UserInfoStatic.O = Convert.ToDouble(uInfo["O"]); UserInfoStatic.R = Convert.ToDouble(uInfo["R"]); UserInfoStatic.T = Convert.ToDouble(uInfo["T"]); UserInfoStatic.E = Convert.ToDouble(uInfo["E"]); UserInfoStatic.W = Convert.ToDouble(uInfo["W"]); UserInfoStatic.HRVS = Convert.ToDouble(uInfo["HRVS"]); } if (medal != null) { if (Convert.ToInt32(medal["ALLC"]) == 1) { this.CourseAllMark.Visibility = System.Windows.Visibility.Hidden; this.CourseAllShow.Visibility = System.Windows.Visibility.Visible; } if (Convert.ToInt32(medal["ALLT"]) == 1) { this.TrainAllMark.Visibility = System.Windows.Visibility.Hidden; this.TrainAllShow.Visibility = System.Windows.Visibility.Visible; } if (Convert.ToInt32(medal["ALLE"]) == 1) { this.EPAllMark.Visibility = System.Windows.Visibility.Hidden; this.EPAllShow.Visibility = System.Windows.Visibility.Visible; } } GetUserInfo udb = new GetUserInfo(); this.SystemNoticeText.Text = udb.GetNotice(); strNotice = this.SystemNoticeText.Text; NoticeTimer = new DispatcherTimer(); NoticeTimer.Tick += new EventHandler(OnTimerNotice); NoticeTimer.Interval = new TimeSpan(0, 0, 0, 10, 0); NoticeTimer.Start(); }
public void OnLevelChange() { GetUserInfo.UpdateUserInfo(); if (_connection.Connected) { if (_loadedlevel > 2) { StartCoroutine(WaitForControllers()); try { localPlayerInfo = new PlayerInfo(GetUserInfo.GetUserName(), GetUserInfo.GetUserID()); SendString(JsonUtility.ToJson(new ClientCommand(ClientCommandType.SetPlayerInfo, JsonUtility.ToJson(localPlayerInfo)))); DataReceived += ReceivedFromServer; StartCoroutine(ReceiveFromServerCoroutine()); try { scoreScreen = new GameObject("ScoreScreen"); scoreScreen.transform.position = new Vector3(0f, 4f, 12f); scoreScreen.transform.rotation = Quaternion.Euler(0f, 0f, 0f); scoreDisplays.Clear(); for (int i = 0; i < 5; i++) { PlayerInfoDisplay buffer = new GameObject("ScoreDisplay").AddComponent <PlayerInfoDisplay>(); buffer.transform.SetParent(scoreScreen.transform); buffer.transform.localPosition = new Vector3(0f, 2.5f - i, 0); scoreDisplays.Add(buffer); } } catch (Exception e) { Console.WriteLine("SCREEN EXCEPTION: " + e); } } catch (Exception e) { Console.WriteLine("Can't connect to the server! Exception: " + e); } } else if (_loadedlevel <= 1) { DataReceived -= ReceivedFromServer; DisconnectFromServer(); StartCoroutine(WaitForResults()); } } }
private void OnTimerNotice(object source, EventArgs e) { GetUserInfo udb = new GetUserInfo(); this.SystemNoticeText.Text = udb.GetNotice(); if (strNotice != this.SystemNoticeText.Text) { strNotice = this.SystemNoticeText.Text; PmtsMessageBox.CustomControl1.Show("有新的系统公告,请在右侧面板查看!", PmtsMessageBox.ServerMessageBoxButtonType.OK); } }
public ActionResult EditByUser() { User user = GetUserInfo.GetUser(); if (user == null) { return(HttpNotFound()); } ViewBag.CityId = new SelectList(db.Cities, "Id", "Title", user.CityId); return(View(user)); }
public void Awake() { if (instance != this) { DontDestroyOnLoad(this); instance = this; GetUserInfo.UpdateUserInfo(); SongCore.Loader.SongsLoadedEvent += SongsLoaded; CreateUI(); } }
private void Awake() { _instance = this; DontDestroyOnLoad(this); StartCoroutine(WaitForGameData()); ui = BSMultiplayerUI._instance; GetUserInfo.UpdateUserInfo(); }
public void OnRefreshInfo() { GetUserInfo udb = new GetUserInfo(); uInfo = udb.GetUserInfoByUID(); medal = udb.GetUserMedal(); if (uInfo != null) { this.UserNameText.Text = uInfo["name"].ToString(); this.PoliceTypeText.Text = uInfo["pType"].ToString(); if (!String.IsNullOrEmpty(uInfo["age"].ToString())) { TimeSpan nowTick = new TimeSpan(DateTime.Now.Ticks); TimeSpan birTick = new TimeSpan(Convert.ToDateTime(uInfo["age"].ToString()).Ticks); TimeSpan diffTick = nowTick.Subtract(birTick).Duration(); this.AgeText.Text = Math.Floor((diffTick.TotalDays / 365)).ToString(); } if (uInfo["sex"].ToString() == "1") { this.SexText.Text = "男"; } else { this.SexText.Text = "女"; } this.AreaText.Text = uInfo["area"].ToString(); UserInfoStatic.O = Convert.ToDouble(uInfo["O"]); UserInfoStatic.R = Convert.ToDouble(uInfo["R"]); UserInfoStatic.T = Convert.ToDouble(uInfo["T"]); UserInfoStatic.E = Convert.ToDouble(uInfo["E"]); UserInfoStatic.W = Convert.ToDouble(uInfo["W"]); UserInfoStatic.HRVS = Convert.ToDouble(uInfo["HRVS"]); } if (medal != null) { if (Convert.ToInt32(medal["ALLC"]) == 1) { this.CourseAllMark.Visibility = System.Windows.Visibility.Hidden; this.CourseAllShow.Visibility = System.Windows.Visibility.Visible; } if (Convert.ToInt32(medal["ALLT"]) == 1) { this.TrainAllMark.Visibility = System.Windows.Visibility.Hidden; this.TrainAllShow.Visibility = System.Windows.Visibility.Visible; } if (Convert.ToInt32(medal["ALLE"]) == 1) { this.EPAllMark.Visibility = System.Windows.Visibility.Hidden; this.EPAllShow.Visibility = System.Windows.Visibility.Visible; } } this.SystemNoticeText.Text = udb.GetNotice(); }
public UserInfo GetUserInfo(string email) { var getUserInfo = new GetUserInfo(Client.Ticket, Token, Client.AccountDomain, email); var xml = getUserInfo.Post().CreateNavigator(); var userId = xml.SelectSingleNode("/qdbapi/user").GetAttribute("id", String.Empty); var firstName = xml.SelectSingleNode("/qdbapi/user/firstName").Value; var lastName = xml.SelectSingleNode("/qdbapi/user/lastName").Value; var login = xml.SelectSingleNode("/qdbapi/user/login").Value; var emailAddress = xml.SelectSingleNode("/qdbapi/user/email").Value; var screenName = xml.SelectSingleNode("/qdbapi/user/screenName").Value; return(new UserInfo(userId, firstName, lastName, login, emailAddress, screenName)); }
public ActionResult SupervisorIndex(Guid id) { User user = GetUserInfo.GetUser(); var projectDetails = db.ProjectDetails.Include(p => p.Project) .Where(p => p.ProjectId == id && p.UserId == user.Id && p.IsDeleted == false) .Include(p => p.Store).OrderByDescending(p => p.CreationDate); var project = db.Projects.Where(c => c.Id == id).Select(c => c.Title); ViewBag.Title = "جزییات پروژه " + project.FirstOrDefault(); return(View(projectDetails.ToList())); }
protected override void DidActivate(bool firstActivation, ActivationType activationType) { base.DidActivate(firstActivation, activationType); if (firstActivation) { _roomName = $"{GetUserInfo.GetUserName()}'s room".ToUpper(); _roomPassword = ""; } _createRoomButton.interactable = PluginUI.instance.roomCreationFlowCoordinator.CheckRequirements(); parserParams.EmitEvent("cancel"); }
public ActionResult PromoterIndex() { User user = GetUserInfo.GetUser(); var dailyPromoterPlans = db.DailyPromoterPlans.Include(d => d.ProjectDetailPromoter) .Where(d => d.ProjectDetailPromoter.UserId == user.Id && d.IsDeleted == false) .OrderByDescending(d => d.ShiftDate); ViewBag.Title = "برنامه روزانه "; return(View(dailyPromoterPlans.ToList())); }