//internal string Email { get; private set; } internal Security(IAppServerServices services) { AllowedInAtAll = false; var uuid = services.UserContext.UUID; // Only allow user who had uuid if (!string.IsNullOrWhiteSpace(uuid)) { AllowedInAtAll = true; } }
public string TRR(string query, string body, IAppServerServices services) { services.AppHits.AppHitsFeatureHit("TRR"); services.AppHits.AppHitsFeatureHit(""); var rstResult = GetSoapValue(body, TestResultForwarder.RequestAnalyzerServiceXmlns, "SubmitCompressedTestResult", "rstResult"); if (!string.IsNullOrEmpty(rstResult)) return WebCallsImpl.SubmitTestResult(rstResult, services); rstResult = GetSoapValue(body, TestResultForwarder.RequestAnalyzerServiceXmlns, "SubmitTestResult", "rstResult"); if (!string.IsNullOrEmpty(rstResult)) return WebCallsImpl.SubmitTestResult(rstResult, services, false); //services.Logger.LogWarn("cannot process TRR service: body = " + body); return ""; }
public string TSG(string query, string body, IAppServerServices services) { const string requestAnalyzerServiceXmlns = "http://www.reuters.com/RST/TSG/Service/RequestAnalyzerService"; var noiseData = GetSoapValue(body, requestAnalyzerServiceXmlns, "UploadNoiseString", "noiseData"); if (!string.IsNullOrEmpty(noiseData)) { services.AppHits.AppHitsFeatureHit("UP"); return WebCallsImpl.UploadNoiseString(noiseData, services); } var dlSize = GetSoapValue(body, requestAnalyzerServiceXmlns, "DownloadNoiseString", "size"); if (!string.IsNullOrEmpty(dlSize)) { services.AppHits.AppHitsFeatureHit("DOWN"); int size; return int.TryParse(dlSize, out size) ? WebCallsImpl.DownloadNoiseString(size, services) : ""; } var profile1 = GetSoapValue(body, requestAnalyzerServiceXmlns, "RequestHeaders", "profile"); if (profile1 != null) { services.AppHits.AppHitsFeatureHit("PROF"); return WebCallsImpl.RequestHeaders(profile1, services); } const string getTestSuiteServiceXmlns = "http://www.reuters.com/rst/tsg/"; var profile = GetSoapValue(body, getTestSuiteServiceXmlns, "GetTestSuite", "profile"); if (!string.IsNullOrEmpty(profile)) { services.AppHits.AppHitsFeatureHit("TSG"); return WebCallsImpl.GetTestSuite(profile, services); } services.Logger.LogWarn("cannot process TSG service: body = " + body); return ""; }
private static XmlDocument FormatingTestResultByXslt(XmlDocument doc, string xsltString, IAppServerServices services) { try { var formattedXml = new XmlDocument(); var xdelc = formattedXml.CreateXmlDeclaration("1.0", "utf-8", null); formattedXml.AppendChild(xdelc); var formattedXmlString = new StringBuilder(); var settings = new XmlWriterSettings { Encoding = new UTF8Encoding(false), ConformanceLevel = ConformanceLevel.Document, Indent = false }; var writer = XmlWriter.Create(formattedXmlString, settings); XmlReader xmlreader = new XmlTextReader(new StringReader(xsltString)); var doXslt = new System.Xml.Xsl.XslCompiledTransform(); doXslt.Load(xmlreader); doXslt.Transform(doc, writer); writer.Close(); xmlreader.Close(); var tmp = new XmlDocument(); tmp.LoadXml(formattedXmlString.ToString()); var xe = formattedXml.ImportNode(tmp.DocumentElement, true); formattedXml.AppendChild(xe); return formattedXml; } catch (Exception ex) { services.Logger.LogError("WebCallsImpl.FormatingTestResultByXslt(): " + ex.Message); return doc; } }
internal static string SubmitTestResult(string rstResult, IAppServerServices services, bool isCompressed = true) { var uuid = services.UserContext.UUID; string testID = ""; services.Logger.LogInfo("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Started"); try { if (isCompressed) { rstResult = GzipDecompress(rstResult); } services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Decompressed"); inputXML = LoadStringToXmlDocument(rstResult); if (string.IsNullOrEmpty(XSLTString)) { using (var mStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ThomsonReuters.Eikon.SystemTest.MappingTestResult.xslt")) { using (var reader = new StreamReader(mStream)) { mStream.Seek(0, SeekOrigin.Begin); XSLTString = reader.ReadToEnd(); } } } inputXML = FormatingTestResultByXslt(inputXML, XSLTString, services); //services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] XSLT Loaded/Transformed"); //Insert server detail into test result /*#region Insert server detail into the test result XmlNode userProfileNode = null; XmlNode refNode = inputXML.DocumentElement; XmlNode userProfileXml = CreateUserProfileXml(inputXML); if (userProfileXml != null) { userProfileNode = inputXML.DocumentElement.InsertBefore(userProfileXml, refNode.FirstChild); } XmlNode serverVersionXml = CreateServerVersionXml(inputXML); if (serverVersionXml != null) { inputXML.DocumentElement.InsertAfter(serverVersionXml, userProfileNode); } services.Logger.LogDebug("SubmitTestResult: [" + uuid + "] GetAAAservice"); #endregion*/ var forwarder = new TestResultForwarder { XMLResult = inputXML, Logger = services.Logger }; if(!forwarder.ForwardTest(uuid, out testID)) SaveOfflineResult(inputXML, uuid); services.Logger.LogDebug("WebCallsImpl.SubmitTestResult(): [" + uuid + "] Forwarded"); } catch (Exception ex) { SaveOfflineResult(inputXML, uuid); services.Logger.LogError("SubmitTestResult: [" + uuid + "], " + ex.Message); services.Logger.LogError("SubmitTestResult: [" + uuid + "], " + ex.StackTrace); } if (string.IsNullOrEmpty(testID)) { return TRR_RETURNMSG1 + uuid + TRR_RETURNMSG2; } else { return TRR_RETURNMSG1 + testID + TRR_RETURNMSG2; } }
public string GetCriticalUsers(string query, string body, IAppServerServices services) { var req = JsonConvert.DeserializeObject<GetCriticalUsersRequest>(body); req.product = "est"; var product = new List<string> { "est" }; if (Permission.IsAllowToGetStats(services.UserContext, product) && Permission.IsUserInScope(services.UserContext, req.uuid)) { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var response = opsConsoleSvc.GetCriticalUsers(req); if (response == null) { services.Logger.LogError("WebCallableFunctions.GetCriticalUsers() - null is returned"); return "{}"; } return JsonConvert.SerializeObject(response); } catch (Exception ex) { services.Logger.LogError("WebCallableFunctions.GetCriticalUsers() - Exception: {0}", ex.Message); return "{}"; } } } else { return "{}"; } }
// Temp method public string GetLocationInfo(string query, string body, IAppServerServices services) { var logger = services.Logger; try { // Load the incoming request into the request params object (for easy passing to the half dozen functions that need the parameters) var req = JsonConvert.DeserializeObject<GetLocationInfoRequest>(body); using (var client = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { var res = client.GetLocationInfo(req); return JsonConvert.SerializeObject(res); } } catch (Exception ex) { logger.LogError("WebCallableFunctions.GetLocationInfo() - Exception: {0}" + ex.Message); return "{ }"; } }
public string GetUserPermissions(string query, string body, IAppServerServices services) { var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(body); var product = new List<string> { "est" }; var enterUuid = values != null && values.ContainsKey("uuid") ? values["uuid"] : null; var fromCache = false; var cacheKey = string.Format("{0}_{1}_PEMISSION", services.UserContext.UUID, enterUuid ?? "INITIAL"); UserPermission userPermission; if (_Cache.Contains(cacheKey)) { userPermission = _Cache.Get(cacheKey) as UserPermission; fromCache = true; } else { userPermission = new UserPermission { IsAllowToUploadMetadata = Permission.IsAllowToUploadMetadata(services.UserContext, product) ? "true" : "false", IsAllowToGetStats = Permission.IsAllowToGetStats(services.UserContext, product) ? "true" : "false", IsInternal = Permission.IsUserInternal(services.UserContext) ? "true" : "false", IsUserInScope = string.IsNullOrEmpty(enterUuid) ? "true" : Permission.IsUserInScope(services.UserContext, enterUuid) ? "true" : "false" }; _Cache.Set(cacheKey, userPermission, DateTimeOffset.UtcNow.AddMinutes(1)); } return String.Format("{{\"isAllowToUploadMetadata\":{0},\"isAllowToGetStats\":{1},\"isInternal\":{2},\"isUserInScope\":{3},\"cache\":{4},\"scope\":{5}}}", userPermission.IsAllowToUploadMetadata, userPermission.IsAllowToGetStats, userPermission.IsInternal, userPermission.IsUserInScope, fromCache?"true":"false", Permission.GetUserInScopeAaaDetails(services.UserContext.UUID, enterUuid) ); }
public string GetTop100LocationAtRisk(string query, string body, IAppServerServices services) { var req = JsonConvert.DeserializeObject<GetTop100LocationAtRiskRequest>(body); req.product = "est"; //var product = string.IsNullOrEmpty(req.product) ? null : new List<string>() { req.product }; var product = new List<string> { "est" }; // For external user, the location dashboard will only show the users under the user's location scope if (!Permission.IsUserInternal(services.UserContext)) { var scope = Permission.GetTopLocationScope(services.UserContext); if (!scope.Equals(default(KeyValuePair<FindLocationFilter, string>))) { var temp = 0; switch (scope.Key) { case FindLocationFilter.LOC: temp = 1; break; case FindLocationFilter.LGL: temp = 2; break; case FindLocationFilter.ULT: temp = 3; break; } req.locationScope = new KeyValuePair<int, string>(temp, scope.Value); } else { services.Logger.LogWarn("WebCallableFunctions.GetTop100LocationAtRisk() - External user without scope {0} - {1}", services.UserContext.UUID, scope.ToString()); return "{}"; } } if (Permission.IsAllowToGetStats(services.UserContext, product)) { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var response = opsConsoleSvc.GetTop100LocationAtRisk(req); if (response == null) { services.Logger.LogError("WebCallableFunctions.GetTop100LocationAtRisk() - null is returned"); return "{}"; } return JsonConvert.SerializeObject(response); } catch (Exception ex) { services.Logger.LogError("WebCallableFunctions.GetTop100LocationAtRisk() - Exception: {0}", ex.Message); return "{}"; } } } else { return "{}"; } }
public string FindUser(string query, string body, IAppServerServices services) { var logger = services.Logger; try { // Load the incoming request into the request params object (for easy passing to the half dozen functions that need the parameters) var req = JsonConvert.DeserializeObject<FindUserRequest>(body); req.Filter = FindUserFilter.All; using (var userInfoServiceclient = new UserInfoServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { var svcResp = userInfoServiceclient.FindUser(req); return (svcResp == null) ? "{ \"Users\":[]}" : JsonConvert.SerializeObject(svcResp); } } catch (Exception ex) { logger.LogError("STOpsConsole - FindUser - Caught exception: " + ex.Message); return "{ }"; } }
internal static string DownloadNoiseString(int size, IAppServerServices services) { var noiseStringResult = new StringBuilder(); noiseStringResult.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); noiseStringResult.Append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"); noiseStringResult.Append("<soap:Body>"); noiseStringResult.Append("<DownloadNoiseStringResponse xmlns=\"http://www.reuters.com/RST/TSG/Service/RequestAnalyzerService\">"); noiseStringResult.Append("<DownloadNoiseStringResult>"); try { noiseStringResult.Append(size >= 4194304 ? "" : RandomString(size, false)); } catch (Exception) { noiseStringResult.Append(""); } noiseStringResult.Append("</DownloadNoiseStringResult>"); noiseStringResult.Append("</DownloadNoiseStringResponse>"); noiseStringResult.Append("</soap:Body>"); noiseStringResult.Append("</soap:Envelope>"); return noiseStringResult.ToString(); }
public string GetMetadataVersion(string query, string body, IAppServerServices services) { var logger = services.Logger; try { using (var client = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { var metadataVersionReq = JsonConvert.DeserializeObject<GetMetadataVersion>(body); metadataVersionReq.product = "est"; var version = client.GetMetadataVersion(metadataVersionReq); int returnVersion = 0; if (version != null) { returnVersion = version.GetValueOrDefault(); } return string.Format("{{\"version\": {0}}}", returnVersion); } } catch (Exception ex) { logger.LogError("Error while getting metadata: {0}", ex.Message); return "{}"; } }
public string GetMachineInstallInfo(string query, string body, IAppServerServices services) { var logger = services.Logger; using (var client = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var machInstReq = JsonConvert.DeserializeObject<MachInstInfoRequest>(body); machInstReq.product = "est"; var response = client.GetMachineInstallInfo(machInstReq); return response == null ? "{ \"items\":[]}" : JsonConvert.SerializeObject(response); } catch (Exception ex) { logger.LogError("STOpsConsole - GetMachineInstallInfo - Caught exception: " + ex.Message); return "{}"; } } }
public string GetMetadata(string query, string body, IAppServerServices services) { var logger = services.Logger; try { using (var client = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { var metadataReq = JsonConvert.DeserializeObject<GetMetadataRequest>(body) ?? new GetMetadataRequest(); metadataReq.product = "est"; metadataReq.disable = Permission.GetDisableTests(services.UserContext); var metadata = client.GetMetadata(metadataReq); return string.IsNullOrEmpty(metadata) ? "{}" : metadata; } } catch (Exception ex) { logger.LogError("Error while getting metadata: {0}", ex.Message); return "{}"; } }
public string EditStat(string query, string body, IAppServerServices services) { var req = JsonConvert.DeserializeObject<EditStatRequest>(body); req.product = "est"; //var product = string.IsNullOrEmpty(req.product) ? null : new List<string>() { req.product }; var product = new List<string> { "est" }; if (Permission.IsAllowToUploadMetadata(services.UserContext, product)) { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var response = opsConsoleSvc.EditStat(req); if (response == null) { services.Logger.LogError("STOpsConsole - EditStat returned null"); return "{}"; } return JsonConvert.SerializeObject(response); } catch (Exception ex) { services.Logger.LogError("STOpsConsole - EditStat - Caught exception: {0}", ex.Message); return "{}"; } } } else { return JsonConvert.SerializeObject(new EditStatResponse { success = false }); } }
public string GetUserScope(string query, string body, IAppServerServices services) { var logger = services.Logger; try { var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(body); var product = new List<string> { "est" }; var loginUser = values != null && values.ContainsKey("loginUser") ? values["loginUser"] : null; var lookedUpUser = values != null && values.ContainsKey("lookedUpUser") ? values["lookedUpUser"] : null; var searchString = values != null && values.ContainsKey("searchString") && !string.IsNullOrEmpty(values["searchString"]) ? values["searchString"] : "*"; var loginAaaUser = new AaaUser(); loginAaaUser.SetUser(!String.IsNullOrEmpty(loginUser) ? loginUser : services.UserContext.UUID); var fromCache = false; var cacheKey = string.Format("{0}_{1}_PEMISSION", services.UserContext.UUID, lookedUpUser ?? "INITIAL"); UserPermission userPermission; if (_Cache.Contains(cacheKey)) { userPermission = _Cache.Get(cacheKey) as UserPermission; fromCache = true; } else { userPermission = new UserPermission { IsAllowToUploadMetadata = Permission.IsAllowToUploadMetadata(loginAaaUser, product) ? "true" : "false", IsAllowToGetStats = Permission.IsAllowToGetStats(loginAaaUser, product) ? "true" : "false", IsInternal = Permission.IsUserInternal(loginAaaUser) ? "true" : "false", IsUserInScope = string.IsNullOrEmpty(lookedUpUser) ? "n/a" : Permission.IsUserInScope(loginAaaUser, lookedUpUser) ? "true" : "false" }; _Cache.Set(cacheKey, userPermission, DateTimeOffset.UtcNow.AddMinutes(1)); } #region loginUser var userSettingString = "{}"; var userPermissionSetting = Permission.GetUserPermission(loginAaaUser); if (userPermissionSetting != null) { userSettingString = JsonConvert.SerializeObject(userPermissionSetting); } var permissionString = "{}"; if (userPermission != null) { permissionString = JsonConvert.SerializeObject(userPermission); } var loginUserPermission = String.Format("{{\"userPermission\":{0},\"setting\":{1},\"cache\":\"{2}\"}}", permissionString, userSettingString, fromCache.ToString().ToLower() ); var loginUserLocation = String.Format("{{\"locationScope\":{0},\"topLocationScope\":\"{1}\"}}", Permission.GetUserInScopeAaaDetails(loginUser, loginUser), Permission.GetTopLocationScope(loginAaaUser) ); var loginUserResult = String.Format("{{\"Info\":{0},\"Permissions\":{1},\"Locations\":{2}}}", loginAaaUser.GetJsonString(), loginUserPermission, loginUserLocation ); #endregion #region searchUser var req = new FindMachineInstallRequest() { SearchString = searchString, Product = "est", Filter = true }; var searchResult = FindMachineInstall(req,loginAaaUser,logger); #endregion #region lookupUser var lookupUserResult = String.Format("{{\"locationScope\":\"empty argument\"}}"); var lookupAaaUser = new AaaUser(); if (!String.IsNullOrEmpty(lookedUpUser)) { var lookupUserLocation = String.Format("{{\"locationScope\":{0}}}", Permission.GetUserInScopeAaaDetails(loginUser, lookedUpUser) ); lookupAaaUser.SetUser(lookedUpUser); lookupUserResult = String.Format("{{\"Info\":{0},\"Locations\":{1}}}", lookupAaaUser.GetJsonString(), lookupUserLocation ); } #endregion var result = String.Format("{{\"LogInUser\":{0},\"LookUpUser\":{1},\"SearchResult\":{2},\"status\":\"{3}\"}}", loginUserResult, lookupUserResult, searchResult, "Done" ); return result; } catch (Exception ex) { logger.LogError("GetUserScope - error {0}", ex.Message); return String.Format("{{\"status\":\"{0}\"}}", "Error: " + ex.Message ); } }
// simple the function that only called by Eikon 3.x by return static TestSuite => do not calculate from profile internal static string GetTestSuite(string profile, IAppServerServices services) { if (!string.IsNullOrEmpty(TestSuite)) return TestSuite; try { if (string.IsNullOrEmpty(TestSuiteFromFile)) { using (var xStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ThomsonReuters.Eikon.SystemTest.TestSuite.xml")) { using (var reader = new StreamReader(xStream)) { xStream.Seek(0, SeekOrigin.Begin); TestSuiteFromFile = reader.ReadToEnd(); } } } var testSuiteReturn = new StringBuilder(); testSuiteReturn.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>"); testSuiteReturn.Append("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"); testSuiteReturn.Append("<soap:Body>"); testSuiteReturn.Append("<GetTestSuiteResponse xmlns=\"http://www.reuters.com/rst/tsg/\">"); testSuiteReturn.Append("<GetTestSuiteResult>"); testSuiteReturn.Append(HttpUtility.HtmlEncode(TestSuiteFromFile)); testSuiteReturn.Append("</GetTestSuiteResult>"); testSuiteReturn.Append("</GetTestSuiteResponse>"); testSuiteReturn.Append("</soap:Body>"); testSuiteReturn.Append("</soap:Envelope>"); TestSuite = testSuiteReturn.ToString(); } catch (Exception e) { services.Logger.LogWarn("WebCallsImpl.GetTestSuite(): Cannot load TestSuite, error = " + e.Message); return ""; } services.Logger.LogDebug("WebCallsImpl.GetTestSuite(): TestSuite = " + TestSuite); return TestSuite; }
public string GetSystemTestSummary(string query, string body, IAppServerServices services) { var getMultiStatsRequest = JsonConvert.DeserializeObject<GetMultiStatsRequest>(body); if (Permission.IsAllowToGetStats(services.UserContext, getMultiStatsRequest.products)) { using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var response = opsConsoleSvc.GetMultiStats(getMultiStatsRequest); response.firstName = services.UserSearch.GetUserByUuid(getMultiStatsRequest.uuid).FirstName; response.lastName = services.UserSearch.GetUserByUuid(getMultiStatsRequest.uuid).LastName; response.email = services.UserSearch.GetUserByUuid(getMultiStatsRequest.uuid).EmailAddress; return response == null ? "{}" : JsonConvert.SerializeObject(response); } catch (Exception ex) { services.Logger.LogError("Error while invoking GetMultiStats: {0}", ex.Message); return "{}"; } } } else { return "{}"; } }
internal static string RequestHeaders(string profile1, IAppServerServices services) { try { var sbHeaders = new StringBuilder(); sbHeaders.Append("POST /SystemTest/TSG/RequestAnalyzerService.asmx HTTP/1.1\n"); sbHeaders.Append("Cache-Control: no-cache\n"); sbHeaders.Append("Connection: Keep-Alive\n"); sbHeaders.Append("Content-Length: 393\n"); sbHeaders.Append("Content-Type: text/xml; charset=utf-8\n"); sbHeaders.Append("Accept-Encoding: gzip, deflate\n"); sbHeaders.Append("Authorization: dsame\n"); sbHeaders.Append("Cookie: EIKON_USER_AGENT='NET40,EIKON8.3.503,SR0,UA12.1.34,ADF6.20132.5.31,Charcoal'; iPlanetDirectoryPro=\n"); // blank the iPlanetDirectoryPro value sbHeaders.Append("Host: \n"); // blank the request URL sbHeaders.Append("User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; Thomson Reuters File Download 6.0)\n"); sbHeaders.Append("SOAPAction: http://www.reuters.com/RST/TSG/Service/RequestAnalyzerService/RequestHeaders\n"); sbHeaders.Append("reutersuuid: " + services.UserContext.UUID); var strHeader = sbHeaders.ToString(); services.Logger.LogDebug("WebCallsImpl.RequestHeaders(): strHeader = " + strHeader); return strHeader; } catch (Exception e) { services.Logger.LogWarn("WebCallsImpl.RequestHeaders(): error = " + e.Message); return ""; } }
public string GetAggStatMetadata(string query, string body, IAppServerServices services) { var logger = services.Logger; var req = JsonConvert.DeserializeObject<GetAggStatMetadataRequest>(body); req.product = "est"; try { using (var client = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { //var metadata = client.GetAggStatMetadata(new GetAggStatMetadataRequest()); var metadata = client.GetAggStatMetadata(req); return (metadata != null) ? JsonConvert.SerializeObject(metadata, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }) : "{}"; } } catch (Exception ex) { logger.LogError("WebCallableFunctions.GetAggStatMetadata() - Exception: {0}", ex.Message); return "{}"; } }
public string FindMachineInstall(string query, string body, IAppServerServices services) { IDictionary<string, FindUserEntity> userDetailDic = new Dictionary<string, FindUserEntity>(); var logger = services.Logger; try { // Load the incoming request into the request params object (for easy passing to the half dozen functions that need the parameters) var req = JsonConvert.DeserializeObject<FindMachineInstallRequest>(body); return FindMachineInstall(req, services.UserContext, logger); } catch (Exception ex) { logger.LogError("STOpsConsole - FindMachineInstall - Caught exception: " + ex.Message); return "{ }"; } }
public string IsAllowToGetStats(string query, string body, IAppServerServices services) { var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(body); //var product = values != null && values.ContainsKey("product") ? new List<string>() { values["product"] } : null; var product = new List<string> { "est" }; return Permission.IsAllowToGetStats(services.UserContext, product) ? "{\"isAllowToGetStats\":true}" : "{\"isAllowToGetStats\":false}"; }
public string RemoveAllLog(string query, string body, IAppServerServices services) { /*if (string.IsNullOrEmpty(query)) return "usage: http://AppServer/Apps/SystemTest/RemoveLog?file=All|20151201"; var fileFormat = query.Split('=');*/ return WebCallsImpl.RemoveAllLog(); }
public string GetStats(string query, string body, IAppServerServices services) { var req = JObject.Parse(body); string uuid = null, mid = null, iid = null, prod = null; int testid = 0; try { uuid = (string) req["uuid"]; prod = (string) req["product"]; mid = (string) req["machineGuid"]; iid = (string) req["installGuid"]; testid = (int) req["testid"]; } catch (Exception ex) { services.Logger.LogInfo("STOpsConsole - GetStats - by UUID extract query parameter exception {0}", ex.Message); } if (testid > 0 && (string.IsNullOrEmpty(uuid) || string.IsNullOrEmpty(mid) || string.IsNullOrEmpty(iid))) { services.Logger.LogInfo("STOpsConsole - GetStats - by test id {0}", testid); } else if (string.IsNullOrEmpty(mid) && string.IsNullOrEmpty(iid)) // If request has only uuid specify, try to get the stat of the latest machine id and installation id. { services.Logger.LogInfo("STOpsConsole - GetStats - by UUID"); using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local,RouterAddresses.Local.RequestReply)) { try { var machInstReq = new MachInstInfoRequest() { uuids = new List<string> {uuid}, product = prod, filter = true }; var response = opsConsoleSvc.GetMachineInstallInfo(machInstReq); var latest = response.Items.FirstOrDefault() .machInstInfoList.OrderByDescending(y => DateTime.Parse(y.dateLastSeen)) .First(); req.Add(new JProperty("installGuid", latest.instGUID)); req.Add(new JProperty("machineGuid", latest.machGUID)); body = JsonConvert.SerializeObject(req); } catch (Exception ex) { services.Logger.LogError("STOpsConsole - GetStats:GetMachineInstallInfo - Caught exception: " + ex.Message); } } } else if (string.IsNullOrEmpty(mid) || string.IsNullOrEmpty(iid)) { services.Logger.LogWarn(string.IsNullOrEmpty(mid) ? "STOpsConsole - GetStats:GetMachineInstallInfo - machine id is null or empty" : "STOpsConsole - GetStats:GetMachineInstallInfo - installation id is null or empty"); return "{}"; } var getStatsRequest = JsonConvert.DeserializeObject<GetStatsRequest>(body); getStatsRequest.product = "est"; var product = new List<string> { "est" }; if (Permission.IsAllowToGetStats(services.UserContext, product) && Permission.IsUserInScope(services.UserContext, getStatsRequest.uuid)){ using (var opsConsoleSvc = new OpsConsoleServiceClient(RouterBindings.Local, RouterAddresses.Local.RequestReply)) { try { var response = opsConsoleSvc.GetStats(getStatsRequest); if (response == null || String.IsNullOrEmpty(response.uuid)) { return "{}"; } response.firstName = services.UserSearch.GetUserByUuid(response.uuid).FirstName; response.lastName = services.UserSearch.GetUserByUuid(response.uuid).LastName; response.email = services.UserSearch.GetUserByUuid(response.uuid).EmailAddress; return JsonConvert.SerializeObject(response); } catch (Exception ex) { services.Logger.LogError("Error while invoking GetStats: {0}", ex.Message); return "{}"; } } } else { return "{}"; } }