예제 #1
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);
            }
예제 #2
0
        public static LogDataList MakeLogSet(this IEnumerable <BoolAndRMFile> listOfBoolAndRM, string prefixStr, string _namespace, string rootDir = null)
        {
            if (listOfBoolAndRM == null || listOfBoolAndRM.Count() == 0)
            {
                return(null);
            }
            LogDataList log           = new LogDataList();
            string      resultingText = (string.IsNullOrWhiteSpace(prefixStr)) ? "" : prefixStr;

            resultingText += LoggerMessages.Extension.MISS_FILE;
            if (!string.IsNullOrWhiteSpace(rootDir))
            {
                resultingText += rootDir + "\\";
            }
            foreach (BoolAndRMFile boolAndRMFile in listOfBoolAndRM)
            {
                if (!boolAndRMFile.Boolean)
                {
                    log.WriteErrorLog(resultingText + boolAndRMFile.PackFile.Path + LoggerMessages.Extension.MISS_FILE_1, _namespace, null);
                }
            }
            return(log);
        }
예제 #3
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);
            }
            // -------- 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);
            }
예제 #5
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);
            }
            internal static RMSingleFileCollection RetrieveSingleFileCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMSingleFileCollection.CollectionType typeOfCollection, RMPackage package)
            {
                log = new LogDataList();
                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(package.Name, path, typeOfCollection.ToRMCollectionType()), _namespace);
                RMSingleFileCollection newCollection = typeOfCollection.ToNewClassInstance(package);
                string fileExtension = typeOfCollection.ToFileExtension();

                if (newCollection == null)
                {
                    return(null);
                }
                string[] files = null;
                try
                {
                    files = Directory.GetFiles(path, "*." + fileExtension);
                }
                catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, package.Name, typeOfCollection.ToRMCollectionType()), _namespace, ex);
                    return(null);
                }
                if (files == null || files.Length == 0)
                {
                    return(null);
                }

                for (int i = 0; i < files.Length; i++)
                {
                    string originalFileName = Path.GetFileNameWithoutExtension(files[i]);
                    if (string.IsNullOrWhiteSpace(originalFileName))
                    {
                        continue;
                    }
                    RMSingleFile newDataFile = new RMSingleFile(newCollection);
                    if (trimRootPath)
                    {
                        newDataFile.Path = Helper.GetRelativePath(files[i], rootPath);
                    }
                    else
                    {
                        newDataFile.Path = files[i];
                    }
                    newDataFile.FileName = originalFileName;
                    newCollection.Files.Add(newDataFile);
                    log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(package.Name, files[i], typeOfCollection.ToRMCollectionType()), _namespace);
                }
                if (newCollection.Files.Count == 0)
                {
                    return(null);
                }
                return(newCollection);
            }
예제 #7
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);
            }
            // ---- 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);
            }
