Пример #1
0
            private static DiscountMethodType GetDiscountMethodType(PeriodicDiscountOfferType periodicDiscountType, int discountTypeFromDatabase)
            {
                DiscountMethodType discountMethod = DiscountMethodType.DealPrice;

                // ISNULL(pdmm.MIXANDMATCHDISCOUNTTYPE, ISNULL(pdmb.MULTIBUYDISCOUNTTYPE, pd.PERIODICDISCOUNTTYPE))
                switch (periodicDiscountType)
                {
                case PeriodicDiscountOfferType.Offer:
                case PeriodicDiscountOfferType.Promotion:
                    discountMethod = DiscountMethodType.LineSpecific;
                    break;

                case PeriodicDiscountOfferType.MixAndMatch:
                case PeriodicDiscountOfferType.MultipleBuy:
                    discountMethod = (DiscountMethodType)discountTypeFromDatabase;
                    break;

                case PeriodicDiscountOfferType.Threshold:
                    discountMethod = DiscountMethodType.LineSpecific;
                    break;

                default:
                    NetTracer.Warning("Unsupported discount type: {0}", discountTypeFromDatabase);
                    break;
                }

                return(discountMethod);
            }
Пример #2
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException"></exception>
        public void Load()
        {
            if (LSRetailPosis.Settings.HardwareProfiles.PinPad.DeviceType != DeviceTypes.OPOS)
            {
                return;
            }

            NetTracer.Information("Peripheral [PinPad] - OPOS device loading: {0}", DeviceName ?? "<Undefined>");

            oposPinpad = new OPOSPINPadClass();

            // Open
            oposPinpad.Open(DeviceName);
            Peripherals.CheckResultCode(this, oposPinpad.ResultCode);

            // Claim
            oposPinpad.ClaimDevice(Peripherals.ClaimTimeOut);
            Peripherals.CheckResultCode(this, oposPinpad.ResultCode);

            // Configure/Enable
            oposPinpad.DataEvent    += new _IOPOSPINPadEvents_DataEventEventHandler(posPinpad_DataEvent);
            oposPinpad.ErrorEvent   += new _IOPOSPINPadEvents_ErrorEventEventHandler(posPinpad_ErrorEvent);
            oposPinpad.DeviceEnabled = true;

            IsActive = true;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SearchViewModel"/> class.
        /// </summary>
        /// <param name="searchType">Startup type of the search.</param>
        /// <param name="searchTerm">The search term.</param>
        public SearchViewModel(SearchType searchType, string searchTerm)
        {
            this.MinimumSearchTermLengh = MINIMUM_SEARCH_TERM_LENGTH;
            this.SearchTerms            = searchTerm ?? string.Empty;
            this.SearchType             = searchType;

            // If search type is category then search term is the "Category RecId"
            if (searchType == SearchType.Category)
            {
                Tuple <string, long> categoryDetail;

                if ((long.TryParse(SearchTerms, out this.searchCategoryId)) &&
                    (categoryDetail = itemData.GetCategoryDetails(searchCategoryId)) != null)
                {
                    this.SearchTerms = categoryDetail.Item1;
                    this.searchCategoryHierarchyId = categoryDetail.Item2;
                }
                else
                {
                    NetTracer.Warning("SearchViewModel : Invalid category specified '{0}'", searchTerm);
                }
            }

            if (searchCategoryHierarchyId == 0)
            {
                this.searchCategoryHierarchyId = itemData.GetRetailProductHierarchy();
            }
        }
Пример #4
0
        /// <summary>
        /// Open the cash drawer.
        /// </summary>
        public void OpenDrawer()
        {
            if (FiscalPrinter.FiscalPrinter.Instance.FiscalPrinterEnabled())
            {
                FiscalPrinter.FiscalPrinter.Instance.OpenDrawer();
                return;
            }

            if (IsActive)
            {
                NetTracer.Information("Peripheral [CashDrawer] - Open drawer");

                switch (this.DeviceType)
                {
                case DeviceTypes.OPOS:
                    oposCashDrawer.OpenDrawer();
                    break;

                case DeviceTypes.Windows:
                    using (SerialPort port = new SerialPort(this.DeviceName, 9600, Parity.None, 8, StopBits.One))
                    {
                        port.Open();
                        port.Write(OPEN_DRAWER_SEQUENCE);
                    }
                    break;

                case DeviceTypes.Manual:
                    // NoOp
                    break;
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Process Linked InfoCodes for TenderLineItem
        /// </summary>
        /// <param name="posTransaction"></param>
        /// <param name="tenderLineItem"></param>
        /// <param name="storeId"></param>
        /// <param name="tableRefId"></param>
        /// <param name="infoCodeType"></param>
        public void ProcessLinkedInfoCodes(IPosTransaction posTransaction, ITenderLineItem tenderLineItem, string storeId, InfoCodeTableRefType tableRefId, InfoCodeType infoCodeType)
        {
            TenderLineItem lineItem = tenderLineItem as TenderLineItem;

            if (lineItem == null)
            {
                NetTracer.Warning("tenderLineItem parameter is null");
                throw new ArgumentNullException("tenderLineItem");
            }

            //Loop while a linkedInfoCode is found
            int i = 0; //Set as a stop for a infinite loop
            LinkedListNode <InfoCodeLineItem> infoCodeItem = lineItem.InfoCodeLines.Last;

            if (infoCodeItem != null)
            {
                while (!string.IsNullOrEmpty(infoCodeItem.Value.LinkedInfoCodeId) && (i < 10))
                {
                    ProcessInfoCode(posTransaction, 0, lineItem.Amount, storeId, lineItem.TenderTypeId, lineItem.CurrencyCode, tableRefId, infoCodeItem.Value.LinkedInfoCodeId, infoCodeItem.Value, infoCodeType);
                    // This is to prevent an infinite loop when infocodes link to themselves..
                    if (infoCodeItem.Value.LinkedInfoCodeId == lineItem.InfoCodeLines.Last.Value.LinkedInfoCodeId)
                    {
                        break;
                    }

                    infoCodeItem = lineItem.InfoCodeLines.Last;
                    i++;
                }
            }
        }
Пример #6
0
            void ReaderController.ReaderStateChangedListener.onError(string message)
            {
                NetTracer.Warning(string.Format("An error occured : {0}", message));

                // Restart the device to capture the swipe information again.
                this.StartReader();
            }
Пример #7
0
            void ReaderController.ReaderStateChangedListener.onDecodeCompleted(Dictionary <string, string> decodeData)
            {
                NetTracer.Information(string.Format("Entering onDecodeCompleted event..."));

                if (this.RamblerCardSwipeEvent != null)
                {
                    // The card has been read and decoded.
                    // Now parse the received data and send it to the subscriber
                    lock (SyncLock)
                    {
                        if (!this.isCardReaderEnabled)
                        {
                            return;
                        }

                        try
                        {
                            RamblerMagneticStripeCardData ramblerCardData = new RamblerMagneticStripeCardData();

                            // Parse the received data and return card
                            ramblerCardData.ParseCard(decodeData);

                            // Notify the client with the rambler card data.
                            this.NotifyCompleted(ramblerCardData);
                        }
                        catch
                        {
                            NetTracer.Warning(string.Format("The tracks information are not extracted correctly. Retrying again..."));

                            // Restart the device to capture the swipe information again.
                            this.StartReader();
                        }
                    }
                }
            }
Пример #8
0
            void ReaderController.ReaderStateChangedListener.onDecodeError(DecodeResult decodeResult)
            {
                NetTracer.Warning(string.Format("The decode error occured : {0}", decodeResult.ToString()));

                // Restart the device to capture the swipe information again.
                this.StartReader();
            }
Пример #9
0
            private bool ShowPinEntry(string strFormName, string optionalCardNumber)
            {
                bool success = false;

                try
                {
                    if (this.DeviceIsConnected())
                    {
                        if (!string.IsNullOrWhiteSpace(optionalCardNumber))
                        {
                            this.fpe.SetVariableValue("cnum", optionalCardNumber);
                        }

                        this.fpe.GoToScreen(strFormName);

                        success = true;
                    }
                }
                catch (COMException ex)
                {
                    NetTracer.Warning(ex, "L5300Terminal - FPE COM exception for PinPadFrm");
                }

                return(success);
            }
Пример #10
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException"></exception>
        public void Load()
        {
            if (LSRetailPosis.Settings.HardwareProfiles.Scale.DeviceType != DeviceTypes.OPOS)
            {
                return;
            }

            NetTracer.Information("Peripheral [Scale] - OPOS device loading: {0}", DeviceName ?? "<Undefined>");

            oposScale = new OPOSScaleClass();

            // Open
            oposScale.Open(DeviceName);
            Peripherals.CheckResultCode(this, oposScale.ResultCode);

            // Claim
            oposScale.ClaimDevice(Peripherals.ClaimTimeOut);
            Peripherals.CheckResultCode(this, oposScale.ResultCode);

            // Enable/Configure
            oposScale.DataEvent       += new _IOPOSScaleEvents_DataEventEventHandler(posScale_DataEvent);
            oposScale.ErrorEvent      += new _IOPOSScaleEvents_ErrorEventEventHandler(posScale_ErrorEvent);
            oposScale.DeviceEnabled    = true;
            oposScale.AsyncMode        = true;
            oposScale.AutoDisable      = true;
            oposScale.DataEventEnabled = true;
            oposScale.PowerNotify      = (int)OPOS_Constants.OPOS_PN_ENABLED;

            IsActive = true;
        }
Пример #11
0
            private bool ShowForm(string strFormName, IEnumerable <FormProperty> properties)
            {
                bool success = false;

                try
                {
                    if (this.DeviceIsConnected())
                    {
                        this.fpe.GoToScreen(strFormName);

                        if (strFormName == "TransactionMsrFrm" && properties != null)
                        {
                            this.DisplayLines(properties.ToArray());
                        }

                        success = true;
                    }
                }
                catch (COMException ex)
                {
                    NetTracer.Warning(ex, "L5300Terminal - FPE COM exception");
                }

                return(success);
            }
Пример #12
0
        /// <summary>
        /// Load the device.
        /// </summary>
        /// <exception cref="IOException">Cannot load device</exception>
        public void Load()
        {
            if (this.DeviceType == DeviceTypes.None)
            {
                return;
            }

            if (this.DeviceType == DeviceTypes.OPOS)
            {
                NetTracer.Information("Peripheral [CashDrawer] - OPOS device loading: {0}", this.DeviceName ?? "<Undefined>");

                oposCashDrawer = new OPOSCashDrawerClass();

                // Open
                oposCashDrawer.Open(this.DeviceName);
                Peripherals.CheckResultCode(this, oposCashDrawer.ResultCode);

                // Claim
                oposCashDrawer.ClaimDevice(Peripherals.ClaimTimeOut);
                Peripherals.CheckResultCode(this, oposCashDrawer.ResultCode);

                // Enable
                oposCashDrawer.DeviceEnabled      = true;
                oposCashDrawer.StatusUpdateEvent += new _IOPOSCashDrawerEvents_StatusUpdateEventEventHandler(posCashDrawer_StatusUpdateEvent);
            }

            IsActive = true;
        }
        /// <summary>
        /// Given a transaction, choose the discounts which should be active on each line
        ///   according to the concurrency rules and add them to the sales items
        /// </summary>
        /// <param name="retailTransaction">Transaction whose discounts and sales items will be processed</param>
        public static void ApplyConcurrencyRules(RetailTransaction retailTransaction)
        {
            if (retailTransaction == null)
            {
                NetTracer.Warning("retailTransaction parameter is null");
                throw new ArgumentNullException("retailTransaction");
            }

            // In order to choose the best discount to apply when choosing from multiple we need to know
            //  the effect of the offer on the whole transaction. So we get a list of offers on the transaction
            //  for each type of concurrency, and sort them with largest discounts first.
            List <OfferGroup> sortedExclusiveOffers;
            List <OfferGroup> sortedBestPriceOffers;
            List <OfferGroup> sortedConcurrentOffers;

            GetSortedOfferLists(retailTransaction, out sortedExclusiveOffers, out sortedBestPriceOffers, out sortedConcurrentOffers);

            // Then, starting with exclusive offers, then best price, then compound offers, we find the best that apply.
            //   We keep track of applied offers to given them priority. This ensures that once a line in a discount group (like mix and match)
            //    chooses an offer, the rest of the members of the group will see the offer first.
            //   We keep track of rejected offers to exclude them from consideration. This ensures that once an exclusive offer or best price
            //    offer is chosen, no other offers one that line are available for use. Example would be if an exclusive multibuy on an item
            //    is activated and a mix and match offer is also available for that item. The exclusive multibuy takes priority and no other
            //    items in that mix and match group should be able to have the mix and match discount.
            HashSet <OfferGroup> appliedOffers  = new HashSet <OfferGroup>();
            HashSet <OfferGroup> rejectedOffers = new HashSet <OfferGroup>();

            ApplyPeriodicDiscounts(retailTransaction, ConcurrencyMode.Exclusive, sortedExclusiveOffers, appliedOffers, rejectedOffers);
            ApplyPeriodicDiscounts(retailTransaction, ConcurrencyMode.BestPrice, sortedBestPriceOffers, appliedOffers, rejectedOffers);
            ApplyPeriodicDiscounts(retailTransaction, ConcurrencyMode.Compounded, sortedConcurrentOffers, appliedOffers, rejectedOffers);
        }
Пример #14
0
        public virtual Image Create(string text, float xDpi = DEFAULT_DPI, float yDpi = DEFAULT_DPI)
        {
            NetTracer.Information("Peripheral [{0}] - Create", this);

            Bitmap barcodeImage = null;

            using (Font barcodeFont = new Font(FontName, FontSize))
            {
                if (barcodeFont.Name.Equals(barcodeFont.OriginalFontName, StringComparison.Ordinal)) // If font installed.
                {
                    using (Font barcodeTextFont = new Font(TEXT_FONT_NAME, TEXT_FONT_SIZE))          // Text font
                    {
                        try
                        {
                            text = Encode(text);

                            SizeF barcodeSizeF      = GetTextSizeF(text, barcodeFont, xDpi, yDpi);
                            float barcodeTextHeight = barcodeTextFont.GetHeight(yDpi);

                            barcodeImage = new Bitmap((int)barcodeSizeF.Width, (int)(barcodeSizeF.Height + barcodeTextHeight));
                            barcodeImage.SetResolution(xDpi, yDpi);

                            using (Graphics graphic = Graphics.FromImage(barcodeImage))
                            {
                                // Calculate left/right margin for drawing barcode considering dpi being used.
                                float XYWithMargin = (xDpi / DEFAULT_DPI) * 5;

                                // Draw barcode
                                graphic.DrawString(text, barcodeFont, Brushes.Black, XYWithMargin, XYWithMargin);

                                // Draw text below barcode in center
                                RectangleF textRect = new RectangleF(0, barcodeSizeF.Height, barcodeSizeF.Width, barcodeTextHeight);
                                using (StringFormat textFormat = new StringFormat(StringFormatFlags.NoClip)
                                {
                                    Alignment = StringAlignment.Center
                                })
                                {
                                    graphic.DrawString(text, barcodeTextFont, Brushes.Black, textRect, textFormat);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            if (barcodeImage != null)
                            {
                                barcodeImage.Dispose();
                            }

                            NetTracer.Error(ex, "Peripheral [{0}] - Exception during barcode creation.", this);
                        }
                    }
                }
                else
                {
                    NetTracer.Error("Peripheral [{0}] - Barcode creation failed. Font {1} in not installed.", this, FontName);
                }
            }

            return(barcodeImage);
        }
Пример #15
0
        /// <summary>
        /// Read the formula from the DB for the given group and code.
        /// </summary>
        /// <param name="taxGroup"></param>
        /// <param name="taxCode"></param>
        /// <returns></returns>
        public static Formula GetFormula(string taxGroup, string taxCode)
        {
            // Default value for the formula
            Formula formula = new Formula
            {
                TaxableBasis     = TaxableBases.LineAmount,
                PriceIncludesTax = false,
                Id = 0,                 // Since Id's are always greater than 0 in AX, this 0 value indicates formula was not found.
                CalculationExpression = String.Empty
            };

            try
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection  = Connection;
                    command.CommandText = @"SELECT TAXABLEBASIS, PRICEINCLTAX, ID, CALCEXP1 
											FROM dbo.FORMULADESIGNER_IN	
											WHERE TAXITEMGROUP = @TaxItemGroup AND TAXCODE = @TaxCode AND DATAAREAID = @DataAreaID"                                            ;

                    command.Parameters.AddWithValue("@TaxItemGroup", taxGroup);
                    command.Parameters.AddWithValue("@TaxCode", taxCode);
                    command.Parameters.AddWithValue("@DataAreaID", ApplicationSettings.Database.DATAAREAID);

                    if (Connection.State != ConnectionState.Open)
                    {
                        Connection.Open();
                    }
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            formula.TaxableBasis     = (TaxableBases)reader["TAXABLEBASIS"];
                            formula.PriceIncludesTax = (int)reader["PRICEINCLTAX"] == 1;
                            formula.Id = (int)reader["ID"];
                            formula.CalculationExpression = (string)reader["CALCEXP1"];
                        }
                        else
                        {
                            NetTracer.Warning("GetFormula: Formula set to default. Unable to obtain formula from DB. No rows present for taxGroup: {0}; taxCode: {1}; DataAreaID: {2}", taxGroup, taxCode, ApplicationSettings.Database.DATAAREAID);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                NetTracer.Warning(ex, "GetFormula: Formula set to default. Unable to obtain formula from DB due to an exception. taxGroup: {0}; taxCode: {1}", taxGroup, taxCode);
                LSRetailPosis.ApplicationExceptionHandler.HandleException("FormulaData", ex);
                // Not necessary to rethrow because formula is set to default state.
            }
            finally
            {
                if (Connection.State == ConnectionState.Open)
                {
                    Connection.Close();
                }
            }
            return(formula);
        }
Пример #16
0
        /// <summary>
        /// Given a set of promotion lines, tentative item price, and item, calculate the price after promotions are applied
        /// </summary>
        /// <param name="promotionLines">List of promotion configurations active for this item</param>
        /// <param name="price">Price of the item before the promotion, derived from trade agreement or base item price</param>
        /// <param name="saleItem">The sale item whose price is being determined</param>
        /// <returns>Unrounded price after applying all promotions</returns>
        public static decimal CalculatePromotionPrice(IEnumerable <PromotionInfo> promotionLines, decimal price, BaseSaleItem saleItem)
        {
            if (saleItem == null)
            {
                NetTracer.Warning("saleItem parameter is null");
                throw new ArgumentNullException("saleItem");
            }

            if (promotionLines == null || promotionLines.Count() == 0)
            {
                return(price);
            }

            decimal            promoPrice  = price;
            IList <PromoPrice> promoPrices = new List <PromoPrice>();

            foreach (PromotionInfo promo in promotionLines)
            {
                PromoPrice promoLine = new PromoPrice();
                promoLine.PromoId        = promo.PromoId;
                promoLine.Concurrency    = promo.Concurrency;
                promoLine.IsCompoundable = false;

                switch (promo.DiscountMethod)
                {
                case DiscountMethod.DiscountPercent:
                    promoLine.PercentOff     = promo.MaxDiscPct;
                    promoLine.IsCompoundable = true;
                    promoPrices.Add(promoLine);
                    break;

                case DiscountMethod.OfferPrice:
                    if (!saleItem.Transaction.TaxIncludedInPrice)
                    {
                        promoLine.AmountOff = price - promo.Price;
                        promoPrices.Add(promoLine);
                    }
                    break;

                case DiscountMethod.OfferPriceInclTax:
                    if (saleItem.Transaction.TaxIncludedInPrice)
                    {
                        promoLine.AmountOff = price - promo.PriceInclTax;
                        promoPrices.Add(promoLine);
                    }
                    break;

                case DiscountMethod.DiscountAmount:
                    promoLine.AmountOff      = promo.MaxDiscAmount;
                    promoLine.IsCompoundable = true;
                    promoPrices.Add(promoLine);
                    break;
                }
            }

            promoPrice = price - FindConcurrentPromoAmount(promoPrices, price);

            return(promoPrice);
        }
Пример #17
0
 /// <summary>
 /// Display transaction on device
 /// </summary>
 /// <param name="posTransaction">PosTransation</param>
 public void ShowTransaction(IPosTransaction posTransaction)
 {
     if (IsActive)
     {
         NetTracer.Information("Peripheral [DualDisplay] - Show Transaction");
         dualDisplayForm.ShowTransaction((PosTransaction)posTransaction);
     }
 }
Пример #18
0
            /// <summary>
            /// Opens a peripheral.
            /// </summary>
            /// <param name="peripheralName">Name of the peripheral.</param>
            /// <param name="peripheralConfig">The peripheral configuration.</param>
            public void Open(string peripheralName, PeripheralConfiguration peripheralConfig)
            {
                this.CashDispenserName = peripheralName;

                // Open the cash dispenser.
                NetTracer.Information("Cash dispenser is opened for device '{0}'.", peripheralName);

                return;
            }
Пример #19
0
            private void NotifyCompleted(RamblerMagneticStripeCardData card)
            {
                NetTracer.Information("Notify client with the MSR card data");

                if (this.RamblerCardSwipeEvent != null)
                {
                    this.RamblerCardSwipeEvent(this, card);
                }
            }
Пример #20
0
            public void Unlock(LockedSessionRequest request)
            {
                ThrowIf.Null(request, "request");

                LockManager.ReleaseLock <IRamblerStripeReader>(request.Token);

                NetTracer.Information(string.Format("The device is closed"));
                NetTracer.Information(string.Format("The Msr lock is released, token: {0}", request.Token));
            }
Пример #21
0
        private void posScale_DataEvent(int weight)
        {
            NetTracer.Information("Peripheral [Scale] - Data Event: {0}", weight);

            if (ScaleDataMessageEvent != null)
            {
                ScaleDataMessageEvent(weight);
            }
        }
Пример #22
0
        /// <summary>
        /// Executes the assign on currently selected operator.
        /// </summary>
        /// <param name="extendedLogOnInfo">The extended log on info.</param>
        /// <exception cref="PosisException">Thrown if save failed.</exception>
        public void ExecuteAssign(IExtendedLogOnInfo extendedLogOnInfo)
        {
            NetTracer.Information("ExtendedLogOnViewModel::ExecuteAssign: Start.");
            bool saved = false;

            try
            {
                logonData.DbUtil.BeginTransaction();

                // Save a local copy for immediate availability at store.
                logonData.CreateExtendedLogOn(this.SelectedResult.OperatorID, extendedLogOnInfo);

                // Save in HQ
                this.AxCreateExtendedLogOn(extendedLogOnInfo);

                saved = true;
            }
            catch (SqlException ex)
            {
                if (ex.Number == SQL_ERROR_DUPLICATE_RECORD)
                {
                    throw new PosisException(ex.Number, ex)
                          {
                              ErrorMessageNumber = STRING_ALREADY_EXISTS
                          };
                }
                else if (ex.Number == SQL_ERROR_NULL_DATA)
                {
                    throw new PosisException(ex.Number, ex)
                          {
                              ErrorMessageNumber = STRING_STAFF_NOT_FOUND
                          };
                }

                // Any other Sql error will be thrown as it is.
                throw;
            }
            finally
            {
                if (saved)
                {
                    logonData.DbUtil.EndTransaction();

                    SelectedResult.ExtendedLogOnAssigned = true;
                    OnPropertyChanged("Results");

                    NetTracer.Information("ExtendedLogOnViewModel::ExecuteAssign: Successful.");
                }
                else
                {
                    logonData.DbUtil.CancelTransaction();

                    NetTracer.Error("ExtendedLogOnViewModel::ExecuteAssign: Failed.");
                }
            }
        }
Пример #23
0
            /// <summary>
            /// Called when [application end request].
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
            private void OnApplicationEndRequest(object sender, EventArgs e)
            {
                var response = HttpContext.Current.Response;

                if (response.StatusCode == (int)HttpStatusCode.Unauthorized)
                {
                    NetTracer.Warning("Authentication failed for request '{0}' from the host '{1}'", HttpContext.Current.Request.Url, HttpContext.Current.Request.UserHostAddress);
                    response.Headers.Add(AuthenticateHeader, AuthorizationScheme);
                }
            }
Пример #24
0
            /// <summary>
            /// Creates failed <see cref="ValidateAddressDataResponse"/> response.
            /// </summary>
            /// <param name="errorCode">The error code associated with the failed address component.</param>
            /// <param name="faultAddressComponent">The failed address component.</param>
            /// <returns>The <see cref="ValidateAddressDataResponse"/> response.</returns>
            private static ValidateAddressDataResponse CreateFailedValidateAddressDataResponse(DataValidationErrors errorCode, string faultAddressComponent)
            {
                // If address is not valid, tell the user/client code : which component is the faulty one
                var message = string.Format(CultureInfo.InvariantCulture, @"Incorrect address provided: validate {0} property.", faultAddressComponent);

                NetTracer.Information(message);

                // create the response object and return
                return(new ValidateAddressDataResponse(isAddressValid: false, invalidAddressComponentName: faultAddressComponent, errorCode: errorCode, errorMessage: message));
            }
        /// <summary>
        /// Disable device for capture.
        /// </summary>
        public void EndCapture()
        {
            if (this.oposSigCapClass != null && this.IsActive)
            {
                NetTracer.Information("Peripheral [SigCap] - End Capture");

                this.oposSigCapClass.DeviceEnabled    = false;
                this.oposSigCapClass.DataEventEnabled = false;
            }
        }
Пример #26
0
        /// <summary>
        /// Disable MSR for swipe.
        /// </summary>
        public void DisableForSwipe()
        {
            if (IsActive)
            {
                NetTracer.Information("Peripheral [MSR] - Device and Data Event disabled");

                oposMSR.DeviceEnabled    = false;
                oposMSR.DataEventEnabled = false;
            }
        }
Пример #27
0
        /// <summary>
        /// Enable Scanner device for scan.
        /// </summary>
        public void ReEnableForScan()
        {
            if (IsActive)
            {
                NetTracer.Information("Peripheral [Scanner] - Device and Data Event enabled");

                oposScanner.DataEventEnabled = true;
                oposScanner.DeviceEnabled    = true;
            }
        }
Пример #28
0
            /// <summary>
            /// Gets the sales line shipping rates for sales line group.
            /// </summary>
            /// <param name="salesLineGroup">The sales line group.</param>
            /// <param name="warehouseAddresses">The warehouse addresses.</param>
            /// <param name="itemGrossWeights">The item gross weights.</param>
            /// <param name="shippingAdapterConfigRecords">The shipping adapter configuration records.</param>
            /// <param name="requestContext">The request context.</param>
            /// <returns>
            /// An enumeration of sales line ids with corresponding shipping rates and weights.
            /// </returns>
            private static IEnumerable <SalesLineShippingRate> GetSalesLineShippingRatesPerGroup(
                IEnumerable <SalesLine> salesLineGroup,
                Dictionary <string, Address> warehouseAddresses,
                Dictionary <string, decimal> itemGrossWeights,
                IEnumerable <ShippingAdapterConfig> shippingAdapterConfigRecords,
                RequestContext requestContext)
            {
                // We package all the items with identical dlv mode, origin and destination addresses into one package.
                // Total weight of all items in current saleslines group
                decimal totalWeight;

                Address shippingDestination = null;
                Address shippingOrigin      = null;
                string  deliveryModeId      = null;

                // Since destination, origin and delivery mode are identical for all lines within a group, we can grab values from any member of the list.
                // Does not matter if it is the first element, or the last, or anywhere in the middle.
                if (salesLineGroup != null && salesLineGroup.Any())
                {
                    shippingDestination = salesLineGroup.First().ShippingAddress;
                    shippingOrigin      = warehouseAddresses[salesLineGroup.First().InventoryLocationId.ToUpperInvariant()];
                    deliveryModeId      = salesLineGroup.First().DeliveryMode;
                }

                var salesLineShippingRateList = GetSalesLineShippingRateListAndTotalWeight(salesLineGroup, itemGrossWeights, out totalWeight);

                ShippingRateInfo shippingRateInfo = new ShippingRateInfo {
                    FromAddress = shippingOrigin, ToAddress = shippingDestination, GrossWeight = totalWeight
                };

                // Get Carrier info
                ParameterSet    adapterConfig         = ExtractAdapterConfigForSpecificDeliveryMode(deliveryModeId, shippingAdapterConfigRecords);
                var             carrierServiceRequest = new GetShippingRateFromCarrierServiceRequest(adapterConfig, shippingRateInfo);
                IRequestHandler carrierAdapterHandler = GetCarrierAdapterService(requestContext, carrierServiceRequest.GetType(), adapterConfig);

                if (carrierAdapterHandler != null)
                {
                    // Contact carrier
                    var carrierServiceResponse = requestContext.Execute <GetShippingRateFromCarrierServiceResponse>(carrierServiceRequest, carrierAdapterHandler);
                    var totalShippingCharge    = carrierServiceResponse.ShippingRate;

                    // Redistribute rates across the salesline based on their weights
                    foreach (var lineShippingRate in salesLineShippingRateList)
                    {
                        lineShippingRate.ShippingCharge = (totalShippingCharge * lineShippingRate.NetWeight) / totalWeight;
                    }
                }
                else
                {
                    NetTracer.Warning("No registered carrier adapter is found.");
                }

                return(salesLineShippingRateList);
            }
Пример #29
0
        public void Print()
        {
            DM.CustomerDataManager customerDataManager = new DM.CustomerDataManager(
                ApplicationSettings.Database.LocalConnection, ApplicationSettings.Database.DATAAREAID);

            //Get the balances
            IList <DE.CustomerBalanceInfo> customerBalances = customerDataManager.GetCustomersBalances();

            if ((customerBalances != null) && (customerBalances.Count > 0))
            {
                //Print header information
                int    charsInLine = 44;
                string line        = "--------------------------------------------" + "\n";
                string reportName  = LSRetailPosis.ApplicationLocalizer.Language.Translate(51020); //"BALANCE REPORT"
                int    leftPad     = (charsInLine - reportName.Length) / 2;
                string report      = "\n" + reportName.PadLeft(leftPad + reportName.Length) + "\n\n\n";
                report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51021) + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n\n"; //"Report printed"
                //Customer         //Name               //Balance
                report += LSRetailPosis.ApplicationLocalizer.Language.Translate(51022).PadRight(10).Substring(0, 10) + " " + LSRetailPosis.ApplicationLocalizer.Language.Translate(51023).PadRight(20).Substring(0, 20) + " " + LSRetailPosis.ApplicationLocalizer.Language.Translate(51024).PadLeft(12).Substring(0, 12) + "\n";
                report += line;

                string  customerId = string.Empty;
                string  name       = string.Empty;
                decimal balance    = 0;
                decimal total      = 0;

                //Loop throug the customer balances
                foreach (var customerBalance in customerBalances)
                {
                    customerId = customerBalance.AccountNumber;
                    name       = customerBalance.Name;
                    balance    = customerBalance.Balance;
                    total     += balance;

                    report += customerId.PadRight(10) + " " + name.PadRight(20).Substring(0, 20) + " " + (balance.ToString("n2")).PadLeft(12) + "\n";
                }

                //Printer footer
                report += line;
                string totalText = LSRetailPosis.ApplicationLocalizer.Language.Translate(51025) + ": "; //TOTAL
                report += totalText.PadLeft(32) + (total.ToString("n2")).PadLeft(12) + "\n\n\n";

                //Send text to printer
                if (((object)Customer.InternalApplication.Services.Printing) is IPrintingV2)
                {   // Print to the default printer
                    Customer.InternalApplication.Services.Printing.PrintDefault(true, report);
                }
                else
                {   // Legacy support - direct print to printer #1
                    NetTracer.Warning("BalanceReport.Print - Printing service does not support default printer.  Using printer #1");
                    Customer.InternalApplication.Services.Peripherals.Printer.PrintReceipt(report);
                }
            }
        }
Пример #30
0
        /// <summary>
        /// Unload the device.
        /// </summary>
        public void Unload()
        {
            if (IsActive && dualDisplayForm != null)
            {
                NetTracer.Information("Peripheral [DualDisplay] - Device Released");

                dualDisplayForm.Dispose();
                dualDisplayForm = null;
                IsActive        = false;
            }
        }