Exemplo n.º 1
0
        private async void OnStartedAsync()
        {
            Logger.LogInformation("メインロジック開始");
            Logger.LogTrace("設定ファイルの内容を出力");
            Console.WriteLine(Configuration.GetValue <string>("aaaa:bbbb"));
            Console.WriteLine(Configuration.GetValue <string>("cccc"));
            Logger.LogTrace("環境変数の内容を出力");
            Console.WriteLine(Configuration.GetValue <string>("TEST"));

            // 実際の処理はここに書きます
            Logger.LogTrace("ログレベルのテスト");
            Logger.Log(LogLevel.Trace, "Trace");
            Logger.Log(LogLevel.Debug, "Debug");
            Logger.Log(LogLevel.Information, "Information");
            Logger.Log(LogLevel.Warning, "Warning");
            Logger.Log(LogLevel.Error, "Error");
            Logger.Log(LogLevel.Critical, "Critical");
            Logger.Log(LogLevel.None, "None");

            Logger.LogInformation("メインロジックからサービスの呼び出しを行います。");
            MyService.MyServiceMethod();

            Logger.LogInformation("OCRを行います。");
            var ocrResult = OcrService.Recognize("./Samples/sample.png");

            Logger.LogInformation($"OCR結果:{ocrResult.Text}");

            Logger.LogInformation("PDF -> OCRを行います。");
            var pdfResult = await PdfService.RecognizeAsync(".\\Samples\\sample.pdf", 0);

            Logger.LogInformation($"PDF -> OCR結果:{pdfResult}");

            AppLifetime.StopApplication(); // 自動でアプリケーションを終了させる
        }
Exemplo n.º 2
0
        public void GenerateFileTest()
        {
            var fieldsToFill = new Dictionary <string, string>();

            fieldsToFill["topmostSubform[0].Page1[0].Address[0].f1_7[0]"] = "Hello";

            IDictionary <string, PdfField> fields;
            var inFile   = Path.GetTempFileName();
            var outFile  = Path.GetTempFileName();
            var jsonFile = Path.GetTempFileName();

            using (var pdfStream = Assembly.GetAssembly(typeof(PdfService)).GetManifestResourceStream("PdfFormFiller.Common.Resources.fw9.pdf"))
            {
                using (var fileStream = File.Create(inFile))
                {
                    pdfStream.CopyTo(fileStream);
                }
            }

            File.WriteAllText(jsonFile, JsonConvert.SerializeObject(fieldsToFill));
            var filler = new PdfService();

            filler.GenerateFile(inFile, jsonFile, outFile);

            using (var pdfStream = File.OpenRead(outFile))
            {
                fields = filler.GetFormFields(pdfStream);
            }

            Assert.IsNotNull(fields);
            Assert.IsTrue(fields.Count > 0);
            Assert.IsTrue(fields.ContainsKey("topmostSubform[0].Page1[0].Address[0].f1_7[0]"));
            Assert.AreEqual(0, string.CompareOrdinal(fields["topmostSubform[0].Page1[0].Address[0].f1_7[0]"].Value, fieldsToFill["topmostSubform[0].Page1[0].Address[0].f1_7[0]"]));
        }
Exemplo n.º 3
0
        public async Task <PrintResponse> PrintBonoAsync([FromBody] PrintBonoReq req)
        {
            PdfService service  = new PdfService();
            var        response = await service.ConvertTxtToPdfAndPrint(req);

            return(response);
        }
Exemplo n.º 4
0
        public ActionResult ReportToPDF(int id = -1)
        {
            PdfService pdfService = new PdfService();
            var        item       = _itemService.Get(id);
            string     name       = null;

            switch (item.TempMode)
            {
            case 1:
                name = pdfService.ReportToPDF1(item, _itemService.GetContrastPrice(id));
                break;

            case 2:
                name = pdfService.ReportToPDF2(item, _itemService.GetContrastPrice(id));
                break;

            case 3:
                name = pdfService.ReportToPDF3(item, _itemService.GetContrastPrice(id));
                break;

            case 4:
                name = pdfService.ReportToPDF4(item, _itemService.GetContrastPrice(id));
                break;

            case 5:
                name = pdfService.ReportToPDF5(item, _itemService.GetContrastPrice(id));
                break;

            default:
                break;
            }
            return(Json(new { code = 200, message = "文件生成成功!", name = name }));
        }
