コード例 #1
0
        public async void UploadFileToDatalake(Stream fileStream, string fileName, int documentTypeId, int documentTemplateId)
        {
            try
            {
                string fileType    = fileName.Substring(fileName.Length - 4);
                string newFileName = fileName.Remove(fileName.Length - 5);
                int    lastIndex   = newFileName.LastIndexOf(".");
                if (lastIndex < 0)
                {
                    newFileName = newFileName + "_v1.0.0.0";
                    lastIndex   = newFileName.LastIndexOf(".");
                }
                string lastNumber = newFileName.Substring(lastIndex + 1);
                string increment  = (int.Parse(lastNumber) + 1).ToString();
                string result     = string.Concat(newFileName.Substring(0, lastIndex + 1), increment) + "." + fileType;

                var  folderPath             = $"{"Techathon20"}/{documentTypeId}/{documentTemplateId}";
                var  blobStorageDetail      = _DAO.GetDataLakeStorageDetails();
                var  resourceConfigurations = _DAO.GetResourcesConfigurations();
                bool isFileMoved            = await DataLakeHelper.MoveFileToDataLakeWithRetry(blobStorageDetail.StorageName, folderPath, result, fileStream, resourceConfigurations);

                if (!isFileMoved)
                {
                    throw new ApplicationException("Error: File could not moved due to unknown problem at blob storage");
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        public async Task <Stream> GetUploadedDoc(string docName = "Master Agreement_Template (1) (1)", string version = "1.0.0.1")
        {
            BlobStorageDetail blobStorageDetail = _DAO.GetDataLakeStorageDetails();

            string storageConnectionString = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}",
                                                           blobStorageDetail.StorageName, blobStorageDetail.StorageKey);

            var storageBlob = new StorageBlob(storageConnectionString, blobStorageDetail.FSContainerName);

            string filepath = storageBlob.Account.BlobStorageUri.PrimaryUri.AbsoluteUri + blobStorageDetail.FSContainerName + "/Techathon20/12/13/" + docName + "_v" + version + ".docx";

            Stream file = await DataLakeHelper.GetFileStreamWithStorageBlob(storageBlob, filepath);

            //var parameters = ClientRequestParametersProvider.GetClientParameters(HttpContext, clientId);
            return(file);
        }