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