예제 #1
0
        private void linkLic_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string         _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();
            frmLicenseEdit licEdit    = null;

            if (License == null)
            {
                licEdit = new frmLicenseEdit();
            }
            else
            {
                licEdit = new frmLicenseEdit(License);
            }

            if (licEdit.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            License = licEdit.PackageLicense;
            if (StartupDone)
            {
                MadeChanges = true;
            }

            if (cboxImplicit.Checked)
            {
                ProcessLicenseAndImplicitDirCommonPath();
            }
            else
            {
                ProcessCustomAssetsCommonPath(_namespace);
            }
        }
        private void btnOK_Click(object sender, EventArgs e)
        {
            RMPackLic.Source licSource = ToLicenseSource(comboType.SelectedIndex);
            if (ValidateLicenseValue(txtValue.Text, licSource))
            {
                DialogResult   = DialogResult.OK;
                PackageLicense = new RMPackLic(licSource, txtValue.Text);
                Close();
            }
            else
            {
                switch (licSource)
                {
                case RMPackLic.Source.File:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.FileNotFound(txtValue.Text), MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case RMPackLic.Source.Text:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.TEXT_EMPTY, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;

                case RMPackLic.Source.URL:
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmLicenseEdit.INVALID_URL, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    break;
                }
            }
        }
 bool ValidateLicenseValue(string value, RMPackLic.Source type)
 {
     if (type == RMPackLic.Source.File)
     {
         if (File.Exists(value) && RMPackLic.HasAValidLicFileExtension(Path.GetExtension(value)))
         {
             return(true);
         }
         return(false);
     }
     else if (type == RMPackLic.Source.Text)
     {
         if (string.IsNullOrWhiteSpace(value))
         {
             return(false);
         }
         return(true);
     }
     else
     {
         if (value.IsAValidURL())
         {
             return(true);
         }
         return(false);
     }
 }
 RMPackLic GetProperPackLicenseFieldPack()
 {
     if (License == null || License.LicenseSource != RMPackLic.Source.File)
     {
         return(License);
     }
     if (cboxImplicit.Checked)
     {
         RMPackLic lic = License.Clone();
         lic.Data = LicenseFileRelativePath;
         return(lic);
     }
     else
     {
         if (FormattedCustomAssetPack == null)
         {
             return(null);
         }
         return(FormattedCustomAssetPack.License);
     }
 }
 public frmLicenseEdit(RMPackLic license)
 {
     RequiredInit();
     PackageLicense = license;
 }
