Пример #1
0
        public static string GetTempRootPath(ContentURI uri)
        {
            string sPathToTempContent = string.Empty;

            FileStorageIO.PLATFORM_TYPES ePlatform = FileStorageIO.GetPlatformType(uri);
            if (ePlatform == FileStorageIO.PLATFORM_TYPES.webserver)
            {
                //store in temp subfolder of resources directory (set permissions once)
                bool   bIsAzureStorage = false;
                string sRoot           = GetResourceRootPath(uri, bIsAzureStorage);
                if (!sRoot.EndsWith(GeneralHelpers.FILE_PATH_DELIMITER) &&
                    (!string.IsNullOrEmpty(sRoot)))
                {
                    sRoot = string.Concat(sRoot, GeneralHelpers.FILE_PATH_DELIMITER);
                }
                sPathToTempContent = string.Format("{0}{1}{2}",
                                                   sRoot, uri.URIDataManager.TempDocsURIName,
                                                   GeneralHelpers.FILE_PATH_DELIMITER);
            }
            else if (ePlatform == FileStorageIO.PLATFORM_TYPES.azure)
            {
                //performance will be better when temp files are in same cloud storage as content
                //copying back and forth will be easier
                sPathToTempContent = string.Format("{0}{1}{2}",
                                                   uri.URIDataManager.DefaultRootWebStoragePath,
                                                   uri.URIDataManager.TempDocsURIName,
                                                   GeneralHelpers.WEBFILE_PATH_DELIMITER);
            }
            return(sPathToTempContent);
        }
Пример #2
0
        public static string GetResourceRootPath(ContentURI uri,
                                                 string networkWebFileSystemPath)
        {
            string sPathToContent = string.Empty;
            //networkWebFileSystemName derives from uri.URINetwork.WebFileSystemPath
            //and is stored in db table Network
            string sContentContainerOrFolderName =
                (string.IsNullOrEmpty(networkWebFileSystemPath)) ?
                uri.URIDataManager.ContentURIName
                : networkWebFileSystemPath;

            FileStorageIO.PLATFORM_TYPES ePlatform = FileStorageIO.GetPlatformType(uri);
            if (ePlatform == FileStorageIO.PLATFORM_TYPES.webserver)
            {
                //store in temp subfolder of resources directory (set permissions once)
                bool   bIsAzureStorage = false;
                string sRoot           = GetResourceRootPath(uri, bIsAzureStorage);
                if (!sRoot.EndsWith(GeneralHelpers.FILE_PATH_DELIMITER) &&
                    (!string.IsNullOrEmpty(sRoot)))
                {
                    sRoot = string.Concat(sRoot, GeneralHelpers.FILE_PATH_DELIMITER);
                }
                sPathToContent = string.Format("{0}{1}{2}",
                                               sRoot, sContentContainerOrFolderName,
                                               GeneralHelpers.FILE_PATH_DELIMITER);
            }
            else if (ePlatform == FileStorageIO.PLATFORM_TYPES.azure)
            {
                //store in 'commontreks' (or other network containername) container
                sPathToContent = string.Format("{0}{1}{2}",
                                               uri.URIDataManager.DefaultRootWebStoragePath,
                                               sContentContainerOrFolderName, GeneralHelpers.WEBFILE_PATH_DELIMITER);
            }
            return(sPathToContent);
        }
Пример #3
0
        //set in ViewDataHelper when uri is configured with appsettings
        public static void SetAbsoluteURLPath(ContentURI uri,
                                              string absoluteURLPath)
        {
            string sWebPath = absoluteURLPath;

            FileStorageIO.PLATFORM_TYPES ePlatform = FileStorageIO.GetPlatformType(uri);
            if (ePlatform != FileStorageIO.PLATFORM_TYPES.azure)
            {
                //only azure should be using https
                sWebPath = absoluteURLPath.Replace("https", "http");
            }
            uri.URIDataManager.WebPath = sWebPath;
        }
