Пример #1
0
            /// <summary>
            /// Creates or Updates the retail device.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private NullResponse CreateOrUpdateDevice(CreateOrUpdateDeviceDataRequest request)
            {
                ThrowIf.Null(request.Device, "request.Device");

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@dt_ActivatedDateTime"]           = request.Device.ActivatedDateTime;
                    parameters["@i_ActivationStatus"]             = request.Device.ActivationStatus;
                    parameters["@nvc_DeactivateComments"]         = request.Device.DeactivateComments;
                    parameters["@dt_DeactivatedDateTime"]         = request.Device.DeactivatedDateTime;
                    parameters["@nvc_Description"]                = request.Device.Description;
                    parameters["@nvc_DeviceId"]                   = request.Device.DeviceNumber;
                    parameters["@nvc_Terminal"]                   = request.Device.TerminalId;
                    parameters["@bi_TypeRecordId"]                = request.Device.DeviceTypeRecordId;
                    parameters["@nvc_DeviceTokenData"]            = request.Device.TokenData;
                    parameters["@nvc_DeviceTokenSalt"]            = request.Device.TokenSalt;
                    parameters["@nvc_DeviceTokenAlgorithm"]       = request.Device.TokenAlgorithm;
                    parameters["@dt_DeviceTokenIssueTime"]        = request.Device.TokenIssueTime;
                    parameters["@i_UseInMemoryDeviceDataStorage"] = request.Device.UseInMemoryDeviceDataStorage;
                    parameters["@bi_RecordId"] = request.Device.RecordId;

                    databaseContext.ExecuteStoredProcedureNonQuery(CreateUpdateDeviceSprocName, parameters);
                }

                DeviceL2CacheDataStoreAccessor levelL2CacheDataAccessor = this.GetDeviceL2CacheDataStoreAccessor(request.RequestContext);

                levelL2CacheDataAccessor.ClearCacheDeviceById(request.Device.DeviceNumber);

                return(new NullResponse());
            }
Пример #2
0
            private static NullResponse UpdateReturnQuantities(UpdateReturnQuantitiesDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.SalesLines, "request.SalesLines");

                foreach (var salesline in request.SalesLines)
                {
                    if (salesline.IsReturnByReceipt)
                    {
                        ParameterSet parameters = new ParameterSet();
                        parameters[DatabaseAccessor.ChannelIdVariableName] = salesline.ReturnChannelId;
                        parameters["@nvc_StoreNumber"]   = salesline.ReturnStore;
                        parameters["@nvc_TerminalId"]    = salesline.ReturnTerminalId;
                        parameters["@nvc_TransactionId"] = salesline.ReturnTransactionId;
                        parameters["@nu_LineNumber"]     = salesline.ReturnLineNumber;
                        parameters["@nu_Quantity"]       = salesline.Quantity;

                        using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                        {
                            databaseContext.ExecuteStoredProcedureNonQuery("UPDATERETURNQUANTITY", parameters);
                        }
                    }
                }

                return(new NullResponse());
            }
            /// <summary>
            /// Delete the shift from shift staging table.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>A null response.</returns>
            private NullResponse DeleteShiftStagingTable(DeleteShiftDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.Shift, "request.Shift");

                Shift shift = request.Shift;

                ParameterSet parameters = new ParameterSet();

                parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                parameters[TerminalIdVariableName] = shift.TerminalId;
                parameters[ShiftIdVariableName]    = shift.ShiftId;
                parameters[RowVersionViarableName] = shift.RowVersion;

                int errorCode;

                using (var sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(DeleteShiftStagingSprocName, parameters);
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(
                              StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError,
                              errorCode,
                              string.Format("Unable to execute the stored procedure {0}.", DeleteShiftStagingSprocName));
                }

                return(new NullResponse());
            }
