public void GetQuery(IHqlQuery query, QueryRecord queryRecord) { var availableFilters = DescribeFilters().ToList(); foreach (var group in queryRecord.FilterGroups) { foreach (var filter in group.Filters) { var filterContext = new FilterContext() { Query = query, State = JsonConvert.DeserializeObject(filter.State) }; string category = filter.Category; string property = filter.PropertyName; var descriptor = availableFilters.FirstOrDefault(x => x.Category == category && x.Property == property); if (descriptor == null) { continue; } descriptor.Filter(filterContext); } } }
// List of QueryRecord objects that holds the mockup database entries public List <QueryRecord> InitializeList() { List <QueryRecord> result = new List <QueryRecord>(); // elements are randomly added from the data entries Random rand = new Random(); for (int i = 0; i < ROWS; i++) { QueryRecord record = new QueryRecord(); record.Clinic = clinics[rand.Next(clinics.Length)]; record.Province = provinces[rand.Next(provinces.Length)]; record.Device = devices[rand.Next(devices.Length)]; record.Date = dates[rand.Next(dates.Length)]; record.FailedPhoto = rand.NextDouble() <= FAILURE_LIKELIHOOD; // failed photos return 'N/A' bilirubin levels if (record.FailedPhoto) { record.BiliConcentration = "N/A"; } else { record.BiliConcentration = biliConcentrations[rand.Next(biliConcentrations.Length)]; } record.DeviceOS = osList[rand.Next(osList.Length)]; record.Photo = photoList[rand.Next(photoList.Length)]; result.Add(record); } return(result); }
public ActionResult PassMsg(QueryRecord data) { Connection obj = new Connection(); String query = "insert into Query(Name,Contact,Email,Msg) values('" + data.Name.ToString() + "','" + data.Contact.ToString() + "','" + data.Email.ToString() + "','" + data.Message.ToString() + "')"; obj.SqlQuery(query); return(View("PassingQuery")); }
private bool DeviceMatch(QueryRecord singleRecord) { if (!string.IsNullOrWhiteSpace(model.UserInputDevice)) { return(String.Equals(singleRecord.Device, model.UserInputDevice) || singleRecord.Device.Contains(model.UserInputDevice) || singleRecord.Device.Contains(ti.ToTitleCase(model.UserInputDevice))); } else { return(false); } }
// private helper functions for string-matching methods; each method returns partial string-matching of user input and database elements private bool ClinicMatch(QueryRecord singleRecord) { if (!string.IsNullOrWhiteSpace(model.UserInputClinic)) { return(String.Equals(singleRecord.Clinic, model.UserInputClinic) || singleRecord.Clinic.Contains(model.UserInputClinic) || singleRecord.Clinic.Contains(ti.ToTitleCase(model.UserInputClinic))); } else { return(false); } }
private bool DateMatch(QueryRecord singleRecord) { bool condition = false; string[] formats = new string[] { "M-d-yyyy", "M/d/yyyy", "MM-dd-yyyy", "MM/dd/yyyy" }; if (!string.IsNullOrWhiteSpace(model.UserInputStartDate) || !string.IsNullOrWhiteSpace(model.UserInputEndDate)) { // try-catch is necessary because date conversions cause crashes on empty/null entries try { if (DateTime.ParseExact(singleRecord.Date, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None) >= DateTime.ParseExact(model.UserInputStartDate, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None) && DateTime.ParseExact(singleRecord.Date, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None) <= DateTime.ParseExact(model.UserInputEndDate, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None)) { condition = true; } } catch { }; } return(condition); }
public int Count() { IHqlQuery hqlQuery = HqlQuery(); //hqlQuery.Where(x => x.Named("a"), y => y.Eq("UserName", "admin")); QueryRecord record = new QueryRecord(); FilterGroupRecord group = new FilterGroupRecord(); var state = new { Description = "test", Operator = "Equals", Value = "phoenix" }; group.Filters.Add(new FilterRecord() { Category = "UserEntity", PropertyName = "UserName", State = JsonConvert.SerializeObject(state) }); record.FilterGroups.Add(group); _hqlQueryManager.GetQuery(hqlQuery, record); return(hqlQuery.Count()); }
internal PromisedQuery(QueryRecord record) { _record = record; _sw = Stopwatch.StartNew(); }