Exemplo n.º 1
0
        private static bool SetOrder(List <Good> itemsToSale, int osnovanId)
        {
            try
            {
                var gForSale = new GoodsForSale
                {
                    Host      = Hosts.ACTIVE_TERMINAL.ToString(),
                    OpCode    = (int)Operations.Установка,
                    ItemCount = itemsToSale.Count(),
                    Items     = itemsToSale.Select(t => new GoodForSale(t)
                    {
                        //FuellingPointId = 1,
                        PresetMode     = t is GoodFuel ? 1 : 0,
                        PresetPrice    = ((decimal)t.Price),
                        PresetAmount   = t is GoodFuel ? t.Amount : 0,
                        PresetQuantity = t is GoodFuel ? 0 : t.Quantity,
                        DiscountCount  = t.Discount == 0 ? 0 : 1,
                        Discounts      = t.Discount == 0 ? new Discount[] { } : new Discount[] { new Discount {
                                                                                                     DiscountId    = 1,
                                                                                                     DiscountType  = 2,
                                                                                                     DiscountValue = t.Discount
                                                                                                 } },
                    }).ToArray(),
                    PaymentCount = 1,
                    Payments     = new[]
                    {
                        new OsnovanForSale(osnovanId)
                        {
                            //CardNumber = "10101021215414"
                        }
                    }
                };

                var json      = new JavaScriptSerializer().Serialize(gForSale);
                var req       = setOrder.Replace("{0}", json);
                var order_Raw = GET(req, request_code);

                ++request_code;
                //++operation_code;
                SaveCodes();

                var res = JsonHelper.ParseResponseErrors(order_Raw);
                if (res != null)
                {
                    LogError("SetOrder ERROR: " + res.ErrorDescription, "error code: " + res.ErrorCode);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogError("SetOrder ERROR: " + ex.ToString(), ex.StackTrace);
                return(false);
            }
        }
Exemplo n.º 2
0
        private static bool ReturnOrder(List <Good> itemsToSale, Osnovan osnovan)
        {
            var gForSale = new GoodsForSale
            {
                Host      = Hosts.ACTIVE_TERMINAL.ToString(),
                OpCode    = (int)Operations.Возврат,
                ItemCount = itemsToSale.Count(),
                Items     = itemsToSale.Select(t => new GoodForSale(t)
                {
                    //FuellingPointId = 1,
                    PresetMode     = t is GoodFuel ? 1 : 0,
                    PresetPrice    = t.Price,
                    PresetAmount   = t is GoodFuel ? t.Amount : 0,
                    PresetQuantity = t is GoodFuel ? 0 : t.Quantity,
                    DiscountCount  = 1,//t?.Discounts.Count()??0,
                    Discounts      = new Discount[] { new Discount {
                                                          DiscountId    = 1,
                                                          DiscountType  = 2,
                                                          DiscountValue = t.Discount
                                                      } }
                }).ToArray(),
                PaymentCount = 1,
                Payments     = new[]
                {
                    new OsnovanForSale(osnovan)
                    {
                        //CardNumber = "10101021215414"
                    }
                }
            };

            var json      = new JavaScriptSerializer().Serialize(gForSale);
            var req       = setOrder.Replace("{0}", json);
            var order_Raw = GET(req, request_code);

            ++request_code;
            //++operation_code;
            SaveCodes();

            return(true);
        }