Exemple #1
0
        //updateTimelimit
        private static DateTime UpdateClaimTimelimit(ReservationState state)
        {
            try
            {
                //по умолчанию ставим таймлимит максимальным
                DateTime timelimit = DateTime.Now.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["timelimit_max_hours"])); // ставим максимальный таймлимит

                //state.o
                foreach (ReservationOrder order in state.orders)
                {
                    DateTime orderTimeLimit = GetOrderTimeLimit(order.excursion.id, order.datefrom, order.excursion.language);

                    if (timelimit > orderTimeLimit)
                    {
                        timelimit = orderTimeLimit;
                    }
                }

                DateTime minTimelimit = DateTime.Now.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["timelimit_min_hours"]));

                if (timelimit < minTimelimit)
                {
                    timelimit = minTimelimit;
                }

                //updateTimeLimit in claim
                DatabaseOperationProvider.Query("insert into pr_claim_timelimit values(@claimId, @timelimit)", "customer", new { claimId = state.claimId, timelimit = timelimit.ToString("yyyy-MM-dd HH:mm:ss") });

                return(timelimit);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

                return(DateTime.Now.AddHours(Convert.ToInt32(ConfigurationManager.AppSettings["timelimit_max_hours"])));
            }
        }
Exemple #2
0
        private static ReservationState BuildBookingProcessResult(string language, string action, XElement xml, int?partnerPassId)
        {
            DataSet ds = DatabaseOperationProvider.QueryProcedure("up_guest_BookingProcess", "state,orders,people,errors", new
            {
                action   = action,
                xml      = xml,
                lang     = language,
                partpass = partnerPassId
            });
            ReservationState result = (
                from DataRow row in ds.Tables["state"].Rows
                select BookingProvider.factory.ReservationState(row)).FirstOrDefault <ReservationState>();

            var orderNote = "";

            try
            {
                orderNote = System.Web.HttpContext.Current.Session["ordernote"].ToString();
            }
            catch (Exception ex) { }

            if (result != null)
            {
                result.orders = (
                    from DataRow row in ds.Tables["orders"].Rows
                    orderby BookingProvider.factory.ReservationOrderSorting(row)
                    select BookingProvider.factory.ReservationOrder(row, language, result.claimId, orderNote)).ToList <ReservationOrder>();
                foreach (ReservationOrder order in result.orders)
                {
                    if (order.freight != null)
                    {
                        DataSet freightds = DatabaseOperationProvider.QueryProcedure("up_guest_getFreightInfo", "freight", new
                        {
                            freight  = order.freight.id,
                            date     = order.datefrom,
                            language = language
                        });
                        BookingProvider.factory.FillFreightInfo(order.freight, freightds.Tables["freight"].Rows.Cast <DataRow>().FirstOrDefault <DataRow>());
                    }
                }
                result.people = (
                    from DataRow row in ds.Tables["people"].Rows
                    select BookingProvider.factory.ReservationPeople(row)).ToList <ReservationPeople>();
                result.errors = (
                    from DataRow row in ds.Tables["errors"].Rows
                    select BookingProvider.factory.ReservationError(row)).ToList <ReservationError>();

                result.customer = GetCustomer(Convert.ToInt32(result.claimId));

                if ((action != "save") && (result.claimId != null))
                {
                    result.agent = GetAgencyName(Convert.ToInt32(result.claimId)); //по id заказа из note забираем alias, по alias получаем login, и agent id
                }
            }

            //привязываем путевку к аккаунту
            if (action == "save")
            {
                //делаем привязку путевки к партнеру
                AddClaimForUser(result.claimId.Value, language);

                //считаем таймлимит
                var timelimit = UpdateClaimTimelimit(result);

                result.timelimit = timelimit;

                //делаем отбивку
                Task[] tasks = new Task[]
                {
                    Task.Factory.StartNew(() => new SimpleEmailService().SendEmail <ReservationState>(result.customer.mail, "confirmation", language, result)),
                    Task.Factory.StartNew(() => new SmsSender().SendMessage <ReservationState>(result.customer.phone, "confirmation", language, result))
                };

                Task.WaitAll(tasks);
            }

            return(result);
        }