public static bool SendOrder(AlohaService.OrderFlight orderFlight)
        {
            Utils.ToLog("AlohaFlyExport SendOrder ");
            try {
                var cl = GetClient();
                if (cl == null)
                {
                    Utils.ToLog("AlohaFlyExport SendOrder cl == null");
                    return(false);
                }

                var res = cl.InsertOrderFlightFromAloha(orderFlight);
                if (!res)
                {
                    Utils.ToLog("AlohaFlyExport SendOrder not Success ");
                    return(false);
                }

                /*
                 * long Id = res.CreatedObjectId;
                 * Utils.ToLog("AlohaFlyExport Order inserted Id:" + Id);
                 *
                 * foreach (var d in orderFlight.DishPackages)
                 * {
                 *  int maxTryCount = 10;
                 *  int curentTry=1;
                 *  bool ok = false;
                 *
                 *      while (!ok && curentTry<maxTryCount)
                 *      {
                 *      d.OrderFlightId = Id;
                 *      var resD =  cl.CreateDishPackageFlightOrder(d);
                 *      ok = resD.Success;
                 *      if (!ok) {
                 *          Utils.ToLog("AlohaFlyExport SendOrder add Dish error " + resD.ErrorMessage + " Count " + curentTry);
                 *      }
                 *      curentTry++;
                 *      }
                 *      if (!ok)
                 *      {
                 *          return false;
                 *      }
                 *
                 * }
                 *
                 * Utils.ToLog("AlohaFlyExport SendOrder Success Id = " + res.CreatedObjectId);
                 * */
                return(true);
            }
            catch (Exception e)
            {
                Utils.ToLog("Error AlohaFlyExport SendOrder " + e.Message);
                return(false);
            }
        }
Exemple #2
0
        public static AlohaService.OrderFlight GetOrderFlightFromAlohaCheck(Check chk)
        {
            var of = new AlohaService.OrderFlight();

            if (chk.Tenders.Count == 0)
            {
                Utils.ToLog("[GetOrderFlightFromAlohaCheck] no tenders");
                return(null);
            }
            of.AlohaGuidId = chk.GuidId;
            int Tndrid = chk.Tenders[0].AlohaTenderId;

            if (Tndrid < 100)
            {
                if (Tndrid == 1)
                {
                    of.AirCompanyId = 44;
                }
                else if (Tndrid == 20)
                {
                    of.AirCompanyId = 45;
                }
                else
                {
                    of.AirCompanyId = 41;
                }

                of.Closed          = true;
                of.PreCheckPrinted = (Tndrid == 2);
                of.FRPrinted       = (Tndrid != 2);
                of.OrderStatus     = AlohaService.OrderStatus._16;
            }
            else
            {
                of.AirCompanyId = Tndrid - 100;
                of.Closed       = false;
                of.OrderStatus  = AlohaService.OrderStatus._4;
            }

            of.CreatedById     = iniFile.AlohaFlyExportUserId;
            of.SendById        = iniFile.AlohaFlyExportUserId;
            of.CreationDate    = chk.SystemDateOfOpen;
            of.ReadyTime       = chk.SystemDateOfOpen;
            of.ExportTime      = chk.SystemDateOfOpen;
            of.DeliveryPlaceId = iniFile.AlohaFlyExportPlaceId;
            //of.DishPackages = new AlohaService.DishPackageFlightOrder();
            of.FlightNumber  = GetFightNumber(chk);
            of.IsSHSent      = false;
            of.NumberOfBoxes = 1;
            of.DeliveryDate  = chk.SystemDate;

            var dList = new List <AlohaService.DishPackageFlightOrder>();

            foreach (var d in chk.ConSolidateDishez)
            {
                if (d.BarCode == iniFile.AlohaFlyExportFlightNumberDishId)
                {
                    continue;
                }
                var pd = new AlohaService.DishPackageFlightOrder();
                pd.Amount          = d.Count * d.QtyQUANTITY;
                pd.Code            = d.BarCode;
                pd.DishName        = d.Name;
                pd.PositionInOrder = dList.Count + 1;
                pd.TotalPrice      = (decimal)d.Priceone;
                dList.Add(pd);
            }
            of.DishPackages = dList.ToArray();
            return(of);
        }