Пример #4
0
            private static NullResponse DeleteCart(DeleteCartDataRequest request)
            {
                ThrowIf.Null(request, "request");

                int errorCode;

                using (StringIdTableType transactionIdsTableType = new StringIdTableType(request.SalesTransactionIds, string.Empty))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters[SalesTransactionIdsTableTypeVariableName] = transactionIdsTableType;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(DeleteSalesTransactionsSprocName, parameters);
                    }
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    if (errorCode == (int)DatabaseErrorCodes.AuthorizationError)
                    {
                        throw new SecurityException(SecurityErrors.Microsoft_Dynamics_Commerce_Runtime_AuthorizationFailed, "One or more transactions could not be deleted.");
                    }

                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to delete transactions.");
                }

                return(new NullResponse());
            }
Пример #5
0
            /// <summary>
            /// Inserts audit log.
            /// </summary>
            /// <param name="request">The <see cref="InsertAuditLogDataRequest"/>log request.</param>
            /// <returns>The <see cref="NullResponse"/>response.</returns>
            private NullResponse InsertAuditLog(InsertAuditLogDataRequest request)
            {
                // Insert
                ChannelConfiguration channelConfiguration = request.RequestContext.GetChannelConfiguration();

                // RetailLog is an AX table, DataAreaId field is mandatory. We need to confirm channelConfiguration is present
                // before inserting data to RetailLog, otherwise P-job will fail due to DataAreaId is missing.
                if (channelConfiguration != null)
                {
                    var parameters = new ParameterSet();
                    parameters["@RETAILLOGID"]        = DateTimeOffset.UtcNow.Ticks;
                    parameters["@DATE"]               = request.RequestContext.GetNowInChannelTimeZone().DateTime;
                    parameters["@CODEUNIT"]           = request.Source;
                    parameters["@LOGSTRING"]          = request.LogEntry;
                    parameters["@LOGLEVEL"]           = request.LogLevel;
                    parameters["@STOREID"]            = request.StoreId;
                    parameters["@TERMINALID"]         = request.TerminalId;
                    parameters["@DURATIONINMILLISEC"] = request.DurationInMilliseconds;
                    parameters["@DATAAREAID"]         = channelConfiguration.InventLocationDataAreaId;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(AuditLogSqlServerDataService.InsertAuditLogSprocName, parameters);
                    }
                }

                return(new NullResponse());
            }
Пример #6
0
            private ValidateAddressDataResponse ValidateAddress(ValidateAddressDataRequest request)
            {
                ThrowIf.Null(request.Address, "address");

                if (string.IsNullOrWhiteSpace(request.Address.ThreeLetterISORegionName))
                {
                    return(CreateFailedValidateAddressDataResponse(DataValidationErrors.Microsoft_Dynamics_Commerce_Runtime_InvalidCountryRegion, AddressServiceConstants.ThreeLetterISORegionName));
                }

                Address address = request.Address;

                ParameterSet parameters = new ParameterSet();

                parameters[AddressServiceConstants.CountryRegionId] = address.ThreeLetterISORegionName;

                if (!string.IsNullOrWhiteSpace(address.State))
                {
                    parameters[AddressServiceConstants.StateProvinceId] = address.State;
                }

                if (!string.IsNullOrWhiteSpace(address.County))
                {
                    parameters[AddressServiceConstants.CountyId] = address.County;
                }

                if (!string.IsNullOrWhiteSpace(address.City))
                {
                    parameters[AddressServiceConstants.CityComponentName] = address.City;
                }

                if (!string.IsNullOrWhiteSpace(address.DistrictName))
                {
                    parameters[AddressServiceConstants.DistrictId] = address.DistrictName;
                }

                if (!string.IsNullOrWhiteSpace(address.ZipCode))
                {
                    parameters[AddressServiceConstants.ZipPostalCodeComponentName] = address.ZipCode;
                }

                int result;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    result = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(ValidateAddressSprocName, parameters);
                }

                if (result == 0)
                {
                    return(new ValidateAddressDataResponse(true));
                }

                Tuple <DataValidationErrors, string> faultAddressComponent = HandleNonZeroResult(result);

                return(CreateFailedValidateAddressDataResponse(faultAddressComponent.Item1, faultAddressComponent.Item2));
            }
