Exemple #1
0
        static void CopyGeneratorFile(string toWhere, RMGenFile genFile, string _namespace, string rootDir = null)
        {
            int    tempPos     = genFile.Parent.Parent.Parts.IndexOf(genFile.Parent) + 1;
            string newFileName = null;

            try
            {
                newFileName = genFile.RetrieveInstallFileName(tempPos);
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.GEN_FILE_ERR_FILE_NAME, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                throw;
            }
            string copyToPath = toWhere + "\\" + newFileName;

            if (string.IsNullOrWhiteSpace(genFile.Path))
            {
                try
                {
                    throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_PATH_NULL, InvalidGeneratorPartFileException.WhichInvalid.PathNotSet, genFile.Parent);
                }
                catch (Exception ex)
                {
                    Logger.WriteErrorLog(LoggerMessages.PackageMaker.Error.FILE_PATH_NOT_SET, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                    throw;
                }
            }
            Exception outEx;

            string originFile = genFile.Path;

            if (!string.IsNullOrWhiteSpace(rootDir))
            {
                originFile = rootDir + "\\" + genFile.Path;
            }

            if (Helper.CopyFileSafely(originFile, copyToPath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageUtil.Error.CopyFileFailed)) != CopyFileResult.Success)
            {
                throw outEx;
            }
        }
                public static void InstallGeneratorFile(string toWhere, string fromRootDir, string rootInstallPath, RMGenFile fileToInstall, int position, string _namespace)
                {
                    string newFileName = null;

                    try
                    {
                        newFileName = fileToInstall.RetrieveInstallFileName(position);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.INVALID_GEN_FILE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                        throw;
                    }

                    string copyToPath = toWhere + "\\" + newFileName;

                    if (string.IsNullOrWhiteSpace(fileToInstall.Path))
                    {
                        try
                        {
                            throw new InvalidGeneratorPartFileException(ExceptionMessages.RMPackage.GEN_FILE_PATH_NULL, InvalidGeneratorPartFileException.WhichInvalid.PathNotSet, fileToInstall.Parent);
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteErrorLog(LoggerMessages.PackageManagement.Installer.Error.NO_FILE_PATH_GEN_FILE, _namespace, ex, BasicDebugLogger.DebugErrorType.Error);
                            throw;
                        }
                    }

                    Exception outEx;
                    string    sourceFile = fromRootDir + "\\" + fileToInstall.Path;

                    if (Helper.CopyFileSafely(sourceFile, copyToPath, true, _namespace, out outEx, new CopyFileLogMessages(copyFileFailed: LoggerMessages.PackageManagement.Installer.Error.GeneratorFileFailedCopy)) != CopyFileResult.Success)
                    {
                        throw outEx;
                    }
                    // fileToInstall.InstallationStatus = RMPackObject.InstallStatus.Installed;
                    fileToInstall.Path = Helper.GetRelativePath(copyToPath, rootInstallPath);
                }