Exemplo n.º 1
0
        private static string ZipFileName(NippsPackage np, bool timeBased = true)
        {
            StringBuilder sb = new StringBuilder(np.HostName.Replace(" ", "").Replace(":", ""));
            DateTime backupTime = DateTime.Now;

            if (!String.IsNullOrEmpty(np.SiteName))
                sb.AppendFormat("_{0}",
                    np.SiteName.Replace(" ", ""));

            if (!String.IsNullOrEmpty(np.ApplicationName))
                sb.AppendFormat("_{0}",
                    np.ApplicationName.Replace(" ", "").Replace("/", ""));

            if (timeBased)
                sb.AppendFormat("_{0}",
                    backupTime.ToString("yyyyMMdd_HHmm"));

            sb.Append(".zip");

            return sb.ToString();
        }
Exemplo n.º 2
0
        private static string ApplicationRestore(NippsPackage np)
        {
            string currentAppFolder = AppDomain.CurrentDomain.BaseDirectory;
            string applicationFolder =
                ServerManagerHelper.PutEnvVarValue(
                    ServerManagerHelper.GetApplicationPhysicalPath(
                        np.SiteName,
                        np.ApplicationName
                        ));

            string BackupTargetPath = GetBackupTargetPath();
            string zipName = BackupTargetPath + np.PackageZIP;

            _Logger.Debug("{0}, {1}, {2}", currentAppFolder, applicationFolder, zipName);
            if (applicationFolder.StartsWith(currentAppFolder) || currentAppFolder.StartsWith(applicationFolder))
                return "[ErrorCode: RESTORE_COULD_NOT_EXTRACT_OVER_SELF]";

            applicationFolder = applicationFolder.EndsWith("\\") ? applicationFolder : applicationFolder + "\\";

            NippsZipHelper.Unzip(applicationFolder, zipName);

            return zipName.Substring(BackupTargetPath.Length);

        }
Exemplo n.º 3
0
        private static string ApplicationBackup(NippsPackage np)
        {
            string applicationFolder = 
                ServerManagerHelper.PutEnvVarValue(
                    ServerManagerHelper.GetApplicationPhysicalPath(
                        np.SiteName, 
                        np.ApplicationName
                        ));
            string BackupTargetPath = GetBackupTargetPath();
            string zipName = BackupTargetPath + (np.ApplicationName.Equals("/") ? "Site_" : "Appl_") + ZipFileName(np);

            _Logger.Debug("{0}, {1}", applicationFolder, zipName);

            NippsZipHelper.ZipFolder(applicationFolder, zipName);
            return zipName.Substring(BackupTargetPath.Length);

        }
        private string SavePackage(NippsPackage nippsPackage, Site site)
        {
            NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

            logger.Debug(nippsPackage);

            //decode zip-file
            byte[] packageZipBuffer = Convert.FromBase64String(nippsPackage.PackageZIP);
            
            //calculate physical-path of the / -default- app&virtualpath
            string basePath = site.Applications
                    .Where(a => a.Path.Equals("/"))
                    .Single()
                    .VirtualDirectories
                        .Where(v => v.Path.Equals("/"))
                        .Single()
                        .PhysicalPath;

            basePath += "\\";

            basePath = ServerManagerHelper.PutEnvVarValue(basePath);

            logger.Debug(basePath);

            NippsZipHelper.Unzip(basePath, packageZipBuffer);

            return basePath;
        }