Esempio n. 1
0
        public DocumentsPrinterDlg(
            IUnitOfWork uow,
            RouteList routeList,
            IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory,
            RouteListPrintableDocuments selectedType)
        {
            Build();
            TabName = "Печать документов МЛ";
            _entityDocumentsPrinter =
                (entityDocumentsPrinterFactory ?? throw new ArgumentNullException(nameof(entityDocumentsPrinterFactory)))
                .CreateRouteListWithOrderDocumentsPrinter(uow, routeList, new[] { selectedType });

            _currentRouteList = routeList;

            Configure();
        }
Esempio n. 2
0
        public DocumentsPrinterViewModel(
            IUnitOfWork uow,
            IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory,
            INavigationManager navigationManager,
            RouteList routeList,
            RouteListPrintableDocuments selectedType,
            IInteractiveService interactiveService) : base(interactiveService, navigationManager)
        {
            EntityDocumentsPrinter =
                (entityDocumentsPrinterFactory ?? throw new ArgumentNullException(nameof(entityDocumentsPrinterFactory)))
                .CreateRouteListWithOrderDocumentsPrinter(uow, routeList, new[] { selectedType });

            TabName = "Печать документов МЛ";

            _currentRouteList = routeList;
            Configure();
        }
        /// <summary>
        /// Добавление в спсиок печати документов маршрутного листа <paramref name="routeList"/> с выделением типов,
        /// указанных в массиве <paramref name="routeListPrintableDocumentTypes"/>, а также добавление в этот спсиок
        /// документов всех заказов из маршрутного листа <paramref name="routeList"/> с выделением типов, указанных в
        /// массиве <paramref name="orderDocumentTypes"/>. Если <paramref name="orderDocumentTypes"/> не указывать, то
        /// печать документов заказов произведена не будет.
        /// </summary>
        /// <param name="uow">Unit Of Work</param>
        /// <param name="routeList">Маршрутный лист</param>
        /// <param name="entityDocumentsPrinterFactory">Фабрика принтеров</param>
        /// <param name="routeListPrintableDocumentTypes">Типы документов МЛ, которые необходимо отметить</param>
        /// <param name="orderDocumentTypes">Типы документов заказа, которые необходимо отметить</param>
        public EntityDocumentsPrinter(
            IUnitOfWork uow,
            RouteList routeList,
            IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory,
            RouteListPrintableDocuments[] routeListPrintableDocumentTypes,
            IList <OrderDocumentType> orderDocumentTypes = null)
        {
            if (entityDocumentsPrinterFactory == null)
            {
                throw new ArgumentNullException(nameof(entityDocumentsPrinterFactory));
            }

            DocPrinterInit();

            //Эти документы не будут добавлены в список печати вообще
            RouteListPrintableDocuments[] documentsToSkip =
            {
                RouteListPrintableDocuments.All,
                RouteListPrintableDocuments.LoadSofiyskaya,
                RouteListPrintableDocuments.TimeList,
                RouteListPrintableDocuments.OrderOfAddresses
            };

            foreach (RouteListPrintableDocuments rlDocType in Enum.GetValues(typeof(RouteListPrintableDocuments)))
            {
                if (!documentsToSkip.Contains(rlDocType))
                {
                    var rlDoc      = new RouteListPrintableDocs(uow, routeList, rlDocType);
                    var isSelected = routeListPrintableDocumentTypes.Contains(RouteListPrintableDocuments.All) ||
                                     routeListPrintableDocumentTypes.Contains(rlDocType);

                    var doc = new SelectablePrintDocument(rlDoc)
                    {
                        Selected = isSelected
                    };

                    DocumentsToPrint.Add(doc);
                }
            }

            if (orderDocumentTypes != null)
            {
                PrintOrderDocumentsFromTheRouteList(routeList, entityDocumentsPrinterFactory, orderDocumentTypes);
            }
        }
Esempio n. 4
0
        public DocumentsPrinterDlg(Order order, IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory)
        {
            Build();

            TabName = "Печать документов заказа";

            _entityDocumentsPrinter =
                (entityDocumentsPrinterFactory ?? throw new ArgumentNullException(nameof(entityDocumentsPrinterFactory)))
                .CreateOrderDocumentsPrinter(order);

            if (!string.IsNullOrEmpty(_entityDocumentsPrinter.ODTTemplateNotFoundMessages))
            {
                MessageDialogHelper.RunWarningDialog(_entityDocumentsPrinter.ODTTemplateNotFoundMessages);
            }

            _currentOrder = order;

            Configure();
        }
Esempio n. 5
0
        public DocumentsPrinterViewModel(
            IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory,
            IInteractiveService interactiveService,
            INavigationManager navigationManager,
            Order order) : base(interactiveService, navigationManager)
        {
            EntityDocumentsPrinter =
                (entityDocumentsPrinterFactory ?? throw new ArgumentNullException(nameof(entityDocumentsPrinterFactory)))
                .CreateOrderDocumentsPrinter(order);

            TabName = "Печать документов заказа";

            if (!string.IsNullOrEmpty(EntityDocumentsPrinter.ODTTemplateNotFoundMessages))
            {
                interactiveService.ShowMessage(ImportanceLevel.Warning, EntityDocumentsPrinter.ODTTemplateNotFoundMessages);
            }

            _currentOrder = order;
            Configure();
        }
        //для печати документов заказов из МЛ, если есть при печати требуется их печать
        private void PrintOrderDocumentsFromTheRouteList(
            RouteList routeList,
            IEntityDocumentsPrinterFactory entityDocumentsPrinterFactory,
            IList <OrderDocumentType> orderDocumentTypes)
        {
            var orders = routeList.Addresses
                         .Where(a => a.Status != RouteListItemStatus.Transfered)
                         .Select(a => a.Order);

            foreach (var o in orders)
            {
                var orderPrinter = entityDocumentsPrinterFactory.CreateOrderDocumentsPrinter(
                    o,
                    true,
                    //При массовой печати документов заказов из МЛ, в случае наличия у клиента признака UseSpecialDocFields,
                    //не будут печататься обычные счета и УПД
                    orderDocumentTypes.Where(
                        t => !o.Client.UseSpecialDocFields ||
                        t != OrderDocumentType.UPD &&
                        t != OrderDocumentType.Bill).ToList()
                    );

                orderPrinter.PrintingCanceled += (sender, e) =>
                {
                    _cancelPrinting = true;
                    PrintingCanceled?.Invoke(sender, e);
                };

                ODTTemplateNotFoundMessages = string.Concat(orderPrinter.ODTTemplateNotFoundMessages);
                orderPrinter.Print();

                if (_cancelPrinting)
                {
                    return;
                }
            }
        }