/// <summary> /// 修改个人资料 /// </summary> /// <param name="mode"></param> /// <returns></returns> public JsonResult MobileSaveUserEdit(EditUserInfo mode) { ReturnJson r = new ReturnJson() { s = "ok", r = "修改成功!" }; var querypsw = db.userinfoes.Where(p => p.LoginName == mode.LoginName).FirstOrDefault(); try { querypsw.DOTA2ID = mode.DOTA2ID; querypsw.PubgID = mode.PubgID; querypsw.Email = mode.Email; querypsw.Name = mode.userName; db.userinfoes.Attach(querypsw); db.Entry(querypsw).Property(x => x.DOTA2ID).IsModified = true; db.Entry(querypsw).Property(x => x.PubgID).IsModified = true; db.Entry(querypsw).Property(x => x.Email).IsModified = true; db.Entry(querypsw).Property(x => x.Name).IsModified = true; db.SaveChanges(); return(Json(r)); } catch (Exception ex) { r.r = "修改失败," + ex.Message; r.s = "error"; return(Json(r)); } }
private void EditMenubutton_Click(object sender, RoutedEventArgs e) { EditUserInfo editUserInfo = new EditUserInfo(this, cl); editUserInfo.Show(); this.Hide(); }
void UploadProfileImage(EditUserInfo info, string path) { if (path != null) { // Crop and Resize image System.Drawing.Image img = ProcessImage(path); if (img != null) { // Generate random file name for processed/temp image (to be saved in temp folder) string newFilename = String_Functions.RandomString(20); // Get file extension of original file string ext = Path.GetExtension(path); // Make sure Temp directory exists FileLocations.CreateTempDirectory(); // Create new full path of temp file string localPath = Path.Combine(FileLocations.TrakHoundTemp, newFilename); //if (ext != null) localPath += "." + ext; if (ext != null) { localPath = Path.ChangeExtension(localPath, ext); } // Save the processed image to the new temp path img.Save(localPath); // Create a temp UserConfiguration object to pass the current SessionToken to the Files.Upload() method var userConfig = new UserConfiguration(); userConfig.SessionToken = info.SessionToken; // Set the HTTP Content Type based on the type of image string contentType = null; if (ext == "jpg") { contentType = "image/jpeg"; } else if (ext == "png") { contentType = "image/png"; } else if (ext == "gif") { contentType = "image/gif"; } var fileData = new HTTP.FileContentData("uploadimage", localPath, contentType); // Upload File var uploadInfos = TrakHound.API.Files.Upload(userConfig, fileData); if (uploadInfos != null && uploadInfos.Length > 0) { string fileId = uploadInfos[0].Id; info.ImageUrl = fileId; } } } }
void Excursie_ClientGetMessage(object sender, GetMessageEventArgs e) { switch (e.Messages[0]) { case _Details.GetUserDataByPhone: { string UserPhone = e.Messages[1]; foreach (TripClient tClient in ClientsList) { if (tClient.TClientData.NumarTelefon.Equals(UserPhone)) { using (SqlConnection Database = new SqlConnection(_Details.DatabaseConnectionString)) { Database.Open(); string t = "SELECT * FROM Utilizatori WHERE [NumarTelefon]='" + tClient.NumarTelefon + "'"; SqlCommand cmd = new SqlCommand(t, Database); SqlDataReader Reader = cmd.ExecuteReader(); if (Reader.Read()) { string UserNume = (string)Reader[0]; string UserPrenume = (string)Reader[1]; string UserVarsta = (string)Reader[2]; string UserSex = (string)Reader[3]; string UserEmail = (string)Reader[4]; string[] RegularData = new string[] { _Details.GetUserDataByPhone, UserNume, UserPrenume, UserVarsta, UserSex, UserEmail }; tClient.OUTPUT_SEND(RegularData); } } } } } break; case _Details.EditUserInfo: { EditUserInfo.Handle(e.Messages, ClientsList); } break; default: { foreach (TripClient t in ClientsList.ToList()) { t.OUTPUT_SEND(e.Messages); } } break; } }
private void UpdateProfileImage_Worker(object o) { var updateInfo = (UpdateProfileImageInfo)o; var info = new EditUserInfo(); info.SessionToken = updateInfo.UserSessionToken; UploadProfileImage(info, updateInfo.ImagePath); var userConfig = UserManagement.EditUser(info, "TrakHound Client Edit User"); Dispatcher.BeginInvoke(new Action <UserConfiguration>(UpdateProfileImage_Finished), System.Windows.Threading.DispatcherPriority.Background, new object[] { userConfig }); }
EditUserInfo NewEditUserInfo() { var info = new EditUserInfo(); info.SessionToken = CurrentUser.SessionToken; info.FirstName = FirstName; info.LastName = LastName; if (ShowChangePassword) { info.Password = password_TXT.PasswordText; } info.Company = Company; info.Email = Email; info.Phone = Phone; info.Address1 = Address1; info.Address2 = Address2; info.City = City; if (country_COMBO.SelectedItem != null) { info.Country = country_COMBO.SelectedItem.ToString(); } else { info.Country = ""; } if (state_COMBO.SelectedItem != null) { info.State = state_COMBO.SelectedItem.ToString(); } else { info.State = ""; } info.Zipcode = ZipCode; return(info); }
private EditUserInfo GetUserInfo() { if (Session[UserInfoSessionKey] == null || !(Session[UserInfoSessionKey] is EditUserInfo)) Session[UserInfoSessionKey] = new EditUserInfo(); return (EditUserInfo) Session[UserInfoSessionKey]; }
void EditUser(EditUserInfo info) { Saving = true; ThreadPool.QueueUserWorkItem(new WaitCallback(EditUser_Worker), info); }