public EfUser Toentity(UserJson Domainobj) { var entity = new EfUser(); fillentity(entity, Domainobj); return(entity); }
public UserData Import (IDataStoreContext ctx, UserJson json, Guid? localIdHint = null, UserData mergeBase = null) { var data = GetByRemoteId<UserData> (ctx, json.Id.Value, localIdHint); var merger = mergeBase != null ? new UserMerger (mergeBase) : null; if (merger != null && data != null) merger.Add (new UserData (data)); if (json.DeletedAt.HasValue) { if (data != null) { ctx.Delete (data); data = null; } } else if (merger != null || ShouldOverwrite (data, json)) { data = data ?? new UserData (); ImportJson (ctx, data, json); if (merger != null) { merger.Add (data); data = merger.Result; } data = ctx.Put (data); } return data; }
public async Task <ResponseMessage <UserJson> > Get([FromBody] UserJson user) { // 日志输出:请求体 Console.WriteLine("WS------ Request: \r\n" + user); // 创建响应体 ResponseMessage <UserJson> response = new ResponseMessage <UserJson>(); // 模型验证 if (!Util.ModelValidCheck(ModelState, response)) { return(response); } try { /// 业务处理 response.Extension = await Manager.GetUserJson(response, user); } catch (Exception e) { response.Code = ResponseDefine.ServiceError; response.Message += "\r\n" + e.Message; // 日志输出:服务器错误 Console.WriteLine("WS------ ServiceError: \r\n" + e); } if (response.Extension == null) { response.Code = ResponseDefine.NotFound; // 日志输出:找不到资源 Console.WriteLine("WS------ NotFund: \r\n" + ""); } // 日志输出:响应体 Console.WriteLine("WS------ Response: \r\n" + response != null ? JsonUtil.ToJson(response) : ""); return(response); }
void Start() { // Load User path = Application.persistentDataPath + "\\user.json"; if (File.Exists(path)) { string contents = File.ReadAllText(path); userJson = JsonUtility.FromJson <UserJson>(contents); if (part == Part.Body) { string folderSkins = Directory.GetParent(Application.dataPath).ToString() + "\\Skins\\"; if (File.Exists(folderSkins + userJson.skin)) { Texture2D textureSkin = new Texture2D(0, 0); textureSkin.LoadImage(File.ReadAllBytes(folderSkins + userJson.skin)); gameObject.GetComponent <MeshRenderer>().material.mainTexture = textureSkin; } } if (part == Part.Arm) { gameObject.GetComponent <MeshRenderer>().material.color = userJson.armColor; transform.GetChild(0).GetComponent <MeshRenderer>().material.color = userJson.gloveColor; } } if (part == Part.Body) { gameObject.GetComponent <MeshRenderer>().enabled = true; } }
void OnPlayerMove(string data) { //print("WebSocketManager OnPlayerMove: START"); //print("WebSocketManager OnPlayerMove: Received string: " + data); UserJson userJSON = UserJson.CreateFromJson(data); // if it is the current player, exit if (userJSON.name == playerNameStr) { return; } GameObject p = GameObject.Find(userJSON.name) as GameObject; if (p != null) { //print("Got userJSON: " + userJSON); Vector3 position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]); Vector2 velocity = new Vector2(userJSON.velocity[0], userJSON.velocity[1]); Vector2 acceleration = new Vector2(userJSON.acceleration[0], userJSON.acceleration[1]); Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]); CarController carController = p.GetComponent <CarController>(); carController.updateDestination(position, velocity, acceleration, rotation); // Send back an ack to the player that sent this message to get a RTT estimate simStepAckJson simStepAck = new simStepAckJson(userJSON.simulationStep, userJSON.name); Dispatch("ackMessage", JsonUtility.ToJson(simStepAck), true); } }
public static UserData Import(this UserJson json, IDataStoreContext ctx, Guid?localIdHint = null, UserData mergeBase = null) { var converter = ServiceContainer.Resolve <UserJsonConverter> (); return(converter.Import(ctx, json, localIdHint, mergeBase)); }
public async Task <IActionResult> Edit(string id, [Bind("Id,SignName,PassWord")] UserJson user) { Logger.Trace($"[{nameof(Edit)}] 用户[{SignUser.SignName}]({SignUser.Id})编辑用户({id}) 请求参数:\r\n" + JsonUtil.ToJson(user)); // 0. 参数检查 if (id != user.Id) { return(NotFound()); } try { // 1. 权限验证 if (!await RoleOrgPerManager.HasPermissionInSelfOrg(SignUser.Id, Constants.USER_UPDATE)) { Logger.Warn($"[{nameof(Edit)}] 没有权限"); ModelState.AddModelError("All", "没有权限"); return(RedirectToAction(nameof(Index))); } // 2. 业务处理 await UserManager.Update(user); // 编辑成功 -跳转到用户列表 return(RedirectToAction(nameof(Index))); } catch (Exception e) { Logger.Error($"[{nameof(Edit)}] 用户信息更新失败: " + e); if (!await UserManager.ExistById(user.Id)) { return(NotFound()); } ModelState.AddModelError("All", "用户信息更新失败"); return(View(user)); } }
public User(UserJson userJson) { this.Login = userJson.login; this.ID = userJson.id; this.AvatarUrl = userJson.avatar_url; this.GravatarId = userJson.gravatar_id; this.Url = userJson.url; this.HtmlUrl = userJson.html_url; this.FollowersUrl = userJson.followers_url; this.FollowingUrl = userJson.following_url; this.GistsUrl = userJson.gists_url; this.StarredUrl = userJson.starred_url; this.SubscriptionsUrl = userJson.subscriptions_url; this.ReposUrl = userJson.repos_url; this.EventsUrl = userJson.events_url; this.ReceivedEventsUrl = userJson.received_events_url; this.Type = userJson.type; this.SiteAdmin = userJson.site_admin; this.Name = userJson.name; this.Company = userJson.company; this.Blog = userJson.blog; this.Location = userJson.location; this.Email = userJson.email; this.Hireable = userJson.hireable; this.Bio = userJson.bio; this.PublicRepos = userJson.public_repos; this.PublicGists = userJson.public_gists; this.Followers = userJson.followers; this.Following = userJson.following; this.CreatedAt = userJson.created_at; this.UpdatedAt = userJson.updated_at; }
/// <summary> /// Set the current session's Google OAuth 2.0 token and the corresponding user in the database /// </summary> /// <param name="token"></param> private static void SetSession(TokenJson token) { System.Web.HttpContext.Current.Session["token"] = token; if (token != null) { UserJson googleUser = GoogleInterface.GetUserInfo(token); if (String.IsNullOrEmpty(googleUser.email)) { throw new ArgumentNullException("Could not get user's email from Google."); } List <User> dbUsers = Db.Db.GetUsersSearch(googleUser.email, null); if (dbUsers.Count == 0) { throw new ArgumentException("User with email (" + googleUser.email + ") could not be found in the database."); } User curUser = dbUsers[0];//current user for this session //update the user's picture in the database if needed if (!String.IsNullOrEmpty(googleUser.picture) && (String.IsNullOrEmpty(curUser.PhotoUrl) || !curUser.PhotoUrl.Equals(googleUser.picture))) { curUser.PhotoUrl = googleUser.picture; Db.Db.UpdateUser(curUser); } System.Web.HttpContext.Current.Session["user"] = curUser; } else { System.Web.HttpContext.Current.Session["user"] = null; } }
public void ImportUpdatedKeepDirtyLocal() { RunAsync(async delegate { var workspaceData = await DataStore.PutAsync(new WorkspaceData() { RemoteId = 1, Name = "Test", ModifiedAt = new DateTime(2014, 1, 2), }); var userData = await DataStore.PutAsync(new UserData() { RemoteId = 1, Name = "", DefaultWorkspaceId = workspaceData.Id, ModifiedAt = new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc), IsDirty = true, }); var userJson = new UserJson() { Id = 1, Name = "John", DefaultWorkspaceId = 1, ModifiedAt = new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc).ToLocalTime(), }; userData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, userJson)); Assert.AreEqual("", userData.Name); Assert.AreEqual(new DateTime(2014, 1, 2, 10, 0, 0, DateTimeKind.Utc), userData.ModifiedAt); }); }
public void ImportNew() { RunAsync(async delegate { var workspaceData = await DataStore.PutAsync(new WorkspaceData() { RemoteId = 1, Name = "Test", ModifiedAt = new DateTime(2014, 1, 2), }); var userJson = new UserJson() { Id = 1, Name = "John", DefaultWorkspaceId = 1, ModifiedAt = new DateTime(2014, 1, 4), }; var userData = await DataStore.ExecuteInTransactionAsync(ctx => converter.Import(ctx, userJson)); Assert.AreNotEqual(Guid.Empty, userData.Id); Assert.AreEqual(1, userData.RemoteId); Assert.AreEqual("John", userData.Name); Assert.AreEqual(new DateTime(2014, 1, 4), userData.ModifiedAt); Assert.IsFalse(userData.IsDirty); Assert.IsFalse(userData.RemoteRejected); Assert.IsNull(userData.DeletedAt); }); }
public async Task <ActionResult> Login(string email, string password) { var result = await SignInManager.PasswordSignInAsync(email, password, false, shouldLockout : false); var userJson = new UserJson(); if (result == SignInStatus.Success) { var handler = new APIHandler { Action = "company/login/", Values = new JavaScriptSerializer().Serialize(new { username = email, password = password, companyDomain = "veloly" }) }; var jObject = JObject.Parse(await handler.RequestPostAsync()); string nokeId = string.Empty; if (jObject != null) { if (!jObject["result"].Value <string>().Equals("failure")) { nokeId = jObject["user"]["id"].Value <string>(); } } userJson = new UserJson { UserId = (await UserManager.FindByEmailAsync(email)).Id, Email = email, NokeId = nokeId }; } return(View("User", userJson)); }
public async Task <AuthResult> NoUserSetupAsync() { IsAuthenticating = true; //Create dummy user and workspace. var userJson = new UserJson() { Id = 100, Name = OfflineUserName, StartOfWeek = DayOfWeek.Monday, Locale = "", Email = OfflineUserEmail, Password = "******", Timezone = Time.TimeZoneId, DefaultWorkspaceId = 1000 }; var workspaceJson = new WorkspaceJson() { Id = 1000, Name = OfflineWorkspaceName, IsPremium = false, IsAdmin = false }; try { // Import the user into our database: UserData userData; try { var dataStore = ServiceContainer.Resolve <IDataStore> (); userData = await dataStore.ExecuteInTransactionAsync(ctx => userJson.Import(ctx)); await dataStore.ExecuteInTransactionAsync(ctx => workspaceJson.Import(ctx)); } catch (Exception ex) { var log = ServiceContainer.Resolve <ILogger> (); log.Error(Tag, ex, "Failed to import authenticated user."); ServiceContainer.Resolve <MessageBus> ().Send( new AuthFailedMessage(this, AuthResult.SystemError, ex)); return(AuthResult.SystemError); } var credStore = ServiceContainer.Resolve <ISettingsStore> (); credStore.UserId = userData.Id; credStore.ApiToken = userJson.ApiToken; credStore.OfflineMode = userData.Name == OfflineUserName; credStore.HasEntries = false; User = userData; Token = userJson.ApiToken; OfflineMode = userData.Name == OfflineUserName; IsAuthenticated = true; ServiceContainer.Resolve <MessageBus> ().Send( new AuthChangedMessage(this, AuthChangeReason.NoUser)); } finally { IsAuthenticating = false; } return(AuthResult.Success); }
public Task <UserJson> CreateUser(UserJson jsonObject) { var url = new Uri(v8Url, jsonObject.GoogleAccessToken != null ? "signups?app_name=toggl_mobile" : "signups"); jsonObject.CreatedWith = String.Format("{0}-obm-{1}", Platform.DefaultCreatedWith, OBMExperimentManager.ExperimentNumber); return(CreateObject(url, jsonObject)); }
void OnWeaponRotateAndFire(string data) { print("Player weapon rotated and possibly fired"); UserJson userJson = UserJson.CreateFromJson(data); // todo weapon rotates and fires (true/false), use or rework BulletJson? }
public Task <UserJson> CreateUser(UserJson jsonObject) { var url = new Uri(v8Url, jsonObject.GoogleAccessToken != null ? "signups?app_name=toggl_mobile" : "signups"); jsonObject.CreatedWith = Platform.DefaultCreatedWith; return(CreateObject(url, jsonObject)); }
public async Task <IActionResult> CheckinAsync(IFormFile file) { try { var info = string.Empty; using (var memoryStream = new MemoryStream()) { await file.CopyToAsync(memoryStream); var img = (Bitmap)Image.FromStream(memoryStream); info = RetrieveInfo(img); } var checkinUser = new UserJson(); if (!string.IsNullOrEmpty(info)) { checkinUser = JsonConvert.DeserializeObject <UserJson>(info); } user = CheckinUser(checkinUser); if (string.IsNullOrEmpty(user.username)) { return(RedirectToAction("Index")); } return(View(user)); } catch { return(RedirectToAction("Index")); } }
private async void ExecuteLoginCommand() { try { Body = false; Load = true; if (!CrossConnectivity.Current.IsConnected) { DialogParameters param = new DialogParameters { { "Message", "Sem conexão com a internet" }, { "Title", "Erro" }, { "Icon", IconTheme.IconName("bug") } }; DialogService.ShowDialog("DialogPage", param, CloseDialogCallback); } else { User = await HeritageAPIService.UserLogin(User); if (User == null) { DialogParameters param = new DialogParameters { { "Message", "Email ou senha incorretos" }, { "Title", "Erro" }, { "Icon", IconTheme.IconName("bug") } }; DialogService.ShowDialog("DialogPage", param, CloseDialogCallback); } else { if (Application.Current.Properties.ContainsKey("Login")) { Application.Current.Properties["Login"] = IsChecked; } else { Application.Current.Properties.Add("Login", IsChecked); } UserJson.SetUsuarioJson(User); await NavigationService.NavigateAsync(new Uri("https://www.Heritage/Menu/NavigationPage/Main", UriKind.Absolute)); } } } catch (Exception ex) { Console.WriteLine($"Ocorreu um erro ao baixar os dados: {ex.Message}, Página: Login"); } finally { Body = true; Load = false; } }
public DisplayHeritage() { InitializeComponent(); UserJson jsonUsuario = new UserJson(); User = jsonUsuario.GetUsuarioJson(); }
private User CheckinUser(UserJson juser) { User user = new User(); var duser = GetCheckedInUser(juser); user = GetCurrCheckedUser(duser); return(user); }
public override void Initialize(INavigationParameters parameters) { User = new User(); UserJson = new UserJson(); IconTheme = new IconTheme(); Body = true; }
public DisplayEnvironment() { InitializeComponent(); UserJson userJson = new UserJson(); User = userJson.GetUsuarioJson(); }
/// <summary> /// Get the JSON user /// </summary> /// <param name="username">The user you want to retrieve</param> private JsonUser GetUser(string username) { if (!string.IsNullOrEmpty(username)) { return(UserJson.GetUser(username)); } return(null); }
public DisplaySupport() { InitializeComponent(); UserJson userJson = new UserJson(); User = userJson.GetUsuarioJson(); }
/// <summary> /// 通过或运算来查询User /// </summary> /// <param name="response"></param> /// <param name="userJson"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public IQueryable <User> GetUsersOr([Required] ResponseMessage response, [Required] UserJson userJson, CancellationToken cancellationToken = default(CancellationToken)) { // 放到Store中去 var query = from u in TheUsers.Context.Users where u.Id == userJson.Id || u.Name == userJson.Name || u.Email == userJson.Email // those value is only one in db select new User(u); return(query); }
public UserJson GetByFullQualify(string fullQualifyName) { var result = new UserJson(); UserRepository _UserRepository = new UserRepository(); UserTranslator _UserTranslator = new UserTranslator(); result = _UserTranslator.ToDomainObject(_UserRepository.GetByFullQualify(fullQualifyName)); return(result); }
public void getUserData() { UserJson user = (UserJson)dataManager.GetComponent <StaticDataManager>().dataMap["user"]; transportManager.GetComponent <Transport>().SendGet("/api/user/" + user.id, new UserJson(), (result) => { dataManager.GetComponent <StaticDataManager>().dataMap["user"] = (UserJson)result; }); }
public static UserJson GetUserDetail(string accessToken, string openId, Language lang = Language.zh_CN) { string url = string.Format("https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang={2}", accessToken, openId, lang.ToString()); UserJson result = JsonHelper.ConvertJson <UserJson>(url); return(result); }
void Start() { DontDestroyOnLoad(this); myObject = new UserJson(); socket = gameObject.GetComponent <SocketIOComponent>(); socket.On("logged", OnLogin); socket.On("noUsername", OnLoginFailed); socket.On("rivalPosition", OnRivalPosition); }
private string TryGetValue(string propertyName) { JToken t; if (UserJson.TryGetValue(propertyName, out t)) { return(t.ToString()); } return(String.Empty); }
private IEnumerable<TimeEntryJson> GetChangesTimeEntryObjects (JToken json, UserJson user) { if (json == null) { return Enumerable.Empty<TimeEntryJson> (); } return json.ToObject<List<TimeEntryJson>> ().Select ((te) => { te.UserId = user.Id.Value; return te; }); }
public string DisplayJSON() { List<UserJson> l = new List<UserJson>(); foreach (Account acc in _accounts) { UserJson uj = new UserJson(); uj.name = acc.UserName; uj.image = acc.ImageUrl; l.Add(uj); } JavaScriptSerializer js = new JavaScriptSerializer(); StringBuilder sb = new StringBuilder(); js.Serialize(l, sb); return sb.ToString(); }
private static void ImportJson (IDataStoreContext ctx, UserData data, UserJson json) { var defaultWorkspaceId = GetLocalId<WorkspaceData> (ctx, json.DefaultWorkspaceId); data.Name = json.Name; data.Email = json.Email; data.StartOfWeek = json.StartOfWeek; data.DateFormat = json.DateFormat; data.TimeFormat = json.TimeFormat; data.ImageUrl = json.ImageUrl; data.Locale = json.Locale; data.Timezone = json.Timezone; data.SendProductEmails = json.SendProductEmails; data.SendTimerNotifications = json.SendTimerNotifications; data.SendWeeklyReport = json.SendWeeklyReport; data.TrackingMode = json.StoreStartAndStopTime ? TrackingMode.StartNew : TrackingMode.Continue; data.DefaultWorkspaceId = defaultWorkspaceId; ImportCommonJson (data, json); }
public UserData Import (IDataStoreContext ctx, UserJson json, Guid? localIdHint = null, UserData mergeBase = null) { var log = ServiceContainer.Resolve<ILogger> (); var data = GetByRemoteId<UserData> (ctx, json.Id.Value, localIdHint); var merger = mergeBase != null ? new UserMerger (mergeBase) : null; if (merger != null && data != null) { merger.Add (new UserData (data)); } if (json.DeletedAt.HasValue) { if (data != null) { log.Info (Tag, "Deleting local data for {0}.", data.ToIdString ()); ctx.Delete (data); data = null; } } else if (merger != null || ShouldOverwrite (data, json)) { data = data ?? new UserData (); ImportJson (ctx, data, json); if (merger != null) { merger.Add (data); data = merger.Result; } if (merger != null) { log.Info (Tag, "Importing {0}, merging with local data.", data.ToIdString ()); } else { log.Info (Tag, "Importing {0}, replacing local data.", data.ToIdString ()); } data = ctx.Put (data); } else { log.Info (Tag, "Skipping import of {0}.", json.ToIdString ()); } return data; }