Esempio n. 1
0
        public OrderDTO GetOrderDetailed(string authKey, int orderId)
        {
                        #if DEBUG
            logger.Debug("GetOrderDetailed called with args:\nauthKey: {0}\norderId: {1}", authKey, orderId);
                        #endif

            try
            {
                if (!CheckAuth(authKey))
                {
                    return(null);
                }

                using (var orderUoW = UnitOfWorkFactory.CreateForRoot <Order>(orderId, "[ADS]Детальная информация по заказу"))
                {
                    if (orderUoW == null || orderUoW.Root == null)
                    {
                        return(null);
                    }
                    var              routeListItem    = _routeListItemRepository.GetRouteListItemForOrder(orderUoW, orderUoW.Root);
                    OrderDTO         orderDTO         = new OrderDTO(routeListItem);
                    SmsPaymentStatus?smsPaymentStatus = _orderRepository.GetOrderPaymentStatus(orderUoW, orderUoW.Root.Id);
                    if (smsPaymentStatus == null)
                    {
                        orderDTO.PaymentStatus = PaymentStatus.None;
                    }
                    else
                    {
                        switch (smsPaymentStatus.Value)
                        {
                        case SmsPaymentStatus.WaitingForPayment:
                            orderDTO.PaymentStatus = PaymentStatus.WaitingForPayment;
                            break;

                        case SmsPaymentStatus.Paid:
                            orderDTO.PaymentStatus = PaymentStatus.Paid;
                            break;

                        case SmsPaymentStatus.Cancelled:
                            orderDTO.PaymentStatus = PaymentStatus.Cancelled;
                            break;
                        }
                    }

                    return(orderDTO);
                }
            }
            catch (Exception e)
            {
                logger.Error(e);
            }
            return(null);
        }
Esempio n. 2
0
        public FineDlg(UndeliveredOrder undeliveredOrder) : this()
        {
            Entity.UndeliveredOrder = undeliveredOrder;
            var RouteList = _routeListItemRepository.GetRouteListItemForOrder(UoW, undeliveredOrder.OldOrder)?.RouteList;

            Entity.RouteList = RouteList;
        }
Esempio n. 3
0
        /// <summary>
        /// Получение заказа в требуемом формате из заказа программы ДВ (использует функцию ниже)
        /// </summary>
        /// <param name="orderId">Идентификатор заказа</param>
        /// <returns>APIOrder</returns>
        public OrderDto Get(int orderId)
        {
            var vodovozOrder = _orderRepository.GetOrder(_unitOfWork, orderId)
                               ?? throw new DataNotFoundException(nameof(orderId), $"Заказ { orderId } не найден");
            var routeListItem = _routeListItemRepository.GetRouteListItemForOrder(_unitOfWork, vodovozOrder);

            var order = _orderConverter.convertToAPIOrder(
                vodovozOrder,
                routeListItem.CreationDate,
                _aPISmsPaymentModel.GetOrderSmsPaymentStatus(orderId),
                _fastPaymentModel.GetOrderFastPaymentStatus(orderId));

            order.OrderAdditionalInfo = GetAdditionalInfo(vodovozOrder);

            return(order);
        }