예제 #6
0
            public static void CopyPackageInstallInfo(string dirPath, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                log.WriteInformationLog(NewProjectMessages.Info.CopyInstallInfoInit(dirPath), _namespace);
                Exception exOut;

                if (!Directory.Exists(dirPath))
                {
                    return;
                }
                string packageXMLFile = dirPath + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;

                if (!File.Exists(packageXMLFile))
                {
                    try
                    {
                        throw new FileNotFoundException(packageXMLFile + ExceptionMessages.General.COULD_NOT_BE_FOUND);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(NewProjectMessages.Error.XML_FILE_NOT_FOUND + packageXMLFile + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                LogDataList outLog  = null;
                RMPackage   package = null;

                try
                {
                    package = new RMPackage(packageXMLFile, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.AppendLogs(outLog);
                    throw new InvalidInstalledPackageFile(ExceptionMessages.PackageManagement.InstalledPackage.INVALID_XML + packageXMLFile + ".", packageXMLFile, ex);
                }
                log.AppendLogs(outLog);


                if (package.ContentsSummary == RMCollectionType.Generator)//If package only contains generator parts then we don't copy it.
                {
                    return;
                }

                if (package.ContentsSummary.HasFlag(RMCollectionType.Generator))
                {
                    PackageUtil.RemoveGeneratorFilesAndCollection(package, dirPath, _namespace);

                    package.SaveToFile(packageXMLFile, _namespace, logMessage: new WriteAllTextLogMessages(writeFailed: LoggerMessages.PackageManagement.NewProject.Error.XMLFileSaveFailed));

                    try
                    {
                        Helper.DeleteEmptySubDir(dirPath, _namespace);
                    }
                    catch (Exception ex)
                    {
                        log.WriteWarningLog(NewProjectMessages.Warning.DELETE_SUB_DIR + PMFileSystem.PackMan_TempMakeDir + ".", _namespace, ex);
                    }
                }

                string newDataNewDir = PMFileSystem.MV_NewDataMan_Dir + "\\" + package.UniqueIDInMD5;

                if (Directory.Exists(newDataNewDir) && Helper.DeleteFolderSafely(newDataNewDir, _namespace, out exOut, LoggerMessages.GeneralError.REQUIRED_DIR_EXISTS_DEL_FAILED_ARG) == DeleteFolderResult.UserCancelled)
                {
                    throw exOut;
                }

                if (Helper.CreateFolderSafely(newDataNewDir, _namespace, out exOut, new CreateFolderLogMessages(createFailed: NewProjectMessages.Error.ErrorMakeDir)) == CreateFolderResult.UserCancelled)
                {
                    throw exOut;
                }

                string destArch = newDataNewDir + "\\" + Vars.INSTALLED_ARCH_FILENAME;

                ArchiveManagement.CreateNewZip(dirPath, destArch, _namespace);

                if (package.License.LicenseSource == RMPackLic.Source.File)
                {
                    if (RMPackLic.IsAValidLicenseSourceFile(package.License.Data, package.XMLDirectory))
                    {
                        string licSourcePath = package.XMLDirectory + "\\" + package.License.Data;
                        string fileName      = null;
                        try
                        {
                            fileName = Path.GetFileName(licSourcePath);
                        }
                        catch (Exception ex)
                        {
                            package.License = null;
                            log.WriteWarningLog(NewProjectMessages.Warning.LIC_COPY_FAILED_GEN, _namespace, ex);
                            goto skipLic;
                        }
                        string destPath = newDataNewDir + "\\" + fileName;

                        if (Helper.CopyFileSafely(licSourcePath, destPath, true, _namespace, out exOut, new CopyFileLogMessages(copyFileFailed: NewProjectMessages.Warning.LicCopyFailed, logGroup: log)) != CopyFileResult.Success)
                        {
                            package.License = null;
                            goto skipLic;
                        }
                        package.License.Data = fileName;
                    }
                    else
                    {
                        package.License = null;
                        log.WriteWarningLog(NewProjectMessages.Warning.LIC_COPY_FAILED_GEN, _namespace);
                    }
                }


skipLic:
                string newPackageXMLFile = newDataNewDir + "\\" + Vars.INSTALLED_XML_FILENAME;

                //package.Installed = true;
                //package.SetInstalledPropertyAll(RMPackObject.InstallStatus.Installed);
                package.SaveToFile(newPackageXMLFile, _namespace, RMPackage.SaveToFileMode.ExplicitAssetInfo,
                                   logMessage: new WriteAllTextLogMessages(writeFailed: LoggerMessages.PackageManagement.NewProject.Error.XMLFileSaveFailed));

                log.WriteInformationLog(NewProjectMessages.Info.CopyInstallInfoDone(dirPath), _namespace);
            }
예제 #7
0
        public RMPackLic Clone()
        {
            RMPackLic clone = new RMPackLic(LicenseSource, Data);

            return(clone);
        }
예제 #8
0
        public static void MakeInstalledPackageFileForDefPackage(string XmlPath, string _namespace, out LogDataList log, string rootDirectory = null, bool ignoreClash = false)
        {
            log = new LogDataList();
            log.WriteInformationLog(MakeInstalledPackagesMessages.Info.CreateInstalledPack(XmlPath, rootDirectory), _namespace);
            LogDataList outLog  = null;
            RMPackage   newPack = null;
            Exception   exResult;

            try
            {
                newPack = new RMPackage(XmlPath, _namespace, out outLog, rootDirectory);
            }
            catch (Exception ex)
            {
                log.AppendLogs(outLog);
                Logger.WriteErrorLog(MakeInstalledPackagesMessages.Error.InvalidXML(XmlPath, rootDirectory), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                throw;
            }
            log.AppendLogs(outLog);

            string origDir = newPack.XMLDirectory;

            InstalledPackage installedPackage = GlobalPackages.FindByUID(newPack.UniqueID);
            string           newPackDir       = PMFileSystem.PackMan_ManDir + "\\" + newPack.UniqueIDInMD5;

            if (installedPackage != null)
            {
                if (ignoreClash)
                {
                    Logger.WriteWarningLog(MakeInstalledPackagesMessages.Warning.InstalledPackExistsExit(newPack.Name), _namespace, null);
                    return;
                }
                else
                {
                    log.WriteWarningLog(MakeInstalledPackagesMessages.Warning.InstalledPackExistsReplace(newPack.Name), _namespace);
                    if (Helper.DeleteFolderSafely(newPackDir, _namespace, out exResult, new DeleteFolderLogMessages(deleteFailed: MakeInstalledPackagesMessages.Error.UnableToDeleteExistingFolder)) == DeleteFolderResult.UserCancelled)
                    {
                        throw exResult;
                    }
                }
            }



            string tempPackDir = PMFileSystem.PackMan_TempDir + "\\" + newPack.UniqueIDInMD5;

            if (Helper.DeleteFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG) == DeleteFolderResult.UserCancelled)
            {
                throw exResult;
            }

            if (Helper.CreateFolderSafely(newPackDir, _namespace, out exResult, new CreateFolderLogMessages(createFailed: MakeInstalledPackagesMessages.Error.UnableCreateRootDir)) == CreateFolderResult.UserCancelled)
            {
                throw exResult;
            }

            if (Helper.CreateFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_CREATE_TEMP_DIR_ARG) == CreateFolderResult.UserCancelled)
            {
                throw exResult;
            }

            string backupXMLInstallerPath = tempPackDir + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;



            makeInstPackageAnon onErrorBackup = delegate()
            {
                if (Helper.ShowMessageBox(MessageBoxStrings.PackageManagement.FailedMakeInstallPackageArch(newPack.Name), MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    return(true);
                }

                Logger.WriteErrorLog(MakeInstalledPackagesMessages.Error.UserRequiredOnFailedBackUpNo(newPack.Name), _namespace, null, BasicDebugLogger.DebugErrorType.Error);
                Helper.DeleteFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                Helper.DeleteFolderSafely(newPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_UNUSED_DIR_ARG);
                return(false);
            };



            string rootPathOfFiles;

            if (rootDirectory == null)
            {
                rootPathOfFiles = newPack.XMLDirectory;
            }
            else
            {
                rootPathOfFiles = rootDirectory;
            }

            PackageUtil.ExplicitCopyAssetsAndLicFileTo(newPack, rootPathOfFiles, tempPackDir, _namespace);

            try
            {
                newPack.SaveToFile(backupXMLInstallerPath, _namespace, RMPackage.SaveToFileMode.ImplicitAssetInfo,
                                   logMessage: new WriteAllTextLogMessages(writeFailed: MakeInstalledPackagesMessages.Error.UnableCreateInstXML, logGroup: log));
            }
            catch
            {
                if (onErrorBackup())
                {
                    goto onerrorContinue;
                }
                throw;
            }

            string archDest = newPackDir + "\\" + Vars.INSTALLED_ARCH_FILENAME;

            try
            {
                ArchiveManagement.CreateNewZip(tempPackDir, archDest, _namespace);
            }
            catch (Exception ex)
            {
                log.WriteWarningLog(MakeInstalledPackagesMessages.Error.UnableMakeBackup(newPack.Name, tempPackDir, archDest), _namespace, ex);
                if (onErrorBackup())
                {
                    goto onerrorContinue;
                }
                throw;
            }

onerrorContinue:
            //newPack.Installed = true;
            //newPack.SetInstalledPropertyAll(RMPackObject.InstallStatus.Installed);

            if (newPack.License != null && newPack.License.LicenseSource == RMPackLic.Source.File && RMPackLic.IsAValidLicenseSourceFile(newPack.License.Data, origDir))
            {
                string         licSourcePath = origDir + "\\" + newPack.License.Data;
                string         fileName      = Path.GetFileName(licSourcePath);
                string         destPath      = newPackDir + "\\" + fileName;
                CopyFileResult copyRes       = Helper.CopyFileSafely(licSourcePath, destPath, true, _namespace, out exResult, new CopyFileLogMessages(copyFileFailed: MakeInstalledPackagesMessages.Error.UnableCopyLicenseFile));
                if (copyRes == CopyFileResult.UserCancelled || copyRes == CopyFileResult.SourceFileNotFound)
                {
                    Helper.DeleteFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                    Helper.DeleteFolderSafely(newPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_UNUSED_DIR_ARG);
                    throw exResult;
                }
                newPack.License.Data = fileName;
            }
            string installedXMLDest = newPackDir + "\\" + Vars.INSTALLED_XML_FILENAME;

            newPack.Implicit = false;
            try
            {
                newPack.SaveToFile(installedXMLDest, _namespace, RMPackage.SaveToFileMode.ExplicitAssetInfo,
                                   logMessage: new WriteAllTextLogMessages(writeFailed: MakeInstalledPackagesMessages.Error.UnableMakeMainXML));
            }
            catch
            {
                Helper.DeleteFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
                Helper.DeleteFolderSafely(newPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_UNUSED_DIR_ARG);
                throw;
            }

            try
            {
                GlobalPackages.AddSafely(new InstalledPackage(newPackDir, _namespace, out outLog));
            }
            catch (Exception ex)
            {
                log.WriteWarningLog(LoggerMessages.PackageManagement.InstalledPackage.Error.ErrorTryLoad(newPackDir), _namespace, ex);
                if (ex is InvalidInstalledPackageFile castedEx)
                {
                    log.WriteErrorLog(castedEx.Message, _namespace, castedEx.InnerException);
                }
                else
                {
                    log.WriteErrorLog(ex.Message, _namespace, ex);
                }
            }
            log.AppendLogs(outLog);

            try
            {
                NewProject.CopyPackageInstallInfo(tempPackDir, _namespace, out outLog);
            }
            catch (Exception ex)
            {
                log.WriteWarningLog(MakeInstalledPackagesMessages.Warning.UnableCopyNewProj(newPack.Name, newPackDir), _namespace, ex);
            }
            log.AppendLogs(outLog);


            Helper.DeleteFolderSafely(tempPackDir, _namespace, out exResult, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
            log.WriteInformationLog(MakeInstalledPackagesMessages.Info.SUCCESS_CREATE + newPack.Name + ".", _namespace);
        }
        void CopyAssetFilesToTemp(string _namespace, RMPackage rootedFilesPack, out RMPackLic license)
        {
            license = License;
            if (rootedFilesPack == null || rootedFilesPack.Collections == null || rootedFilesPack.Collections.Count == 0)
            {
                throw new NullReferenceException(ExceptionMessages.GUI.frmPropPack.NO_ASSETS_SEL);
            }
            Exception outEx;

            CleanupMakeTemp(_namespace);


            if (Helper.CreateFolderSafely(PMFileSystem.PackMan_TempMakeDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_CREATE_TEMP_DIR_ARG) == CreateFolderResult.UserCancelled)
            {
                throw outEx;
            }

            try
            {
                PackageUtil.ImplicitCopyAssetFilesTo(rootedFilesPack, PMFileSystem.PackMan_TempMakeDir, _namespace);
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(frmPropPackMessagse.Error.COPY_SEL_FAILED + PMFileSystem.PackMan_TempMakeDir + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                CleanupMakeTemp(_namespace, false);
                throw;
            }

            if (License != null && License.LicenseSource == RMPackLic.Source.File)
            {
                if (string.IsNullOrWhiteSpace(License.Data))
                {
                    try
                    {
                        throw new InvalidPackageLicenseException(ExceptionMessages.RMPackage.LIC_FILE_PATH_NULL, InvalidPackageLicenseException.WhichInvalid.InvalidLicenseFile, rootedFilesPack);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(frmPropPackMessagse.Error.LICENSE_FILE_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        CleanupMakeTemp(_namespace, false);
                        throw;
                    }
                }
                if (!File.Exists(License.Data))
                {
                    try
                    {
                        throw new InvalidPackageLicenseException(ExceptionMessages.RMPackage.LicFileNotExist(License.Data), InvalidPackageLicenseException.WhichInvalid.InvalidLicenseFile, rootedFilesPack);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(frmPropPackMessagse.Error.LicenseFileNotExist(License.Data), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        CleanupMakeTemp(_namespace, false);
                        throw;
                    }
                }
                string destLicFile     = Vars.LICENSE_FILE_DEF_NAME + Path.GetExtension(License.Data);
                string destLicFilePath = PMFileSystem.PackMan_TempMakeDir + "\\" + destLicFile;
                if (Helper.CopyFileSafely(License.Data, destLicFilePath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: frmPropPackMessagse.Error.LicenseFileNonCopy)) != CopyFileResult.Success)
                {
                    CleanupMakeTemp(_namespace, false);
                    throw outEx;
                }
                license      = License.Clone();
                license.Data = destLicFile;
            }
        }
        void CreateZIPFile(string _namespace, bool implicitAssets)
        {
            if (implicitAssets)
            {
                if (string.IsNullOrWhiteSpace(txtAssetDir.Text))
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.NO_IMPLICIT_DIR_SEL_SAVE, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!Directory.Exists(txtAssetDir.Text))
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.NO_IMPLICIT_DIR_SEL_SAVE, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                if (CustomAssetPack == null || CustomAssetPack.Collections == null || CustomAssetPack.Collections.Count == 0)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.NO_EXPLICIT_ASSET_SEL_SAVE, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            RMPackage finalPackage = CreatePackageFromUserDetails(true, false);

            if (finalPackage == null)
            {
                return;
            }

            saveFileDialog.FileName         = string.Empty;
            saveFileDialog.InitialDirectory = string.Empty;
            saveFileDialog.Filter           = FileDialogFilters.INSTALL_ZIP;
            if (saveFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            Logger.WriteInformationLog(LoggerMessages.GUI.frmPropPack.Info.SAVE_ZIP_INIT + saveFileDialog.FileName + ".", _namespace);

            RMPackage  temppackage = null;
            Thread     thread      = null;
            frmLoading loadingForm = null;
            bool       error       = false;

            if (implicitAssets)
            {
                temppackage      = new RMPackage();
                temppackage.Name = "Package Manager Probe";
                LogDataList log = null;

                loadingForm = new frmLoading(StringConst.frmLoading.RETRIEVING_ASSETS_DIR + txtAssetDir.Text + ".");
                thread      = new Thread(delegate()
                {
                    try
                    {
                        RMImplicit.RetrievePackFromDir(txtAssetDir.Text, _namespace, false, out log, ref temppackage);
                    }
                    catch (Exception ex)
                    {
                        Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.UNABLE_RETRIEVE_PACK, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Logger.WriteErrorLog(frmPropPackMessagse.Error.UnableRetrievePack(txtAssetDir.Text), _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();
                }
            }
            else
            {
                temppackage = CustomAssetPack;
            }

            RMPackLic license = null;

            loadingForm = new frmLoading(StringConst.frmLoading.COPYING_ASSETS_TO_TEMP + temppackage + ".");
            thread      = new Thread(delegate()
            {
                try
                {
                    CopyAssetFilesToTemp(_namespace, temppackage, out license);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.ZIP_FILE_MAKE_ERR_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPropPackMessagse.Error.ZipFileCopyAssetToTempErr(PMFileSystem.PackMan_TempMakeDir), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    error = true;
                    loadingForm.SafeClose();
                    return;
                }
                loadingForm.SafeClose();
            });
            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                CleanupMakeTemp(_namespace, false);
                return;
            }


            finalPackage.License = license;

            string xmlPath = PMFileSystem.PackMan_TempMakeDir + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;

            try
            {
                finalPackage.SaveToFile(xmlPath, _namespace, logMessage: new WriteAllTextLogMessages(writeFailed: frmPropPackMessagse.Error.ZipSaveXMLFailed));
            }
            catch
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.ZIP_FILE_MAKE_ERR_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                CleanupMakeTemp(_namespace, false);
                return;
            }

            loadingForm = new frmLoading(StringConst.frmLoading.CREATE_AN_ARCH_OF_PACK + saveFileDialog.FileName + ".");
            thread      = new Thread(delegate()
            {
                try
                {
                    ArchiveManagement.CreateNewZip(PMFileSystem.PackMan_TempMakeDir, saveFileDialog.FileName, _namespace);
                }
                catch (Exception ex)
                {
                    Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.ZIP_FILE_MAKE_ERR_GEN, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Logger.WriteErrorLog(frmPropPackMessagse.Error.ZIP_MAKE + saveFileDialog.FileName + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    loadingForm.SafeClose();
                    error = true;
                    return;
                }
                loadingForm.SafeClose();
            });
            thread.Start();
            loadingForm.ShowDialog();

            if (error)
            {
                CleanupMakeTemp(_namespace, false);
                return;
            }

            MadeChanges = false;

            Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.ZIP_SUCCESS + saveFileDialog.FileName + ".", MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Information);

            Logger.WriteInformationLog(LoggerMessages.GUI.frmPropPack.Info.SAVE_ZIP_SUCCESS + saveFileDialog.FileName + ".", _namespace);
        }
            // ---- Helper Methods ---- //
            static void CreateInstalledFile(RMPackage package, string sourceFolder, string newInstalledDir, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                log.WriteInformationLog(InstallerMessages.Information.CREATE_INSTALLED_FILE_START, _namespace);
                Exception outEx;

                if (Helper.CreateFolderSafely(newInstalledDir, _namespace, out outEx, LoggerMessages.GeneralError.CREATE_REQUIRED_DIR_FAILED_ARG) == CreateFolderResult.UserCancelled)
                {
                    throw outEx;
                }

                try
                {
                    Helper.DeleteEmptySubDir(sourceFolder, _namespace);
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.DELETE_SUB_DIR + sourceFolder + ".", _namespace, ex);
                }

                string destArch = newInstalledDir + "\\" + Vars.INSTALLED_ARCH_FILENAME;

                try
                {
                    ArchiveManagement.CreateNewZip(sourceFolder, destArch, _namespace);
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.UnableMakeZip(destArch), _namespace, ex);
                }

                if (package.License == null)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.LIC_SOURCE_NULL, _namespace);
                }
                else
                {
                    if (package.License.LicenseSource == RMPackLic.Source.File)
                    {
                        if (RMPackLic.IsAValidLicenseSourceFile(package.License.Data, package.XMLDirectory))
                        {
                            string licSourcePath = package.XMLDirectory + "\\" + package.License.Data;
                            string fileName      = null;
                            try
                            {
                                fileName = Path.GetFileName(licSourcePath);
                            }
                            catch (Exception ex)
                            {
                                package.License = null;
                                log.WriteWarningLog(InstallerMessages.Warning.INVALID_FILE_NAME_LIC, _namespace, ex);
                                goto skipLic;
                            }
                            string destPath = newInstalledDir + "\\" + fileName;

                            if (Helper.CopyFileSafely(licSourcePath, destPath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: InstallerMessages.Warning.UnableCopyLicFile, logGroup: log)) != CopyFileResult.Success)
                            {
                                package.License = null;
                                goto skipLic;
                            }
                            package.License.Data = fileName;
                        }
                        else
                        {
                            package.License = null;
                            log.WriteWarningLog(InstallerMessages.Warning.INVALID_LIC, _namespace);
                        }
                    }
                }
skipLic:
                string saveToXMLPath = newInstalledDir + "\\" + Vars.INSTALLED_XML_FILENAME;

                package.Implicit = false;
                package.SaveToFile(saveToXMLPath, _namespace, RMPackage.SaveToFileMode.ExplicitAssetInfo,
                                   logMessage: new WriteAllTextLogMessages(writeFailed: InstallerMessages.Error.UnableSaveInstalledXml));
                log.WriteInformationLog(InstallerMessages.Information.CREATE_INSTALLED_FILE_DONE, _namespace);
            }