/// <summary>
            /// Gets the manager log book view for all employees for the given store and filter by activity.
            /// </summary>
            /// <param name="context">Request context.</param>
            /// <param name="storeNumber">Store number.</param>
            /// <param name="employeeActivityTypes">Employee activity types.</param>
            /// <param name="fromDateTimeOffset">The employee activity date and time offset lower bound.</param>
            /// <param name="toDateTimeOffset">The employee activity date and time offset upper bound.</param>
            /// <param name="pagingInfo">The paging information.</param>
            /// <param name="sortingInfo">The sorting information.</param>
            /// <returns>The results collection of employee activities.</returns>
            public static ReadOnlyCollection <EmployeeActivity> GetManagerLogbookView(
                RequestContext context,
                string storeNumber,
                EmployeeActivityType[] employeeActivityTypes,
                DateTimeOffset?fromDateTimeOffset,
                DateTimeOffset?toDateTimeOffset,
                PagingInfo pagingInfo,
                SortingInfo sortingInfo)
            {
                ThrowIf.Null(context, "context");

                // Get the UTC date and time from the channel date and time offset
                var fromUtcDateTime = fromDateTimeOffset.GetUtcDateTime();
                var toUtcDateTime   = toDateTimeOffset.GetUtcDateTime();

                // Get the store numbers the user is working at
                var  storeIds           = GetEmployeeStoreIds(context);
                bool storeNumberDefined = !string.IsNullOrWhiteSpace(storeNumber);

                if ((storeIds == null) ||
                    (storeNumberDefined && !storeIds.Contains(storeNumber)))
                {
                    // if no store the user is assigned to, nor the input storeNumber is among the store(s) the user is assigned to
                    return(null);
                }
                else if (storeNumberDefined)
                {
                    // if the input store number is defined, use it directly
                    storeIds = new[] { storeNumber };
                }

                // Get the break activity categories
                var breakActivities = GetBreakActivityJobIds(context, employeeActivityTypes);

                var request = new GetManagerActivityHistoryRealtimeRequest(
                    storeIds,
                    employeeActivityTypes,
                    breakActivities,
                    fromUtcDateTime,
                    toUtcDateTime,
                    pagingInfo,
                    sortingInfo);

                return(context.Execute <EntityDataServiceResponse <EmployeeActivity> >(request).PagedEntityCollection.Results);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Executes get manager activity history requests.
            /// </summary>
            /// <param name="request">The service request.</param>
            /// <returns>The activity response.</returns>
            private static EntityDataServiceResponse <EmployeeActivity> GetManagerActivityHistory(GetManagerActivityHistoryRealtimeRequest request)
            {
                var transactionService = new TransactionServiceClient(request.RequestContext);

                var activities = transactionService.GetManagerActivityHistory(
                    request.StoreIds,
                    request.EmployeeActivityTypes,
                    request.BreakActivities,
                    request.FromUtcDateTime,
                    request.ToUtcDateTime,
                    request.PagingInfo,
                    request.SortingInfo);

                // Convert the UTC date time offset field of each employee activity to channel time zone
                foreach (EmployeeActivity activity in activities.Results.Where(activity => activity.ActivityDateTimeOffset.HasValue))
                {
                    activity.ActivityDateTimeOffset = request.RequestContext.ConvertDateTimeToChannelDate(activity.ActivityDateTimeOffset.Value);
                }

                return(new EntityDataServiceResponse <EmployeeActivity>(activities));
            }