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); } }
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); }
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); }
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); }
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); }
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); } } }
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); }
// ---- 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); }