예제 #9
0
            static void RetrieveGeneratorPartOnGender(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMGenPart> partsCollection, RMGenFile.GenFileType whichFilePart, RMGenPart.eGender whichGender, RMGeneratorCollection parent)
            {
                log = new LogDataList();
                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Parent.Name, path, RMCollectionType.Generator), _namespace);
                string[] listOfFiles = null;
                try
                {
                    listOfFiles = Directory.GetFiles(path, "*" + RMPConstants.GenFileNamePrefixANDSuffix.PNG);
                }
                catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Parent.Name, RMCollectionType.Generator), _namespace, ex);
                    return;
                }
                if (listOfFiles == null || listOfFiles.Length == 0)
                {
                    return;
                }
                string prefix;

                switch (whichFilePart)
                {
                case RMGenFile.GenFileType.Face:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.FACE_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.SV:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.SV_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.TV:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.TV_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.TVD:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.TVD_LOWER + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                case RMGenFile.GenFileType.Var:
                    prefix = RMPConstants.GenFileNamePrefixANDSuffix.VARIATION + RMPConstants.GenFileNamePrefixANDSuffix.SEPARATOR;
                    break;

                default:
                    return;
                }
                for (int i = 0; i < listOfFiles.Length; ++i)
                {
                    string nonLoweredPath = listOfFiles[i];
                    listOfFiles[i] = listOfFiles[i].ToLower();
                    string fileName = Path.GetFileName(listOfFiles[i]);


                    if (fileName.Length > prefix.Length && fileName.StartsWith(prefix))
                    {
                        TempGenFileNameParsed tgfnm = null;
                        try
                        {
                            tgfnm = new TempGenFileNameParsed(fileName, prefix.Length);
                            VerifyFile(tgfnm, listOfFiles[i]);
                        }
                        catch (Exception ex)
                        {
                            log.WriteErrorLog(LoggerMessages.RMPackage.Error.InvalidGenFile(nonLoweredPath), _namespace, ex);
                            continue;
                        }
                        RMGenPart tempPart = partsCollection.GetPartByInternalPosition(tgfnm.Part, whichGender, tgfnm.Position);

                        RMGenFile newGenFile;

                        string pathToSave = (trimRootPath) ? Helper.GetRelativePath(nonLoweredPath, rootPath) : nonLoweredPath;

                        newGenFile = CreateGenFileFromTempGenFileName(tgfnm, GetProperFileType(tgfnm, whichFilePart), pathToSave);
                        if (tempPart == null)
                        {
                            tempPart = CreateNewPart(tgfnm, whichGender, parent, (partsCollection.CountPartOfType(tgfnm.Part, whichGender) + 1));
                            partsCollection.Add(tempPart);
                        }

                        newGenFile.Parent = tempPart;
                        tempPart.Files.Add(newGenFile);
                        log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Parent.Name, nonLoweredPath, RMCollectionType.Generator), _namespace);
                    }
                }
            }
