public static void InstallSingleFileCollection(string toWhere, string fromRootDirectory, RMSingleFileCollection.CollectionType collectionType, RMSingleFileCollection collection, string _namespace) { string collType = collectionType.ToDirectoryName(); if (string.IsNullOrWhiteSpace(collType)) { try { throw new InvalidSingleFileCollectionException(ExceptionMessages.RMPackage.COLL_NO_TYPE, InvalidSingleFileCollectionException.WhichInvalid.NoType, collection.Parent); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.UNABLE_INSTALL_SF_NO_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string dirPath = toWhere + "\\" + collType; Helper.MakeDirIfNotExistInstall(dirPath, _namespace); if (collection.Files != null) { foreach (RMSingleFile singleFile in collection.Files) { if (string.IsNullOrWhiteSpace(singleFile.Path)) { try { throw new InvalidSingleFileException(ExceptionMessages.RMPackage.FILE_PATH_NULL); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.UNABLE_INSTALL_SF_NO_PATH, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string fileName = Path.GetFileName(singleFile.Path); string newFile = dirPath + "\\" + fileName; string oldFile = fromRootDirectory + "\\" + singleFile.Path; Exception outEx; if (Helper.CopyFileSafely(oldFile, newFile, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.UnableInstallSFCopyFailed)) != CopyFileResult.Success) { throw outEx; } //singleFile.InstallationStatus = RMPackObject.InstallStatus.Installed; singleFile.Path = Helper.GetRelativePath(newFile, toWhere); } } }
static void CopySingleFileCollection(string toWhere, RMSingleFileCollection.CollectionType collectionType, RMSingleFileCollection collection, string _namespace, string rootDir = null) { string collType = collectionType.ToDirectoryName(); if (string.IsNullOrWhiteSpace(collType)) { try { throw new InvalidSingleFileCollectionException(ExceptionMessages.RMPackage.COLL_NO_TYPE, InvalidSingleFileCollectionException.WhichInvalid.NoType, collection.Parent); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.COLLECTION_NO_TYPE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string dirPath = toWhere + "\\" + collType; Helper.MakeDirIfNotExistCopy(dirPath, _namespace); if (collection.Files == null) { return; } foreach (RMSingleFile singleFile in collection.Files) { if (string.IsNullOrWhiteSpace(rootDir) && singleFile.NonRootedPath) { try { throw new InvalidPathException(ExceptionMessages.PackUtil.FILE_PATH_REL, singleFile.Path); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_ALREADY_RELATIVE + singleFile.Path + ".", _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } if (string.IsNullOrWhiteSpace(singleFile.Path)) { try { throw new InvalidSingleFileException(ExceptionMessages.RMPackage.FILE_PATH_NULL); } catch (Exception ex) { Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_PATH_NOT_SET, _namespace, ex, BasicDebugLogger.DebugErrorType.Error); throw; } } string fileName = Path.GetFileName(singleFile.Path); string newFile = dirPath + "\\" + fileName; string originFile = singleFile.Path; if (!string.IsNullOrWhiteSpace(rootDir)) { originFile = rootDir + "\\" + singleFile.Path; } Exception outEx; if (Helper.CopyFileSafely(originFile, newFile, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageUtil.Error.CopyFileFailed)) != CopyFileResult.Success) { throw outEx; } } }