public DeleteFromCacheResponse DeleteCacheForSite(DeploymentCacheRequest cacheRequest)
        {
            DeleteFromCacheResponse deleteFromCacheResponse = new DeleteFromCacheResponse();

            try
            {
                contentCache.DropSite(cacheRequest.RootDirectory);
            }
            catch (Exception)
            {
                DeploymentCacheFault df = new DeploymentCacheFault("Failed to delete site from Cache.", cacheRequest.RootDirectory, cacheRequest.StorageVolumePath);
                throw new FaultException <DeploymentCacheFault>(df);
            }

            deleteFromCacheResponse.IsDeleteSuccessful = true;

            return(deleteFromCacheResponse);
        }
        public DeploymentCacheResponse RefreshCacheForSite(DeploymentCacheRequest cacheRequest)
        {
            DeploymentCacheResponse cacheRefreshResponse = new DeploymentCacheResponse();

            cacheRefreshResponse.SiteName = cacheRequest.SiteName;

            cacheRefreshResponse.FileContents = contentCache.UpdateSite(cacheRequest.RootDirectory, cacheRequest.StorageVolumePath);

            if (cacheRefreshResponse.FileContents == null)
            {
                // Failed to add site to Cache
                DeploymentCacheFault df = new DeploymentCacheFault("Failed to Refersh site in Cache. Could not get site contents", cacheRequest.RootDirectory, cacheRequest.StorageVolumePath);
                throw new FaultException <DeploymentCacheFault>(df);
            }

            cacheRefreshResponse.FileLength = cacheRefreshResponse.FileContents.Length;

            return(cacheRefreshResponse);
        }
        public DeploymentCacheResponse TestDowloadSpeedForZip(DeploymentCacheRequest cacheRequest)
        {
            DeploymentCacheResponse cacheResponse = new DeploymentCacheResponse();

            cacheResponse.FileName = cacheRequest.RootDirectory;

            string fileAbsolutePath = Path.Combine(cacheRequest.StorageVolumePath, cacheRequest.RootDirectory);

            try
            {
                cacheResponse.FileContents = File.ReadAllBytes(fileAbsolutePath);
                cacheResponse.FileLength   = cacheResponse.FileContents.Length;
            }
            catch (Exception e)
            {
                DeploymentCacheFault df = new DeploymentCacheFault(e.Message);
                throw new FaultException <DeploymentCacheFault>(df);
            }

            return(cacheResponse);
        }