public IActionResult GetPDFById([FromRoute] int id)
        {
            try
            {
                VerifyUser();
                var model = _service.Read(id);

                if (model == null)
                {
                    var result = new ResultFormatter(ApiVersion, General.NOT_FOUND_STATUS_CODE, General.NOT_FOUND_MESSAGE)
                                 .Fail();
                    return(NotFound(result));
                }
                else
                {
                    var stream = PDFGenerator.Generate(model, _identityService.Username, _identityService.TimezoneOffset);
                    return(new FileStreamResult(stream, "application/pdf")
                    {
                        FileDownloadName = "Bukti Memorial.pdf"
                    });
                }
            }
            catch (Exception e)
            {
                var result = new ResultFormatter(ApiVersion, General.INTERNAL_ERROR_STATUS_CODE, e.Message)
                             .Fail();
                return(StatusCode(General.INTERNAL_ERROR_STATUS_CODE, result));
            }
        }
Ejemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Zapisz();
            var pdfGenerator = new PDFGenerator();

            pdfGenerator.Generate(_zakup, _person);
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            IDatabase db = new Database();

            //read from zip file & populate the database with more data + create updates pdf, xml & json files
            var reader = new ReadExcelFromZip();
            var movies = reader.SelectExcelFilesFromZip("../../../../Movies.zip");


            foreach (var movie in movies)
            {
                Console.WriteLine(movie.Name);
            }

            var import = new MoviesImportToSql();

            import.Import(movies);

            Console.WriteLine("Importing data from xml...");
            //Importing data from xml
            XmlImporter.ImportXml(db);

            //Console.WriteLine("Importing data to Mongo...");
            //Importing data to MongoDB
            //ImportToMongo.ImportToMongo.ImportData();

            Console.WriteLine("Generating xml files...");
            //Generating Xml file report
            var generateXMLFile = new XMLGenerator();

            generateXMLFile.Generate(db);

            Console.WriteLine("Generating json files...");
            //Generating Json file reports
            var generateJsonReports = new JSONGenerator();

            generateJsonReports.Generate(db);

            Console.WriteLine("Generating pdf reports...");
            //Generating Pdf fle reports
            var generatePdfReports = new PDFGenerator();

            generatePdfReports.Generate(db);

            Console.WriteLine("Sending data to MySql...");
            //Sending data to MySql
            var sendDataToMySQL = new MySqlManager();

            sendDataToMySQL.SendDataToMySql();

            Console.WriteLine("Exporting data from MySql to excel file...");
            //Exporting data from MySql to excel file
            var mySqlExcelExport = new MySqlManager();

            mySqlExcelExport.ExportDataFromMySql();
        }
Ejemplo n.º 4
0
        public FileResult Create(int?votingId)
        {
            if (votingId == null)
            {
                throw new ArgumentNullException();
            }

            var db     = new VotingContext();
            var voting = db.Votings.Find(votingId);

            PDFGenerator.Generate(voting);
            string ReportURL = Server.MapPath("~/documents/") + $"Karta głosowania {voting.Name}.pdf";

            byte[] FileBytes = System.IO.File.ReadAllBytes(ReportURL);
            return(File(FileBytes, "application/pdf"));
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            //var db = new MoviesDatabaseOfTeamSingaporeSlingEntities();
            //var employees = db.Employees
            //                .Where(e => e.FirstName == "Tom")
            //                .Select(n =>
            //                new
            //                {
            //                    FirstName = n.FirstName,
            //                    LastName = n.LastName,
            //                    Salary = n.Salary,
            //                    Movies = n.Movies.Select(m => m.Name).ToList(),
            //                    IsDirector = n.IsDirector
            //                }
            //                    )
            //                .ToList();

            //foreach (var employee in employees)
            //{
            //    Console.WriteLine("The actor {0} {1} has participated in this movies:", employee.FirstName, employee.LastName);
            //    foreach (var movie in employee.Movies)
            //    {
            //        Console.WriteLine(movie);
            //    }
            //}
            var db = new Database();

            //Generating Xml file report
            var generateXMLFile = new XMLGenerator();

            generateXMLFile.Generate(db);
            //Generating Json file reports
            var generateJsonReports = new JSONGenerator();

            generateJsonReports.Generate(db);
            //Generating Pdf fle reports
            var generatePdfReports = new PDFGenerator();

            generatePdfReports.Generate(db);

            //XMLImporter.ImportXML();
        }
