Пример #1
0
            public static async void CreateShiftV2(CreateShiftRequest request, CreateShiftResponse response)
            {
                ThrowIf.Null(request, "CreateShiftRequest");
                ThrowIf.Null(response, "CreateShiftResponse");

                string inventLocationDataAreaId = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

                CreateShiftRTSAsync(request, response);

                using (var databaseContext = new DatabaseContext(request))
                {
                    ParameterSet parameters = new ParameterSet();

                    parameters["@CHANNEL"]           = response.Shift.StoreRecordId;
                    parameters["@TERMINALID"]        = response.Shift.TerminalId;
                    parameters["@STOREID"]           = response.Shift.StoreId;
                    parameters["@SHIFTID"]           = response.Shift.ShiftId;
                    parameters["@STAFFID"]           = response.Shift.StaffId;
                    parameters["@CURRENTSTAFFID"]    = response.Shift.CurrentStaffId;
                    parameters["@STATUS"]            = response.Shift.Status;
                    parameters["@CURRENTTERMINALID"] = response.Shift.CurrentTerminalId;
                    parameters["@ISSHARED"]          = response.Shift.IsShared;
                    parameters["@STARTDATETIMEUTC"]  = DateTimeOffsetDataHelper.GetDbNullableDateTime(response.Shift.StartDateTime);
                    parameters["@STATUSDATETIMEUTC"] = DateTimeOffsetDataHelper.GetDbNullableDateTime(response.Shift.StatusDateTime);
                    parameters["@DATAAREAID"]        = inventLocationDataAreaId;
                    parameters["@CASHDRAWER"]        = response.Shift.CashDrawer;

                    databaseContext.ExecuteStoredProcedureNonQuery("[ext].[CreateNewShift]", parameters);
                }
            }
            /// <summary>
            /// Convert the shift object to a data row to insert into RetailPosBatchTable or RetailShiftStagingTable.
            /// </summary>
            /// <param name="table">The data table.</param>
            /// <param name="shift">The shift object.</param>
            /// <param name="inventLocationDataAreaId">The invent location area id.</param>
            /// <param name="isShiftStagingTableRow">True, if the shift info is to be put into RetailShiftStagingTable.</param>
            /// <returns>The DataRow object containing the shift info.</returns>
            private DataRow ConvertToShiftDataRow(DataTable table, Shift shift, string inventLocationDataAreaId, bool isShiftStagingTableRow = true)
            {
                DateTime?startShiftDateTime, closeShiftDateTime, statusShiftDateTime;
                DataRow  row = table.NewRow();

                if (isShiftStagingTableRow)
                {
                    startShiftDateTime  = DateTimeOffsetDataHelper.GetDbNullableDateTime(shift.StartDateTime);
                    closeShiftDateTime  = DateTimeOffsetDataHelper.GetDbNullableDateTime(shift.CloseDateTime);
                    statusShiftDateTime = DateTimeOffsetDataHelper.GetDbNullableDateTime(shift.StatusDateTime);
                }
                else
                {
                    startShiftDateTime  = DateTimeOffsetDataHelper.GetDbNullableUtcDateTime(shift.StartDateTime);
                    closeShiftDateTime  = DateTimeOffsetDataHelper.GetDbNullableUtcDateTime(shift.CloseDateTime);
                    statusShiftDateTime = DateTimeOffsetDataHelper.GetDbNullableUtcDateTime(shift.StatusDateTime);
                }

                row[CashDrawerColumn]                 = shift.CashDrawer;
                row[ChannelRecordIdColumn]            = shift.StoreRecordId;
                row[CloseDateColumn]                  = DateTimeOffsetDataHelper.GetDbNullableDate(shift.CloseDateTime);
                row[CloseDateTimeUtcColumn]           = closeShiftDateTime;
                row[CloseDateTimeUtcTimeZoneIdColumn] = 0; // Not assigned in POS.
                row[CloseTimeColumn]                  = DateTimeOffsetDataHelper.GetDbNullableTimeInSeconds(shift.CloseDateTime);
                row[ClosedAtTerminalIdColumn]         = shift.ClosedAtTerminalId;
                row[CurrentTerminalIdColumn]          = shift.CurrentTerminalId;
                row[CustomerCountColumn]              = shift.CustomerCount;
                row[DiscountTotalColumn]              = shift.DiscountTotal;
                row[LogOnTransactionCountColumn]      = shift.LogOnTransactionCount;
                row[NoSaleCountColumn]                = shift.NoSaleTransactionCount;
                row[PaidToAccountTotalColumn]         = shift.PaidToAccountTotal;
                row[PostedColumn]                     = 0; // Not assigned in POS.
                row[ReturnsTotalColumn]               = shift.ReturnsTotal;
                row[RoundedAmountTotalColumn]         = shift.RoundedAmountTotal;
                row[SaleTransactionCountColumn]       = shift.SaleTransactionCount;
                row[SalesTotalColumn]                 = shift.SalesTotal;
                row[ShiftIdColumn]                    = shift.ShiftId;
                row[StaffIdColumn]                    = shift.StaffId;
                row[CurrentStaffIdColumn]             = shift.CurrentStaffId;
                row[StartDateColumn]                  = DateTimeOffsetDataHelper.GetDbNullableDateTime(shift.StartDateTime);
                row[StartDateTimeUtcColumn]           = startShiftDateTime;
                row[StartDateTimeUtcTimeZoneIdColumn] = 0; // Not assigned in POS.
                row[StartTimeColumn]                  = DateTimeOffsetDataHelper.GetDbNullableTimeInSeconds(shift.StartDateTime);
                row[StatusColumn]                     = (int)shift.Status;
                row[StatusDateTimeUtcColumn]          = statusShiftDateTime;
                row[StoreIdColumn]                    = shift.StoreId;
                row[TaxTotalColumn]                   = shift.TaxTotal;
                row[TerminalIdColumn]                 = shift.TerminalId;
                row[TransactionCountColumn]           = shift.TransactionCount;
                row[VoidTransactionCountColumn]       = shift.VoidTransactionCount;
                row[IsSharedColumn]                   = shift.IsShared;
                row[DataAreaIdColumn]                 = inventLocationDataAreaId;

                return(row);
            }