Exemplo n.º 5
0
    static void __executeCommand(oRequestService rs)
    {
        switch (rs.command)
        {
        case COMMANDS.CURL_GET_HTML:
            //if (!string.IsNullOrEmpty(input))
            //{
            //    if (input.Contains("https")) __getUrlHttps(requestId, input);
            //    else __getUrlHttp(requestId, input);
            //}
            break;

        case COMMANDS.PDF_SPLIT_ALL_PNG:
            //PdfService.SplitAllPng(requestId, input);
            break;

        case COMMANDS.PDF_SPLIT_ALL_JPG:
            PdfService.SplitAllJpeg(rs);
            break;

        case COMMANDS.PDF_MMF_TT:
            //PdfService.PDF_MMF_TT(requestId, input);
            break;
        }
    }
Exemplo n.º 6
0
 public DocumentsController(ApplicationDbContext context, PdfService pdf, UserManager <ApplicationUser> user, AccessService access)
 {
     _context = context;
     _pdf     = pdf;
     _user    = user;
     _access  = access;
 }
Exemplo n.º 7
0
        public ActionResult Pdf(string id)
        {
            var country    = _countryService.GetCountryViewModel(id);
            var htmlString = this.RenderPartialViewToString("pv_country_print_template", country);

            var fullFileName = "";

            try
            {
                if (Request.Url != null)
                {
                    var fileName = UrlHelper.GenerateContentUrl(
                        $"~/content/assets/{country.CountryCode}.pdf", HttpContext);
                    fullFileName = Server.MapPath(fileName);

                    var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
                    PdfService.Create(htmlString, fullFileName, baseUrl, country.CountryName);
                }
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }

            return(File(fullFileName, "application/pdf", country.CountryName + ".pdf"));
        }
Exemplo n.º 8
0
        public IActionResult GetPdfFile(string code, string party)
        {
            List <Product> items = GetProductsByCodeAndPartyProduct(code, party);

            PdfService.ExportToPDF(ref items);

            return(Content("Файл успешно создан."));
        }
 public CompleteEvaluationReminderJob()
 {
     this.modelContext = new ModelContext();
     this.supplyCompleteRegistrationReminderEmailService = new SupplyCompleteRegistrationReminderEmailService();
     this.pdfService  = new PdfService();
     this.emailSender = new EmailSender();
     this.sendEmailToContinueService = new SendEmailToContinueService();
 }
 public InvoiceController(PaymentService payment, ApplicationDbContext context, UserManager <ApplicationUser> userManager, CourseService courseService, PdfService pdf)
 {
     _payment       = payment;
     _context       = context;
     _userManager   = userManager;
     _courseService = courseService;
     _pdf           = pdf;
 }
Exemplo n.º 11
0
        public IActionResult GetPdfFile(string storageName)
        {
            List <Product> items = _db.Products.Where(x => x.Place.Storage.Name == storageName).Include(x => x.Place).Include(x => x.Place.Storage).ToList();

            PdfService.ExportToPDF(ref items);

            return(Content("Очет успешно создан."));
        }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            var file = @"C:\dev\tests\poc-pdf-reader-.net\file-test.PDF";

            PdfService pdfParser = new PdfService();
            var        content   = pdfParser.ExtractText(file);

            Console.WriteLine("Done");
        }
        private async Task LoadPdfFile(string pdfUrlStr)
        {
            readPdfPageViewModel.IsDownloading = true;
            var localFilePath = await PdfService.DownloadAsync(pdfUrlStr).ConfigureAwait(false);

            readPdfPageViewModel.IsDownloading = false;

            readPdfPageViewModel.PdfSource = new Uri(localFilePath);
        }
        public AzureQueueClient()
        {
            pdfService = new PdfService();
            xmlService = new XmlService();

            namespaceManager = NamespaceManager.Create();

            pdfQueueClient    = CreateQueue(pdfMessageQueueName, true);
            statusQueueClient = CreateQueue(statusQueueName, false);
        }
