public async Task UnusedTestAsync() { var connection = new ClientCredentialsConnection( new Uri("TODO"), "TODO", "TODO", new HttpClient()); var teamDirectoryClient = new TeamDirectoryClient(connection); // ReSharper disable once UnusedVariable var memberProfile = await teamDirectoryClient.Profiles .GetProfileAsync(ProfileIdentifier.Username("Heather.Stewart"), partial => partial .WithAllFieldsWildcard() // Include all first-level fields .WithManagers(manager => manager .WithId() .WithUsername() .WithName(name => name .WithFirstName() .WithLastName()))); }
public void InitBookHotelRQ(ref WBSAPIRouterData objWBSAPIRouterData, BookingAction enumBookingAction) { WBSAPIRouterGateway gwWBS = new WBSAPIRouterGateway(objEventLog, objExceptionEventLog, bIsProduction); HotelAvailabilityRS objHotelAvailabilityRS = (HotelAvailabilityRS)Session["HotelAvailabilityRS"]; StayCriteriaSelection objStayCriteriaSelection = (StayCriteriaSelection)Session[Constants.Sessions.StayCriteriaSelection]; RoomRateSelection[] objRoomRateSelections = (RoomRateSelection[])Session["RoomRateSelections"]; AddOnPackageSelection[] objAddOnPackageSelections = (AddOnPackageSelection[])Session["AddOnPackageSelections"]; GuestDetailsEntryInfo objGuestDetailsEntryInfo = (GuestDetailsEntryInfo)Session["GuestDetailsEntryInfo"]; CancelDetailsEntryInfo objCancelDetailsEntryInfo = (CancelDetailsEntryInfo)Session["CancelDetailsEntryInfo"]; PaymentGatewayInfo[] objPaymentGatewayInfos = (PaymentGatewayInfo[])Session[Constants.Sessions.PaymentGatewayInfos]; PaymentGatewayInfo objPaymentGatewayInfo = (PaymentGatewayInfo)Session[Constants.Sessions.PaymentGatewayInfo]; HotelBookingPaymentAllocation[] objHotelBookingPaymentAllocations = (HotelBookingPaymentAllocation[])Session[Constants.Sessions.HotelBookingPaymentAllocations]; HotelPaymentRQ objHotelPaymentRQ = (HotelPaymentRQ)Session["HotelPaymentRQ"]; HotelPaymentRS objHotelPaymentRS = (HotelPaymentRS)Session["HotelPaymentRS"]; bool bIsOnlinePayment = WBSPGHelper.IsOnlinePayment(objPaymentGatewayInfos, objHotelBookingPaymentAllocations, objGuestDetailsEntryInfo.PaymentCardType); Profile[] objProfiles = (Profile[])Session["LoginProfiles"]; bool bIsLoggedIn = (bool)Session["IsLoggedIn"]; Profile objCompanyProfile = ProfileHelper.GetProfile(objProfiles, ProfileType.Corporation); Profile objAgencyProfile = ProfileHelper.GetProfile(objProfiles, ProfileType.TravelAgent); HotelBookingRQ objHotelBookingRQ = new HotelBookingRQ(); objHotelBookingRQ.RequestHeader = this.GetRequestHeader(); objHotelBookingRQ.BookingAction = enumBookingAction; List<HotelBookingRequestSegment> lSegments = new List<HotelBookingRequestSegment>(); if (enumBookingAction == BookingAction.Sell || enumBookingAction == BookingAction.TestSell || enumBookingAction == BookingAction.Modify) { for (int ri = 0; ri < objStayCriteriaSelection.RoomOccupantSelections.Length; ri++) { HotelBookingRequestSegment objSegment = new HotelBookingRequestSegment(); lSegments.Add(objSegment); string strRoomRefID = objStayCriteriaSelection.RoomOccupantSelections[ri].RoomRefID; HotelRoomAvailInfo objHotelRoomAvailInfo = this.GetHotelRoomAvailInfo(objHotelAvailabilityRS.HotelRoomAvailInfos, strRoomRefID); RoomRateSelection objRoomRateSelection = this.GetRoomRateSelection(objRoomRateSelections, strRoomRefID); HotelAvailRatePlan objHotelAvailRatePlan = this.GetRatePlanInfo(objHotelRoomAvailInfo.RatePlans, objRoomRateSelection.RatePlanCode); AddOnPackageSelection[] objRoomAddOnPackageSelections = this.GetAddOnPackageSelections(objAddOnPackageSelections, strRoomRefID); objSegment.SegmentRefID = strRoomRefID; objSegment.HotelCode = objStayCriteriaSelection.HotelCode; objSegment.ChainCode = ConfigurationManager.AppSettings["HotelChainCode"]; objSegment.ConfirmationNumber = ""; objSegment.ArrivalDate = objStayCriteriaSelection.ArrivalDate.Date; objSegment.DepartureDate = objStayCriteriaSelection.DepartureDate.Date; objSegment.RoomTypeCode = objRoomRateSelection.RoomTypeCode; objSegment.RatePlanCode = objRoomRateSelection.RatePlanCode; objSegment.PromoCode = objStayCriteriaSelection.PromotionCode; objSegment.NumRooms = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberRooms; objSegment.NumAdults = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberAdults; objSegment.NumChildren = objStayCriteriaSelection.RoomOccupantSelections[ri].NumberChildren; // Enhancement: special requests section needs to be "by room" in guest details objSegment.NumCribs = objGuestDetailsEntryInfo.NumberCribs; objSegment.NumRollawaysAdult = objGuestDetailsEntryInfo.NumberRollawaysAdult; objSegment.NumRollawaysChild = objGuestDetailsEntryInfo.NumberRollawaysChild; objSegment.SpecialInstructions = objGuestDetailsEntryInfo.SpecialInstructions; objSegment.IsBaseOccupancyPricing = false; objSegment.NumBaseOccupants = 0; // Enhancement: arrival time needs to be "by room" in guest details objSegment.FlightNumber = objGuestDetailsEntryInfo.FlightNumber; if (objGuestDetailsEntryInfo.ArrivalTime != null && objGuestDetailsEntryInfo.ArrivalTime != "") { DateTime dtArrivalTime; if (DateTime.TryParse(objGuestDetailsEntryInfo.ArrivalTime, out dtArrivalTime)) { objSegment.ArrivalTime = dtArrivalTime; objSegment.ArrivalTimeSpecified = true; } else { objSegment.ArrivalTime = DateTime.Today.Date; objSegment.ArrivalTimeSpecified = false; } } else { objSegment.ArrivalTime = DateTime.Today.Date; objSegment.ArrivalTimeSpecified = false; } List<Profile> lProfiles = new List<Profile>(); Profile objGuest = new Profile(); lProfiles.Add(objGuest); objGuest.Type = ProfileType.Traveler; objGuest.PersonNamePrefix = objGuestDetailsEntryInfo.NamePrefix; objGuest.PersonFirstName = objGuestDetailsEntryInfo.FirstName; objGuest.PersonLastName = objGuestDetailsEntryInfo.LastName; objGuest.CompanyName = ""; objGuest.Address1 = objGuestDetailsEntryInfo.Address1; objGuest.Address2 = objGuestDetailsEntryInfo.Address2; objGuest.City = objGuestDetailsEntryInfo.City; objGuest.StateRegion = objGuestDetailsEntryInfo.StateRegion; objGuest.PostalCode = objGuestDetailsEntryInfo.PostalCode; objGuest.Country = objGuestDetailsEntryInfo.Country; objGuest.Phone = objGuestDetailsEntryInfo.Phone; objGuest.Fax = ""; objGuest.Email = objGuestDetailsEntryInfo.Email; objGuest.SubscribeToNewsletter = objGuestDetailsEntryInfo.SubscribeToNewsletter; objGuest.TravelPurpose = objGuestDetailsEntryInfo.TravelPurpose; List<ProfileIdentifier> lGuestProfileIdentifiers = new List<ProfileIdentifier>(); if (objGuestDetailsEntryInfo.HotelProgramCode != null && objGuestDetailsEntryInfo.HotelProgramCode != "") { ProfileIdentifier objProfileIdentifier = new ProfileIdentifier(); lGuestProfileIdentifiers.Add(objProfileIdentifier); objProfileIdentifier.Type = ProfileIdentifierType.HotelLoyaltyProgram; objProfileIdentifier.ProgramCode = objGuestDetailsEntryInfo.HotelProgramCode; objProfileIdentifier.Identifier = objGuestDetailsEntryInfo.HotelProgramIdentifier; } if (objGuestDetailsEntryInfo.AirlineProgramCode != null && objGuestDetailsEntryInfo.AirlineProgramCode != "") { ProfileIdentifier objProfileIdentifier = new ProfileIdentifier(); lGuestProfileIdentifiers.Add(objProfileIdentifier); objProfileIdentifier.Type = ProfileIdentifierType.AirlineLoyaltyProgram; objProfileIdentifier.ProgramCode = objGuestDetailsEntryInfo.AirlineProgramCode; objProfileIdentifier.Identifier = objGuestDetailsEntryInfo.AirlineProgramIdentifier; } objGuest.ProfileIdentifiers = lGuestProfileIdentifiers.ToArray(); if (objCompanyProfile != null) { lProfiles.Add(objCompanyProfile); } else if (objGuestDetailsEntryInfo.CompanyName != null && objGuestDetailsEntryInfo.CompanyName != "") { Profile objCompany = new Profile(); lProfiles.Add(objCompany); objCompany.Type = ProfileType.Corporation; objCompany.PersonNamePrefix = ""; objCompany.PersonFirstName = ""; objCompany.PersonLastName = ""; objCompany.CompanyName = objGuestDetailsEntryInfo.CompanyName; objCompany.Address1 = ""; objCompany.Address2 = ""; objCompany.City = ""; objCompany.StateRegion = ""; objCompany.PostalCode = ""; objCompany.Country = ""; objCompany.Phone = ""; objCompany.Fax = ""; objCompany.Email = ""; objCompany.SubscribeToNewsletter = false; objCompany.TravelPurpose = TravelPurpose.NotIdentified; objCompany.ProfileIdentifiers = new ProfileIdentifier[0]; } if (objAgencyProfile != null) { lProfiles.Add(objAgencyProfile); } else if (objGuestDetailsEntryInfo.TravelAgencyIATA != null && objGuestDetailsEntryInfo.TravelAgencyIATA != "") { Profile objAgency = new Profile(); lProfiles.Add(objAgency); objAgency.Type = ProfileType.TravelAgent; objAgency.PersonNamePrefix = ""; objAgency.PersonFirstName = ""; objAgency.PersonLastName = ""; objAgency.CompanyName = ""; objAgency.Address1 = ""; objAgency.Address2 = ""; objAgency.City = ""; objAgency.StateRegion = ""; objAgency.PostalCode = ""; objAgency.Country = ""; objAgency.Phone = ""; objAgency.Fax = ""; objAgency.Email = ""; objAgency.SubscribeToNewsletter = false; objAgency.TravelPurpose = TravelPurpose.NotIdentified; ProfileIdentifier objAgencyIATA = new ProfileIdentifier(); objAgencyIATA.Type = ProfileIdentifierType.IATA; objAgencyIATA.Identifier = objGuestDetailsEntryInfo.TravelAgencyIATA; objAgencyIATA.ProgramCode = ""; objAgency.ProfileIdentifiers = new ProfileIdentifier[1]; objAgency.ProfileIdentifiers[0] = objAgencyIATA; } objSegment.Profiles = lProfiles.ToArray(); objSegment.PackageQuantities = new HotelBookingPackageQuantity[objRoomAddOnPackageSelections.Length]; for (int i = 0; i < objRoomAddOnPackageSelections.Length; i++) { HotelBookingPackageQuantity objHotelBookingPackageQuantity = new HotelBookingPackageQuantity(); objSegment.PackageQuantities[i] = objHotelBookingPackageQuantity; objHotelBookingPackageQuantity.Code = objRoomAddOnPackageSelections[i].PackageCode; objHotelBookingPackageQuantity.Quantity = objRoomAddOnPackageSelections[i].Quantity; } objSegment.GuaranteeType = objHotelAvailRatePlan.GuaranteeType; objSegment.PaymentCard = null; objSegment.DepositPaymentAmount = 0; objSegment.PaymentAuthCode = ""; objSegment.PaymentTransRefID = ""; if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.CCDCVoucher && objGuestDetailsEntryInfo.ProfileGuaranteeRequested) { objSegment.GuaranteeType = GuaranteeType.Profile; } else if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.CCDCVoucher) { HotelBookingPaymentCard objPaymentCard = new HotelBookingPaymentCard(); objSegment.PaymentCard = objPaymentCard; objPaymentCard.PaymentCardType = objGuestDetailsEntryInfo.PaymentCardType; objPaymentCard.PaymentCardNumber = objGuestDetailsEntryInfo.PaymentCardNumber; objPaymentCard.PaymentCardHolder = objGuestDetailsEntryInfo.PaymentCardHolder; objPaymentCard.PaymentCardEffectiveDate = objGuestDetailsEntryInfo.PaymentCardEffectiveDate; objPaymentCard.PaymentCardExpireDate = objGuestDetailsEntryInfo.PaymentCardExpireDate; objPaymentCard.PaymentCardIssueNumber = objGuestDetailsEntryInfo.PaymentCardIssueNumber; objPaymentCard.PaymentCardSecurityCode = objGuestDetailsEntryInfo.PaymentCardSecurityCode; objSegment.CurrencyCode = objHotelAvailRatePlan.DepositRequiredCurrencyCode; } else if (objHotelAvailRatePlan.GuaranteeType == GuaranteeType.Deposit || objHotelAvailRatePlan.GuaranteeType == GuaranteeType.PrePay) { HotelBookingPaymentCard objPaymentCard = new HotelBookingPaymentCard(); objSegment.PaymentCard = objPaymentCard; objPaymentCard.PaymentCardType = objGuestDetailsEntryInfo.PaymentCardType; objPaymentCard.PaymentCardNumber = objGuestDetailsEntryInfo.PaymentCardNumber; objPaymentCard.PaymentCardHolder = objGuestDetailsEntryInfo.PaymentCardHolder; objPaymentCard.PaymentCardEffectiveDate = objGuestDetailsEntryInfo.PaymentCardEffectiveDate; objPaymentCard.PaymentCardExpireDate = objGuestDetailsEntryInfo.PaymentCardExpireDate; objPaymentCard.PaymentCardIssueNumber = objGuestDetailsEntryInfo.PaymentCardIssueNumber; objPaymentCard.PaymentCardSecurityCode = objGuestDetailsEntryInfo.PaymentCardSecurityCode; objSegment.CurrencyCode = objHotelAvailRatePlan.DepositRequiredCurrencyCode; decimal decDepositPaymentAmount = WBSPGHelper.GetBookingSegmentPayment(objHotelBookingPaymentAllocations, strRoomRefID); if (bIsOnlinePayment && decDepositPaymentAmount != 0) { objSegment.PaymentCard = objHotelPaymentRS.PaymentCard; objSegment.DepositPaymentAmount = decDepositPaymentAmount; objSegment.PaymentAuthCode = objHotelPaymentRS.PaymentAuthCode; objSegment.PaymentTransRefID = objHotelPaymentRS.PaymentTransRefID; objSegment.PaymentCard.PaymentCardSecurityCode = ""; // remove security code (no longer needed) } } } } if (enumBookingAction == BookingAction.Cancel) { for (int ci = 0; ci < objCancelDetailsEntryInfo.SelectedConfirmationNumbersToCancel.Length; ci++) { HotelBookingRequestSegment objSegment = new HotelBookingRequestSegment(); lSegments.Add(objSegment); objSegment.SegmentRefID = ((int)(ci + 1)).ToString(); objSegment.ConfirmationNumber = objCancelDetailsEntryInfo.SelectedConfirmationNumbersToCancel[ci]; } } objHotelBookingRQ.Segments = lSegments.ToArray(); gwWBS.InitHotelBookingRQ(ref objWBSAPIRouterData, objHotelBookingRQ); return; }
public async Task OnGet() { #region Example with default fields (1 level) MemberProfile = await _teamDirectoryClient.Profiles.GetProfileAsync(ProfileIdentifier.Me); #endregion #region Example with full field definitions MemberProfile = await _teamDirectoryClient.Profiles.GetProfileAsync(ProfileIdentifier.Me, partial => partial .WithAllFieldsWildcard() // adds all fields for the current partial request (one level) .WithId() .WithName(name => name .WithFirstName() .WithLastName()) .WithEmails(emails => emails.WithAllFieldsWildcard()) .WithMessengers() .WithPhones() .WithLinks() .WithBirthday() .WithLanguages(languages => languages .WithAllFieldsWildcard() .WithLanguage(language => language.WithAllFieldsWildcard())) .WithAbsences(absence => absence.WithAllFieldsWildcard()) .WithMemberships(membership => membership .WithAllFieldsWildcard() .WithRole(role => role.WithName()) .WithTeam(team => team.WithName())) .WithLocations(locations => locations .WithId() .WithLocation(location => location .WithName()))); #endregion var weekStart = StartOfWeek(DateTime.UtcNow, DayOfWeek.Monday); var weekEnd = weekStart.AddDays(7).AddHours(23).AddMinutes(59).AddSeconds(59); var issuesCreatedThisWeek = 0; var issuesResolvedThisWeek = 0; var reviewsCreatedThisWeek = 0; var reviewsParticipatedThisWeek = 0; var todoClosedThisWeek = 0; var meetingsThisWeek = 0; await foreach (var project in _projectClient.GetAllProjectsByMemberAsyncEnumerable(ProfileIdentifier.Id(MemberProfile.Id))) { try { // Check # of issues resolved this week var issueStatuses = await _projectClient.Planning.Issues.Statuses.GetAllIssueStatusesAsync(ProjectIdentifier.Id(project.Id)); await foreach (var issue in _projectClient.Planning.Issues.GetAllIssuesAsyncEnumerable(ProjectIdentifier.Id(project.Id), assigneeId: new List <ProfileIdentifier>(), statuses: issueStatuses.Select(it => it.Id).ToList(), sorting: IssuesSorting.UPDATED, descending: true, partial: _ => _ .WithAllFieldsWildcard() .WithCreationTime() .WithCreatedBy(createdBy => createdBy .WithDetails(details => details .ForInherited <CUserPrincipalDetails>(details => details .WithUser(user => user .WithId())) .ForInherited <CUserWithEmailPrincipalDetails>(details => details .WithName() .WithEmail()))) .WithStatus() .WithAssignee(assignee => assignee .WithId()) .WithChannel(channel => channel .WithLastMessage(lastMessage => lastMessage .WithText() .WithTime())))) { var created = issue.CreationTime; var lastUpdated = issue.Channel.LastMessage?.Time.AsDateTime() ?? created; if (lastUpdated < weekStart) { break; } // Created if (issue.CreatedBy.Details is CUserPrincipalDetails userPrincipal && userPrincipal.User?.Id == MemberProfile.Id) { if (created >= weekStart && created <= weekEnd) { issuesCreatedThisWeek++; } } // Resolved if (issue.Assignee?.Id == MemberProfile.Id) { if (lastUpdated >= weekStart && lastUpdated <= weekEnd) { var wasStatusUpdate = issue.Channel.LastMessage?.Text == "changed status"; if (wasStatusUpdate && issue.Status.IsResolved) { issuesResolvedThisWeek++; } } } } } catch (Exception ex) { _logger.LogError("An error occurred", ex); } try { // Check # of reviews created and participated in Partial <CodeReviewWithCount> codeReviewPartial(Partial <CodeReviewWithCount> _) => _ .WithAllFieldsWildcard() .WithReview() .WithAuthors() .WithParticipants(); var reviews = await _projectClient.CodeReviews.GetAllCodeReviewsAsyncEnumerable(ProjectIdentifier.Id(project.Id), ReviewSorting.LastUpdatedDesc, state : null, from : weekStart, partial : codeReviewPartial).ToListAsync(); foreach (var review in reviews) { var createdAt = review.Review switch { CommitSetReviewRecord commitSetReview => commitSetReview.CreatedAt.AsDateTime(), MergeRequestRecord mergeRequest => mergeRequest.CreatedAt.AsDateTime(), _ => DateTime.MinValue }; if (createdAt >= weekStart && createdAt <= weekEnd) { if (review.Participants.Participants.Any(it => it.User.Id == MemberProfile.Id && it.Role == CodeReviewParticipantRole.Author)) { reviewsCreatedThisWeek++; } } if (review.Participants.Participants.Any(it => it.User.Id == MemberProfile.Id && it.Role == CodeReviewParticipantRole.Reviewer)) { reviewsParticipatedThisWeek++; } } } catch (Exception ex) { _logger.LogError("An error occurred", ex); } } try { // Check # of TO-DO items resolved await foreach (var todo in _todoClient.GetAllTodoItemsAsyncEnumerable(from: weekStart, partial: _ => _ .WithId() .WithContent(content => content .ForInherited <TodoItemContentMdText>(md => md .WithAllFieldsWildcard())) .WithStatus())) { if (todo.Status == "Closed") { todoClosedThisWeek++; } } } catch (Exception ex) { _logger.LogError("An error occurred", ex); } try { await foreach (var meeting in _calendarClient.Meetings.GetAllMeetingsAsyncEnumerable(profiles: new List <string> { MemberProfile.Id }, includePrivate: true, includeArchived: false, includeMeetingInstances: true, startingAfter: weekStart, endingBefore: weekEnd, partial: _ => _ .WithAllFieldsWildcard() .WithId() .WithSummary() .WithDescription() .WithConferenceLink())) { meetingsThisWeek++; if (meeting.OccurrenceRule.Start.Date == DateTime.UtcNow.Date) { MeetingsToday.Add(meeting); } } } catch (Exception ex) { _logger.LogError("An error occurred", ex); } IssuesCreatedThisWeek = issuesCreatedThisWeek; IssuesResolvedThisWeek = issuesResolvedThisWeek; ReviewsCreatedThisWeek = reviewsCreatedThisWeek; ReviewsParticipatedThisWeek = reviewsParticipatedThisWeek; TodoClosedThisWeek = todoClosedThisWeek; MeetingsThisWeek = meetingsThisWeek; }