Ejemplo n.º 1
0
        /******************************************************************

                                   Import Funktion

         *****************************************************************/
        /// <summary>
        /// Imports the whole project.
        /// </summary>
        /// Erstellt von Joshua Frey, am 13.01.2016
        public void ImportWholeProject()
        {
            // if archive file does not exist any more, cancel import.
            if (!File.Exists(this.ZipArchiveFilePath))
            {
                MessageBox.Show(MessageArchiveFileDoesNotExistAnyMore());
                return;
            }

            // extract archive data to temporary dir.
            using (ArchiveZipper zipper = new ArchiveZipper())
            {
                string tempExtractDir = this.ImportFilesDirectory;
                List<string> extracedFiles = zipper.ExtractArchiveDataToDir(tempExtractDir, this.ZipArchiveFilePath);
                SetImportFilePaths(extracedFiles);
            }
            MessageBox.Show("Importvorgang wird gestartet. Bitte bestätigen Sie mit \"Ok\"");
            ImportProjectData();
            ImportCriterionData();
            ImportProductData();
            ImportProjectCriterionData();
            ImportProjectProductData();
            ImportFulfillmentData();
            MessageBox.Show(MessageEndOfImportProcess());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Exports the whole project. This is the main method which will be called
        /// </summary>
        /// Erstellt von Joshua Frey, am 28.01.2016
        public void ExportWholeProject()
        {
            bool allExportsSucceeded = true;

            // export FulFillment
            string fulfillmentExportFilePath = ExportFulfillments();
            if (VerifyFulfillmentsExport(fulfillmentExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("Fulfillment"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("Fulfillment"));
            }

            // Export ProjectProducts
            string projectProductExportFilePath = ExportProjectProducts();
            if (VerifyProjectProductsExport(projectProductExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("ProjectProduct"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("ProjectProduct"));
            }

            // Export ProjectCriterions
            string projectCriterionExportFilePath = ExportProjectCriterions();
            if (VerifyProjectCriterionsExport(projectCriterionExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("ProjectCriterion"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("ProjectCriterion"));
            }

            // Export Products
            string productExportFilePath = ExportProducts();
            if (VerifyProductsExport(productExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("Product"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("Product"));
            }

            // Export criterions
            string CriterionExportFilePath = ExportCriterion();
            if (VerifyCriterionsExport(CriterionExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("Criterion"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("Criterion"));
            }

            // Export project
            string projectExportFilePath = ExportProjectInformation();
            if (VerifyProjectExport(projectExportFilePath))
            {
                this.ArchiveLogWriter.Log(MessageExportVerified("Project"));
            }
            else
            {
                allExportsSucceeded = false;
                this.ArchiveLogWriter.Log(MessageExportNotVerified("Project"));
            }

            if (!allExportsSucceeded)
            {
                string exportErrorMessage = MessageWholeExportProcessFailed();
                MessageBox.Show(exportErrorMessage);
                this.ArchiveLogWriter.Log(exportErrorMessage);
            }
            else
            {
                string exportSuccessMessage = MessageWholeExportProcessSucceeded();
                MessageBox.Show(exportSuccessMessage);
                this.ArchiveLogWriter.Log(exportSuccessMessage);

                bool allDeletionsSucceeded = true;

                // delete Data from db
                if (DeleteFulFillmentData())
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("Fulfillment"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("Fulfillment"));
                    allDeletionsSucceeded = false;
                }

                if (DeleteProjectProductData())
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("ProjectProduct"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("ProjectProduct"));
                    allDeletionsSucceeded = false;
                }

                if (DeleteProjectCriterionData())
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("ProjectCriterion"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("ProjectCriterion"));
                    allDeletionsSucceeded = false;
                }

                if (DeleteProductData(productExportFilePath))
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("Product"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("Product"));
                    allDeletionsSucceeded = false;
                }

                if (DeleteCriterionData(CriterionExportFilePath))
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("Criterion"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("Criterion"));
                    allDeletionsSucceeded = false;
                }

                if (DeleteProjectData())
                {
                    this.ArchiveLogWriter.Log(MessageDeletionVerified("Project"));
                }
                else
                {
                    this.ArchiveLogWriter.Log(MessageDeletionNotVerified("Project"));
                    allDeletionsSucceeded = false;
                }

                // if everey deletion was successful, the zip Process will start
                if (allDeletionsSucceeded)
                {
                    string deletionSuccess = MessageWholeDeletionProcessSucceeded();
                    MessageBox.Show(deletionSuccess);
                    this.ArchiveLogWriter.Log(MessageDeletionVerified(deletionSuccess));

                    // create zip archive
                    using (ArchiveZipper archZipper = new ArchiveZipper())
                    {
                        try
                        {
                            string zipArchivePath = this.FileBaseName + ".zip";
                            archZipper.CompressFilesToZipArchive(zipArchivePath, this.ExportFilePaths);
                        }
                        catch (NWATException zipperError)
                        {
                            throw zipperError;
                        }
                    }

                    string caption = "Löschen der Export Dateien";
                    var result = MessageBox.Show(MessageZipProcessSuccessful(), caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    // User interaction --> User can decide if export files outside the zip archive should be deleted
                    if (result == DialogResult.Yes)
                    {
                        foreach (string file in this.ExportFilePaths)
                        {
                            if (File.Exists(file))
                            {
                                File.Delete(file);
                            }
                        }
                    }
                }
                else
                {
                    string deletionError = MessageWholeDeletionProcessFailed();
                    MessageBox.Show(deletionError);
                    this.ArchiveLogWriter.Log(deletionError);
                }
            }
        }