Exemplo n.º 15
0
        public static async Task DownloadDocumentsAsync(PdfModel PdfModel)
        {
            var stream = await PdfService.DownloadFileAsync(PdfModel.Url);

            if (stream == null)
            {
                return;
            }
            await SaveFileAsync(PdfModel.FileName, stream);
        }
        public void ConvertToPdf_ShouldReturnNull_GivenInvalidInput()
        {
            // Arrange
            var pdfService = new PdfService();

            // Act
            var result = pdfService.ConvertToPdf(TestContentInvalid);

            // Assert
            Assert.Null(result);
        }
 public MatterixPlus(ApplicationDbContext context, UserManager <ApplicationUser> userManager, FilesService file, InformationService info, CourseService course, AccessService access, PdfService pdf, EmailService email)
 {
     _context     = context;
     _userManager = userManager;
     _file        = file;
     _info        = info;
     _course      = course;
     _access      = access;
     _pdf         = pdf;
     _email       = email;
 }
Exemplo n.º 18
0
 public HomeController(UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, CourseService courseService, ApplicationDbContext context, PaymentService paymentService, IHostingEnvironment environment, InformationService information, EmailService email, PdfService pdf)
 {
     _userManager    = userManager;
     _signInManager  = signInManager;
     _courseService  = courseService;
     _context        = context;
     _paymentService = paymentService;
     _environment    = environment;
     _information    = information;
     _email          = email;
     _pdf            = pdf;
 }
Exemplo n.º 19
0
        public async Task GenerateAndSaveIllustration(Guid meetingId, IllustrationRequest illustrationRequest)
        {
            var pdfService = new PdfService(_templateProvider, illustrationRequest);
            var key        = pdfService.GeneratedId;
            var stream     = await pdfService.CreateForm1();

            var bytedata = stream.ReadToEnd();

            //     _blogStorage.StoreValue(key, new MemoryStream(bytedata));
            PDFDocController.InsertDocument(key, bytedata);
            NotifyPdfAvailable(meetingId, key);
        }
Exemplo n.º 20
0
        public OfertaSurveyController()
        {
            this.modelContext = new ModelContext();
            this.surveyPartialCompletionBySupplyEmailService = new SurveyPartialCompletionBySupplyEmailService();
            this.surveyCompletionBySupplyEmailService        = new SurveyCompletionBySupplyEmailService();
            this.pdfService = new PdfService();

            var userStore = new UserStore <ApplicationUser>(this.modelContext);
            var roleStore = new RoleStore <ApplicationRole>(this.modelContext);

            this.userManager = new UserManager <ApplicationUser>(userStore);
            this.roleManager = new RoleManager <ApplicationRole>(roleStore);
        }
Exemplo n.º 21
0
 public BackWorker(MainFormOption mainFormOption)
 {
     this.pageSettingService  = new PageSettingService();
     this.headerFooterService = new HeaderFooterService();
     this.docInfoService      = new DocInfoService();
     this.textReplaceService  = new TextReplaceService();
     this.paragraphService    = new ParagraphService();
     this.imageService        = new ImageService();
     this.hyperLinkService    = new HyperLinkService();
     this.tableService        = new TableService();
     this.pdfService          = new PdfService();
     this.mainFormOption      = mainFormOption;
     this.logger = LogManager.GetCurrentClassLogger();
 }