예제 #10
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);
            }
        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);
        }
 public static void RenumberParts(string _namespace, out LogDataList log, bool relinkGlobalPackages = false)
 {
     RenumberParts(PMFileSystem.MV_Installation_Directory, _namespace, out log, relinkGlobalPackages);
 }
        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);
        }
            public static string InitPackageInstaller(string packagePath, bool globalPackageInstall, string _namespace, out LogDataList log, bool performChecksumMatching = false)
            {
                log = null;
                Logger.WriteInformationLog(LoggerMessages.PackageManagement.InitPackageInstaller.Info.INIT_START, _namespace);
                Exception outEx;

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

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

                string origPackPath = packagePath;

                if (!File.Exists(packagePath))
                {
                    try
                    {
                        throw new InstallFileNotFoundException(ExceptionMessages.PackageManagement.Installer.INSTALLER_FILE_NOT_FOUND + packagePath + ".", packagePath);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.InitPackageInstaller.Error.MissInstallFile(packagePath), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                if (Path.GetExtension(packagePath).ToLower() == "." + RMPConstants.MiscFileExtensions.ZIP)
                {
                    try
                    {
                        ArchiveManagement.ExtractZip(packagePath, PMFileSystem.PackMan_TempInstall, _namespace, performChecksumMatching);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.InitPackageInstaller.Error.ExtractZipFailed(packagePath, PMFileSystem.PackMan_TempInstall), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                    packagePath = PMFileSystem.PackMan_TempInstall + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;

                    if (!globalPackageInstall)
                    {
                        RMPackage packageParsed = null;

                        try
                        {
                            packageParsed = new RMPackage(packagePath, _namespace, out log);
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteErrorLog(InstallerMessages.Error.FAIL_PACKAGE_PARSE + origPackPath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                            throw;
                        }

                        if (packageParsed.Collections == null || packageParsed.Collections.Count == 0 || packageParsed.ContentsSummary == RMCollectionType.Generator)
                        {
                            try
                            {
                                throw new EmptyPackageException();
                            }
                            catch (Exception ex)
                            {
                                Logger.WriteErrorLog(InstallerMessages.Error.EMPTY_PACKAGE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                                throw;
                            }
                        }

                        if (packageParsed.ContentsSummary.HasFlag(RMCollectionType.Generator))
                        {
                            PackageUtil.RemoveGeneratorFilesAndCollection(packageParsed, PMFileSystem.PackMan_TempInstall, _namespace);
                            packageParsed.SaveToFile(packagePath, _namespace, logMessage: new WriteAllTextLogMessages(writeFailed: InstallerMessages.Error.SaveCopyXMLFailed));
                        }
                    }
                }
                else
                {
                    string packageDir = Path.GetDirectoryName(packagePath);

                    RMPackage packageParsed = null;

                    try
                    {
                        packageParsed = new RMPackage(packagePath, _namespace, out log, null, false, !globalPackageInstall);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(InstallerMessages.Error.FAIL_PACKAGE_PARSE + origPackPath + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }


                    try
                    {
                        PackageUtil.ExplicitCopyAssetsAndLicFileTo(packageParsed, packageDir, PMFileSystem.PackMan_TempInstall, _namespace);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.InitPackageInstaller.Error.CopyPackageFilesFailed(packageDir, PMFileSystem.PackMan_TempInstall), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }

                    if (packageParsed.Collections == null || packageParsed.Collections.Count == 0)
                    {
                        try
                        {
                            throw new EmptyPackageException();
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteErrorLog(InstallerMessages.Error.EMPTY_PACKAGE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                            throw;
                        }
                    }

                    packagePath = PMFileSystem.PackMan_TempInstall + "\\" + Vars.INSTALL_FILE_DEFAULT_FILENAME;
                    packageParsed.SaveToFile(packagePath, _namespace, logMessage: new WriteAllTextLogMessages(writeFailed: InstallerMessages.Error.SaveCopyXMLFailed));
                }
                Logger.WriteInformationLog(LoggerMessages.PackageManagement.InitPackageInstaller.Info.INIT_DONE, _namespace);
                return(packagePath);
            }
            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);
            }
 public static void PerformPackageFilesExistenceCheck(RMPackage package, string _namespace, out LogDataList outLog)
 {
     outLog = null;
     if (!package.Implicit)
     {
         List <BoolAndRMFile> fileExistenceCheckRes = package.CheckFileExistences(package.XMLDirectory);
         if (fileExistenceCheckRes.HasNonExistingFile())
         {
             try
             {
                 throw new FileNotFoundException(ExceptionMessages.PackageManagement.Installer.ASSETS_NOT_FOUND);
             }
             catch
             {
                 outLog = fileExistenceCheckRes.MakeLogSet(InstallerMessages.Error.MISS_FILE_PREFIX, _namespace);
                 throw;
             }
         }
     }
 }
예제 #17
0
 public static void RetrieveSubCharacterImages(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, ref List <RMCharImageGroup> collection, RMCharImageFile.ImageTypes imageType, RMCharImageCollection parent)
 {
     log = new LogDataList();
     log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Parent.Name, path, RMCollectionType.Characters), _namespace);
     string[] files = null;
     try
     {
         files = Directory.GetFiles(path, "*" + RMPConstants.GenFileNamePrefixANDSuffix.PNG);
     }
     catch (Exception ex)
     {
         log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Parent.Name, RMCollectionType.Characters), _namespace, ex);
         return;
     }
     if (files == null || files.Length == 0)
     {
         return;
     }
     for (int i = 0; i < files.Length; ++i)
     {
         string realFileName = Path.GetFileNameWithoutExtension(files[i]);
         if (string.IsNullOrWhiteSpace(realFileName))
         {
             continue;
         }
         string nonLoweredPath = files[i];
         files[i] = files[i].ToLower();
         string           fileName = realFileName.ToLower();
         string           rootFileName;
         bool             atlas = IsAnAtlasPartFile(realFileName, out rootFileName);
         RMCharImageGroup parentNode;
         parentNode = collection.FindByInternalName((atlas) ? rootFileName.ToLower() : fileName);
         if (parentNode == null)
         {
             parentNode = new RMCharImageGroup(parent);
             parentNode.internalName = (atlas) ? rootFileName.ToLower() : fileName;
             parentNode.Name         = (atlas) ? rootFileName : realFileName;
             collection.Add(parentNode);
         }
         RMCharImageFile newFile = new RMCharImageFile(parentNode);
         newFile.FileName  = realFileName;
         newFile.ImageType = imageType;
         if (trimRootPath)
         {
             newFile.Path = Helper.GetRelativePath(nonLoweredPath, rootPath);
         }
         else
         {
             newFile.Path = nonLoweredPath;
         }
         parentNode.Files.Add(newFile);
         log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Parent.Name, nonLoweredPath, RMCollectionType.Characters), _namespace);
     }
 }