Пример #7
0
            /// <summary>
            /// Delete user credentials associated to the <paramref name="request"/>.
            /// </summary>
            /// <param name="request">The data request.</param>
            /// <returns>A void service response.</returns>
            private NullResponse DeleteUserCredentials(DeleteUserCredentialsDataRequest request)
            {
                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@nvc_staffId"]   = request.UserId;
                    parameters["@nvc_grantType"] = request.GrantType;

                    databaseContext.ExecuteStoredProcedureNonQuery(DeleteUserCredentialsSprocName, parameters);
                }

                return(new NullResponse());
            }
Пример #8
0
            private static NullResponse SaveCart(SaveCartDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.SalesTransactions, "request.SalesTransactions");

                var salesTransactionDataCollection = SalesTransactionConverter.ConvertToData(request.SalesTransactions, serializeData: true);

                using (DataTable table = new DataTable(SalesTransactionTableTypeName))
                {
                    SalesTransactionData.FillSchemaForSave(table);
                    foreach (SalesTransactionData salesTransactionData in salesTransactionDataCollection)
                    {
                        table.Rows.Add(salesTransactionData.CreateDataRow(table));
                    }

                    ParameterSet parameters = new ParameterSet();
                    parameters[SalesTransactionTableTypeVariableName] = table;
                    parameters["@b_IgnoreRowVersionCheck"]            = request.IgnoreRowVersionCheck;

                    try
                    {
                        int errorCode;
                        using (var databaseContext = new SqlServerDatabaseContext(request))
                        {
                            errorCode = databaseContext.ExecuteStoredProcedureNonQuery(SaveSalesTransactionSprocName, parameters);
                        }

                        if (errorCode == (int)DatabaseErrorCodes.VersionMismatchError)
                        {
                            throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_ObjectVersionMismatchError, errorCode, "Version mismatch while saving transaction.");
                        }

                        if (errorCode != (int)DatabaseErrorCodes.Success)
                        {
                            throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save transactions.");
                        }
                    }
                    catch (DatabaseException databaseException)
                    {
                        throw new StorageException(
                                  StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError,
                                  (int)databaseException.ErrorCode,
                                  databaseException,
                                  "Unable to save transactions.");
                    }
                }

                return(new NullResponse());
            }
Пример #9
0
            private NullResponse SaveOfflineTransactions(SqlServerDatabaseContext databaseContext, byte[] compressedTransactions)
            {
                string offlineTransactionsInXmlString = DecompressTransactions(compressedTransactions);

                ParameterSet parameters = new ParameterSet();

                parameters[OfflineTransactionsParameter] = offlineTransactionsInXmlString;
                int errorCode = databaseContext.ExecuteStoredProcedureNonQuery("UpsertOfflineTransactions", parameters);

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save offline transactions.");
                }

                return(new NullResponse());
            }
Пример #10
0
            /// <summary>
            /// Persists the user credential on the database.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private NullResponse SaveUserCredentials(SaveUserCredentialsDataRequest request)
            {
                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@bi_recId"]                         = request.UserCredential.RecId;
                    parameters["@nvc_StaffId"]                      = request.UserCredential.StaffId;
                    parameters["@nvc_HashedCredential"]             = request.UserCredential.HashedCredential;
                    parameters["@nvc_Salt"]                         = request.UserCredential.Salt;
                    parameters["@nvc_HashAlgorithm"]                = request.UserCredential.HashAlgorithm;
                    parameters["@nvc_GrantType"]                    = request.UserCredential.GrantType;
                    parameters["@nvc_CredentialId"]                 = request.UserCredential.CredentialId;
                    parameters["@nvc_AdditionalAuthenticationData"] = request.UserCredential.AdditionalAuthenticationData;

                    databaseContext.ExecuteStoredProcedureNonQuery(SaveUserCredentialsSprocName, parameters);
                }

                return(new NullResponse());
            }
