コード例 #1
0
            static InstalledPackage CreateLocalInstalledFile(RMPackage package, string sourceFolder, string packManStorePath, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                string      newInstalledDir = packManStorePath + "\\" + package.UniqueIDInMD5;
                LogDataList outLog          = null;

                try
                {
                    CreateInstalledFile(package, sourceFolder, newInstalledDir, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.UNABLE_CREATE_INSTALLED_FILES, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage retVal = null;

                try
                {
                    retVal = new InstalledPackage(newInstalledDir, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.UNABLE_LOAD_PACK, _namespace, ex);
                }
                log.AppendLogs(outLog);
                return(retVal);
            }
コード例 #2
0
            public static InstalledPackage InstallLocalPackage(string packagePath, string projectPath, string _namespace, out LogDataList log, bool ignoreClash = false, bool alreadyCopiedToTemp = false, bool procEvents = true)
            {
                if (string.IsNullOrWhiteSpace(projectPath))
                {
                    try
                    {
                        throw new ArgumentNullException(ExceptionMessages.General.PROJ_PATH_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.UNABLE_OPEN_LOCAL_PACKAGE_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                log = new LogDataList();
                ProjectPackMan openedProject = null;
                LogDataList    outLog        = null;

                try
                {
                    openedProject = new ProjectPackMan(projectPath, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.UNABLE_OPEN_LOCAL_PACKAGE + projectPath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage retVal = InstallLocalPackage(packagePath, openedProject, _namespace, out outLog, ignoreClash, alreadyCopiedToTemp, procEvents);

                log.AppendLogs(outLog);
                return(retVal);
            }
コード例 #3
0
            static void RetrieveGeneratorFileParts(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMGenPart> collection, RMGenFile.GenFileType whichFilePart, RMGeneratorCollection parent)
            {
                log = new LogDataList();
                string      appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_FEMALE;
                LogDataList outLog       = null;

                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Female, parent);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_MALE;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Male, parent);
                    log.AppendLogs(outLog);
                }
                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_PART_KID;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorPartOnGender(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref collection, whichFilePart, RMGenPart.eGender.Kid, parent);
                    log.AppendLogs(outLog);
                }
            }
コード例 #4
0
            public static InstalledPackage UpdateLocalPackage(string pathToInstaller, string pathToProject, bool packageAlreadyCopiedToTem, string _namespace, out LogDataList log, bool skipInstallFileExistenceCheck = false)
            {
                if (string.IsNullOrWhiteSpace(pathToProject))
                {
                    try
                    {
                        throw new ArgumentNullException(ExceptionMessages.General.PROJ_PATH_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Uninstaller.Error.UNABLE_OPEN_LOCAL_PACKAGE_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                log = new LogDataList();
                LogDataList    outLog        = null;
                ProjectPackMan openedProject = null;

                try
                {
                    openedProject = new ProjectPackMan(pathToProject, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Uninstaller.Error.UNABLE_OPEN_LOCAL_PACKAGE + pathToProject + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage retVal = UpdateLocalPackage(pathToInstaller, openedProject, packageAlreadyCopiedToTem, _namespace, out outLog, skipInstallFileExistenceCheck);

                log.AppendLogs(outLog);
                return(retVal);
            }
コード例 #5
0
            public static RMGeneratorCollection RetrieveGeneratorCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMPackage parent)
            {
                log = new LogDataList();
                RMGeneratorCollection newCollection   = new RMGeneratorCollection(parent);
                List <RMGenPart>      tempListOfFiles = new List <RMGenPart>();
                LogDataList           outLog          = null;

                string appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_FACE;

                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.Face, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_SV;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.SV, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_TV;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.TV, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_TVD;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.TVD, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.GEN_VARIATION;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveGeneratorFileParts(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref tempListOfFiles, RMGenFile.GenFileType.Var, newCollection);
                    log.AppendLogs(outLog);
                }

                if (tempListOfFiles.Count == 0)
                {
                    return(null);
                }

                newCollection.Parts.AddRange(tempListOfFiles);

                return(newCollection);
            }
コード例 #6
0
            public static RMCharImageCollection RetrieveCharacterImages(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMPackage parent)
            {
                log = new LogDataList();
                RMCharImageCollection   newCollection    = new RMCharImageCollection(parent);
                List <RMCharImageGroup> ListOfCharacters = new List <RMCharImageGroup>();
                LogDataList             outLog           = null;

                string appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_CHARACTERS;

                if (Directory.Exists(appendedPath))
                {
                    RetrieveSubCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref ListOfCharacters, RMCharImageFile.ImageTypes.Character, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_ENEMIES;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveSubCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref ListOfCharacters, RMCharImageFile.ImageTypes.Enemy, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_FACES;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveSubCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref ListOfCharacters, RMCharImageFile.ImageTypes.Face, newCollection);
                    log.AppendLogs(outLog);
                }


                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_SV_ACTORS;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveSubCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref ListOfCharacters, RMCharImageFile.ImageTypes.SV_Actor, newCollection);
                    log.AppendLogs(outLog);
                }

                appendedPath = path + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_SV_ENEMIES;
                if (Directory.Exists(appendedPath))
                {
                    RetrieveSubCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, ref ListOfCharacters, RMCharImageFile.ImageTypes.SV_Enemy, newCollection);
                    log.AppendLogs(outLog);
                }

                if (ListOfCharacters.Count == 0)
                {
                    return(null);
                }
                newCollection.Groups.AddRange(ListOfCharacters);
                return(newCollection);
            }
コード例 #7
0
            static UninstallResult ProcDelNonReadXMLPackage(string arg, string installedDir, InstalledPackage installedPackage, ProjectPackMan openedProject, string _namespace, out LogDataList log, bool procEvents = true, UninstallArgType argType = UninstallArgType.UID, bool globalPackage = true, string whereToRemove = null)
            {
                log = new LogDataList();

                if (argType == UninstallArgType.DirectoryPath || argType == UninstallArgType.XMLPath)
                {
                    LogDataList outLog  = null;
                    RMPackage   package = null;
                    if (procEvents && OnPackageUninstallBegin != null)
                    {
                        OnPackageUninstallBegin.Invoke(package, globalPackage, installedDir, installedPackage, openedProject);
                    }

                    RMPackage parsedPackage = null;

                    try
                    {
                        parsedPackage = new RMPackage(arg, _namespace, out outLog);
                    }
                    catch (Exception ex)
                    {
                        log.AppendLogs(outLog);
                        Logger.WriteErrorLog(UninstallerMessages.Error.XML_FILE_INVALID + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                    log.AppendLogs(outLog);

                    UninstallResult res = UninstallPackage(parsedPackage, _namespace, out outLog, globalPackage, whereToRemove);

                    log.AppendLogs(outLog);

                    if (procEvents && OnPackageUninstalled != null)
                    {
                        OnPackageUninstalled.Invoke(package, globalPackage, installedPackage, openedProject);
                    }

                    return(res);
                }
                else
                {
                    try
                    {
                        throw new InvalidArgumentException(argType.GetType(), "argType");
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.INVALID_PROCDELNONREADXMLPACKAGE_ARG, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
            }
コード例 #8
0
            public ProjectPackMan(string ProjectDirectoryPath, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                if (!Directory.Exists(ProjectDirectoryPath))
                {
                    throw new DirectoryNotFoundException(ExceptionMessages.General.DirNotFound(ProjectDirectoryPath));
                }
                DirectoryPath = ProjectDirectoryPath;
                string packManStorePath = ProjectDirectoryPath + "\\" + Vars.PACKAGE_MANAGER_DIRECTORY;

                if (!Directory.Exists(packManStorePath))
                {
                    return;
                }

                string[] directories = Directory.GetDirectories(packManStorePath);
                if (directories == null || directories.Length == 0)
                {
                    return;
                }

                foreach (string directory in directories)
                {
                    try
                    {
                        LogDataList outLog;
                        InstalledPackages.AddSafely(new InstalledPackage(directory, _namespace, out outLog));
                        log.AppendLogs(outLog);
                    }
                    catch (Exception ex)
                    {
                        log.WriteWarningLog(LoggerMessages.PackageManagement.ProjectPackMan.Warning.InvalidPackage(directory), _namespace, ex);
                    }
                }
            }
コード例 #9
0
        public static void InitializePackageManagement(this frmMain form)
        {
            string _namespace = MethodBase.GetCurrentMethod().ToLogFormatFullName();

            string[] directories = null;
            try
            {
                directories = Directory.GetDirectories(PMFileSystem.PackMan_ManDir);
            }
            catch (Exception ex)
            {
                Helper.ShowMessageBox(MessageBoxStrings.PackageManagement.INIT_GLOBAL_GET_DIRS_ERROR, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Logger.WriteErrorLog(LoggerMessages.PackageManagement.GLOBAL_DIR_ERROR + PMFileSystem.PackMan_ManDir + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                return;
            }
            if (directories == null || directories.Length == 0)
            {
                return;
            }

            LogDataList log = new LogDataList();


            foreach (string directory in directories)
            {
                LogDataList outLog = null;
                try
                {
                    GlobalPackages.AddSafely(new InstalledPackage(directory, _namespace, out outLog));
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(LoggerMessages.PackageManagement.InstalledPackage.Error.ErrorTryLoad(directory), _namespace, ex);
                    if (ex is InvalidInstalledPackageFile castedEx)
                    {
                        log.WriteErrorLog(castedEx.Message, _namespace, castedEx.InnerException);
                    }
                    else
                    {
                        log.WriteErrorLog(ex.Message, _namespace, ex);
                    }
                }
                log.AppendLogs(outLog);
            }
            if (log.HasErrorsOrWarnings())
            {
                Helper.ShowMessageBox(MessageBoxStrings.PackageManagement.INIT_ERROR_WARNS_FOUND, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                Logger.WriteInformationLog(LoggerMessages.PackageManagement.INIT_GLOBAL_DIR + PMFileSystem.PackMan_ManDir + ".", _namespace);
            }
        }
コード例 #10
0
            public static void ReinstallLocalPackage(string UID, string projectPath, string _namespace, out LogDataList log)
            {
                if (File.Exists(projectPath))
                {
                    projectPath = Path.GetDirectoryName(projectPath);
                }

                if (!Directory.Exists(projectPath))
                {
                    try
                    {
                        throw new DirectoryNotFoundException(projectPath + ExceptionMessages.General.COULD_NOT_BE_FOUND);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.OpenProjNullOrMiss(projectPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                log = new LogDataList();

                ProjectPackMan openedProject = null;

                LogDataList outLog = null;

                try
                {
                    openedProject = new ProjectPackMan(projectPath, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.LOAD_FAILED_PROJ + projectPath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                ReinstallLocalPackage(UID, openedProject, _namespace, out outLog);
                log.AppendLogs(outLog);
            }
コード例 #11
0
            public static void UninstallLocalPackage(string projectPath, string arg, string _namespace, out LogDataList log, UninstallArgType argType = UninstallArgType.UID, bool deleteInstallFiles = true, bool procEvents = true)
            {
                if (string.IsNullOrWhiteSpace(projectPath))
                {
                    try
                    {
                        throw new ArgumentNullException(ExceptionMessages.General.PROJ_PATH_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.UNABLE_OPEN_LOCAL_PACKAGE_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                log = new LogDataList();
                LogDataList    outLog        = null;
                ProjectPackMan openedProject = null;

                try
                {
                    openedProject = new ProjectPackMan(projectPath, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(UninstallerMessages.Error.UNABLE_OPEN_LOCAL_PACKAGE + projectPath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                try
                {
                    UninstallLocalPackage(openedProject, arg, _namespace, out outLog, argType, deleteInstallFiles, procEvents);
                }
                catch
                {
                    throw;
                }
                log.AppendLogs(outLog);
            }
コード例 #12
0
            static InstalledPackage CreateGlobalInstalledFile(RMPackage package, string sourceFolder, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                string newInstalledDir = PMFileSystem.PackMan_ManDir + "\\" + package.UniqueIDInMD5;

                LogDataList outLog = null;

                try
                {
                    CreateInstalledFile(package, sourceFolder, newInstalledDir, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.UNABLE_CREATE_INSTALLED_FILES, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage retVal = null;

                try
                {
                    retVal = new InstalledPackage(newInstalledDir, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.UNABLE_LOAD_PACK, _namespace, ex);
                }
                if (outLog != null)
                {
                    log.Logs.AddRange(outLog.Logs);
                }

                try
                {
                    NewProject.CopyPackageInstallInfo(sourceFolder, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.WriteWarningLog(InstallerMessages.Warning.UNABLE_COPY_NEWDATA_DIR, _namespace, ex);
                }
                if (outLog != null)
                {
                    log.Logs.AddRange(outLog.Logs);
                }
                return(retVal);
            }
コード例 #13
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);
        }
コード例 #14
0
            public static InstalledPackage UpdateLocalPackage(string pathToInstaller, ProjectPackMan openProject, bool packageAlreadyCopiedToTemp, string _namespace, out LogDataList log, bool skipInstallFileExistenceCheck = false)
            {
                log = new LogDataList();
                if (openProject == null)
                {
                    try
                    {
                        throw new NullProjectException(ExceptionMessages.General.OPEN_PROJ_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.NO_OPEN_PROJ, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                if (string.IsNullOrWhiteSpace(openProject.DirectoryPath))
                {
                    try
                    {
                        throw new InvalidPathException(ExceptionMessages.General.OPEN_PROJ_DIR_PATH_ARG_NULL, openProject.DirectoryPath);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.INVALID_OPEN_PROJ_DIR, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                string origPath = pathToInstaller;

                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Updater.Information.UpdatePackageStart(openProject.DirectoryPath, pathToInstaller), _namespace);
                LogDataList outLog = null;

                try
                {
                    if (!packageAlreadyCopiedToTemp)
                    {
                        pathToInstaller = Installer.InitPackageInstaller(pathToInstaller, false, _namespace, out outLog);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.UNABLE_EXTRACT_LOCAL + pathToInstaller + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);


                RMPackage package = null;

                try
                {
                    package = new RMPackage(pathToInstaller, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.AppendLogs(outLog);
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.UNABLE_PARSE_XML_LOCAL + pathToInstaller + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                if (openProject.InstalledPackages == null)
                {
                    try
                    {
                        throw new PackageNotFoundException(false, ExceptionMessages.General.PROJ_NO_PACKAGES);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.OPEN_PROJ_NOT_ABLE_FIND_PACK, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                InstalledPackage packageInstalled = openProject.InstalledPackages.FindByUID(package.UniqueID);

                if (packageInstalled == null)
                {
                    try
                    {
                        throw new PackageNotFoundException(false, ExceptionMessages.General.PackWIDNotFound(package.UniqueID));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.OPEN_PROJ_NOT_ABLE_FIND_PACK, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (OnPackageUpdateBegin != null)
                {
                    OnPackageUpdateBegin.Invoke(packageInstalled, package, false, origPath, openProject);
                }


                try
                {
                    Uninstaller.UninstallLocalPackage(openProject, package.UniqueID, _namespace, out outLog, procEvents: false);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.FAILED_UNINSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                    throw;
                }
                log.AppendLogs(outLog);


                InstalledPackage newlyInstalledPackage = null;

                try
                {
                    newlyInstalledPackage = Installer.InstallLocalPackage(pathToInstaller, openProject, _namespace, out outLog, true, true, false, skipInstallFileExistenceCheck);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.FAILED_INSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                    throw;
                }
                log.AppendLogs(outLog);

                if (OnPackageUpdateDone != null)
                {
                    OnPackageUpdateDone.Invoke(newlyInstalledPackage, newlyInstalledPackage.Package, false, origPath, openProject);
                }

                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Updater.Information.UpdatePackageDone(origPath), _namespace);
                return(newlyInstalledPackage);
            }
コード例 #15
0
            // -------- Global Packages -------- //
            public static InstalledPackage InstallGlobalPackage(string packagePath, string _namespace, out LogDataList log, bool ignoreClash = false, bool alreadyCopiedToTemp = false, bool procEvents = true, bool skipFileExistenceCheck = false)
            {
                Logger.WriteInformationLog(InstallerMessages.Information.PACKAGE_INSTALL_START_G + packagePath + ".", _namespace);
                log = new LogDataList();
                string      oldPackagePath = packagePath;
                LogDataList outLog         = null;

                try
                {
                    if (!alreadyCopiedToTemp)
                    {
                        packagePath = packagePath = InitPackageInstaller(packagePath, true, _namespace, out outLog);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.INIT_ERROR + packagePath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                log.AppendLogs(outLog);

                RMPackage package = null;

                try
                {
                    package = new RMPackage(packagePath, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.AppendLogs(outLog);
                    Logger.WriteErrorLog(InstallerMessages.Error.XML_READ_ERROR + packagePath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                log.AppendLogs(outLog);

                if (!skipFileExistenceCheck)
                {
                    PerformPackageFilesExistenceCheck(package, _namespace, out outLog);
                    log.AppendLogs(outLog);
                }

                if (!ignoreClash && GlobalPackages.FindByUID(package.UniqueID) != null)
                {
                    try
                    {
                        throw new PackageAlreadyExistsException(ExceptionMessages.General.PackWIDExists(package.UniqueID));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.PACKAGE_ALREADY_EXISTS, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        if (procEvents)
                        {
                            CleanupTempInstallDir(_namespace, false);
                        }
                        throw;
                    }
                }

                if (procEvents && OnPackageInstallBegin != null)
                {
                    OnPackageInstallBegin.Invoke(package, true, oldPackagePath, null);
                }

                try
                {
                    PerformInstallGlobal(package, _namespace);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.INSTALL_PACK_FAILED, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }

                InstalledPackage newInstall = null;

                try
                {
                    newInstall = CreateGlobalInstalledFile(package, Path.GetDirectoryName(packagePath), _namespace, out outLog);
                    GlobalPackages.AddSafely(newInstall);
                }
                catch
                {
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                log.AppendLogs(outLog);

                if (!alreadyCopiedToTemp)
                {
                    CleanupTempInstallDir(_namespace, false);
                }

                if (OnPackageInstalled != null)
                {
                    OnPackageInstalled.Invoke(package, true, oldPackagePath, null);
                }
                Logger.WriteInformationLog(InstallerMessages.Information.PACKAGE_INSTALL_DONE_G, _namespace);
                return(newInstall);
            }
コード例 #16
0
            public static InstalledPackage InstallLocalPackage(string packagePath, ProjectPackMan openProject, string _namespace, out LogDataList log, bool ignoreClash = false, bool alreadyCopiedToTemp = false, bool procEvents = true, bool skipFileExistenceCheck = false)
            {
                log = new LogDataList();

                if (string.IsNullOrWhiteSpace(packagePath))
                {
                    try
                    {
                        throw new ArgumentNullException(ExceptionMessages.General.PACK_PATH_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.PACKAGE_PATH_NULL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (openProject == null || string.IsNullOrWhiteSpace(openProject.DirectoryPath))
                {
                    try
                    {
                        throw new ArgumentException(ExceptionMessages.General.OPEN_PROJ_ARG_OR_DIRPATH_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.NO_OPEN_PROJECT, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                Logger.WriteInformationLog(InstallerMessages.Information.PACKAGE_INSTALL_START_L + packagePath + ".", _namespace);
                Exception   outEx;
                LogDataList outLog         = null;
                string      oldPackagePath = packagePath;

                try
                {
                    if (!alreadyCopiedToTemp)
                    {
                        packagePath = InitPackageInstaller(packagePath, false, _namespace, out outLog);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.INIT_ERROR + packagePath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                log.AppendLogs(outLog);

                RMPackage package = null;

                try
                {
                    package = new RMPackage(packagePath, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.AppendLogs(outLog);
                    Logger.WriteErrorLog(InstallerMessages.Error.XML_READ_ERROR + packagePath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                log.AppendLogs(outLog);

                if (!skipFileExistenceCheck)
                {
                    PerformPackageFilesExistenceCheck(package, _namespace, out outLog);
                    if (outLog != null)
                    {
                        log.Logs.AddRange(outLog.Logs);
                    }
                }

                if (!ignoreClash && openProject.InstalledPackages.FindByUID(package.UniqueID) != null)
                {
                    try
                    {
                        throw new PackageAlreadyExistsException(ExceptionMessages.General.PackWIDExists(package.UniqueID));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.PACKAGE_ALREADY_EXISTS, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        if (procEvents)
                        {
                            CleanupTempInstallDir(_namespace, false);
                        }
                        throw;
                    }
                }

                if (procEvents && OnPackageInstallBegin != null)
                {
                    OnPackageInstallBegin.Invoke(package, false, oldPackagePath, openProject);
                }

                try
                {
                    PerformInstallLocal(package, openProject.DirectoryPath, _namespace);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(InstallerMessages.Error.INSTALL_PACK_FAILED, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }

                string packManStorePath = openProject.DirectoryPath + "\\" + Vars.PACKAGE_MANAGER_DIRECTORY;

                if (!Directory.Exists(packManStorePath) && Helper.CreateFolderSafely(packManStorePath, _namespace, out outEx, LoggerMessages.GeneralError.CREATE_REQUIRED_DIR_FAILED_ARG) == CreateFolderResult.UserCancelled)
                {
                    throw outEx;
                }
                InstalledPackage newInstall = null;

                try
                {
                    newInstall = CreateLocalInstalledFile(package, Path.GetDirectoryName(packagePath), packManStorePath, _namespace, out outLog);
                    openProject.InstalledPackages.AddSafely(newInstall);
                }
                catch
                {
                    if (procEvents)
                    {
                        CleanupTempInstallDir(_namespace, false);
                    }
                    throw;
                }
                if (outLog != null)
                {
                    log.Logs.AddRange(outLog.Logs);
                }

                if (!alreadyCopiedToTemp)
                {
                    CleanupTempInstallDir(_namespace, false);
                }

                if (procEvents && OnPackageInstalled != null)
                {
                    OnPackageInstalled.Invoke(package, false, oldPackagePath, openProject);
                }

                Logger.WriteInformationLog(InstallerMessages.Information.PACKAGE_INSTALL_DONE_L, _namespace);
                return(newInstall);
            }
コード例 #17
0
            public static void ReinstallLocalPackage(InstalledPackage installedPackage, ProjectPackMan openProject, string _namespace, out LogDataList log)
            {
                log = new LogDataList();
                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Reinstaller.Information.REINSTALL_PACKAGE_START_L, _namespace);
                Exception outEx;

                if (openProject == null || !Directory.Exists(openProject.DirectoryPath))
                {
                    try
                    {
                        throw new DirectoryNotFoundException(ExceptionMessages.General.OPEN_PROJ_ARG_OR_DIRPATH_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.OpenProjNullOrMiss(openProject.DirectoryPath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (installedPackage == null || string.IsNullOrWhiteSpace(installedPackage.ArchivePath) || !File.Exists(installedPackage.ArchivePath))
                {
                    try
                    {
                        throw new FileNotFoundException(ExceptionMessages.PackageManagement.Reinstaller.ARCH_INSTALL_FILE_NOT_FOUND);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.ARCH_NOT_FOUND, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempInstall, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG) == DeleteFolderResult.UserCancelled)
                {
                    throw outEx;
                }

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

                if (OnReinstallBegin != null)
                {
                    OnReinstallBegin.Invoke(installedPackage, false, openProject);
                }


                try
                {
                    ArchiveManagement.ExtractZip(installedPackage.ArchivePath, PMFileSystem.PackMan_TempInstall, _namespace);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.UNABLE_EXTRACT_ARCH + PMFileSystem.PackMan_TempInstall + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                LogDataList outLog = null;

                try
                {
                    Uninstaller.UninstallLocalPackage(openProject, installedPackage.Namespace, _namespace, out outLog, procEvents: false);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.UNABLE_UNINSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage retVal = null;

                try
                {
                    retVal = Installer.InstallLocalPackage(PMFileSystem.PackMan_TempInstall + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME, openProject, _namespace, out outLog, true, true);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.UNABLE_INSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                if (OnReinstallDone != null)
                {
                    OnReinstallDone.Invoke(retVal, false, openProject);
                }

                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Reinstaller.Information.REINSTALL_PACKAGE_DONE_L, _namespace);
            }
コード例 #18
0
        public static void RenumberParts(string parentFolderPath, string _namespace, out LogDataList log, bool relinkGlobalPackages = false)
        {
            log = new LogDataList();
            log.WriteInformationLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Info.RENUMBER_START + parentFolderPath + ".", _namespace);
            Exception outEx;

            if (!Directory.Exists(parentFolderPath))
            {
                return;
            }


            if (Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempRenumberDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG) == DeleteFolderResult.UserCancelled)
            {
                throw outEx;
            }

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

            RMPackage tempGenPack = new RMPackage();

            tempGenPack.Name = "Generator Parts Renumber Class";
            LogDataList outLog;

            RMImplicit.RetrievePackFromDir(parentFolderPath, _namespace, true, out outLog, ref tempGenPack);
            log.AppendLogs(outLog);

            if (tempGenPack.Collections == null || tempGenPack.Collections.Count == 0)
            {
                return;
            }

            List <ComparedPath> comparedPaths = null;

            foreach (RMCollection collection in tempGenPack.Collections)
            {
                if (collection is RMGeneratorCollection)
                {
                    RMGeneratorCollection genCollection = collection as RMGeneratorCollection;
                    try
                    {
                        if (genCollection.Parts != null)
                        {
                            comparedPaths = PerformRenumber(genCollection, parentFolderPath, _namespace);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Error.RENUMBER_ABORT_GENERAL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                        throw;
                    }
                }
            }



            if (comparedPaths != null && comparedPaths.Count > 0)
            {
                foreach (ComparedPath comparedPath in comparedPaths)
                {
                    string completeTempPath  = PMFileSystem.PackMan_TempRenumberDir + "\\" + comparedPath.New;
                    string completeFinalPath = parentFolderPath + "\\" + comparedPath.New;

                    MoveFileResult moveResult = Helper.MoveFileSafely(completeTempPath, completeFinalPath, true, _namespace, out outEx,
                                                                      new MoveFileLogMessages(sourceFileNotFound: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveFinalSrcNotFound
                                                                                              , moveFileFailed: LoggerMessages.GeneratorPartsManager.RenumberParts.Error.UnableMoveFinal));
                    if (moveResult == MoveFileResult.UserCancelled || moveResult == MoveFileResult.SourceFileNotFound)
                    {
                        throw outEx;
                    }

                    if (relinkGlobalPackages && PackageManagement.GlobalPackages != null)
                    {
                        foreach (InstalledPackage package in PackageManagement.GlobalPackages)
                        {
                            if (package.Package != null)
                            {
                                RMGenFile foundFile = package.Package.FindGenFileWithPath(comparedPath.Old);
                                if (foundFile != null)
                                {
                                    foundFile.Path      = comparedPath.New;
                                    package.ChangesMade = true;
                                    goto continuehere;
                                }
                            }
                        }
                    }
                    continuehere :;
                }
                if (relinkGlobalPackages && PackageManagement.GlobalPackages != null)
                {
                    foreach (InstalledPackage package in PackageManagement.GlobalPackages)
                    {
                        if (package.ChangesMade && package.Package != null)
                        {
                            package.Package.SaveToFile(package.XMLPath, _namespace, logMessage : new WriteAllTextLogMessages(writeFailed : LoggerMessages.GeneratorPartsManager.RenumberParts.Error.FailedSaveXML));
                            package.ChangesMade = false;
                        }
                    }
                }
            }

            Helper.DeleteFolderSafely(PMFileSystem.PackMan_TempRenumberDir, _namespace, out outEx, LoggerMessages.GeneralError.UNABLE_DELETE_TEMP_DIR_ARG);
            log.WriteInformationLog(LoggerMessages.GeneratorPartsManager.RenumberParts.Info.RENUMBER_END + parentFolderPath + ".", _namespace);
        }
コード例 #19
0
        public static void RetrievePackFromDir(string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref RMPackage package, bool skipGenParts = false)
        {
            log      = new LogDataList();
            rootPath = rootPath.ToLower();

            string appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.GENERATOR;



            LogDataList outLog = null;

            if (!skipGenParts && Directory.Exists(appendedPath))
            {
                RMCollection collectionToAdd = GeneratorProbe.RetrieveGeneratorCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, package);
                if (collectionToAdd != null)
                {
                    package.Collections.Add(collectionToAdd);
                }
                log.AppendLogs(outLog);
            }


            appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.AUDIO;
            if (Directory.Exists(appendedPath))
            {
                string newRootPath = appendedPath;
                appendedPath += "\\" + RMPConstants.LowCaseDirectoryNames.AUDIO_BGM;
                if (Directory.Exists(appendedPath))
                {
                    RMCollection collectionToAdd = AudioProbe.RetrieveAudioCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMAudioCollection.AudioType.BGM, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.AUDIO_BGS;
                if (Directory.Exists(appendedPath))
                {
                    RMCollection collectionToAdd = AudioProbe.RetrieveAudioCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMAudioCollection.AudioType.BGS, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.AUDIO_ME;
                if (Directory.Exists(appendedPath))
                {
                    RMCollection collectionToAdd = AudioProbe.RetrieveAudioCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMAudioCollection.AudioType.ME, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.AUDIO_SE;
                if (Directory.Exists(appendedPath))
                {
                    RMCollection collectionToAdd = AudioProbe.RetrieveAudioCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMAudioCollection.AudioType.SE, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }
            }
            appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.DATA;
            if (Directory.Exists(appendedPath))
            {
                RMCollection collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Data, package);
                if (collectionToAdd != null)
                {
                    package.Collections.Add(collectionToAdd);
                }
                log.AppendLogs(outLog);
            }
            appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG;
            if (Directory.Exists(appendedPath))
            {
                RMCollection collectionToAdd = CharacterProbe.RetrieveCharacterImages(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, package);
                if (collectionToAdd != null)
                {
                    package.Collections.Add(collectionToAdd);
                }
                log.AppendLogs(outLog);

                string newRootPath = appendedPath;
                appendedPath += "\\" + RMPConstants.LowCaseDirectoryNames.IMG_ANIM;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Animation, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_BATTLEBACKS_1;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.BattleBacks_1, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_BATTLEBACKS_2;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.BattleBacks_2, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_PARALLAXES;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Parallax, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_PICTURES;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Pictures, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_SYSTEM;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.System, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_TITLES_1;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Titles_1, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_TITLES_2;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Titles_2, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }

                appendedPath = newRootPath + "\\" + RMPConstants.LowCaseDirectoryNames.IMG_TILESETS;
                if (Directory.Exists(appendedPath))
                {
                    collectionToAdd = TilesetProbe.RetrieveTilesetCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, package);
                    if (collectionToAdd != null)
                    {
                        package.Collections.Add(collectionToAdd);
                    }
                    log.AppendLogs(outLog);
                }
            }

            appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.PLUGINS;
            if (Directory.Exists(appendedPath))
            {
                RMCollection collectionToAdd = SingleFileCollectionProbe.RetrieveSingleFileCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, RMSingleFileCollection.CollectionType.Plugins, package);
                if (collectionToAdd != null)
                {
                    package.Collections.Add(collectionToAdd);
                }
                log.AppendLogs(outLog);
            }

            appendedPath = rootPath + "\\" + RMPConstants.LowCaseDirectoryNames.MOVIES;
            if (Directory.Exists(appendedPath))
            {
                RMCollection collectionToAdd = MovieProbe.RetrieveMovieCollection(appendedPath.ToLower(), rootPath, _namespace, trimRootPath, out outLog, package);
                if (collectionToAdd != null)
                {
                    package.Collections.Add(collectionToAdd);
                }
                log.AppendLogs(outLog);
            }
        }
コード例 #20
0
            public static void UninstallGlobalPackage(string arg, string _namespace, out LogDataList log, UninstallArgType argType = UninstallArgType.UID, bool renumberParts = true, bool deleteInstallFiles = true, bool procEvents = true)
            {
                log = new LogDataList();
                Logger.WriteInformationLog(UninstallerMessages.Information.UNINSTALL_PACKAGE_START_G, _namespace);


                if (string.IsNullOrWhiteSpace(arg))
                {
                    try
                    {
                        throw new ArgumentNullException(ExceptionMessages.General.ARG_ARG_NULL);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.ARG_INVALID, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (argType == UninstallArgType.DirectoryPath)
                {
                    arg += "\\" + Vars.INSTALLED_XML_FILENAME;
                }

                if ((argType == UninstallArgType.XMLPath || argType == UninstallArgType.DirectoryPath) && !File.Exists(arg))
                {
                    try
                    {
                        throw new FileNotFoundExceptionWPath(arg);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.XML_FILE_NOT_FOUND, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                Exception       outEx;
                LogDataList     outLog = null;
                UninstallResult result = UninstallResult.normal;

                if (GlobalPackages != null)
                {
                    InstalledPackage installedPackage;
                    if (argType == UninstallArgType.XMLPath || argType == UninstallArgType.DirectoryPath)
                    {
                        installedPackage = GlobalPackages.FindByPath(arg);
                    }
                    else
                    {
                        installedPackage = GlobalPackages.FindByUID(arg);
                    }

                    if (installedPackage != null)
                    {
                        if (installedPackage.Package != null)
                        {
                            if (procEvents && OnPackageUninstallBegin != null)
                            {
                                OnPackageUninstallBegin.Invoke(installedPackage.Package, true, installedPackage.Directory, installedPackage, null);
                            }

                            result = UninstallPackage(installedPackage.Package, _namespace, out outLog);
                            log.AppendLogs(outLog);

                            if (procEvents && OnPackageUninstalled != null)
                            {
                                OnPackageUninstalled.Invoke(installedPackage.Package, true, installedPackage, null);
                            }
                        }
                        else
                        {
                            result = ProcDelNonReadXMLPackage(arg, installedPackage.Directory, installedPackage, null, _namespace, out outLog, procEvents, argType);
                            log.AppendLogs(outLog);
                        }
                        if (deleteInstallFiles)
                        {
                            if (Directory.Exists(installedPackage.Directory))
                            {
                                string MD5INUID = new DirectoryInfo(installedPackage.Directory).Name;
                                Helper.DeleteFolderSafely(installedPackage.Directory, _namespace, out outEx, new DeleteFolderLogMessages(deleteFailed: UninstallerMessages.Warning.DirectoryUnableDelete, logGroup: log));
                                NewProject.DeletePackageInstallInfo(MD5INUID, _namespace);
                            }

                            GlobalPackages.Remove(installedPackage);
                        }
                        //else
                        //{
                        //    if (installedPackage.Package != null)
                        //    {
                        //        installedPackage.Installed = false;
                        //        bool successfulCopy = true;
                        //        try
                        //        {
                        //            installedPackage.Package.SaveToFile(installedPackage.XMLPath, _namespace, RMPackage.SaveToFileMode.ExplicitAssetInfo);

                        //        }
                        //        catch (Exception ex)
                        //        {
                        //            log.DataList.Add(new RMLogDataWarning(UninstallerMessages.Warning.InstalledXMLUpdateFailedInsStatus(installedPackage.XMLPath), _namespace, ex));
                        //            successfulCopy = false;
                        //        }
                        //        if (successfulCopy)
                        //            NewProject.CopyPackageInstallXML(installedPackage.XMLPath, _namespace, installedPackage.Package);
                        //    }
                        //}
                    }
                    else
                    {
                        if (argType == UninstallArgType.UID)
                        {
                            try
                            {
                                throw new PackageNotFoundException(true, ExceptionMessages.General.PackWIDNotFound(arg));
                            }
                            catch (Exception ex)
                            {
                                Logger.WriteErrorLog(UninstallerMessages.Error.PACKAGE_UID_NOT_FOUND + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                throw;
                            }
                        }
                        string installedDir = null;
                        try
                        {
                            installedDir = Path.GetDirectoryName(arg);
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteErrorLog(UninstallerMessages.Error.INVALID_XML_PATH + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                            throw;
                        }
                        result = ProcDelNonReadXMLPackage(arg, installedDir, null, null, _namespace, out outLog, procEvents, argType);
                    }
                }
                else
                {
                    if (argType == UninstallArgType.UID)
                    {
                        try
                        {
                            throw new PackageNotFoundException(true, ExceptionMessages.General.PackWIDNotFound(arg));
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteErrorLog(UninstallerMessages.Error.PACKAGE_UID_NOT_FOUND + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                            throw;
                        }
                    }
                    string installedDir = null;
                    try
                    {
                        installedDir = Path.GetDirectoryName(arg);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.INVALID_XML_PATH + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                    result = ProcDelNonReadXMLPackage(arg, installedDir, null, null, _namespace, out outLog, procEvents, argType);
                }
                outLog = null;

                try
                {
                    if (renumberParts && result == UninstallResult.genPartsRemoved)
                    {
                        GeneratorPartsManager.RenumberParts(_namespace, out outLog, true);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(UninstallerMessages.Error.GEN_PART_RENUMBER_FAILED, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                    throw;
                }
                log.AppendLogs(outLog);
                Logger.WriteInformationLog(UninstallerMessages.Information.UNINSTALL_PACKAGE_DONE_G, _namespace);
            }
コード例 #21
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);
            }
コード例 #22
0
            public static InstalledPackage UpdateGlobalPackage(string pathToInstaller, string _namespace, out LogDataList log, bool alreadyCopiedToTemp = false, bool skipInstallFileExistenceCheck = false)
            {
                log = new LogDataList();
                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Updater.Information.UPDATE_PACKAGE_START_G + pathToInstaller + ".", _namespace);
                string      origPath = pathToInstaller;
                LogDataList outLog   = null;

                try
                {
                    if (!alreadyCopiedToTemp)
                    {
                        pathToInstaller = Installer.InitPackageInstaller(pathToInstaller, true, _namespace, out outLog);
                    }
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.UNABLE_EXTRACT_GLOBAL + pathToInstaller + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                RMPackage package = null;

                try
                {
                    package = new RMPackage(pathToInstaller, _namespace, out outLog);
                }
                catch (Exception ex)
                {
                    log.AppendLogs(outLog);
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.XML_INVALID + pathToInstaller + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
                log.AppendLogs(outLog);

                if (GlobalPackages == null)
                {
                    try
                    {
                        throw new NullGlobalPackagesException();
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.NO_GLOBAL_PACKAGES, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                InstalledPackage packageInstalled = GlobalPackages.FindByUID(package.UniqueID);

                if (packageInstalled == null)
                {
                    try
                    {
                        throw new PackageNotFoundException(true);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteWarningLog(LoggerMessages.PackageManagement.Updater.Warning.PACKAGE_TO_BE_UPDATED_NOT_FOUND, _namespace, ex);
                        throw;
                    }
                }



                if (OnPackageUpdateBegin != null)
                {
                    OnPackageUpdateBegin.Invoke(packageInstalled, package, true, origPath, null);
                }


                try
                {
                    Uninstaller.UninstallGlobalPackage(package.UniqueID, _namespace, out outLog, renumberParts: false, procEvents: false);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.FAILED_UNINSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                    throw;
                }
                log.AppendLogs(outLog);

                InstalledPackage newlyInstalledPackage = null;

                try
                {
                    newlyInstalledPackage = Installer.InstallGlobalPackage(pathToInstaller, _namespace, out outLog, true, true, false, skipInstallFileExistenceCheck);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageManagement.Updater.Error.FAILED_INSTALL, _namespace, ex, BasicDebugLogger.DebugErrorType.CriticalError);
                    throw;
                }
                log.AppendLogs(outLog);


                if (OnPackageUpdateDone != null)
                {
                    OnPackageUpdateDone.Invoke(newlyInstalledPackage, newlyInstalledPackage.Package, true, origPath, null);
                }

                Logger.WriteInformationLog(LoggerMessages.PackageManagement.Updater.Information.UPDATE_PACKAGE_DONE_G, _namespace);
                return(newlyInstalledPackage);
            }