예제 #18
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);
            }
예제 #19
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;
                    }
                }
            }
            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);
            }
        void ProcessCustomAssetsCommonPath(string _namespace)
        {
            if (CustomAssetPack == null || CustomAssetPack.Collections == null || CustomAssetPack.Collections.Count == 0)
            {
                btnSaveXML.Enabled       = true;
                FormattedCustomAssetPack = null;
                return;
            }

            FormattedCustomAssetPack = (RMPackage)CustomAssetPack.Clone();
            if (License != null)
            {
                FormattedCustomAssetPack.License = License.Clone();
            }
            List <RMPackFile> retrievedFiles = null;
            string            commonPath     = null;

            frmLoading loadingForm = new frmLoading(StringConst.frmLoading.FORMAT_PACK_META);
            Thread     thread      = new Thread(delegate()
            {
                commonPath = FormattedCustomAssetPack.TrimPrefixCommonPathOfFiles(out retrievedFiles, true);
                loadingForm.SafeClose();
            });

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

            if (retrievedFiles == null || retrievedFiles.Count == 0 || ((FormattedCustomAssetPack.License == null || FormattedCustomAssetPack.License.LicenseSource != RMPackLic.Source.File) &&
                                                                        retrievedFiles.Count == 1))
            {
                btnSaveXML.Enabled = true;
                if (retrievedFiles != null && retrievedFiles.Count == 1)
                {
                    CustomAssetsCommonPath = Path.GetDirectoryName(retrievedFiles[0].Path);
                }
                return; // User did not select any assets or has selected 1 asset but the license source is not  a file.
            }



            if (string.IsNullOrWhiteSpace(commonPath))
            {
                Helper.ShowMessageBox(MessageBoxStrings.GUI.frmPropPack.NO_COMMON_PATH, MessageBoxStrings.MESSAGEBOX_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                CustomAssetsCommonPath = null;
                btnSaveXML.Enabled     = false;
                return;
            }

            bool        allPathRelative = true;
            LogDataList warningLog      = new LogDataList();

            if (FormattedCustomAssetPack.License != null && FormattedCustomAssetPack.License.LicenseSource == RMPackLic.Source.File && !FormattedCustomAssetPack.License.NonRootedLicenseFile)
            {
                warningLog.WriteWarningLog(frmPropPackMessagse.Warning.NonCommonPathFile(License.Data, commonPath, true), _namespace);
                allPathRelative = false;
            }

            foreach (RMPackFile file in retrievedFiles)
            {
                if (!file.NonRootedPath)
                {
                    warningLog.WriteWarningLog(frmPropPackMessagse.Warning.NonCommonPathFile(file.Path, commonPath), _namespace);
                    allPathRelative = false;
                }
            }
            CustomAssetsCommonPath = commonPath;
            if (allPathRelative)
            {
                btnSaveXML.Enabled = true;
                return;
            }

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

            btnSaveXML.Enabled = false;
        }
예제 #22
0
            static UninstallResult UninstallPackage(RMPackage package, string _namespace, out LogDataList log, bool globalPackage = true, string whereToRemove = null)
            {
                UninstallResult retVal = UninstallResult.normal;

                log = new LogDataList();
                if (package.Collections != null)
                {
                    foreach (RMCollection collection in package.Collections)
                    {
                        RMGeneratorCollection genCollection = collection as RMGeneratorCollection;
                        if (genCollection != null)
                        {
                            if (globalPackage)
                            {
                                whereToRemove = PMFileSystem.MV_Installation_Directory;
                                retVal        = Generator.UninstallGeneratorParts(whereToRemove, _namespace, genCollection);
                                genCollection = null;
                            }
                            //ignore this collection if not a global package
                        }
                        else
                        {
                            if (globalPackage)
                            {
                                whereToRemove = PMFileSystem.MV_NewData_Dir;
                            }
                            List <RMPackFile> files = collection.RetrieveAllFiles();
                            if (files != null)
                            {
                                foreach (RMPackFile file in files)
                                {
                                    if (string.IsNullOrWhiteSpace(file.Path))
                                    {
                                        continue;
                                    }
                                    string concatPath = whereToRemove + "\\" + file.Path;
                                    if (File.Exists(concatPath))
                                    {
                                        Exception ex = null;
                                        if (Helper.DeleteFileSafely(concatPath, _namespace, out ex, new DeleteFileLogMessages(deleteFailed: UninstallerMessages.Warning.FileDeleteFailed, logGroup: log)) == DeleteFileResult.FileNotFound)
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return(retVal);
            }
예제 #23
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);
                }
            }
예제 #24
0
            public static void UninstallLocalPackage(ProjectPackMan openProject, string arg, string _namespace, out LogDataList log, UninstallArgType argType = UninstallArgType.UID, bool deleteInstallFiles = true, bool procEvents = true)
            {
                log = new LogDataList();
                Logger.WriteInformationLog(UninstallerMessages.Information.UNINSTALL_PACKAGE_START_L, _namespace);
                Exception outEx;

                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 FileNotFoundException(ExceptionMessages.PackageManagement.Uninstaller.INSTALL_SCRIPT_FILE_NOT_FOUND + arg + ".");
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(UninstallerMessages.Error.XML_FILE_NOT_FOUND + arg + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }

                LogDataList outLog;

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

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

                            UninstallPackage(installedPackage.Package, _namespace, out outLog, false, openProject.DirectoryPath);
                            if (outLog != null)
                            {
                                log.Logs.AddRange(outLog.Logs);
                            }

                            if (procEvents && OnPackageUninstalled != null)
                            {
                                OnPackageUninstalled.Invoke(installedPackage.Package, false, installedPackage, openProject);
                            }
                        }
                        else
                        {
                            ProcDelNonReadXMLPackage(arg, installedPackage.Directory, installedPackage, openProject, _namespace, out outLog, procEvents, argType, false, openProject.DirectoryPath);
                            if (outLog != null)
                            {
                                log.Logs.AddRange(outLog.Logs);
                            }
                        }
                        if (deleteInstallFiles)
                        {
                            if (Directory.Exists(installedPackage.Directory))
                            {
                                Helper.DeleteFolderSafely(installedPackage.Directory, _namespace, out outEx, new DeleteFolderLogMessages(deleteFailed: UninstallerMessages.Warning.DirectoryUnableDelete, logGroup: log));
                            }
                            openProject.InstalledPackages.Remove(installedPackage);
                        }
                        //else
                        //{
                        //    if (installedPackage.Package != null)
                        //    {
                        //        installedPackage.Installed = false;
                        //        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));
                        //            throw;
                        //        }
                        //    }
                        //}
                    }
                    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;
                        }
                        ProcDelNonReadXMLPackage(arg, installedDir, null, openProject, _namespace, out outLog, procEvents, argType, false, openProject.DirectoryPath);
                    }
                }
                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;
                    }
                    ProcDelNonReadXMLPackage(arg, installedDir, null, openProject, _namespace, out outLog, procEvents, argType, false, openProject.DirectoryPath);
                }
                Logger.WriteInformationLog(UninstallerMessages.Information.UNINSTALL_PACKAGE_DONE_L, _namespace);
            }