Пример #11
0
            /// <summary>
            /// Sets the channel-specific properties of the specified channel.
            /// </summary>
            /// <param name="request">The update channel properties by channel id data request.</param>
            /// <returns>A null response.</returns>
            private NullResponse UpdateChannelPropertiesByChannelId(UpdateChannelPropertiesByChannelIdDataRequest request)
            {
                ThrowIf.Null(request, "request");
                ThrowIf.Null(request.ChannelProperties, "request.ChannelProperties");

                ChannelL2CacheDataStoreAccessor level2CacheDataAccessor = this.GetChannelL2CacheDataStoreAccessor(request.RequestContext);

                bool updateL2Cache = DataStoreManager.DataStores[DataStoreType.L2Cache].Policy.MustUpdateOnMiss &&
                                     request.ChannelProperties.Count() < MaxCachedCollectionSize;

                Stopwatch processTimer = Stopwatch.StartNew();

                foreach (ChannelProperty channelProperty in request.ChannelProperties)
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@bi_ChannelId"]      = request.ChannelId;
                    parameters["@nvc_PropertyName"]  = channelProperty.Name;
                    parameters["@nvc_PropertyValue"] = channelProperty.Value;

                    int errorCode;

                    using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                    {
                        errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(SaveChannelPropertySprocName, parameters);
                    }

                    if (errorCode != (int)DatabaseErrorCodes.Success)
                    {
                        throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to update channel properties.");
                    }
                }

                processTimer.Stop();
                NetTracer.Information("** timer info: UpdateChannelPropertiesByChannelId completed in {0} ms", processTimer.ElapsedMilliseconds);

                if (updateL2Cache)
                {
                    level2CacheDataAccessor.PutChannelPropertiesByChannelId(request.ChannelId, QueryResultSettings.AllRecords, request.ChannelProperties.AsPagedResult());
                }

                return(new NullResponse());
            }
            private static SingleEntityDataServiceResponse <bool> IsProductOrVariantInCategory(CheckIfProductOrVariantAreInCategoryDataRequest request)
            {
                RequestContext context = request.RequestContext;

                ThrowIf.Null(context, "context");

                ParameterSet parameters = new ParameterSet();

                parameters[ProductRecIdColumnName]  = request.ProductRecordId;
                parameters[CategoryRecIdColumnName] = request.CategoryRecordId;

                int result;

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request))
                {
                    result = databaseContext.ExecuteStoredProcedureNonQuery(IsProductInCategorySprocName, parameters);
                }

                return(new SingleEntityDataServiceResponse <bool>(result == 1));
            }
            /// <summary>
            /// Saves the transaction log.
            /// </summary>
            /// <param name="request">The request.</param>
            /// <returns>The empty response.</returns>
            private static NullResponse Save(InsertTransactionLogDataRequest request)
            {
                ParameterSet parameters = new ParameterSet();

                parameters["@bi_ChannelId"]         = request.ChannelId;
                parameters["@TVP_TransactionTable"] = request.TransactionLogTable;

                int errorCode;

                using (var databaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = databaseContext.ExecuteStoredProcedureNonQuery("INSERTTRANSACTION", parameters);
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save transaction log.");
                }

                return(new NullResponse());
            }
            private NullResponse InsertLoyaltyCard(InsertLoyaltyCardDataRequest request)
            {
                ThrowIf.Null(request.LoyaltyCard, "loyaltyCard");

                using (DataTable loyaltyCardTable = new DataTable(LoyaltyCardTypeName))
                    using (DataTable loyaltyCardTierTable = new DataTable(LoyaltyCardTierTypeName))
                    {
                        // Prepare loyalty card data
                        AddLoyaltyCardTableTypeSchema(loyaltyCardTable);
                        loyaltyCardTable.Rows.Add(ConvertLoyaltyCardToDataRow(loyaltyCardTable, request.LoyaltyCard));

                        // Prepare loyalty card tier data
                        AddLoyaltyCardTierTableTypeSchema(loyaltyCardTierTable);
                        foreach (var cardLoyaltyGroup in request.LoyaltyCard.LoyaltyGroups)
                        {
                            foreach (var cardTier in cardLoyaltyGroup.LoyaltyCardTiers)
                            {
                                loyaltyCardTierTable.Rows.Add(ConvertLoyaltyCardTierToDataRow(loyaltyCardTierTable, request.LoyaltyCard, cardLoyaltyGroup, cardTier));
                            }
                        }

                        // Insert
                        var parameters = new ParameterSet();
                        parameters["@TVP_LOYALTYCARDTABLETYPE"]     = loyaltyCardTable;
                        parameters["@TVP_LOYALTYCARDTIERTABLETYPE"] = loyaltyCardTierTable;

                        int errorCode;
                        using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                        {
                            errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(LoyaltySqlServerDataService.InsertLoyaltyCardSprocName, parameters);
                        }

                        if (errorCode != (int)DatabaseErrorCodes.Success)
                        {
                            throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save the loyalty card in the channel database.");
                        }
                    }

                return(new NullResponse());
            }
