Example #1
0
        public string CreateSwapShiftDraftRequest(SwapShiftObj obj)
        {
            var requestorEmployee = new Models.RequestEntities.Hours.Employee
            {
                PersonIdentity = new Models.RequestEntities.Hours.PersonIdentity {
                    PersonNumber = obj.RequestorPersonNumber
                }
            };

            var requestedToEmployee = new Models.RequestEntities.Hours.Employee
            {
                PersonIdentity = new Models.RequestEntities.Hours.PersonIdentity {
                    PersonNumber = obj.RequestedToPersonNumber
                }
            };

            SwapShiftRequest.Request rq = new SwapShiftRequest.Request()
            {
                Action = ApiConstants.AddRequests,
                EmployeeRequestMgmt = new SwapShiftRequest.EmployeeRequestMgmt
                {
                    Employee      = requestorEmployee,
                    QueryDateSpan = obj.QueryDateSpan,
                    RequestItems  = new SwapShiftRequest.RequestItems
                    {
                        SwapShiftRequestItem = new SwapShiftRequest.SwapShiftRequestItem
                        {
                            Employee     = requestorEmployee,
                            RequestFor   = "Shift Swap Request",
                            OfferedShift = new SwapShiftRequest.OfferedShift
                            {
                                ShiftRequestItem = new SwapShiftRequest.ShiftRequestItem
                                {
                                    Employee      = requestorEmployee,
                                    EndDateTime   = obj.Emp1ToDateTime.ToString("MM/d/yyyy hh:mmtt", CultureInfo.InvariantCulture),
                                    OrgJobPath    = obj.SelectedJob,
                                    StartDateTime = obj.Emp1FromDateTime.ToString("MM/d/yyyy hh:mmtt", CultureInfo.InvariantCulture),
                                }
                            },
                            RequestedShift = new SwapShiftRequest.RequestedShift
                            {
                                ShiftRequestItem = new SwapShiftRequest.ShiftRequestItem
                                {
                                    Employee      = requestedToEmployee,
                                    EndDateTime   = obj.Emp2ToDateTime.ToString("MM/d/yyyy hh:mmtt", CultureInfo.InvariantCulture),
                                    OrgJobPath    = obj.SelectedJob,
                                    StartDateTime = obj.Emp2FromDateTime.ToString("MM/d/yyyy hh:mmtt", CultureInfo.InvariantCulture),
                                }
                            }
                        }
                    }
                }
            };

            return(rq.XmlSerialize <SwapShiftRequest.Request>());
        }
Example #2
0
        /// <summary>
        /// This method will create the XML request string for a Swap Shift Request.
        /// </summary>
        /// <param name="swapShiftObj">The current swap shift object.</param>
        /// <returns>A string that represents the XML request.</returns>
        private string CreateSwapShiftDraftRequest(SwapShiftObj swapShiftObj)
        {
            this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateSwapShiftDraftRequest starts: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}");

            var requestorEmployee = new Employee
            {
                PersonIdentity = new Models.RequestEntities.OpenShift.ApproveDecline.RequestManagementApproveDecline.PersonIdentity
                {
                    PersonNumber = swapShiftObj.RequestorPersonNumber,
                },
            };

            var requestedToEmployee = new Employee
            {
                PersonIdentity = new Models.RequestEntities.OpenShift.ApproveDecline.RequestManagementApproveDecline.PersonIdentity
                {
                    PersonNumber = swapShiftObj.RequestedToPersonNumber,
                },
            };

            SubmitRequest.Request rq = new SubmitRequest.Request()
            {
                Action = ApiConstants.AddRequests,
                EmployeeRequestMgmt = new EmployeeRequestMgmt
                {
                    Employee      = requestorEmployee,
                    QueryDateSpan = swapShiftObj.QueryDateSpan,
                    RequestItems  = new RequestItems
                    {
                        SwapShiftRequestItem = new SwapShiftRequestItem
                        {
                            Employee     = requestorEmployee,
                            RequestFor   = ApiConstants.SwapShiftRequest,
                            OfferedShift = new OfferedShift
                            {
                                ShiftRequestItem = new ShiftRequestItem
                                {
                                    Employee = requestorEmployee,

                                    // The Kronos is expecting only these formats to be serialized,
                                    // however we are converting the correct date format while creating actual shifts, timeoff etc.
                                    EndDateTime   = swapShiftObj.Emp1ToDateTime.ToString(ApiConstants.KronosAcceptableDateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                    OrgJobPath    = swapShiftObj.SelectedJob,
                                    StartDateTime = swapShiftObj.Emp1FromDateTime.ToString(ApiConstants.KronosAcceptableDateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                },
                            },
                            RequestedShift = new RequestedShift
                            {
                                ShiftRequestItem = new ShiftRequestItem
                                {
                                    Employee      = requestedToEmployee,
                                    EndDateTime   = swapShiftObj.Emp2ToDateTime.ToString(ApiConstants.KronosAcceptableDateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                    OrgJobPath    = swapShiftObj.SelectedJob,
                                    StartDateTime = swapShiftObj.Emp2FromDateTime.ToString(ApiConstants.KronosAcceptableDateFormat, System.Globalization.CultureInfo.InvariantCulture),
                                },
                            },
                        },
                    },
                },
            };

            this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateSwapShiftDraftRequest: {rq.XmlSerialize().ToString(CultureInfo.InvariantCulture)}");
            this.telemetryClient.TrackTrace($"SwapShiftActivity - CreateSwapShiftDraftRequest ends: {DateTime.UtcNow.ToString("O", CultureInfo.InvariantCulture)}");
            return(rq.XmlSerialize());
        }