public void UploadMetadata(IDictionary<string, object> context) { var user = ((IAaaUser)context["AS.Services.ThomsonReuters.Eikon.Toolkit.Interfaces.IAaaUser"]); MetadataResponse response = null; string body = (string)context["AS.RequestBody"]; HttpFormFileContentPaarser httpParser = new HttpFormFileContentPaarser(body, "metadata"); //var product = string.IsNullOrEmpty(httpParser.Product) ? null : new List<string>() { httpParser.Product }; var product = new List<string> { "est" }; if (!Permission.IsAllowToUploadMetadata(user, product)) { response = new MetadataResponse { success = false, description = "Failed - no permission to upload the metadata" }; } else { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { string data = httpParser.FileContents.Replace("\r\n", string.Empty).Replace("\t", string.Empty).Trim(); if (string.IsNullOrEmpty(data)) { response = new MetadataResponse { success = false, description = "Failed - no metadata content" }; } else if (data.Length > 4194304) // limit to 4MB { response = new MetadataResponse() { success = false, description = "Failed - the file is too big" }; } else if (data[0] != '{' || data[data.Length - 1] != '}') { response = new MetadataResponse { success = false, description = "Failed - the content is invalid" }; } else { var setMreq = new SetMetadataRequest(); setMreq.metadata = data; //setMreq.product = httpParser.Product; setMreq.product = "est"; response = opsConsoleSvc.SetMetadataEx(setMreq); if (response == null) { response = new MetadataResponse() { success = false, description = "Failed - no response from the OpsConsole service" }; } } } } string returnedResult = string.Empty; returnedResult = JsonConvert.SerializeObject(response); context["AS.ResponseBody"] = returnedResult; }
public void UploadAggStatMetadata(IDictionary<string, object> context) { var user = ((IAaaUser)context["AS.Services.ThomsonReuters.Eikon.Toolkit.Interfaces.IAaaUser"]); MetadataResponse response = null; string body = (string)context["AS.RequestBody"]; HttpFormFileContentPaarser httpParser = new HttpFormFileContentPaarser(body, "metadata"); //var product = string.IsNullOrEmpty(httpParser.Product) ? null : new List<string>() { httpParser.Product }; var product = new List<string> { "est" }; if (!Permission.IsAllowToUploadMetadata(user, product)) { response = new MetadataResponse { success = false, description = "Failed - no permission to upload the metadata" }; } else { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { string data = httpParser.FileContents.Replace("\r\n", string.Empty).Replace("\t", string.Empty).Trim(); if (string.IsNullOrEmpty(data)) { response = new MetadataResponse { success = false, description = "Failed - no metadata content" }; } else { try { var req = JsonConvert.DeserializeObject<SetAggStatMetadataRequest>(data); //req.product = httpParser.Product; req.product = "est"; response = opsConsoleSvc.SetAggStatMetadata(req); } catch (Exception ex) { response = new MetadataResponse { success = false, description = "Failed - " + ex.Message }; } } } } string returnedResult = string.Empty; returnedResult = JsonConvert.SerializeObject(response); context["AS.ResponseBody"] = returnedResult; }