/// <summary>
            /// Checks whether the current employee has an open session on the current terminal.
            /// </summary>
            /// <param name="requestContext">The request context.</param>
            /// <returns>The data service response.</returns>
            private SingleEntityDataServiceResponse <bool> CheckEmployeeHasOpenSessionOnCurrentTerminal(RequestContext requestContext)
            {
                const string EmployeeSessionsViewName = "EmployeeSessionsView";
                string       terminalId = requestContext.GetTerminal().TerminalId;
                string       staffId    = requestContext.GetPrincipal().UserId;

                bool employeeHasOpenSessionOnCurrentTerminal;

                DataStoreManager.InstantiateDataStoreManager(requestContext);
                EmployeeL2CacheDataStoreAccessor accessor = new EmployeeL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], requestContext);

                if (!accessor.CheckEmployeeSessionOpenOnTerminal(terminalId, staffId, out employeeHasOpenSessionOnCurrentTerminal))
                {
                    using (DatabaseContext databaseContext = new DatabaseContext(requestContext))
                    {
                        SqlPagedQuery query = new SqlPagedQuery(QueryResultSettings.SingleRecord)
                        {
                            Select = new ColumnSet("STAFFID"),
                            From   = EmployeeSessionsViewName,
                            Where  = "DATAAREAID = @DATAAREAID AND STAFFID = @STAFFID AND TERMINALID = @TERMINALID AND CHANNELID = @CHANNELID",
                        };

                        query.Parameters["@DATAAREAID"] = requestContext.GetChannelConfiguration().InventLocationDataAreaId;
                        query.Parameters["@STAFFID"]    = staffId;
                        query.Parameters["@TERMINALID"] = terminalId;
                        query.Parameters["@CHANNELID"]  = requestContext.GetPrincipal().ChannelId;

                        employeeHasOpenSessionOnCurrentTerminal = databaseContext.ExecuteScalarCollection <string>(query).Any();
                    }

                    accessor.CacheIsEmployeeSessionOpenOnTerminal(terminalId, staffId, employeeHasOpenSessionOnCurrentTerminal);
                }

                return(new SingleEntityDataServiceResponse <bool>(employeeHasOpenSessionOnCurrentTerminal));
            }
示例#2
0
            private SingleEntityDataServiceResponse <bool> RunDBHealthCheck(RunDBHealthCheckDataRequest request)
            {
                DataStoreManager.InstantiateDataStoreManager(request.RequestContext);
                DatabaseHealthDataManager dataManager = new DatabaseHealthDataManager(request.RequestContext);
                bool result = dataManager.RunDatabaseHealthCheck();

                return(new SingleEntityDataServiceResponse <bool>(result));
            }
            private static GetStorageLookupDataResponse GetStorageLookup(GetStorageLookupDataRequest request)
            {
                // initialize caching storage
                DataStoreManager.InstantiateDataStoreManager(request.RequestContext);

                StorageLookupDataManager         dataManager   = new StorageLookupDataManager(request.RequestContext);
                Dictionary <long, StorageLookup> lookupMapping = dataManager.GetStorageLookupMapping(request.ConnectionString);

                return(new GetStorageLookupDataResponse(lookupMapping));
            }
            /// <summary>
            /// Logs On the user in the local store database.
            /// </summary>
            /// <param name="request">The data service request.</param>
            /// <returns>The data service response.</returns>
            private SingleEntityDataServiceResponse <Employee> EmployeeLogOnStore(EmployeeLogOnStoreDataRequest request)
            {
                EmployeeDataManager dataManager = this.GetDataManagerInstance(request.RequestContext);
                var result = dataManager.EmployeeLogOnStore(request.ChannelId, request.StaffId, request.PasswordHash, request.ColumnSet);

                // Clear the cache for the staff at logon.
                DataStoreManager.InstantiateDataStoreManager(request.RequestContext);
                EmployeeL2CacheDataStoreAccessor accessor = new EmployeeL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], request.RequestContext);

                accessor.ClearCacheAuthorizedEmployeeOnStore(request.ChannelId, request.StaffId);

                return(new SingleEntityDataServiceResponse <Employee>(result));
            }
 /// <summary>
 /// Initialize the cache and instantiate the cache accessor.
 /// </summary>
 /// <param name="context">RequestContext instance <see cref="RequestContext"/></param>
 private void InitailizeCache(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     this.cacheAccessor = new PaymentL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context);
 }
 /// <summary>
 /// Gets the cache accessor for the customer data service requests.
 /// </summary>
 /// <param name="context">The request context.</param>
 /// <returns>An instance of the <see cref="CustomerL2CacheDataStoreAccessor"/> class.</returns>
 private CustomerL2CacheDataStoreAccessor GetCustomerL2CacheDataStoreAccessor(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     return(new CustomerL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context));
 }
 /// <summary>
 /// Gets the cache accessor for the India tax data service requests.
 /// </summary>
 /// <param name="context">The request context.</param>
 /// <returns>An instance of the <see cref="ChannelL2CacheDataStoreAccessor"/> class.</returns>
 private IndiaTaxL2CacheDataStoreAccessor GetIndiaTaxL2CacheDataStoreAccessor(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     return(new IndiaTaxL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context));
 }
 /// <summary>
 /// Gets the cache accessor for the reason code data service requests.
 /// </summary>
 /// <param name="context">The request context.</param>
 /// <returns>An instance of the <see cref="ReasonCodeL2CacheDataStoreAccessor"/> class.</returns>
 private static ReasonCodeL2CacheDataStoreAccessor GetReasonCodeL2CacheDataStoreAccessor(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     return(new ReasonCodeL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetProductsHelper"/> class.
 /// </summary>
 /// <param name="request">The request for getting products.</param>
 public GetProductsHelper(GetProductServiceRequest request)
 {
     this.request = request;
     this.DataStoreManagerInstance = DataStoreManager.InstantiateDataStoreManager(request.RequestContext);
     this.DataStoreManagerInstance.RegisterDataStoreAccessor(DataStoreType.L2Cache, ProductL2CacheDataStoreAccessor.Instantiate, request.RequestContext);
 }
示例#10
0
 /// <summary>
 /// Gets the cache accessor for the employee data service requests.
 /// </summary>
 /// <param name="context">The request context.</param>
 /// <returns>An instance of the <see cref="EmployeeL2CacheDataStoreAccessor"/> class.</returns>
 private static EmployeeL2CacheDataStoreAccessor GetCacheAccessor(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     return(new EmployeeL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context));
 }
 /// <summary>
 /// Gets the cache accessor for the commerce identity provider data service requests.
 /// </summary>
 /// <param name="context">The request context.</param>
 /// <returns>An instance of the <see cref="CommerceIdentityProviderL2CacheDataStoreAccessor"/> class.</returns>
 private CommerceIdentityProviderL2CacheDataStoreAccessor GetCommerceIdentityProviderL2CacheDataStoreAccessor(RequestContext context)
 {
     DataStoreManager.InstantiateDataStoreManager(context);
     return(new CommerceIdentityProviderL2CacheDataStoreAccessor(DataStoreManager.DataStores[DataStoreType.L2Cache], context));
 }