private void BtnPrintBarCode_Click_Extend(object sender, EventArgs e)
        {
            this.Model.ClearErrorMessage();
            try
            {
                IList <IUIRecord> selectedRecords = this.Model.ProductBarCode.Cache.GetSelectRecord();
                if (selectedRecords == null || selectedRecords.Count == 0)
                {
                    throw new Exception("没有选择需要打印条码的记录!");
                }

                UIActionEventArgs args     = new UIActionEventArgs();
                IExportSettings   settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();
                settings.PrintTemplateCatalogType = printTemplateCatalogType;
                settings.UserDataCallBack         = DataCallBackHandle;
                // 打印完成委托
                settings.OnFinished = new FinishCallBackHandle(FinishCallBackHandle);
                args.Tag            = settings;

                CommandFactory.DoCommand("OnPrint", this.Action, sender, args);
            }
            catch (Exception ex)
            {
                IUIModel model = this.Model;
                this.Model.ErrorMessage.SetErrorMessage(ref model, ex.Message);
            }
            BtnPrintBarCode_Click_DefaultImpl(sender, e);
        }
Exemple #2
0
        private void CustomerItemPrint_Click(object sender, EventArgs e)
        {
            //输出服务
            IExportSettings settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();

            //最末一级分类目录的实体key
            settings.PrintTemplateCatalogType = "UFIDA.U9.CBO.SCM.Customer.CustomerItem";
            //从GetPrintDataNew()方法取数
            settings.UserDataCallBack = new DataCallBackHandle(this.GetPrintDataNew);
            UIActionEventArgs ex = new UIActionEventArgs();

            ex.Tag = settings;
            UFIDA.U9.UI.Commands.CommandFactory.DoCommand("OnPrint", (BaseAction)part.Action, sender, ex);
        }
        private void BtnPrintBarCode_Click_Extend(object sender, EventArgs e)
        {
            this.Model.ClearErrorMessage();
            IList <IUIRecord> selectedRecords = this.Model.CompleteApplyBarCode.Cache.GetSelectRecord();

            if (selectedRecords == null || selectedRecords.Count == 0)
            {
                IUIModel model = this.Model;
                this.Model.ErrorMessage.SetErrorMessage(ref model, "没有选择需要打印条码的记录!");
                return;
            }

            bool checkFail = false;

            foreach (CompleteApplyBarCodeRecord selectedRecord in selectedRecords)
            {
                //打印外包装允许可以打印条码2次,否则只能允许打印1次
                if (((selectedRecord.IsPrintWrapper ?? false) && selectedRecord.PrintCount >= 2) || (!(selectedRecord.IsPrintWrapper ?? false) && selectedRecord.PrintCount >= 1))
                {
                    IUIRecord record       = selectedRecord;
                    string    errorMessage = string.Format("条码{0}已经超出打印次数,不允许打印", selectedRecord.BarCode);
                    this.Model.ErrorMessage.SetErrorMessage(ref record, "", errorMessage);
                    checkFail = true;
                }
            }
            if (checkFail)
            {
                return;
            }

            UIActionEventArgs args     = new UIActionEventArgs();
            IExportSettings   settings = ExportServiceFactory.GetInstance().CreateExportSettingsObject();

            settings.PrintTemplateCatalogType = printTemplateCatalogType;
            settings.UserDataCallBack         = DataCallBackHandle;
            // 打印完成委托
            settings.OnFinished = new FinishCallBackHandle(FinishCallBackHandle);
            args.Tag            = settings;

            CommandFactory.DoCommand("OnPrint", this.Action, sender, args);

            BtnPrintBarCode_Click_DefaultImpl(sender, e);
        }
