public async Task <IEnumerable <QueryResult> > GetMeassurementsByCityAsync(QueryDetails details) { List <QueryResult> queryresults = new List <QueryResult>(); byte[] results = {}; UriBuilder builder = new UriBuilder($"{this.Client.BaseAddress}/measurements"); builder.Query = $"country={details.CountryCode}"; builder.Query += $"&city={details.City}"; if (details.Parameter != null) { for (int i = 0; i < details.Parameter.Length; i++) { builder.Query += $"¶meter={details.Parameter[i]}"; } } HttpResponseMessage response = await this.Client.GetAsync(builder.Uri); if (response.IsSuccessStatusCode) { results = await response.Content.ReadAsByteArrayAsync(); } queryresults = JsonUtils.ConvertToDTO <QueryResult>(results); return(queryresults); }
public ActionResult Index() { var queryDetails = new QueryDetails(); queryDetails.Username = User.Identity.Name; return(View()); }
/// <summary> /// Requests a list of servers from the Steam game master server. /// Results are returned in a <see cref="QueryCallback"/>. /// The returned <see cref="AsyncJob{T}"/> can also be awaited to retrieve the callback result. /// </summary> /// <param name="details">The details for the request.</param> /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="QueryCallback"/>.</returns> public AsyncJob <QueryCallback> ServerQuery(QueryDetails details) { if (details == null) { throw new ArgumentNullException(nameof(details)); } var query = new ClientMsgProtobuf <CMsgClientGMSServerQuery>(EMsg.ClientGMSServerQuery); query.SourceJobID = Client.GetNextJobID(); query.Body.app_id = details.AppID; if (details.GeoLocatedIP != null) { query.Body.geo_location_ip = NetHelpers.GetIPAddressAsUInt(details.GeoLocatedIP); } query.Body.filter_text = details.Filter; query.Body.region_code = ( uint )details.Region; query.Body.max_servers = details.MaxServers; this.Client.Send(query); return(new AsyncJob <QueryCallback>(this.Client, query.SourceJobID)); }
internal ParseMessage(QueryDetails queryDetails, TypeHandlerRegistry typeHandlerRegistry) : this() { Query = queryDetails.Sql; Statement = queryDetails.PreparedStatementName ?? ""; foreach (var inputParam in queryDetails.InputParameters) { inputParam.ResolveHandler(typeHandlerRegistry); ParameterTypeOIDs.Add(inputParam.Handler.OID); } }
public ActionResult GetDetails(QueryDetails queryDetails) { string responseText = string.Empty; if ("Import".Equals(queryDetails.Request, StringComparison.CurrentCultureIgnoreCase)) { responseText = ImportChecks(queryDetails.CaseId); } return(Json(responseText, JsonRequestBehavior.AllowGet)); }
public QueryDetails PrepareQuery(string countryName, string city, string[] parameters) { QueryDetails details = new QueryDetails(); var countryCode = GetCodeByCountryName(countryName); details.CountryCode = countryCode; details.City = city; details.Parameter = parameters; return(details); }
internal ParseMessage Populate(QueryDetails queryDetails, TypeHandlerRegistry typeHandlerRegistry) { _state = State.WroteNothing; ParameterTypeOIDs.Clear(); Query = queryDetails.Sql; Statement = queryDetails.PreparedStatementName ?? ""; foreach (var inputParam in queryDetails.InputParameters) { inputParam.ResolveHandler(typeHandlerRegistry); ParameterTypeOIDs.Add(inputParam.Handler.OID); } return this; }
internal ParseMessage Populate(QueryDetails queryDetails, TypeHandlerRegistry typeHandlerRegistry) { _state = State.WroteNothing; ParameterTypeOIDs.Clear(); Query = queryDetails.Sql; Statement = queryDetails.PreparedStatementName ?? ""; foreach (var inputParam in queryDetails.InputParameters) { inputParam.ResolveHandler(typeHandlerRegistry); ParameterTypeOIDs.Add(inputParam.Handler.OID); } return(this); }
public static CATALOGEntities entities() { QueryDetails qdetails = new QueryDetails(); bool uk = qdetails.IsCountryUK; if (uk) { return(new CATALOGEntities("name=CATALOGEntitiesUK")); } else { return(new CATALOGEntities("name=CATALOGEntitiesUSA")); } }
private async Task ExecuteQuery(string connectionString, QueryDetails query) { using (var cn = new SqlConnection(connectionString)) { cn.Open(); var cmd = new SqlCommand(query.Query, cn); var reader = await cmd.ExecuteReaderAsync(); var dt = new DataTable(); dt.Load(reader); this.QueryData[query.Name] = dt; } }
public IActionResult Post(QueryDetails queryDetails) { if (queryDetails == null) { BadRequest(); } var result = _elasticService.ElasticSearch(queryDetails); if (result == null) { return(StatusCode(StatusCodes.Status500InternalServerError)); } return(Ok(result)); }
public IEnumerable <ElasticDocument> ElasticSearch(QueryDetails queryDetails) { var result = _elasticClient.Search <QNA>(s => s .Index(queryDetails.Index) .Query(q => q .Match(m => m .Field("question") //.Field("answer") .Query(queryDetails.Query) ) ) ); var response = result?.Hits .Select(i => new ElasticDocument { Score = i?.Score, Answer = i?.Source?.Answer?.Trim()?.Length > 0 ? i?.Source?.Answer : noresult, Question = i?.Source?.Question, Type = i?.Source?.Type }); double?d = response.Sum(i => i.Score); double?mean = response.Sum(i => (double)i.Score) / response.Count(); response = response.Where(i => i.Score >= mean).ToList(); if (response?.Count() < 1) { response = new List <ElasticDocument> { new ElasticDocument { Score = 1, Question = noresult, Answer = noresult } }; } return(response); }
/// <summary> /// Requests a list of servers from the Steam game master server. /// Results are returned in a <see cref="QueryCallback"/>. /// </summary> /// <param name="details">The details for the request.</param> /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="QueryCallback"/>.</returns> public JobID ServerQuery( QueryDetails details ) { var query = new ClientMsgProtobuf<CMsgClientGMSServerQuery>( EMsg.ClientGMSServerQuery ); query.SourceJobID = Client.GetNextJobID(); query.Body.app_id = details.AppID; if ( details.GeoLocatedIP != null ) query.Body.geo_location_ip = NetHelpers.GetIPAddress( details.GeoLocatedIP ); query.Body.filter_text = details.Filter; query.Body.region_code = ( uint )details.Region; query.Body.max_servers = details.MaxServers; this.Client.Send( query ); return query.SourceJobID; }
public FileHeaders() { var files = System.IO.Directory.GetFiles(@".\FileDetails\"); foreach (var a in files) { var result = new QueryDetails(); var data = System.IO.File.ReadAllLines(a); result.ColumnHeader = data[0]; result.QueryFileName = data[1]; result.QueryOutputFile = data[2]; result.IsStoredProcedure = data[3]; result.ExecStoredProcedure = data[4]; queryDetails.Add(result); } }
/// <summary> /// Requests a list of servers from the Steam game master server. /// Results are returned in a <see cref="QueryCallback"/>. /// </summary> /// <param name="details">The details for the request.</param> /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="QueryCallback"/>.</returns> public JobID ServerQuery(QueryDetails details) { var query = new ClientMsgProtobuf <CMsgClientGMSServerQuery>(EMsg.ClientGMSServerQuery); query.SourceJobID = Client.GetNextJobID(); query.Body.app_id = details.AppID; if (details.GeoLocatedIP != null) { query.Body.geo_location_ip = NetHelpers.GetIPAddress(details.GeoLocatedIP); } query.Body.filter_text = details.Filter; query.Body.region_code = ( uint )details.Region; query.Body.max_servers = details.MaxServers; this.Client.Send(query); return(query.SourceJobID); }
public async Task <List <QueryResult> > ShowResults(QueryDetails details) { var queryresult = await Context_.GetMeassurementsByCityAsync(details); return(queryresult.ToList()); }
private void Build() { #region Initial-Values TimestampUtc = DateTime.Now.ToUniversalTime(); Source = new SourceDetails(Common.IpFromIpPort(_IpPort), Common.PortFromIpPort(_IpPort)); ThreadId = Thread.CurrentThread.ManagedThreadId; #endregion #region Convert-to-String-List string[] headers = _RequestHeader.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries); #endregion #region Process-Each-Line for (int i = 0; i < headers.Length; i++) { if (i == 0) { #region First-Line string[] requestLine = headers[i].Trim().Trim('\0').Split(' '); if (requestLine.Length < 3) { throw new ArgumentException("Request line does not contain at least three parts (method, raw URL, protocol/version)."); } Method = (HttpMethod)Enum.Parse(typeof(HttpMethod), requestLine[0], true); Url = new UrlDetails(requestLine[1]); Query = new QueryDetails(requestLine[1]); ProtocolVersion = requestLine[2]; #endregion } else { #region Subsequent-Line string[] headerLine = headers[i].Split(':'); if (headerLine.Length == 2) { string key = headerLine[0].Trim(); string val = headerLine[1].Trim(); if (String.IsNullOrEmpty(key)) { continue; } string keyEval = key.ToLower(); if (keyEval.Equals("keep-alive")) { Keepalive = Convert.ToBoolean(val); } else if (keyEval.Equals("user-agent")) { Useragent = val; } else if (keyEval.Equals("content-length")) { ContentLength = Convert.ToInt32(val); } else if (keyEval.Equals("content-type")) { ContentType = val; } Headers = Common.AddToDict(key, val, Headers); } #endregion } } #endregion #region Payload _DataStream = _Stream; #endregion }
/// <summary> /// HTTP request. /// Instantiate the object using an HttpListenerContext. /// </summary> /// <param name="ctx">HttpListenerContext.</param> public HttpRequest(HttpListenerContext ctx) { if (ctx == null) { throw new ArgumentNullException(nameof(ctx)); } if (ctx.Request == null) { throw new ArgumentNullException(nameof(ctx.Request)); } ListenerContext = ctx; Keepalive = ctx.Request.KeepAlive; ContentLength = ctx.Request.ContentLength64; Useragent = ctx.Request.UserAgent; ContentType = ctx.Request.ContentType; _Uri = new Uri(ctx.Request.Url.ToString().Trim()); ThreadId = Thread.CurrentThread.ManagedThreadId; TimestampUtc = DateTime.Now.ToUniversalTime(); ProtocolVersion = "HTTP/" + ctx.Request.ProtocolVersion.ToString(); Source = new SourceDetails(ctx.Request.RemoteEndPoint.Address.ToString(), ctx.Request.RemoteEndPoint.Port); Destination = new DestinationDetails(ctx.Request.LocalEndPoint.Address.ToString(), ctx.Request.LocalEndPoint.Port, _Uri.Host); Method = (HttpMethod)Enum.Parse(typeof(HttpMethod), ctx.Request.HttpMethod, true); Url = new UrlDetails(ctx.Request.Url.ToString().Trim(), ctx.Request.RawUrl.ToString().Trim()); Query = new QueryDetails(Url.Full); Headers = new Dictionary <string, string>(); for (int i = 0; i < ctx.Request.Headers.Count; i++) { string key = ctx.Request.Headers.GetKey(i); string val = ctx.Request.Headers.Get(i); Headers = AddToDict(key, val, Headers); } foreach (KeyValuePair <string, string> curr in Headers) { if (String.IsNullOrEmpty(curr.Key)) { continue; } if (String.IsNullOrEmpty(curr.Value)) { continue; } if (curr.Key.ToLower().Equals("transfer-encoding")) { if (curr.Value.ToLower().Contains("chunked")) { ChunkedTransfer = true; } if (curr.Value.ToLower().Contains("gzip")) { Gzip = true; } if (curr.Value.ToLower().Contains("deflate")) { Deflate = true; } } } Data = ctx.Request.InputStream; }
public async Task <IEnumerable <QueryResult> > GetMeassurementsByCityAsync(QueryDetails details) { var result = await _querySystem.GetMeassurementsByCityAsync(details); return(result); }
public ActionResult AjaxAdd(string appid, string targetPage, string queryId) { string[] arr = Session["UserData"] as string[]; string userid = arr[0]; object _genericObject; QueryDetails queryDetails; QueryMaster queryMaster; Comment comment; switch (targetPage) { case "QueryCommentRaised": queryDetails = new QueryDetails() { FileRefId = Guid.NewGuid().ToString(), ERApplicationId = appid }; QueryCommentViewModel QueryCommentRaised = new QueryCommentViewModel(); QueryCommentRaised.QueryDetails = queryDetails; if (arr[2] == "coordinator") { ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid) .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } else if (arr[2] == "Consultant Enhanced Recovery") { ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole == "coordinator") .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } else if (arr[2] == "operator") { ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole == "Consultant Enhanced Recovery") .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } else { ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole != "operator") .Select(d => new { ListItemKey = d.UserAccount.Id, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } _genericObject = QueryCommentRaised; break; case "QueryCommentForward": QueryCommentViewModel QueryCommentForward = new QueryCommentViewModel(); QueryDetails qd = QueryDetailsContext.Collection().Where(x => x.Id == queryId).FirstOrDefault(); queryDetails = new QueryDetails() { FileRefId = Guid.NewGuid().ToString(), ERApplicationId = appid, QueryParentId = qd.QueryParentId, }; queryMaster = new QueryMaster() { Subject = QueryMasterContext.Collection().Where(d => d.Id == qd.QueryParentId).FirstOrDefault().Subject, }; comment = new Comment() { Text = commentContext.Collection().Where(c => c.Id == qd.CommentRefId).FirstOrDefault().Text, }; QueryCommentForward.QueryDetails = queryDetails; QueryCommentForward.QueryMaster = queryMaster; QueryCommentForward.Comment = comment; QueryUser queryUser = QueryUserContext.Collection().Where(x => x.QueryId == qd.QueryParentId).FirstOrDefault(); if (arr[2] == "coordinator") { // QueryUserContext.Collection().Where(x=>x.QueryId==queryId) var qmc = QueryMasterContext.Collection().Where(e => e.ERApplicationId == appid).ToList(); var query = from p in qmc join q in qmc on p.Id equals q.QueryParentId select new { pid = p.Id, qid = q.Id }; ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccountId != queryUser.RecieverId && x.UserAccountId != queryUser.SenderId) .Select(d => new { ListItemKey = d.UserAccountId, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } else { ViewBag.ReciverList = ERAppActiveUsersContext.Collection().Where(x => x.ERApplicationId == appid && x.UserAccountId != userid && x.UserAccount.UserRole != "operator" && x.UserAccountId != queryUser.RecieverId && x.UserAccountId != queryUser.SenderId) .Select(d => new { ListItemKey = d.UserAccount.Id, ListItemValue = d.UserAccount.FirstName + " " + d.UserAccount.LastName + " (" + d.UserAccount.UserRole + ")" }).ToList(); } _genericObject = QueryCommentForward; break; case "QueryCommentReply": QueryCommentViewModel QueryCommentReply = new QueryCommentViewModel(); queryDetails = new QueryDetails() { ERApplicationId = appid, QueryParentId = QueryDetailsContext.Collection().Where(x => x.Id == queryId).Select(d => d.QueryParentId).FirstOrDefault().ToString(), FileRefId = Guid.NewGuid().ToString() }; QueryCommentReply.QueryDetails = queryDetails; _genericObject = QueryCommentReply; break; case "QueryCommentResolved": _genericObject = new QueryCommentViewModel(); break; case "ForwardApplication": ForwardAppViewModel forwardAppViewModel = new ForwardAppViewModel(); ForwardApplication forwardApplication = new ForwardApplication(); //if(arr[2]=="HoD") if (arr[2] == UserRoleType.ConsultantEnhancedRecovery.GetDisplayName()) { ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Coordinator.ToString()) && x.Id != userid) .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList(); } else if (arr[2] == UserRoleType.Coordinator.ToString()) { int CountForward = ForwardApplicationContext.Collection().Where(x => x.ERApplicationId == appid && x.Is_Active == true && x.Sender == userid && (x.FileStatus == FileStatus.ReviewAgain || x.FileStatus == FileStatus.Forward)).Count(); int CountRecommended = ForwardApplicationContext.Collection().Where(x => x.ERApplicationId == appid && x.Is_Active == true && x.Reciever == userid && x.FileStatus == FileStatus.Recommended).Count(); if (CountForward == CountRecommended && CountForward != 0 && CountRecommended != 0) { ViewBag.ReciverList = UserAccountContext.Collection().Where(x => x.UserRole == UserRoleType.DG.ToString() && x.Id != userid) .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList(); } else { ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Hod.ToString() || x.UserRole == UserRoleType.Coordinator.ToString() || x.UserRole == UserRoleType.ADG.ToString()) && x.Id != userid) .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList(); } } else { ViewBag.ReciverList = UserAccountContext.Collection().Where(x => (x.UserRole == UserRoleType.Hod.ToString() || x.UserRole == UserRoleType.Coordinator.ToString() || x.UserRole == UserRoleType.ADG.ToString()) && x.Id != userid) .Select(d => new { ListItemKey = d.Id, ListItemValue = d.FirstName + " " + d.LastName + " (" + d.UserRole + ")" }).ToList(); } forwardApplication.FileRef = Guid.NewGuid().ToString(); forwardAppViewModel.ForwardApplication = forwardApplication; _genericObject = forwardAppViewModel; break; case "UploadApprovalLetter": UploadApprovalLetterViewModel uploadApprovalLetterViewModel = new UploadApprovalLetterViewModel(); ForwardApplication forwardApplication1 = new ForwardApplication() { FileRef = Guid.NewGuid().ToString(), ERApplicationId = appid }; uploadApprovalLetterViewModel.ForwardApplication = forwardApplication1; _genericObject = uploadApprovalLetterViewModel; break; default: _genericObject = null; break; } if (null != _genericObject) { ViewBag.appid = appid; return(View(targetPage, _genericObject)); } else { return(Content("<div class=\"alert alert-danger\" role=\"alert\"> An Error has occured </div>")); } }
Task <IEnumerable <QueryResult> > IQAQuerySystem.GetMeassurementsByCityAsync(QueryDetails details) { throw new System.NotImplementedException(); }
static void ExecuteSqlCommand(string connectionString, string instanceName, QueryDetails queryDetails) { string outputFile = _baseResultPath + instanceName + "_" + queryDetails.QueryOutputFile; var sqlClient = new SqlConnection(); var sqlCommand = ReadSqlCommand(_baseScriptPath + queryDetails.QueryFileName); using (SqlConnection con = new SqlConnection( connectionString)) { var result = new List <string>(); result.Add(queryDetails.ColumnHeader); con.Open(); try { // Issue a SQL Command to the server. using (SqlCommand command = new SqlCommand( sqlCommand, con)) { var reader = command.ExecuteReader(); var columns = reader.FieldCount; while (reader.Read()) { var sb = new StringBuilder(); for (int i = 0; i < columns; i++) { switch (reader.GetFieldType(i).ToString()) { case "System.Int32": sb.Append(reader.GetInt32(i)); break; case "System.String": sb.Append(reader.GetString(i)); break; case "System.DateTime": sb.Append(reader.GetDateTime(i)); break; case "System.Single": sb.Append(reader.GetFloat(i)); break; case "System.Boolean": sb.Append(reader.GetBoolean(i)); break; case "System.Double": sb.Append(reader.GetDouble(i)); break; case "System.Int64": sb.Append(reader.GetInt64(i)); break; case "System.Decimal": sb.Append(reader.GetDecimal(i)); break; } if (i < columns - 1) { sb.Append(','); } } result.Add(sb.ToString()); } } } catch (Exception ex) { throw ex; } WriteSqlCommandOutput(outputFile, result); } }