Esempio n. 4
0
        public void CancelOrder(Order order)
        {
            CallTaskWorker callTaskWorker = new CallTaskWorker(
                CallTaskSingletonFactory.GetInstance(),
                new CallTaskRepository(),
                _orderRepository,
                _employeeRepository,
                new BaseParametersProvider(_parametersProvider),
                ServicesConfig.CommonServices.UserService,
                ErrorReporter.Instance);

            if (order.OrderStatus == OrderStatus.InTravelList)
            {
                ValidationContext validationContext = new ValidationContext(order, null, new Dictionary <object, object> {
                    { "NewStatus", OrderStatus.Canceled },
                });
                validationContext.ServiceContainer.AddService(_orderParametersProvider);
                validationContext.ServiceContainer.AddService(_deliveryRulesParametersProvider);
                if (!ServicesConfig.ValidationService.Validate(order, validationContext))
                {
                    return;
                }

                ITdiPage page = tdiNavigation.OpenTdiTab <UndeliveryOnOrderCloseDlg, Order, IUnitOfWork>(null, order, UoW);
                page.PageClosed += (sender, e) => {
                    order.SetUndeliveredStatus(UoW, new BaseParametersProvider(_parametersProvider), callTaskWorker);

                    var routeListItem = _routeListItemRepository.GetRouteListItemForOrder(UoW, order);
                    if (routeListItem != null && routeListItem.Status != RouteListItemStatus.Canceled)
                    {
                        routeListItem.RouteList.SetAddressStatusWithoutOrderChange(routeListItem.Id, RouteListItemStatus.Canceled);
                        routeListItem.StatusLastUpdate = DateTime.Now;
                        routeListItem.SetOrderActualCountsToZeroOnCanceled();
                        UoW.Save(routeListItem.RouteList);
                        UoW.Save(routeListItem);
                    }

                    UoW.Commit();
                };
            }
            else
            {
                order.ChangeStatusAndCreateTasks(OrderStatus.Canceled, callTaskWorker);
                UoW.Save(order);
                UoW.Commit();
            }
        }
        protected override void CreatePopupActions()
        {
            Complaint GetComplaint(object[] objs)
            {
                var selectedNodes = objs.Cast <ComplaintJournalNode>();

                if (selectedNodes.Count() != 1)
                {
                    return(null);
                }
                var complaint = UoW.GetById <Complaint>(selectedNodes.FirstOrDefault().Id);

                return(complaint);
            }

            Order GetOrder(object[] objs)
            {
                var complaint = GetComplaint(objs);

                return(GetComplaint(objs)?.Order);
            }

            RouteList GetRouteList(object[] objs)
            {
                var order = GetOrder(objs);

                if (order == null)
                {
                    return(null);
                }
                var rl = routeListItemRepository.GetRouteListItemForOrder(UoW, order)?.RouteList;

                return(rl);
            }

            bool HasOrder(object[] objs) => GetOrder(objs) != null;

            bool HasRouteList(object[] objs) => GetRouteList(objs) != null;

            PopupActionsList.Add(
                new JournalAction(
                    "Открыть заказ",
                    HasOrder,
                    n => true,
                    n => gtkDlgOpener.OpenOrderDlg(this, GetOrder(n).Id)
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Открыть маршрутный лист",
                    HasRouteList,
                    n => true,
                    n => gtkDlgOpener.OpenCreateRouteListDlg(this, GetRouteList(n).Id)
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Создать штраф",
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate,
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate,
                    n => {
                var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id;
                ComplaintViewModel currentComplaintVM = null;
                if (currentComplaintId.HasValue)
                {
                    currentComplaintVM = new ComplaintViewModel(
                        EntityUoWBuilder.ForOpen(currentComplaintId.Value),
                        unitOfWorkFactory,
                        commonServices,
                        undeliveriesViewOpener,
                        employeeService,
                        employeeSelectorFactory,
                        counterpartySelectorFactory,
                        filePickerService,
                        subdivisionRepository,
                        nomenclatureSelectorFactory,
                        nomenclatureRepository,
                        userRepository
                        );
                    currentComplaintVM.AddFineCommand.Execute(this);
                }
            }
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Закрыть рекламацию",
                    n => n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Status != ComplaintStatuses.Closed && canCloseComplaint,
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate && canCloseComplaint,
                    n => {
                var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id;
                ComplaintViewModel currentComplaintVM = null;
                if (currentComplaintId.HasValue)
                {
                    currentComplaintVM = new ComplaintViewModel(
                        EntityUoWBuilder.ForOpen(currentComplaintId.Value),
                        unitOfWorkFactory,
                        commonServices,
                        undeliveriesViewOpener,
                        employeeService,
                        employeeSelectorFactory,
                        counterpartySelectorFactory,
                        filePickerService,
                        subdivisionRepository,
                        nomenclatureSelectorFactory,
                        nomenclatureRepository,
                        userRepository
                        );
                    string msg = string.Empty;
                    if (!currentComplaintVM.Entity.Close(ref msg))
                    {
                        ShowWarningMessage(msg, "Не удалось закрыть");
                    }
                    else
                    {
                        currentComplaintVM.Save();
                    }
                }
            }
                    )
                );
        }