Exemplo n.º 22
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var uri             = ConfigurationManager.AppSettings["ContosoConsultancy.RestAPI.Uri"];
            var credentials     = new BasicAuthenticationCredentials();
            var client          = new ContosoConsultancyRestClient(new Uri(uri), credentials);
            var serviceProxy    = new ContosoConsultancyServiceProxy(client);
            var contractService = new ContractService();
            var pdfService      = new PdfService();

            Application.Run(new Form1(serviceProxy, contractService, pdfService));
        }
Exemplo n.º 23
0
        public void Setup()
        {
            pdfs = DataGenerator.GetPdfs();
            var options = new DbContextOptionsBuilder <PdfContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString())
                          .EnableSensitiveDataLogging(true)
                          .Options;

            pdfContext = new PdfContext(options);
            pdfService = new PdfService(pdfContext);

            var pdf = pdfService.InsertPdf(pdfs[0]);

            pdf = pdfService.InsertPdf(pdfs[1]);
        }
Exemplo n.º 24
0
        public void GetFormFieldsTest()
        {
            IDictionary <string, PdfField> fields;

            using (var pdfStream = Assembly.GetAssembly(typeof(PdfService)).GetManifestResourceStream("PdfFormFiller.Common.Resources.fw9.pdf"))
            {
                var filler = new PdfService();

                fields = filler.GetFormFields(pdfStream);
            }

            Assert.IsNotNull(fields);
            Assert.IsTrue(fields.Count > 0);
            Assert.IsTrue(fields.ContainsKey("topmostSubform[0].Page1[0].Address[0].f1_7[0]"));
        }
Exemplo n.º 25
0
        // https://itextpdf.com/en/resources/api-documentation/itext-7-net

        static void Main(string[] args)
        {
            //PdfServiceByItextsharp pdfService = new PdfServiceByItextsharp();
            //pdfService.CreatePdfFile();

            //PdfServiceByItext7 pdfServiceByItext7 = new PdfServiceByItext7();
            //pdfServiceByItext7.CreatePdf();

            //CellAndTableWidths cellAndTableWidths = new CellAndTableWidths();
            //cellAndTableWidths.ColumnWidthExample();
            //cellAndTableWidths.FullPageTable();
            //cellAndTableWidths.RightCornerTable();
            //cellAndTableWidths.SimpleTable3();

            //ColspanAndRowspan colspanAndRowspan = new ColspanAndRowspan();
            //colspanAndRowspan.ColspanRowspan();
            //colspanAndRowspan.RowspanAbsolutePosition();
            //colspanAndRowspan.SimpleRowColspan();
            //colspanAndRowspan.SimpleTable11();
            //colspanAndRowspan.SimpleTable12();
            //colspanAndRowspan.SimpleTable2();
            //colspanAndRowspan.SimpleTable9();
            //colspanAndRowspan.TableMeasurements();

            //LargeTables largeTables = new LargeTables();
            //largeTables.IncompleteTable();

            //RowspanAndSplitting rowspanAndSplitting = new RowspanAndSplitting();
            //rowspanAndSplitting.SplittingAndRowspan();
            //rowspanAndSplitting.SplittingNestedTable1();
            //rowspanAndSplitting.SplittingNestedTable2();

            PdfService           pdfService           = new PdfService();
            PdfServiceMultiPages pdfServiceMultiPages = new PdfServiceMultiPages();
            ReceiptModel         receiptModel         = new ReceiptModel();


            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            long elapse;

            stopwatch.Start();

            //pdfService.CreateReceiptPdf(receiptModel);
            pdfServiceMultiPages.CreateReceiptPdf(receiptModel);

            elapse = stopwatch.ElapsedMilliseconds;
            CSiteUtility.WriteLog("500개 발행 : stop", elapse.ToString());
        }