Пример #15
0
            /// <summary>
            /// Updates the current user's password.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private NullResponse UpdateEmployeePassword(UpdateEmployeePasswordDataRequest request)
            {
                ThrowIf.NullOrWhiteSpace(request.StaffId, "StaffId");

                using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                {
                    ParameterSet parameters = new ParameterSet();
                    parameters["@nvc_StaffId"]                    = request.StaffId;
                    parameters["@nvc_PasswordHash"]               = request.PasswordHash;
                    parameters["@nvc_PasswordSalt"]               = request.PasswordSalt;
                    parameters["@nvc_PasswordHashAlgorithm"]      = request.PasswordHashAlgorithm;
                    parameters["@dt_PasswordLastChangedDateTime"] = request.PasswordLastChangedDateTime.UtcDateTime;
                    parameters["i_PasswordLastUpdatedOperation"]  = (int)request.PasswordLastUpdatedOperation;
                    parameters["@nvc_ChangePasswordAtNextLogOn"]  = request.ChangePasswordAtNextLogOn;

                    databaseContext.ExecuteStoredProcedureNonQuery(UpdateEmployeePasswordSprocName, parameters);

                    // Clear cache for the employee object after updating password.
                    GetCacheAccessor(request.RequestContext).ClearCacheAuthorizedEmployeeOnStore(request.RequestContext.GetPrincipal().ChannelId, request.StaffId);
                }

                return(new NullResponse());
            }
Пример #16
0
            private static NullResponse PurgeSalesTransactions(PurgeSalesTransactionsDataRequest request)
            {
                ThrowIf.Null(request, "request");

                if (request.RetentionDays > 0)
                {
                    try
                    {
                        var parameters = new ParameterSet
                        {
                            { "@bi_ChannelId", request.ChannelId },
                            { "@vc_TerminalId", request.TerminalId },
                            { "@i_RetentionDays", request.RetentionDays },
                            { "@f_PurgeOrder", 1 } // purge customer orders first
                        };

                        using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                        {
                            databaseContext.ExecuteStoredProcedureNonQuery(PurgeSalesTransactionsSpProcName, parameters);
                        }

                        // now purge retail transactions
                        parameters["@f_PurgeOrder"] = 0;

                        using (SqlServerDatabaseContext databaseContext = new SqlServerDatabaseContext(request.RequestContext))
                        {
                            databaseContext.ExecuteStoredProcedureNonQuery(PurgeSalesTransactionsSpProcName, parameters);
                        }
                    }
                    catch (Exception exception)
                    {
                        RetailLogger.Log.CrtDataAccessPurgeSalesTransactionFailure(exception);
                    }
                }

                return(new NullResponse());
            }