Esempio n. 6
0
        protected override void CreatePopupActions()
        {
            Complaint GetComplaint(object[] objs)
            {
                var selectedNodes = objs.Cast <ComplaintJournalNode>().ToList();

                if (selectedNodes.Count != 1)
                {
                    return(null);
                }

                var complaint = UoW.GetById <Complaint>(selectedNodes.First().Id);

                return(complaint);
            }

            Order GetOrder(object[] objs)
            {
                return(GetComplaint(objs)?.Order);
            }

            RouteList GetRouteList(object[] objs)
            {
                var order = GetOrder(objs);

                if (order == null)
                {
                    return(null);
                }

                var rl = _routeListItemRepository.GetRouteListItemForOrder(UoW, order)?.RouteList;

                return(rl);
            }

            bool HasOrder(object[] objs) => GetOrder(objs) != null;

            bool HasRouteList(object[] objs) => GetRouteList(objs) != null;

            PopupActionsList.Add(
                new JournalAction(
                    "Открыть заказ",
                    HasOrder,
                    n => true,
                    n => _gtkDlgOpener.OpenOrderDlg(this, GetOrder(n).Id)
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Открыть маршрутный лист",
                    HasRouteList,
                    n => true,
                    n => _gtkDlgOpener.OpenRouteListCreateDlg(this, GetRouteList(n).Id)
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Открыть диалог закрытия МЛ",
                    n => GetRouteList(n)?.CanBeOpenedInClosingDlg ?? false,
                    n => true,
                    n => _gtkDlgOpener.OpenRouteListClosingDlg(this, GetRouteList(n).Id)
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Создать штраф",
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate,
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate,
                    n => {
                var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id;
                ComplaintViewModel currentComplaintVM = null;
                if (currentComplaintId.HasValue)
                {
                    currentComplaintVM = new ComplaintViewModel(
                        EntityUoWBuilder.ForOpen(currentComplaintId.Value),
                        _unitOfWorkFactory,
                        _commonServices,
                        _undeliveredOrdersJournalOpener,
                        _employeeService,
                        _counterpartySelectorFactory.CreateCounterpartyAutocompleteSelectorFactory(),
                        _fileDialogService,
                        _subdivisionRepository,
                        _nomenclatureRepository,
                        _userRepository,
                        _orderSelectorFactory,
                        _employeeJournalFactory,
                        _counterpartyJournalFactory,
                        _deliveryPointJournalFactory,
                        _subdivisionJournalFactory,
                        _gtkDlgOpener,
                        _undeliveredOrdersJournalOpener,
                        _salesPlanJournalFactory,
                        _nomenclatureSelector,
                        _undeliveredOrdersRepository,
                        _employeeSettings,
                        new ComplaintResultsRepository()
                        );
                    currentComplaintVM.AddFineCommand.Execute(this);
                }
            }
                    )
                );

            PopupActionsList.Add(
                new JournalAction(
                    "Закрыть рекламацию",
                    n => n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Status != ComplaintStatuses.Closed && canCloseComplaint,
                    n => EntityConfigs[typeof(Complaint)].PermissionResult.CanUpdate && canCloseComplaint,
                    n => {
                var currentComplaintId = n.OfType <ComplaintJournalNode>().FirstOrDefault()?.Id;
                ComplaintViewModel currentComplaintVM = null;
                if (currentComplaintId.HasValue)
                {
                    currentComplaintVM = new ComplaintViewModel(
                        EntityUoWBuilder.ForOpen(currentComplaintId.Value),
                        _unitOfWorkFactory,
                        _commonServices,
                        _undeliveredOrdersJournalOpener,
                        _employeeService,
                        _counterpartySelectorFactory.CreateCounterpartyAutocompleteSelectorFactory(),
                        _fileDialogService,
                        _subdivisionRepository,
                        _nomenclatureRepository,
                        _userRepository,
                        _orderSelectorFactory,
                        _employeeJournalFactory,
                        _counterpartyJournalFactory,
                        _deliveryPointJournalFactory,
                        _subdivisionJournalFactory,
                        _gtkDlgOpener,
                        _undeliveredOrdersJournalOpener,
                        _salesPlanJournalFactory,
                        _nomenclatureSelector,
                        _undeliveredOrdersRepository,
                        _employeeSettings,
                        new ComplaintResultsRepository()
                        );
                    string msg = string.Empty;
                    if (!currentComplaintVM.Entity.Close(ref msg))
                    {
                        ShowWarningMessage(msg, "Не удалось закрыть");
                    }
                    else
                    {
                        currentComplaintVM.Save();
                    }
                }
            }
                    )
                );
        }