예제 #25
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);
        }
예제 #26
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);
            }
예제 #27
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);
            }
        }
예제 #28
0
            public static void ReinstallLocalPackage(string UID, ProjectPackMan openProject, string _namespace, out LogDataList log)
            {
                if (openProject == null || openProject.InstalledPackages == null)
                {
                    try
                    {
                        throw new InstalledPackageNotFoundException(ExceptionMessages.General.PackWIDNotFound(UID));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.PackageMissng(UID), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                InstalledPackage foundInstalledPackage = openProject.InstalledPackages.FindByUID(UID);

                if (foundInstalledPackage == null)
                {
                    try
                    {
                        throw new InstalledPackageNotFoundException(ExceptionMessages.General.PackWIDNotFound(UID));
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Reinstaller.Error.PackageMissng(UID), _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }
                }
                ReinstallLocalPackage(foundInstalledPackage, openProject, _namespace, out log);
            }
예제 #29
0
            public static RMMovieCollection RetrieveMovieCollection(string path, string rootPath, string _namespace, bool trimRootPath, out LogDataList log, RMPackage parent)
            {
                log = new LogDataList();


                RMMovieCollection newCollection = new RMMovieCollection(parent);

                log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedAutoData(parent.Name, path, RMCollectionType.Movies), _namespace);
                string[] files = null;
                try
                {
                    files = Directory.GetFiles(path);
                } catch (Exception ex)
                {
                    log.WriteErrorLog(LoggerMessages.RMPackage.Error.RetrieveAutoError(path, parent.Name, RMCollectionType.Movies), _namespace, ex);
                    return(null);
                }
                if (files == null || files.Length == 0)
                {
                    return(null);
                }

                for (int i = 0; i < files.Length; ++i)
                {
                    string originalFileName = Path.GetFileNameWithoutExtension(files[i]);
                    string nonLoweredPath   = files[i];
                    files[i] = files[i].ToLower();
                    string fileName      = originalFileName.ToLower();
                    string fileExtension = Path.GetExtension(files[i]);
                    if (fileExtension.Length < RMPConstants.MovieFileType.MP4.Length + 1)
                    {
                        continue;
                    }
                    fileExtension = fileExtension.Substring(1);

                    RMMovieFile.FileType typeOfFile = RMMovieFile.FileType.none;
                    typeOfFile = typeOfFile.ParseString(fileExtension);

                    if (typeOfFile == RMMovieFile.FileType.none || string.IsNullOrWhiteSpace(originalFileName))
                    {
                        continue;
                    }

                    RMMovieGroup rmv = newCollection.Groups.FindByInternalName(fileName);
                    if (rmv == null)
                    {
                        rmv              = new RMMovieGroup(newCollection);
                        rmv.Name         = originalFileName;
                        rmv.internalName = fileName;
                        newCollection.Groups.Add(rmv);
                    }
                    RMMovieFile rmf = new RMMovieFile(rmv);
                    if (trimRootPath)
                    {
                        rmf.Path = Helper.GetRelativePath(nonLoweredPath, rootPath);
                    }
                    else
                    {
                        rmf.Path = nonLoweredPath;
                    }
                    rmf.TypeOfFile = typeOfFile;
                    rmv.Files.Add(rmf);
                    log.WriteInformationLog(LoggerMessages.RMPackage.Info.RetrievedFile(parent.Name, nonLoweredPath, RMCollectionType.Movies), _namespace);
                }
                if (newCollection.Groups.Count == 0)
                {
                    return(null);
                }

                return(newCollection);
            }
            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);
            }