Пример #17
0
            /// <summary>
            /// Updates the publishing status of the channel.
            /// </summary>
            /// <param name="request">The update online channel publish status data request.</param>
            /// <returns>Result that indicates whether the update is successful.</returns>
            private SingleEntityDataServiceResponse <bool> UpdatePublishStatus(UpdateOnlineChannelPublishStatusDataRequest request)
            {
                ThrowIf.Null(request, "request");

                Stopwatch processTimer = Stopwatch.StartNew();

                ParameterSet parameters = new ParameterSet();

                parameters["@bi_ChannelId"]             = request.ChannelId;
                parameters["@i_PublishStatus"]          = request.PublishStatus;
                parameters["@nvc_PublishStatusMessage"] = request.PublishStatusMessage;

                int errorCode;

                using (SqlServerDatabaseContext sqlServerDatabaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = sqlServerDatabaseContext.ExecuteStoredProcedureNonQuery(UpdateOnlineChannelPublishStatusSprocName, parameters);
                }

                processTimer.Stop();
                NetTracer.Information("** timer info: UpdatePublishStatus completed in {0} ms", processTimer.ElapsedMilliseconds);

                return(new SingleEntityDataServiceResponse <bool>(errorCode == (int)DatabaseErrorCodes.Success));
            }
Пример #18
0
            private static NullResponse InsertSalesTransactionTables(InsertSalesTransactionTablesDataRequest request)
            {
                ParameterSet parameters = new ParameterSet();

                parameters[DatabaseAccessor.ChannelIdVariableName] = request.RequestContext.GetPrincipal().ChannelId;
                parameters["@tvp_Transaction"]                 = request.TransactionTable;
                parameters["@tvp_SalesTrans"]                  = request.LinesTable;
                parameters["@tvp_IncomeExpense"]               = request.IncomeExpenseTable;
                parameters["@tvp_MarkupTrans"]                 = request.MarkupTable;
                parameters["@tvp_PaymentTrans"]                = request.PaymentTable;
                parameters["@tvp_TaxTrans"]                    = request.TaxTable;
                parameters["@tvp_AttributeTrans"]              = request.AttributeTable;
                parameters["@tvp_AddressTrans"]                = request.AddressTable;
                parameters["@tvp_DiscountTrans"]               = request.DiscountTable;
                parameters["@tvp_InfoCodeTrans"]               = request.ReasonCodeTable;
                parameters["@tvp_SalesProperties"]             = request.PropertiesTable;
                parameters["@tvp_RewardPointTrans"]            = request.RewardPointTable;
                parameters["@tvp_AffiliationTrans"]            = request.AffiliationsTable;
                parameters["@tvp_CustomerOrderTrans"]          = request.CustomerOrderTable;
                parameters["@tvp_InvoiceTrans"]                = request.InvoiceTable;
                parameters["@tvp_CustomerAccountDepositTrans"] = request.CustomerAccountDepositTable;

                int errorCode;

                using (var databaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = databaseContext.ExecuteStoredProcedureNonQuery("INSERTSALESORDER", parameters);
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save sales order.");
                }

                return(new NullResponse());
            }
Пример #19
0
            /// <summary>
            /// Logs the user authentication request.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The empty response.</returns>
            private NullResponse LogAuthenticationRequest(LogAuthenticationDataRequest request)
            {
                ParameterSet parameters = new ParameterSet();

                parameters[AuthenticationStatusParamName] = (int)request.AuthenticationStatus;
                parameters["@ui_LogId"]     = Guid.NewGuid();
                parameters["@bi_ChannelId"] = request.ChannelId;
                parameters["@nvc_StaffId"]  = request.StaffId;
                parameters["@i_AuthenticationOperation"] = request.AuthenticationOperation;

                int errorCode;

                using (var databaseContext = new SqlServerDatabaseContext(request))
                {
                    errorCode = databaseContext.ExecuteStoredProcedureNonQuery(LogAuthenticationRequestSprocName, parameters);
                }

                if (errorCode != (int)DatabaseErrorCodes.Success)
                {
                    throw new StorageException(StorageErrors.Microsoft_Dynamics_Commerce_Runtime_CriticalStorageError, errorCode, "Unable to save logon attempt.");
                }

                return(new NullResponse());
            }