/// <summary> /// Create XML to add advanced time off request. /// </summary> /// <param name="employees">List of employees.</param> /// <param name="startdate">Start date.</param> /// <param name="enddate">End date.</param> /// <returns>Advanced time of request.</returns> public string CreateRequest(List <HyperfindResponse.ResponseHyperFindResult> employees, string startdate, string enddate) { TimeOffRequest.Request rq = new TimeOffRequest.Request { Action = ApiConstants.RetrieveWithDetails, RequestMgmt = new TimeOffRequest.RequestMgmt { QueryDateSpan = $"{startdate}-{enddate}", RequestFor = "TOR", Employees = new TimeOffRequest.Employees { PersonIdentity = new List <TimeOffRequest.PersonIdentity>(), }, }, }; foreach (var item in employees) { rq.RequestMgmt.Employees.PersonIdentity.Add(new TimeOffRequest.PersonIdentity { PersonNumber = item.PersonNumber }); } return(rq.XmlSerialize <TimeOffRequest.Request>()); }
/// <summary> /// Creates an update time off request. /// </summary> /// <param name="id">The Kronos id of the request.</param> /// <param name="startDateTime">Start date.</param> /// <param name="endDateTime">End Date.</param> /// <param name="queryDateSpan">The queryDateSpan string.</param> /// <param name="personNumber">The Kronos Person Number.</param> /// <param name="reason">Reason string.</param> /// <param name="comments">Any comments to be attached to the TOR.</param> /// <returns>XML request string.</returns> private string CreateUpdateTimeOffRequest( string id, DateTimeOffset startDateTime, DateTimeOffset endDateTime, string queryDateSpan, string personNumber, string reason, Comments comments) { // Kronos API expects a collection of periods so first calculate the actual period // before adding it to a list. var timeOffPeriod = CalculateTimeOffPeriod(startDateTime, endDateTime, reason); var timeOffPeriods = new List <TimeOffPeriod>() { timeOffPeriod }; var request = new TimeOffRequest.Request { Action = ApiConstants.Update, RequestMgmt = new TimeOffRequest.RequestMgmt { Employees = new Employees { PersonIdentity = new List <PersonIdentity> { new PersonIdentity { PersonNumber = personNumber }, }, }, QueryDateSpan = queryDateSpan, RequestItems = new TimeOffRequest.RequestItems { GlobalTimeOffRequestItem = new TimeOffRequest.GlobalTimeOffRequestItem { Id = id, RequestFor = ApiConstants.TOR, TimeOffPeriods = new TimeOffPeriods() { TimeOffPeriod = timeOffPeriods }, Comments = comments, }, }, }, }; return(request.XmlSerialize()); }
/// <summary> /// Create approved SwapShift requests for a list of people. /// </summary> /// <param name="personNumbers">List of person numbers whose request is approved.</param> /// <param name="queryDateSpan">QueryDateSpan string.</param> /// <param name="statusName">Request statusName.</param> /// <returns>XML request string.</returns> private string CreateApprovedSwapShiftRequests( List <string> personNumbers, string queryDateSpan, string statusName) { var telemetryProps = new Dictionary <string, string>() { { "QueryDateSpan", queryDateSpan }, { "KronosStatus", statusName }, }; this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateApproveSwapShiftRequests starts: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}", telemetryProps); List <TimeOff.PersonIdentity> personIdentities = new List <TimeOff.PersonIdentity>(); foreach (var personNumber in personNumbers) { TimeOff.PersonIdentity personIdentity = new TimeOff.PersonIdentity { PersonNumber = personNumber, }; personIdentities.Add(personIdentity); } TimeOff.Request rq = new TimeOff.Request { Action = ApiConstants.RetrieveWithDetails, RequestMgmt = new TimeOff.RequestMgmt { QueryDateSpan = $"{queryDateSpan}", RequestFor = ApiConstants.SwapShiftRequest, StatusName = statusName, Employees = new Employees { PersonIdentity = personIdentities, }, }, }; this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateApproveSwapShiftRequests: {rq.XmlSerialize().ToString(CultureInfo.InvariantCulture)}", telemetryProps); this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateApproveSwapShiftRequests ends: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}", telemetryProps); return(rq.XmlSerialize()); }
/// <summary> /// Create request. /// </summary> /// <param name="personNumber">Person number who created request.</param> /// <param name="queryDateSpan">QueryDateSpan string.</param> /// <returns>XML request string.</returns> public string CreateTORRequest(string personNumber, string queryDateSpan) { TimeOffRequest.Request rq = new TimeOffRequest.Request { Action = ApiConstants.RetrieveWithDetails, RequestMgmt = new TimeOffRequest.RequestMgmt { QueryDateSpan = $"{queryDateSpan}", RequestFor = "TOR", Employees = new TimeOffRequest.Employees { PersonIdentity = new List <TimeOffRequest.PersonIdentity>(), }, }, }; rq.RequestMgmt.Employees.PersonIdentity.Add(new TimeOffRequest.PersonIdentity { PersonNumber = personNumber }); return(rq.XmlSerialize <TimeOffRequest.Request>()); }
/// <summary> /// Fetch TimeOff request. /// </summary> /// <param name="employees">Employees who created request.</param> /// <param name="queryDateSpan">QueryDateSpan string.</param> /// <returns>XML request string.</returns> private string FetchTimeOffRequestsByBatch(List <Models.ResponseEntities.HyperFind.ResponseHyperFindResult> employees, string queryDateSpan) { TimeOffRequest.Request rq = new TimeOffRequest.Request { Action = ApiConstants.RetrieveWithDetails, RequestMgmt = new TimeOffRequest.RequestMgmt { QueryDateSpan = $"{queryDateSpan}", RequestFor = ApiConstants.TOR, Employees = new TimeOffRequest.Employees { PersonIdentity = new List <TimeOffRequest.PersonIdentity>(), }, }, }; var timeOffEmployees = employees.ConvertAll(x => new TimeOffRequest.PersonIdentity { PersonNumber = x.PersonNumber }); rq.RequestMgmt.Employees.PersonIdentity.AddRange(timeOffEmployees); return(rq.XmlSerialize()); }