Пример #4
0
        public static async Task <bool> CopyResourceToPackageAsync(
            ContentURI uri, string resourceRelFilePaths,
            int arrayPos, string rootDirectory, string newDirectory,
            string parentFileName, IDictionary <string, string> zipArgs)
        {
            bool bHasCopied = false;

            string[] arrResourceParams = resourceRelFilePaths.Split(GeneralHelpers.PARAMETER_DELIMITERS);
            string   sResourceParams   = string.Empty;
            string   sResourceRelURI   = string.Empty;
            string   sResourceFullURI  = string.Empty;

            //refactor: parallel didn't work with this loop - keep testing
            //Parallel.For(0, arrResourceParams.Length, i =>
            for (int i = 0; i < arrResourceParams.Length; i++)
            {
                sResourceParams = arrResourceParams[i];
                if (string.IsNullOrEmpty(sResourceParams) == false)
                {
                    //the array holds relative paths; convert to full path for file.copy and package
                    sResourceRelURI = GeneralHelpers.GetDelimitedSubstring(sResourceParams,
                                                                           GeneralHelpers.STRING_DELIMITERS, arrayPos);
                    //remove the rel directories
                    string sBaseResourceURI = sResourceRelURI.Replace("../", string.Empty);
                    if ((!sBaseResourceURI.StartsWith(GeneralHelpers.WEBFILE_PATH_DELIMITER)) &&
                        (!rootDirectory.EndsWith(GeneralHelpers.FILE_PATH_DELIMITER)))
                    {
                        sBaseResourceURI = string.Concat(GeneralHelpers.WEBFILE_PATH_DELIMITER,
                                                         sBaseResourceURI);
                    }
                    FileStorageIO.PLATFORM_TYPES ePlatform
                        = uri.URIDataManager.PlatformType;
                    if (ePlatform == FileStorageIO.PLATFORM_TYPES.webserver)
                    {
                        bHasCopied = await CopyWebServerResourceToPackageAsync(
                            uri, rootDirectory, newDirectory,
                            parentFileName, zipArgs, sBaseResourceURI);
                    }
                    else if (ePlatform == FileStorageIO.PLATFORM_TYPES.azure)
                    {
                        bHasCopied = await CopyAzureResourceToPackageAsync(
                            uri, rootDirectory, newDirectory,
                            parentFileName, zipArgs, sBaseResourceURI);
                    }
                }
            }
            return(bHasCopied);
        }
Пример #5
0
        //gets paths to css, js, images in web root
        public static string GetWebContentFullPath(ContentURI uri,
                                                   string webSubfolder, string filename)
        {
            string sPathToContent = string.Empty;

            FileStorageIO.PLATFORM_TYPES ePlatform = FileStorageIO.GetPlatformType(uri);
            if (ePlatform == FileStorageIO.PLATFORM_TYPES.webserver)
            {
                sPathToContent = string.Format("{0}{1}{2}{3}",
                                               uri.URIDataManager.DefaultRootFullFilePath,
                                               webSubfolder, GeneralHelpers.FILE_PATH_DELIMITER,
                                               filename);
            }
            else if (ePlatform == FileStorageIO.PLATFORM_TYPES.azure)
            {
                //do not use the path to blob storage: DefaultRootWebStoragePath
                sPathToContent = string.Format("{0}{1}{2}{3}",
                                               uri.URIDataManager.DefaultWebDomain,
                                               webSubfolder, GeneralHelpers.WEBFILE_PATH_DELIMITER,
                                               filename);
            }
            return(sPathToContent);
        }
Пример #6
0
        public static async Task <bool> CopyRelatedDataToPackageAsync(
            ContentURI uri, string currentFilePath,
            string packageName, string fileType, string newFilePath,
            bool needsAllRelatedData, IDictionary <string, string> zipArgs)
        {
            bool bHasCopied = false;

            FileStorageIO.PLATFORM_TYPES platform
                = uri.URIDataManager.PlatformType;
            if (platform == FileStorageIO.PLATFORM_TYPES.webserver)
            {
                bHasCopied = await CopyRelatedDataToWebServerPackageAsync(
                    uri, currentFilePath, packageName, fileType, newFilePath,
                    needsAllRelatedData, zipArgs);
            }
            else if (platform == FileStorageIO.PLATFORM_TYPES.azure)
            {
                AzureIOAsync azureIO = new AzureIOAsync(uri);
                bHasCopied = await azureIO.CopyRelatedDataToCloudServerPackageAsync(
                    uri, currentFilePath,
                    packageName, fileType, newFilePath, needsAllRelatedData, zipArgs);
            }
            return(bHasCopied);
        }