private async Task <(User User, Presence Presence)> GetBatchContent(CancellationToken token) { _logger.LogInformation("Getting Graph Data: Profle, Image, Presence"); try { IUserRequest userRequest = _graphServiceClient.Me.Request(); IPresenceRequest presenceRequest = _graphServiceClient.Me.Presence.Request(); BatchRequestContent batchRequestContent = new BatchRequestContent(); var userRequestId = batchRequestContent.AddBatchRequestStep(userRequest); var presenceRequestId = batchRequestContent.AddBatchRequestStep(presenceRequest); BatchResponseContent returnedResponse = await _graphServiceClient.Batch.Request().PostAsync(batchRequestContent, token).ConfigureAwait(true); User user = await returnedResponse.GetResponseByIdAsync <User>(userRequestId).ConfigureAwait(true); Presence presence = await returnedResponse.GetResponseByIdAsync <Presence>(presenceRequestId).ConfigureAwait(true); return(User : user, Presence : presence); } catch (Exception e) { _logger.LogError(e, "Error Occured Getting Batch Content from Graph Api"); throw; } }
public async Task <(User User, Presence Presence)> GetBatchContent() { try { IUserRequest userRequest = _graphServiceClient.Me.Request(); IPresenceRequest presenceRequest = _graphServiceClient.Me.Presence.Request(); BatchRequestContent batchRequestContent = new BatchRequestContent(); var userRequestId = batchRequestContent.AddBatchRequestStep(userRequest); var presenceRequestId = batchRequestContent.AddBatchRequestStep(presenceRequest); BatchResponseContent returnedResponse = await _graphServiceClient.Batch.Request().PostAsync(batchRequestContent).ConfigureAwait(true); User user = await returnedResponse.GetResponseByIdAsync <User>(userRequestId).ConfigureAwait(true); Presence presence = await returnedResponse.GetResponseByIdAsync <Presence>(presenceRequestId).ConfigureAwait(true); return(User : user, Presence : presence); } catch (Exception ex) { _logger.LogError(ex, "Error Occured in GetBatchContent MainWindow"); _diagClient.TrackException(ex); throw; } }
public async Task <bool> DeleteUser(string userUpn, CancellationToken token) { try { IUserRequest userRequest = client.Users[userUpn].Request(); await userRequest.DeleteAsync(token); return(true); } catch (ServiceException se) { if (se.Error.Message.ToLower().Contains("does not exist")) { return(true); } Trace.WriteLine(se.ToString()); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } return(false); }
/// <inheritdoc /> public User Create(IUserRequest userRequest) { var userName = new Name(userRequest.UserName); var password = new Password(userRequest.Password); var user = new User(userName, password, userRequest.Roles.Select(role => new Role(new Name(role)))); return(user); }
public ClanRequestPicker(FrmMain mainForm, IUserRequest request) { this.InitializeComponent(); this.MainForm = mainForm; this.mRequest = request; this.gpgLinkLabelName.Text = request.Description; this.gpgLabelDate.Text = request.RequestDate.ToShortDateString(); this.Refresh(); }
public static IUserRequest InjectUserId(this IUserRequest request, ClaimsPrincipal identity) { Claim idClaim = identity.Claims.FirstOrDefault(x => x.Type == ClaimTypes.NameIdentifier); if (idClaim != null) { request.UserId = idClaim.Value; } return(request); }
public async Task <(User User, Presence Presence)> GetBatchContent() { IUserRequest userRequest = _graphServiceClient.Me.Request(); IPresenceRequest presenceRequest = _graphServiceClient.Me.Presence.Request(); BatchRequestContent batchRequestContent = new BatchRequestContent(); var userRequestId = batchRequestContent.AddBatchRequestStep(userRequest); var presenceRequestId = batchRequestContent.AddBatchRequestStep(presenceRequest); BatchResponseContent returnedResponse = await _graphServiceClient.Batch.Request().PostAsync(batchRequestContent).ConfigureAwait(true); User user = await returnedResponse.GetResponseByIdAsync <User>(userRequestId).ConfigureAwait(true); Presence presence = await returnedResponse.GetResponseByIdAsync <Presence>(presenceRequestId).ConfigureAwait(true); return(User : user, Presence : presence); }
public async System.Threading.Tasks.Task TestBatch() { IUserRequest meRequest = graphClient.Me.Request(); IGraphServiceUsersCollectionRequest newUserRequest = graphClient.Users.Request(); // We have the ./users URL, query parameters, and request headers. User newUser = new User(); newUser.DisplayName = "New User"; newUser.UserPrincipalName = "*****@*****.**"; IDirectoryObjectWithReferenceRequest managerRequest = graphClient.Me.Manager.Request(); // We have the /me/manager URL, query parameters, and request headers. IDriveItemChildrenCollectionRequest driveRequest = graphClient.Me.Drive.Root.Children.Request(); // We have the /me/drive/root/children URL, query parameters, and request headers. IEducationRootRequest eduRequest = graphClient.Education.Request(); // We have the /education URL, query parameters, and request headers. BatchContainer batchContainer = new BatchContainer(); BatchPart part1 = batchContainer.AddToBatch(meRequest, Method.GET); // I don't think we need a copy of the BatchPart. batchContainer.AddToBatch(driveRequest, Method.GET); batchContainer.AddToBatch(eduRequest, Method.GET); batchContainer.AddToBatch(newUserRequest, Method.POST, 4, newUser, new BatchPart[] { part1 }); // We have to use reflection to determine which HttpVerb method we are using, and then, what // the return type will be. This might be costly batch scenario can contain a large number BatchResponse response = await graphClient.Batch.PostAsync(batchContainer); // of requests across many batches. I think we want to avoid reflection. User me = (User)response.batchResponses.Where(i => i.id == 1).First().body; // No auto-deserialization. User me2 = (User)response.batchResponses.Where(i => i.body.GetType() == typeof(User)).FirstOrDefault().body; foreach (BatchResponsePart part in response.batchResponses) { var responseItem = part.body; // If we deserialize into a dynamic object, the customer would have int statusCode = part.status; } Assert.IsNotNull(me.UserPrincipalName); }
public ICustomActivityResult Execute() { DataTable dt = new DataTable("resultSet"); dt.Columns.Add("Result"); IUserRequest user = null; GraphServiceClient client = new GraphServiceClient("https://graph.microsoft.com/v1.0", GetProvider()); user = client.Users[userId].Request(); if (user.GetAsync().Result.UserPrincipalName != null) { // Delete the user. user.DeleteAsync().Wait(); dt.Rows.Add("Success"); } else { throw new Exception("User not found"); } return(this.GenerateActivityResult(dt)); }
/// <summary> /// IUserRequest extension method that takes in a handler for the response. /// </summary> /// <param name="request">Request to send out</param> /// <param name="responseHandler">Handler for the response</param> /// <returns></returns> public static void SendGet(this IUserRequest request, ResponseHandler responseHandler) { SendGet <User>(request, responseHandler); }
public UserRequestEventArgs(IUserRequest request) { this.mRequest = request; }