public async Task <dynamic> UploadObjectTask(BucketUploadFile file, string rootPath) { string fileSavePath = await CreateAndSaveFile(file, rootPath); IObjectsApi objects = GeneralTokenConfigurationSettings <IObjectsApi> .SetToken(new ObjectsApi(), await _authServiceAdapter.GetSecondaryTokenTask()); dynamic uploadObj = null; long fileSize = file.fileToUpload.Length; int UPLOAD_CHUNCK_SIZE = 2; string bucketKey = file.bucketKey; string fileName = Path.GetFileName(file.fileToUpload.FileName); uploadObj = await UploadObjByStatment(fileSize, UPLOAD_CHUNCK_SIZE, objects, bucketKey, fileName, fileSavePath); File.Delete(fileSavePath); return(new { uploadObject = uploadObj, token = objects.Configuration.AccessToken }); }
public async Task <dynamic> GetObjects(string bucketKey) { IObjectsApi api = GeneralTokenConfigurationSettings <IObjectsApi> .SetToken(new ObjectsApi(), await _authServiceAdapter.GetSecondaryTokenTask()); return(await api.GetObjectsAsync(bucketKey)); }
private async Task AddBucketsToNode(string ClientId) { IBucketsApi bucketsApi = GeneralTokenConfigurationSettings <IBucketsApi> .SetToken(new BucketsApi(), await _authServiceAdapter.GetSecondaryTokenTask()); dynamic buckets = await bucketsApi.GetBucketsAsync("US", 100); foreach (KeyValuePair <string, dynamic> bucket in new DynamicDictionaryItems(buckets.items)) { nodes.Add(new TreeNode(bucket.Value.bucketKey, bucket.Value.bucketKey.Replace(ClientId + "-", string.Empty), "bucket", true)); } }
private async Task AddObjectsToNode(string id) { IObjectsApi objectsApi = GeneralTokenConfigurationSettings <IObjectsApi> .SetToken(new ObjectsApi(), await _authServiceAdapter.GetSecondaryTokenTask()); var objectList = objectsApi.GetObjects(id); foreach (KeyValuePair <string, dynamic> objInfo in new DynamicDictionaryItems(objectList.items)) { nodes.Add(new TreeNode(Base64Encoding.Encode((string)objInfo.Value.objectId), objInfo.Value.objectKey, "object", false)); } }
public async Task <dynamic> CreateTask(BucketKey key) { IBucketsApi buckets = GeneralTokenConfigurationSettings <IBucketsApi> .SetToken(new BucketsApi(), await _authServiceAdapter.GetSecondaryTokenTask()); var clientId = AppSettings.GetAppSetting("FORGE_CLIENT_ID").ToLower(); var bucketKey = key.bucketKey.ToLower(); PostBucketsPayload bucketPayload = new PostBucketsPayload(string.Format("{0}{1}", bucketKey, clientId.Substring(0, 18)), null, PostBucketsPayload.PolicyKeyEnum.Transient); var result = await buckets.CreateBucketAsync(bucketPayload, "US"); return(result); }
public async Task <dynamic> GetModelDetailPropertiesAsync(ModelDetails modelDetails) { List <dynamic> results = new List <dynamic>(); string key = "properties"; if (_cacheManager.IsAdd(key)) { return(_cacheManager.Get <dynamic>(key)); } else { DerivativesApi derivativesApi = GeneralTokenConfigurationSettings <IDerivativesApi> .SetToken(new DerivativesApi(), await _authServiceAdapter.GetSecondaryTokenTask()); dynamic detail = await GetModelDetailGuid(derivativesApi, modelDetails.urn); dynamic metadata = detail.data.metadata; foreach (KeyValuePair <string, dynamic> m in new DynamicDictionaryItems(metadata)) { dynamic list = await derivativesApi.GetModelviewPropertiesAsync(modelDetails.urn, m.Value.guid); dynamic collection = list.data.collection; DynamicDictionaryItems items = new DynamicDictionaryItems(collection); foreach (dynamic c in items) { results.Add(c.Value); } } _cacheManager.Add(key, results, 60); return(results); } }
public async Task <dynamic> TranslateTask(TranslateObject translateObject) { string Urn = translateObject.objectName; string rootFileName = translateObject.RootFileName; JobPayload job = BusinessLogicRunner.RunnerStatmentOptional <JobPayload>((rootFileName != null), new JobPayload(new JobPayloadInput(Urn, true, rootFileName), new JobPayloadOutput(outputs)), new JobPayload(new JobPayloadInput(Urn), new JobPayloadOutput(outputs))); DerivativesApi derivativesApi = GeneralTokenConfigurationSettings <IDerivativesApi> .SetToken(new DerivativesApi(), await _authServiceAdapter.GetSecondaryTokenTask()); dynamic jobTranslate = await derivativesApi.TranslateAsync(job, true); return(jobTranslate); }