Exemple #4
0
        public static void Main()
        {
            var appSettings = AppSettings.LoadAppSettings();

            InitLogger();
            var onenoteApp = new Application();


            var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version;

            Log.Debug($"CurrentCulture : {CultureInfo.CurrentCulture}");
            Log.Debug($"OneNoteMdExporter version {assemblyVersion}");

            var notebooks = onenoteApp.GetNotebooks();


            Log.Information("-----------------------");
            Log.Information("- OneNote Md Exporter -");
            Log.Information($"       v{assemblyVersion}");
            Log.Information("-----------------------\n");

            Log.Information(Localizer.GetString("NotebookFounds"), notebooks.Count);
            Log.Information(Localizer.GetString("ExportAllNotebooks"));

            for (int i = 1; i <= notebooks.Count; i++)
            {
                Log.Information(Localizer.GetString("ExportNotebookPositionX"), i, notebooks.ElementAt(i - 1).Title);
            }

            var input = Console.ReadLine();

            if (!Int32.TryParse(input, out var inputInt))
            {
                Log.Information(Localizer.GetString("BadInput"));
                return;
            }

            IList <Notebook> notebookToProcess;

            if (inputInt == 0)
            {
                notebookToProcess = notebooks;
            }
            else
            {
                try
                {
                    notebookToProcess = new List <Notebook> {
                        notebooks.ElementAt(inputInt - 1)
                    };
                }
                catch (ArgumentOutOfRangeException)
                {
                    Log.Information(Localizer.GetString("NotebookNotFound"));
                    return;
                }
            }


            Log.Information(Localizer.GetString("ChooseExportFormat"));
            Log.Information(Localizer.GetString("ChooseExportFormat1"));
            Log.Information(Localizer.GetString("ChooseExportFormat2"));


            var exportFormatTxt = Console.ReadLine();


            Log.Information("");


            if (!Enum.TryParse <ExportFormat>(exportFormatTxt, true, out var exportFormat))
            {
                Log.Information(Localizer.GetString("BadInput"));
                return;
            }

            var exportService = ExportServiceFactory.GetExportService(exportFormat, appSettings, onenoteApp);

            foreach (Notebook notebook in notebookToProcess)
            {
                Log.Information("\n***************************************");
                Log.Information(Localizer.GetString("StartExportingNotebook"), notebook.Title);
                Log.Information("***************************************");

                exportService.ExportNotebook(notebook);
                var exportPath = Path.GetFullPath(notebook.Title);

                Log.Information("");
                Log.Information(Localizer.GetString("ExportSuccessful"), exportPath);
                Log.Information("");
            }


            Log.Information(Localizer.GetString("EndOfExport"));

            Console.ReadLine();
        }
        private void Export(object obj)
        {
            SortedListsOfImagesNames imagesCollectionType = (SortedListsOfImagesNames)obj;
            ExportService            exportService        = ExportServiceFactory.GetExportService(ExportTypes.ExportToZip);

            switch (imagesCollectionType)
            {
            case SortedListsOfImagesNames.BeachesSeaside:
                exportService.Export(BeachesSeaside, imagesCollectionType.ToString());
                BeachesSeaside.Clear();
                break;

            case SortedListsOfImagesNames.CarsVehicles:
                exportService.Export(CarsVehicles, imagesCollectionType.ToString());
                CarsVehicles.Clear();
                break;

            case SortedListsOfImagesNames.EventsParties:
                exportService.Export(EventsParties, imagesCollectionType.ToString());
                EventsParties.Clear();
                break;

            case SortedListsOfImagesNames.FoodDrinks:
                exportService.Export(FoodDrinks, imagesCollectionType.ToString());
                FoodDrinks.Clear();
                break;

            case SortedListsOfImagesNames.InteriorObjects:
                exportService.Export(InteriorObjects, imagesCollectionType.ToString());
                InteriorObjects.Clear();
                break;

            case SortedListsOfImagesNames.MacroFlowers:
                exportService.Export(MacroFlowers, imagesCollectionType.ToString());
                MacroFlowers.Clear();
                break;

            case SortedListsOfImagesNames.NatureLandscape:
                exportService.Export(NatureLandscape, imagesCollectionType.ToString());
                NatureLandscape.Clear();
                break;

            case SortedListsOfImagesNames.PaintingsArt:
                exportService.Export(PaintingsArt, imagesCollectionType.ToString());
                PaintingsArt.Clear();
                break;

            case SortedListsOfImagesNames.PeoplePortraits:
                exportService.Export(PeoplePortraits, imagesCollectionType.ToString());
                PeoplePortraits.Clear();
                break;

            case SortedListsOfImagesNames.PetsAnimals:
                exportService.Export(PetsAnimals, imagesCollectionType.ToString());
                PetsAnimals.Clear();
                break;

            case SortedListsOfImagesNames.StreetviewArchitecture:
                exportService.Export(StreetviewArchitecture, imagesCollectionType.ToString());
                StreetviewArchitecture.Clear();
                break;

            case SortedListsOfImagesNames.SunrisesSunsets:
                exportService.Export(SunrisesSunsets, imagesCollectionType.ToString());
                SunrisesSunsets.Clear();
                break;

            case SortedListsOfImagesNames.TextVisuals:
                exportService.Export(TextVisuals, imagesCollectionType.ToString());
                TextVisuals.Clear();
                break;

            default:
                throw new NoSuchCategoryException("There is no such images category! Contact the application manufacturer!");
            }
        }