Example #1
0
        public async Task <string> InvokeHttpRequestResponseService2(
            ContentURI uri, string baseURL, string apiKey,
            string inputBlob1Location, string inputBlob2Location,
            string outputBlob1Location, string outputBlob2Location)
        {
            string         sResponseMsg = string.Empty;
            PLATFORM_TYPES ePlatform    = uri.URIDataManager.PlatformType;

            if (Path.IsPathRooted(inputBlob1Location))
            {
                //use configure await to make sure the response is returned to algo
                sResponseMsg = await WebServerFileIO.InvokeHttpRequestResponseService2(baseURL, apiKey,
                                                                                       inputBlob1Location, inputBlob2Location, outputBlob1Location, outputBlob2Location).ConfigureAwait(false);
            }
            else
            {
                if (ePlatform == PLATFORM_TYPES.webserver)
                {
                    //use configure await to make sure the response is returned to algo
                    sResponseMsg = await WebServerFileIO.InvokeHttpRequestResponseService2(baseURL, apiKey,
                                                                                           inputBlob1Location, inputBlob2Location, outputBlob1Location, outputBlob2Location).ConfigureAwait(false);
                }
                else if (ePlatform == PLATFORM_TYPES.azure)
                {
                    AzureIOAsync azureIO = new AzureIOAsync(uri);
                    sResponseMsg = await azureIO.InvokeHttpRequestResponseService2(baseURL, apiKey,
                                                                                   inputBlob1Location, inputBlob2Location, outputBlob1Location, outputBlob2Location).ConfigureAwait(false);
                }
            }
            return(sResponseMsg);
        }
Example #2
0
        public async Task <string> ReadTextAsync(ContentURI uri,
                                                 string fullURIPath)
        {
            string sTextString = string.Empty;

            if (await URIAbsoluteExists(uri, fullURIPath) == false)
            {
                return(sTextString);
            }
            if (Path.IsPathRooted(fullURIPath))
            {
                FileIO fileIO = new FileIO();
                sTextString = await fileIO.ReadTextAsync(uri, fullURIPath);
            }
            else
            {
                PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType;
                if (ePlatform == PLATFORM_TYPES.webserver)
                {
                    //this is not debugged
                    WebServerFileIO webIO = new WebServerFileIO();
                    sTextString = await webIO.ReadTextAsync(fullURIPath);
                }
                else if (ePlatform == PLATFORM_TYPES.azure)
                {
                    AzureIOAsync azureIO = new AzureIOAsync(uri);
                    sTextString = await azureIO.ReadTextAsync(fullURIPath);
                }
            }
            return(sTextString);
        }
Example #3
0
        //2.20 upgraded to uniform c#8 syntax
        public async Task <List <string> > ReadLinesAsync(ContentURI uri,
                                                          string fullURIPath, int rowIndex = -1)
        {
            List <string> lines = new List <string>();

            if (await URIAbsoluteExists(uri, fullURIPath) == false)
            {
                return(lines);
            }
            PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType;

            if (Path.IsPathRooted(fullURIPath))
            {
                FileIO fileIO = new FileIO();
                lines = await fileIO.ReadLinesAsync(fullURIPath, rowIndex);
            }
            else
            {
                //176 starting using dataurl prop on localhost
                if (ePlatform == PLATFORM_TYPES.webserver)
                {
                    WebServerFileIO wsfileIO = new WebServerFileIO();
                    lines = await wsfileIO.ReadLinesAsync(fullURIPath, rowIndex);
                }
                else if (ePlatform == PLATFORM_TYPES.azure)
                {
                    AzureIOAsync azureIO = new AzureIOAsync(uri);
                    lines = await azureIO.ReadLinesAsync(fullURIPath, rowIndex);
                }
            }
            return(lines);
        }
Example #4
0
        public static async Task <bool> CopyURIsAsync(ContentURI uri,
                                                      string fromURIPath, string toURIPath)
        {
            bool bHasCopied = false;

            //2.0.0 refactored from URIAbsoluteExists(fromURIPath) because azure uses localhost to debug
            if (await FileExistsAsync(uri, fromURIPath) == true &&
                fromURIPath.Equals(toURIPath) == false &&
                (!string.IsNullOrEmpty(toURIPath)))
            {
                PLATFORM_TYPES ePlatform = uri.URIDataManager.PlatformType;
                if (Path.IsPathRooted(fromURIPath))
                {
                    if (Path.IsPathRooted(toURIPath))
                    {
                        bHasCopied = await FileIO.CopyFilesAsync(
                            uri, fromURIPath, toURIPath);
                    }
                    else
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            //2.0.0 debugs azure blob storage using localhost
                            //note topath and frompath are reversed below
                            ePlatform = GetPlatformType(toURIPath);
                            if (ePlatform == PLATFORM_TYPES.azure)
                            {
                                AzureIOAsync azureIO = new AzureIOAsync(uri);
                                bHasCopied = await azureIO.SaveFileinCloudAsync(fromURIPath, toURIPath);
                            }
                            else
                            {
                                if (ePlatform == PLATFORM_TYPES.webserver)
                                {
                                    WebServerFileIO webIO = new WebServerFileIO();
                                    bHasCopied = await webIO.CopyWebFileToFileSystemAsync(toURIPath, fromURIPath);
                                }
                            }
                        }
                        else
                        {
                            //web server doesn't handle https and should use filesystem
                        }
                    }
                }
                else
                {
                    if (Path.IsPathRooted(toURIPath))
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            //2.0.0 debugs azure blob storage using localhost
                            ePlatform = GetPlatformType(fromURIPath);
                            if (ePlatform == PLATFORM_TYPES.azure)
                            {
                                AzureIOAsync azureIO = new AzureIOAsync(uri);
                                bHasCopied = await azureIO.SaveCloudFileAsync(fromURIPath, toURIPath);
                            }
                            else
                            {
                                if (ePlatform == PLATFORM_TYPES.webserver)
                                {
                                    WebServerFileIO webIO = new WebServerFileIO();
                                    bHasCopied = await webIO.CopyWebFileToFileSystemAsync(fromURIPath, toURIPath);
                                }
                            }
                        }
                        else
                        {
                            //210: to debug using localhost:5001
                            ePlatform = GetPlatformType(fromURIPath);
                            if (ePlatform == PLATFORM_TYPES.webserver)
                            {
                                WebServerFileIO webIO = new WebServerFileIO();
                                bHasCopied = await webIO.CopyWebFileToFileSystemAsync(fromURIPath, toURIPath);
                            }
                        }
                    }
                    else
                    {
                        if (ePlatform == PLATFORM_TYPES.azure)
                        {
                            AzureIOAsync azureIO = new AzureIOAsync(uri);
                            bHasCopied = await azureIO.CopyBlobAsync(
                                uri, fromURIPath, toURIPath);
                        }
                        else
                        {
                            //web server doesn't handle https and should use filesystem
                        }
                    }
                }
            }
            return(bHasCopied);
        }