public ActionResult Edit_get(int id) { PersonLayer cpersonlayer = new PersonLayer(); PersonProperties cpersonproperties = cpersonlayer.person_layer.Single(p => p.ID == id); return(View(cpersonproperties)); }
/// <summary> /// Get current user's manager /// </summary> /// <returns></returns> private string GetCurrentUserManager() { var ownerEmail = string.Empty; try { var spContext = SharePointContextProvider.Current.GetSharePointContext(Context); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetMyProperties(); clientContext.Load(personProperties); clientContext.ExecuteQuery(); foreach (var item in personProperties.UserProfileProperties) { if (item.Key == "Manager") { ownerEmail = item.Value; break; } } } } catch (Exception ex) { Log.LogFileSystem(string.Format("Error happened in getting Current User Manager - {0}", ex.Message) + DateTime.Now.ToString()); } return(ownerEmail); }
static void PP(ClientContext clientContext, string targetUser) { PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetPropertiesFor(targetUser); // Load the request and run it on the server. // This example requests only the AccountName and UserProfileProperties // properties of the personProperties object. clientContext.Load(personProperties, p => p.AccountName, p => p.UserProfileProperties); clientContext.ExecuteQuery(); try { foreach (var property in personProperties.UserProfileProperties) { if (property.Key.ToString().ToLower().Contains("personalspace")) { Console.WriteLine(string.Format("{0}: {1}", property.Key.ToString(), property.Value.ToString())); Console.WriteLine(targetUser); //Download(property.Value.ToString().Replace("MThumb","Lthumb"), targetUser); } } } catch (Exception e) { Console.WriteLine("Exception"); } //Console.ReadKey(false); }
public IEnumerable <Person> GetFilteredPeople(PersonProperties property, string value, bool isJustFilter) { var list = _peopleList .Where(p => ReturnStringPropertyValue(p, property).ToLower().Contains(value.ToLower())); return(!isJustFilter ? list : list.OrderBy(p => p.Surname)); }
public static void GetUserProfiles(ClientContext clientContext) { // Replace the following placeholder values with the target SharePoint site and // target user. // const string serverUrl = "http://serverName/"; const string targetUser = "******"; // Connect to the client context. // ClientContext clientContext = new ClientContext(serverUrl); // Get the PeopleManager object and then get the target user's properties. PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetPropertiesFor(targetUser); // Load the request and run it on the server. // This example requests only the AccountName and UserProfileProperties // properties of the personProperties object. clientContext.Load(personProperties, p => p.AccountName, p => p.UserProfileProperties); clientContext.ExecuteQuery(); foreach (var property in personProperties.UserProfileProperties) { Console.WriteLine(string.Format("{0}: {1}", property.Key.ToString(), property.Value.ToString())); } }
public Arena(ArenaProperties props) { _state = new PopulationState(); _state.StartPopulation = props.Population; _arenaRectTransform = props.ArenaObject.transform as RectTransform; if (_arenaRectTransform == null) { throw new Exception("_arenaRectTransform is null"); } _moveController = new MoveController(_arenaRectTransform); _arenaRectTransform.sizeDelta = new Vector2(props.WorldWidth, props.WorldHeight); var rand = new Random(); for (int i = 0; i < props.Population; i++) { var personProps = new PersonProperties(); if (rand.NextDouble() > props.PercentAtIsolation) { personProps.Speed = (float)(props.PersonSpeed + rand.NextDouble() * props.PersonSpeed); } else { personProps.Speed = 0; } personProps.PersonPrefab = props.PersonObject; var person = ArenaUtils.CreatePerson(personProps, _arenaRectTransform); _persons.Add(person); } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { string hostweburl = Request["SPHostUrl"]; string appweburl = Request["SPAppWebUrl"]; //get context token for var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request); string userAcctName = string.Empty; using (var clientContext = TokenHelper.GetClientContextWithContextToken(appweburl, contextToken, Request.Url.Authority)) { //// PeopleManager class provides the methods for operations related to people PeopleManager peopleManager = new PeopleManager(clientContext); //// PersonProperties class is used to represent the user properties //// GetMyProperties method is used to get the current user's properties PersonProperties personProperties = peopleManager.GetMyProperties(); clientContext.Load(personProperties, p => p.AccountName); clientContext.ExecuteQuery(); userAcctName = personProperties.AccountName; //userLogin.Text = userAcctName; //lblUserLogin.Text = userAcctName; } } }
protected string GetCurrentUserEmail() { var ownerEmail = string.Empty; try { var spContext = SharePointContextProvider.Current.GetSharePointContext(Context); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetMyProperties(); clientContext.Load(personProperties); clientContext.ExecuteQuery(); foreach (var item in personProperties.UserProfileProperties) { if (item.Key == "WorkEmail") { ownerEmail = item.Value; break; } } } } catch (Exception) { } return(ownerEmail); }
/// <summary> /// Shows the profile picture on the app header and persona flyout. /// </summary> /// <param name="clientContext">The client context.</param> /// <param name="refreshToken">The refresh token</param> private void ShowProfilePicture(ClientContext clientContext, string refreshToken) { PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetMyProperties(); ///// Load users my site URL clientContext.Load(personProperties); clientContext.ExecuteQuery(); string personalURL = personProperties.PersonalUrl.ToUpperInvariant().TrimEnd('/'); string[] pictureInfo = personalURL.Split(new string[] { UIConstantStrings.PersonalURLSeparator.ToUpperInvariant() }, StringSplitOptions.None); PersonaTitle.InnerHtml = personProperties.DisplayName; PersonaTitle.Attributes.Add(UIConstantStrings.titleAttribute, personProperties.DisplayName); PersonaEmail.InnerHtml = personProperties.Email; PersonaEmail.Attributes.Add(UIConstantStrings.titleAttribute, personProperties.Email); if (null != refreshToken && 2 == pictureInfo.Length) { using (ClientContext oneDriveClientContext = ServiceUtility.GetClientContext(null, new Uri(pictureInfo[0]), refreshToken, this.Request)) { string profilePictureURL = String.Format(CultureInfo.InvariantCulture, UIConstantStrings.UserPhotoURL, pictureInfo[1], UIConstantStrings.userPhotoSmall); string smallImageContent = UIUtility.GetImageInBase64Format(oneDriveClientContext, profilePictureURL); if (!string.IsNullOrWhiteSpace(smallImageContent)) { AppHeaderPersona.Src = smallImageContent; } profilePictureURL = String.Format(CultureInfo.InvariantCulture, UIConstantStrings.UserPhotoURL, pictureInfo[1], UIConstantStrings.userPhotoMedium); string mediumImageContent = UIUtility.GetImageInBase64Format(oneDriveClientContext, profilePictureURL); if (!string.IsNullOrWhiteSpace(mediumImageContent)) { PersonaPicture.Src = mediumImageContent; } } } }
protected void btnScenario3_Click(object sender, EventArgs e) { var spContext = SharePointContextProvider.Current.GetSharePointContext(Context); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { // Get the people manager instance for current context to get account name PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetMyProperties(); clientContext.Load(personProperties, p => p.AccountName); clientContext.ExecuteQuery(); // Collect values for profile update List <string> skills = new List <string>(); for (int i = 0; i < lstSkills.Items.Count; i++) { skills.Add(lstSkills.Items[i].Value); } // Update the SPS-Skills property for the user using account name from profile. peopleManager.SetMultiValuedProfileProperty(personProperties.AccountName, "SPS-Skills", skills); clientContext.ExecuteQuery(); //Refresh the values RefreshUIValues(); } }
public bool UpdatePerson(PersonProperties personProperties) { var person = this.GetPersonByGuid(personProperties.Guid); if (person == null) { return(false); } // Save the person as a JSON local file var source = person.Source; var folder = person._folder; person.Source = PersonDBSource.LOCAL_FILE_SYSTEM; person._folder = Environment.GetEnvironmentVariable("TEMP"); person.Properties = personProperties; person.SaveAsJsonToLocalFolder(); // Upload the json local file to Azure storage GetBlobManager().UploadJsonFileAsync(person.GetPropertiesJsonFile(), overide: true).GetAwaiter().GetResult(); File.Delete(person.GetPropertiesJsonFile()); // Save the global json file in Azure storage person.Source = source; person._folder = folder; this.SaveJsonDBInAzure(); return(true); }
private void GetUserDetails() { var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { if (clientContext != null) { PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties properties = peopleManager.GetMyProperties(); clientContext.Load(properties); clientContext.ExecuteQuery(); UserInfo userInfo = new UserInfo() { DisplayName = properties.DisplayName, PhotoUrl = spContext.SPHostUrl + "/_layouts/userphoto.aspx?accountname=" + properties.Email, LastPing = DateTime.Now }; HttpRuntime.Cache.Add(properties.AccountName, userInfo, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 3, 0), CacheItemPriority.Normal, new CacheItemRemovedCallback(CacheRemovalCallback)); Session["UserAccountName"] = properties.AccountName; } } }
public async Task <ActionResult <IEnumerable <Person> > > GetAll( [FromQuery(Name = "ps")] PersonProperties property, [FromQuery(Name = "desc")] bool desc) { var response = await Task.Run(() => _people.GetOrderedList(property, desc)); return(Ok(response)); }
public static Person CreatePerson(PersonProperties props, RectTransform parent) { var parentRect = parent.rect; var personObject = Object.Instantiate(props.PersonPrefab, parent); // personObject.transform.localPosition = Utils.GetRandom2dPoint(parentRect); var p = new Person(personObject.GetComponent <PersonComponent>(), props, parentRect); return(p); }
public async Task <ActionResult <IEnumerable <Person> > > GetFiltered ([FromQuery(Name = "pf")] PersonProperties property, [FromQuery(Name = "value")] string value) { var response = await Task.Run(() => _people.GetFilteredPeople(property, value, true)); return(Ok(response)); }
private static string ReturnStringPropertyValue(Person person, PersonProperties property) { var value = ReturnPropertyValue(person, property); return(property switch { PersonProperties.Birthday => value.ToString("o"), _ => value.ToString() });
public ActionResult Create(PersonProperties CpersonProperties) { if (ModelState.IsValid) { PersonLayer personlayer = new PersonLayer(); personlayer.AddPerson(CpersonProperties); return(RedirectToAction("Index")); } return(View()); }
public Person(PersonComponent component, PersonProperties props, Rect bounds) { Props = props; _component = component; _component.Person = this; _bounds = bounds; _transform = component.transform; _state = new PersonState(); updateView(); }
public ActionResult Edit_post(PersonProperties cPersonProperties) { if (ModelState.IsValid) { PersonLayer cpersonlayer = new PersonLayer(); cpersonlayer.Editperson(cPersonProperties); return(RedirectToAction("Index")); } return(View(cPersonProperties)); }
public async Task <ActionResult <IEnumerable <Person> > > GetFilSorted ([FromQuery(Name = "pf")] PersonProperties propertyF, [FromQuery(Name = "value")] string value, [FromQuery(Name = "ps")] PersonProperties propertyS, [FromQuery(Name = "desc")] bool desc) { var response = await Task.Run(() => _people.GetFilteredAndOrderedPeople(propertyF, value, propertyS, desc)); return(Ok(response)); }
public static string GetUserProfileUrl(this PersonProperties props) { if (props.IsPropertyAvailable("UserUrl")) { return(props.UserUrl); } else { return(string.Empty); } }
public static PersonProperties GetSingleUsersProfileProperties(ClientContext context, string emailId) { // Get the PeopleManager object and then get the target user's properties. PeopleManager peopleManager = new PeopleManager(context); PersonProperties userProperties = peopleManager.GetPropertiesFor("i:0#.f|membership|" + emailId); // This request load the AccountName and user's all other Profile Properties context.Load(userProperties, p => p.AccountName, p => p.UserProfileProperties); context.ExecuteQuery(); return(userProperties); }
static void GetUserProfileProperties(string siteUrl, string userName, string userPassword) { try { // get client context ClientContext context = GetUserContext(siteUrl, userName, userPassword); // user account name in Claims format string accountName = "i:0#.f|membership|[email protected]"; // skills values List <string> skills = new List <string>(); skills.Add("SharePoint"); skills.Add("CSOM"); skills.Add("JavaScript"); // Get the PeopleManager object and then get the target user's properties. PeopleManager peopleManager = new PeopleManager(context); // set single value profile property peopleManager.SetSingleValueProfileProperty(accountName, "AboutMe", "I love SharePoint!"); // set multi value profile property peopleManager.SetMultiValuedProfileProperty(accountName, "SPS-Skills", skills); context.ExecuteQuery(); // Get properties PersonProperties personProperties = peopleManager.GetPropertiesFor(accountName); // properties of the personProperties object. context.Load(personProperties, p => p.AccountName, p => p.UserProfileProperties); context.ExecuteQuery(); foreach (var property in personProperties.UserProfileProperties) { Console.WriteLine(string.Format("{0}: {1}", property.Key.ToString(), property.Value.ToString())); } } catch (ClientRequestException clientEx) { Console.WriteLine("Client side error occurred: {0} \n{1} " + clientEx.Message + clientEx.InnerException); throw clientEx; } catch (ServerException serverEx) { Console.WriteLine("Server side error occurred: {0} \n{1} " + serverEx.Message + serverEx.InnerException); throw serverEx; } }
//gavdcodeend 26 //gavdcodebegin 27 static void SpCsCsomUpdateOnePropertyUserProfile(ClientContext spCtx) { PeopleManager myPeopleManager = new PeopleManager(spCtx); PersonProperties myUserProperties = myPeopleManager.GetMyProperties(); spCtx.Load(myUserProperties, prop => prop.AccountName); spCtx.ExecuteQuery(); string newValue = "I am the administrator"; myPeopleManager.SetSingleValueProfileProperty( myUserProperties.AccountName, "AboutMe", newValue); spCtx.ExecuteQuery(); }
//gavdcodeend 24 //gavdcodebegin 25 static void SpCsCsomGetAllMyPropertiesUserProfile(ClientContext spCtx) { PeopleManager myPeopleManager = new PeopleManager(spCtx); PersonProperties myUserProperties = myPeopleManager.GetMyProperties(); spCtx.Load(myUserProperties, prop => prop.AccountName, prop => prop.UserProfileProperties); spCtx.ExecuteQuery(); foreach (var oneProperty in myUserProperties.UserProfileProperties) { Console.WriteLine(oneProperty.Key.ToString() + " - " + oneProperty.Value.ToString()); } }
public IEnumerable <Person> GetOrderedList(PersonProperties propertyToSort, bool descending, IEnumerable <Person> list = null) { list ??= _peopleList; if (descending) { return(list .OrderByDescending(p => ReturnPropertyValue(p, propertyToSort))); } return(list .OrderBy(p => ReturnPropertyValue(p, propertyToSort))); }
protected void RefreshUIValues() { var spContext = SharePointContextProvider.Current.GetSharePointContext(Context); using (var clientContext = spContext.CreateUserClientContextForSPHost()) { // Get the people manager instance and load current properties PeopleManager peopleManager = new PeopleManager(clientContext); PersonProperties personProperties = peopleManager.GetMyProperties(); clientContext.Load(personProperties); clientContext.ExecuteQuery(); // Just to output what we have now for about me aboutMeValue.Text = personProperties.UserProfileProperties["AboutMe"]; } }
//gavdcodeend 27 //gavdcodebegin 28 static void SpCsCsomUpdateOneMultPropertyUserProfile(ClientContext spCtx) { PeopleManager myPeopleManager = new PeopleManager(spCtx); PersonProperties myUserProperties = myPeopleManager.GetMyProperties(); spCtx.Load(myUserProperties, prop => prop.AccountName); spCtx.ExecuteQuery(); List <string> mySkills = new List <string>(); mySkills.Add("SharePoint"); mySkills.Add("Windows"); myPeopleManager.SetMultiValuedProfileProperty( myUserProperties.AccountName, "SPS-Skills", mySkills); spCtx.ExecuteQuery(); }
/// <summary> /// Gets the user detail. /// </summary> /// <param name="id">The identifier.</param> /// <returns></returns> public UserDetails GetUserDetail(int id) { UserDetails detail = new UserDetails(); var peopleManager = new PeopleManager(this.context); User usr = this.context.Web.GetUserById(id); PersonProperties personProperties = peopleManager.GetMyProperties(); this.context.Load(usr, p => p.Id, p => p.LoginName, p => p.Email); this.context.Load(personProperties); this.context.ExecuteQuery(); detail.UserId = usr.Id.ToString(); detail.LoginName = usr.LoginName; detail.Department = personProperties.UserProfileProperties["Department"]; detail.FullName = personProperties.DisplayName; detail.UserEmail = usr.Email; //personProperties.Email; return(detail); }
//gavdcodeend 23 //gavdcodebegin 24 static void SpCsCsomGetAllPropertiesUserProfile(ClientContext spCtx) { string myUser = "******" + ConfigurationManager.AppSettings["spUserName"]; PeopleManager myPeopleManager = new PeopleManager(spCtx); PersonProperties myUserProperties = myPeopleManager.GetPropertiesFor(myUser); spCtx.Load(myUserProperties, prop => prop.AccountName, prop => prop.UserProfileProperties); spCtx.ExecuteQuery(); foreach (var oneProperty in myUserProperties.UserProfileProperties) { Console.WriteLine(oneProperty.Key.ToString() + " - " + oneProperty.Value.ToString()); } }