Exemplo n.º 1
0
        public static void ModifyPackageLoadXML(Form parent, string xmlPath, string dirPath)
        {
            string      _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();
            RMPackage   package    = null;
            LogDataList log        = null;

            frmLoading loadingForm = new frmLoading(StringConst.frmLoading.PARSING_MANIFEST + xmlPath + ".");
            bool       error       = false;
            Thread     thread      = new Thread(delegate()
            {
                try
                {
                    package = new RMPackage(xmlPath, _namespace, out log, NoAssetProbing: true);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_XML_READ_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.ModifyPackXMLReadError(xmlPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    error = true;
                    loadingForm.SafeClose();
                    return;
                }
                loadingForm.SafeClose();
            });

            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                return;
            }

            if (log != null && log.HasErrorsOrWarnings())
            {
                Helper.ShowMessageBox(MessageBoxStrings.General.HAS_ERRORS_WARNINGS, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                frmLogger loggerForm = new frmLogger(_logList: log);
                loggerForm.StartPosition = FormStartPosition.CenterParent;
                loggerForm.ShowDialog();
            }

            frmPropPack loadPackDlg = new frmPropPack(package, dirPath, false);

            loadPackDlg.Text = Vars.FRMPROPPACK_MODFY_TITLE;
            loadPackDlg.ShowDialog(parent);
        }
Exemplo n.º 2
0
        public static void ModifyPackageLoadZIP(Form parent, string zipPath)
        {
            string    _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();
            Exception outEx;

            if (Directory.Exists(PMFileSystem.PackMan_TempMakeDir) && Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG) == DeleteFolderResult.UserCancelled)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_TEMP_DIR_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Helper.CreateFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_CREATE_TEMP_DIR_ARG) == CreateFolderResult.UserCancelled)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_TEMP_DIR_ERR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ArchiveManagement.ChecksumStatus archCheckStat = ArchiveManagement.ChecksumStatus.NoStoredChecksum;
            try
            {
                archCheckStat = ArchiveManagement.PerformArchiveChecksumCheck(zipPath);
            }
            catch (Exception ex)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.UnableReadArchStatus(zipPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                return;
            }

            if (archCheckStat == ArchiveManagement.ChecksumStatus.ChecksumMatchFailed)
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.FailedChecksumZip(zipPath), _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                return;
            }
            else if (archCheckStat == ArchiveManagement.ChecksumStatus.NoStoredChecksum)
            {
                if (Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_ARCH_NO_CHECK, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }

            frmLoading loadingForm = new frmLoading(StringConst.frmLoading.EXTRACTING_ARCH + zipPath + ".");
            bool       error       = false;
            Thread     thread      = new Thread(delegate()
            {
                try
                {
                    ArchiveManagement.ExtractZip(zipPath, PMFileSystem.PackMan_TempMakeDir, _namespace, false);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.UnableExtractZip(zipPath, PMFileSystem.PackMan_TempMakeDir), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    error = true;
                    loadingForm.SafeClose();
                    return;
                }
                loadingForm.SafeClose();
            });

            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                return;
            }

            string      xmlPath = PMFileSystem.PackMan_TempMakeDir + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;
            RMPackage   package = null;
            LogDataList log     = null;

            if (!File.Exists(xmlPath))
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.ZipExtractInstallXmlNull(zipPath), _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                return;
            }


            loadingForm = new frmLoading(StringConst.frmLoading.PARSING_MANIFEST + xmlPath + ".");
            thread      = new Thread(delegate()
            {
                try
                {
                    package = new RMPackage(xmlPath, _namespace, out log, NoAssetProbing: true);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.ZipExtractInstallXMLErr(zipPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    error = true;
                    loadingForm.SafeClose();
                    return;
                }
                loadingForm.SafeClose();
            });
            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                return;
            }


            package.Implicit = false;

            LogDataList outLog = null;

            loadingForm = new frmLoading(StringConst.frmLoading.RETRIEVING_ASSETS_DIR + PMFileSystem.PackMan_TempMakeDir + ".");
            thread      = new Thread(delegate()
            {
                try
                {
                    RMImplicit.RetrievePackFromDir(PMFileSystem.PackMan_TempMakeDir, _namespace, false, out outLog, ref package);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.MODIFY_PACK_ZIP_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(LoggerMessages.GUI.BGWorker.Misc.Error.ZipExtractUnableRetrieveAsset(zipPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    error = true;
                    loadingForm.SafeClose();
                    return;
                }
                loadingForm.SafeClose();
            });
            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                return;
            }

            if (outLog != null)
            {
                log.Logs.AddRange(outLog.Logs);
            }

            if (log != null && log.HasErrorsOrWarnings())
            {
                Helper.ShowMessageBox(MessageBoxStrings.General.HAS_ERRORS_WARNINGS, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                frmLogger loggerForm = new frmLogger(_logList: log);
                loggerForm.StartPosition = FormStartPosition.CenterParent;
                loggerForm.ShowDialog();
            }

            frmPropPack loadPackDlg = new frmPropPack(package, PMFileSystem.PackMan_TempMakeDir, true);

            loadPackDlg.Text = Vars.FRMPROPPACK_MODFY_TITLE;
            loadPackDlg.ShowDialog(parent);
        }