Пример #3
0
            public static void CreateShiftAsync(CreateShiftRequest request, CreateShiftResponse response)
            {
                ThrowIf.Null(request, "CreateShiftRequest");
                ThrowIf.Null(response, "CreateShiftResponse");

                string inventLocationDataAreaId = request.RequestContext.GetChannelConfiguration().InventLocationDataAreaId;

                Task.Run <bool>(() => {
                    InvokeExtensionMethodRealtimeRequest extensionRequest = new InvokeExtensionMethodRealtimeRequest(
                        "CreateNewShift",
                        response.Shift.StoreRecordId,
                        response.Shift.TerminalId,
                        response.Shift.StoreId,
                        response.Shift.ShiftId,
                        response.Shift.StaffId,
                        response.Shift.CurrentStaffId,
                        Convert.ToInt32(response.Shift.Status),
                        response.Shift.CurrentTerminalId,
                        response.Shift.IsShared,
                        response.Shift.CashDrawer,
                        inventLocationDataAreaId);

                    InvokeExtensionMethodRealtimeResponse RTSResponse = request.RequestContext.Execute <InvokeExtensionMethodRealtimeResponse>(extensionRequest);
                    ReadOnlyCollection <object> results = RTSResponse.Result;
                    bool success = Convert.ToBoolean(results[0]);
                    return(success);
                });

                Task.Run(() =>
                {
                    using (var databaseContext = new DatabaseContext(request))
                    {
                        ParameterSet parameters          = new ParameterSet();
                        parameters["@CHANNEL"]           = response.Shift.StoreRecordId;
                        parameters["@TERMINALID"]        = response.Shift.TerminalId;
                        parameters["@STOREID"]           = response.Shift.StoreId;
                        parameters["@SHIFTID"]           = response.Shift.ShiftId;
                        parameters["@STAFFID"]           = response.Shift.StaffId;
                        parameters["@CURRENTSTAFFID"]    = response.Shift.CurrentStaffId;
                        parameters["@STATUS"]            = response.Shift.Status;
                        parameters["@CURRENTTERMINALID"] = response.Shift.CurrentTerminalId;
                        parameters["@ISSHARED"]          = response.Shift.IsShared;
                        parameters["@STARTDATETIMEUTC"]  = DateTimeOffsetDataHelper.GetDbNullableDateTime(response.Shift.StartDateTime);
                        parameters["@STATUSDATETIMEUTC"] = DateTimeOffsetDataHelper.GetDbNullableDateTime(response.Shift.StatusDateTime);
                        parameters["@DATAAREAID"]        = inventLocationDataAreaId;
                        parameters["@CASHDRAWER"]        = response.Shift.CashDrawer;

                        databaseContext.ExecuteStoredProcedureNonQuery("[ext].[CreateNewShift]", parameters);
                    }
                }).Wait();
            }