Exemplo n.º 26
0
 public void SetUp()
 {
     _repository          = new Mock <IRepositoryWrapper>();
     _logger              = new Mock <ILoggerService <PdfService> >();
     _decisionBlobStorage = new Mock <IDecisionBlobStorageRepository>();
     _repository.Setup(rep => rep.User.FindByCondition(It.IsAny <Expression <Func <User, bool> > >()))
     .Returns(GetTestUsersQueryable());
     _repository.Setup(rep => rep.UserProfile.FindByCondition(It.IsAny <Expression <Func <UserProfile, bool> > >()))
     .Returns(GetTestUserProfilesQueryable());
     _repository.Setup(rep => rep.CityMembers.FindByCondition(It.IsAny <Expression <Func <CityMembers, bool> > >()))
     .Returns(GetTestCityMembersQueryable());
     _repository.Setup(rep => rep.ClubMembers.FindByCondition(It.IsAny <Expression <Func <ClubMembers, bool> > >()))
     .Returns(GetTestClubMembersQueryable());
     _logger.Setup(log => log.LogError(It.IsAny <string>()));
     _pdfService = new PdfService(_repository.Object, _logger.Object, _decisionBlobStorage.Object);
 }
        private static void Main(string[] args)
        {
            var settingsProvider = new SettingsProvider();
            var nameHelper       = new FileNameHelper(settingsProvider);
            var pdfService       = new PdfService(settingsProvider, LogManager.GetLogger(nameof(PdfService)));
            var watcherFactory   = new FileHandlerFactory(nameHelper, pdfService);

            HostFactory.Run(x =>
            {
                x.Service(() => new FileHandlerService(watcherFactory, settingsProvider, LogManager.GetLogger(nameof(FileHandlerService))));
                x.SetServiceName("WindowsService.FileHandlerService");
                x.SetDisplayName("File Handler Service");
                x.StartAutomaticallyDelayed();
                x.RunAsLocalService();
                x.EnableServiceRecovery(y => y.RestartService(1).RestartService(1));
            });
        }
Exemplo n.º 28
0
        public SurveyController()
        {
            this.modelContext = new ModelContext();

            var userStore = new UserStore <ApplicationUser>(this.modelContext);
            var roleStore = new RoleStore <ApplicationRole>(this.modelContext);

            this.userManager = new UserManager <ApplicationUser>(userStore);
            this.roleManager = new RoleManager <ApplicationRole>(roleStore);

            this.surveyCompletionByDemandEmailService = new SurveyCompletionByDemandEmailService();
            this.pdfService                 = new PdfService();
            this.rankingService             = new RankingService();
            this.surveyService              = new SurveyService();
            this.evaluationService          = new EvaluationService();
            this.sendEmailToContinueService = new SendEmailToContinueService();
        }
Exemplo n.º 29
0
        public void Check_Can_Upload_With_Correct_Model()
        {
            // Arrange
            var repository = new Mock <IRepository <Pdf> >();
            var service    = new PdfService(repository.Object);
            var pdf        = new Pdf
            {
                Filename = "Document1",
                Location = @"\\server1\documents\",
                Size     = 10
            };

            // Act
            var result = service.Upload(pdf);

            // Assert
            repository.Verify(c => c.Add(It.IsAny <Pdf>()), Times.AtLeastOnce());
        }
Exemplo n.º 30
0
        private static void Main(string[] args)
        {
            var settingsProvider = new SettingsProvider();
            var nameHelper       = new FileNameHelper(settingsProvider);
            var pdfService       = new PdfService(settingsProvider, LogManager.GetLogger(nameof(PdfService)));
            var watcherFactory   = new FileHandlerFactory(nameHelper, pdfService);
            var msmqFactory      = new MessageQueueFactory();
            var logger           = LogManager.GetLogger(nameof(FileHandlerService));

            HostFactory.Run(x =>
            {
                x.Service(() => new FileHandlerService(watcherFactory, msmqFactory, settingsProvider, logger));
                x.SetServiceName("MSMQ.StreamScanning.Worker");
                x.SetDisplayName("MSMQ StreamScanning Worker");
                x.StartAutomaticallyDelayed();
                x.RunAsLocalService();
                x.EnableServiceRecovery(y => y.RestartService(1).RestartService(1));
            });
        }