Ejemplo n.º 6
0
        private void btnSavePdf_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(DocumentName))
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasUnetiNazivDokumentaUzicnik");
                return;
            }
            if (Images == null || Images.Where(x => x.IsSelected).Count() < 1)
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasSkeniratiNestoIOznacitiStavkeUzvicnik");
                return;
            }
            if (String.IsNullOrEmpty(SelectedPath))
            {
                MainWindow.ErrorMessage = (string)Application.Current.FindResource("MorasOdabratiFolderUzvicnik");
                return;
            }
            CanInteractWithForm = false;
            Thread td = new Thread(() =>
            {
                try
                {
                    var tempPath = System.IO.Path.GetTempPath();

                    var generator = new PDFGenerator(Images
                                                     .Where(x => x.IsSelected)
                                                     .OrderBy(x => x.CreatedAt)
                                                     .Select(x => x.ImagePath)
                                                     .ToList(),
                                                     tempPath, DocumentName,
                                                     MainWindow.CurrentUser.FirstName + " " + MainWindow.CurrentUser.LastName);

                    CurrentDocumentFullPath = generator.Generate();

                    if (DocumentSavePathOption.Value == true)
                    {
                        File.Copy(CurrentDocumentFullPath, $"{SelectedPath}\\{DocumentName}.pdf");
                        Dispatcher.BeginInvoke((Action)(() => {
                            DocumentSaved?.Invoke(CurrentDocumentFullPath);
                        }));
                    }
                    else
                    {
                        var documentFolderResp = new DocumentFolderSQLiteRepository().GetDirectoryByPath(MainWindow.CurrentCompanyId, SelectedPath);
                        var documentFolder     = documentFolderResp?.DocumentFolder ?? null;


                        var azureClient = new AzureDataClient();



                        var file = azureClient.GetFile($"{SelectedPath}/{DocumentName}.pdf");
                        file.UploadFromFile(CurrentDocumentFullPath);

                        file.FetchAttributes();

                        var documentFile = new DocumentFileViewModel()
                        {
                            Identifier     = Guid.NewGuid(),
                            Name           = $"{DocumentName}.pdf",
                            DocumentFolder = documentFolder,
                            Path           = file.Uri.LocalPath,
                            Size           = file.Properties.Length / 1024,
                            CreatedAt      = file.Properties.LastModified.Value.DateTime,
                            Company        = new CompanyViewModel()
                            {
                                Id = MainWindow.CurrentCompanyId
                            },
                            CreatedBy = new UserViewModel()
                            {
                                Id = MainWindow.CurrentUserId
                            }
                        };

                        var documentFileService = DependencyResolver.Kernel.Get <IDocumentFileService>();

                        var response = documentFileService.Create(documentFile);
                        if (response.Success)
                        {
                            Dispatcher.BeginInvoke((Action)(() => {
                                DocumentSaved?.Invoke(file.Uri.LocalPath);
                            }));
                        }
                        else
                        {
                            MainWindow.WarningMessage = "Dokument je sačuvan na serveru ali nije indeksiran, molimo kontaktirajte administraciju!";
                            Dispatcher.BeginInvoke((Action)(() => {
                                DocumentSaved?.Invoke(file.Uri.LocalPath);
                            }));
                        }
                    }


                    MainWindow.SuccessMessage = (string)Application.Current.FindResource("DokumentJeUspesnoSacuvanUzvicnik");
                } catch (Exception ex)
                {
                    MainWindow.ErrorMessage = ex.Message;
                } finally
                {
                    CanInteractWithForm = true;
                }
            });

            td.IsBackground = true;
            td.Start();
        }