/// <summary> /// Get data for lookup /// </summary> /// <param name="query"></param> /// <param name="selector"></param> /// <returns></returns> public virtual JsonResult GetLookupForEntity(LookupQuery query, Func <TEntity, LookupItemVo> selector) { var queryData = _masterfileService.GetLookup(query, selector); var clientsJson = Json(queryData, JsonRequestBehavior.AllowGet); return(clientsJson); }
/// <summary> /// SQL Definitions /// </summary> /// <param name="search"></param> private void HandleSqlQuery(string search) { Connection.Open(); switch (SelectedTarget) { case Target.Item: SetGridSource(LookupQuery.FindItemsByName(search).Item1); break; case Target.Quest: SetGridSource(LookupQuery.FindQuestByName(search).Item1); break; case Target.Creature: SetGridSource(LookupQuery.FindCreatureByName(search).Item1); break; case Target.GameObject: SetGridSource(LookupQuery.FindGoByName(search).Item1); break; case Target.Spell: // Combined SQL & DBC SetGridSource(FindSpell(search)); break; default: DataGridTextColumn col = new DataGridTextColumn(); col.Header = "Error. Press a find button before searching."; dataGrid.Columns.Add(col); break; } }
public int LookupBestMatches(string a_string, ref List <ILookupQuery> a_matchList) { a_matchList.Clear(); // Perform Initial Query for Partial/Full LookupQuery query = LookupMatchIncludingPartialString(m_Root, a_string); if (query.IsValid) { if (query.IsComplete) { a_matchList.Add(query); } if (query.Node.IsLeaf() == false) { // Closest Match has children. int maxClosestDepth = 9999999; GetClosestCompleteMatchesFromChildren(query.Node, ref maxClosestDepth, ref a_matchList); } } return(a_matchList.Count); }
/// <summary> /// Build the query for lookup for searching the shortname or name, also if there is parent hierarchy lookup filter. /// For eg: filter State by CountryID or Region by StateID and CountryID. /// For standard lookup the fields are standardised and fixed therefore it is ok to use dynamic linq which is not strongly typed. /// </summary> /// <param name="query"></param> /// <returns></returns> protected virtual string BuildLookupCondition(LookupQuery query) { var where = new StringBuilder(); //if (!query.IncludeInactiveRecords) //{ // @where.Append(string.Format(" Active != false AND ")); //} @where.Append("("); var innerWhere = new List <string>(); var queryDisplayName = String.Format("{0}.Contains(\"{1}\") ", DisplayColumnForCombobox, query.Query); innerWhere.Add(queryDisplayName); @where.Append(String.Join(" OR ", innerWhere.ToArray())); @where.Append(")"); if (query.HierachyItems != null) { foreach (var parentItem in query.HierachyItems.Where(parentItem => parentItem.Value != string.Empty && parentItem.Value != "-1" && parentItem.Value != "0" && !parentItem.IgnoredFilter)) { var filterValue = parentItem.Value.Replace(",", string.Format(" OR {0} = ", parentItem.Name)); @where.Append(string.Format(" AND ( {0} = {1})", parentItem.Name, filterValue)); } } return(@where.ToString()); }
public List <DndRulebook> getRuleBooks(List <long> ids) { Console.WriteLine(string.Format("log - LookupQuery - getRuleBooks ")); LookupQuery lq = new LookupQuery(); List <DndRulebook> lookupResult = null; try { List <DndRulebook> data; // get the spell #refactor lookupResult = lq.Query_dndRuleBooks(ids).ToList(); if (lookupResult != null) { Console.WriteLine(string.Format("log - getRuleBooks - results {0}", lookupResult.Count())); return(lookupResult); } ; } catch (Exception) { throw; } return(null); }
public virtual List <LookupItemVo> GetLookup(LookupQuery query, Func <TEntity, LookupItemVo> selector) { var lookupWhere = BuildLookupCondition(query); var lookupList = GetAll().AsNoTracking().Where(lookupWhere); var currentRecord = GetAll().AsNoTracking().Where(x => x.Id == query.Id); if (!query.IncludeCurrentRecord && currentRecord.SingleOrDefault() != null) // Return single record to reduce the size of return data when first time binding. { return(currentRecord.Select(selector).ToList()); } if (!string.IsNullOrEmpty(query.Query) || !query.IncludeCurrentRecord) { currentRecord = Enumerable.Empty <TEntity>().AsQueryable(); } var lookupAnonymous = lookupList .Union(currentRecord) .OrderBy(DisplayColumnForCombobox) .Skip(0) .Take(query.Take) .Select(selector); return(lookupAnonymous.ToList()); }
public ILookupQuery LookupBestMatch(string a_string) { LookupQuery query = LookupMatchIncludingPartialString(m_Root, a_string); if (query.IsValid) { if (query.IsComplete) { return(query); } if (query.Node.IsLeaf() == false) { // Closest Match has children. int closestDepth = 9999999; Node closestNode = GetClosestCompleteMatchFromChildren(query.Node, ref closestDepth); if (closestNode != null) { return(new LookupQuery(closestNode, false, 0, 0)); } } } return(query); }
public async Task <IEnumerable <TextValue <int> > > Schools() { var request = new LookupQuery <School, int>(); var data = await mediator.Send(request); return(data); }
public bool Insert(string a_string, int a_id) { LookupQuery query = LookupMatchForInsert(m_Root, a_string); if (query.IsValid == false) { return(false); } if (query.IsPartial == false) { // Already Exists return(false); } int matchingChars = query.MatchingChars; if (query.TotalMatchingChars != 0 && matchingChars != query.Node.Value.Length) { // Partial Match within node value - Split the node string nodeValue = query.Node.Value; string prefix = nodeValue.Substring(0, matchingChars); int postfixLen = nodeValue.Length - matchingChars; string postfix = nodeValue.Substring(matchingChars, postfixLen); int nodeCompleteID = query.Node.CompleteID; query.Node.CompleteID = Node.InvalidCompleteID; query.Node.Value = prefix; query.Node.Depth = query.Node.Parent.Depth + matchingChars; // Add new split child Node newChildNode = new Node(postfix, query.Node, query.Node.Depth + postfixLen, nodeCompleteID); if (query.Node.IsLeaf() == false) // Parent has Children { // Move Previous Children to new Child for (int i = 0; i < query.Node.Children.Count; ++i) { newChildNode.Children.Add(query.Node.Children[i]); } // Clear Parents Children query.Node.Children.Clear(); } // Add new Child node query.Node.Children.Add(newChildNode); } string postFix = a_string.Substring(query.TotalMatchingChars, a_string.Length - query.TotalMatchingChars); query.Node.Children.Add(new Node(postFix, query.Node, query.Node.Depth + postFix.Length, a_id)); return(true); }
private void autoSetDisenchantBtn_Click(object sender, RoutedEventArgs e) { int deLootId = LookupQuery.GetDisenchantLootId(_item.Quality.Id, _item.MinLevel); _item.DisenchantLootId = deLootId; int skillReq = (_item.MinLevel * 5) - 25; _item.RequiredDisenchantSkill = skillReq < 0 ? 0 : skillReq; }
public ActionResult GetLookup(LookupQuery queryInfo) { var selector = new Func <User, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = CaculatorHelper.GetFullName(o.FirstName, o.MiddleName, o.LastName) }); return(base.GetLookupForEntity(queryInfo, selector)); }
public JsonResult GetLookup(LookupQuery queryInfo) { var selector = new Func <Location, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = o.Name }); return(base.GetLookupForEntity(queryInfo, selector)); }
public JsonResult GetLookup(LookupQuery queryInfo) { var selector = new Func <Courier, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = o.User != null ? Framework.Utility.CaculatorHelper.GetFullName(o.User.FirstName, o.User.MiddleName, o.User.LastName) : "" }); var result = base.GetLookupForEntity(queryInfo, selector); return(result); }
public async Task <HttpResponseMessage> Get(string indexName, [FromUri] LookupQuery lookupQuery) { var result = await _searchClient.LookupAsync(indexName, lookupQuery); if (!result.IsSuccess) { return(Request.CreateResponse(result.StatusCode, result)); } return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public async Task <IEnumerable <TextValue <int> > > Handle(LookupQuery <DTOs.School, int> request, CancellationToken cancellationToken) { var list = await ctx.School .OrderBy(a => a.Name) .Select(a => new TextValue <int> { Value = a.Id, Text = $"{a.Name} ({a.Town.Postcode} {a.Town.Name})" }) .ToListAsync(cancellationToken); return(list); }
private DataTable FindSpell(string search) { LocalSearch = true; DataTable result = new DataTable(); List <uint> listed = new List <uint>(); result.Columns.Add("ID", typeof(int)); result.Columns.Add("Name", typeof(string)); result.Columns.Add("Description", typeof(string)); // Get data DataTable dbc = DBCQuery.GetSpells(); // "m_ID", "m_name_lang_1", "m_description_lang_1" (DataTable sql, bool _) = LookupQuery.GetSpells(search); // Id, Comment(name) DataRow newRow = null; // Add DBC spells if (dbc.Rows.Count != 1 && dbc.Columns.Count != 1) // Invalid DBC config { foreach (DataRow dr in dbc.Rows) { if (dr["m_name_lang_1"].ToString().Contains(search)) { newRow = result.NewRow(); newRow["ID"] = dr["m_ID"]; newRow["Name"] = dr["m_name_lang_1"]; newRow["Description"] = dr["m_description_lang_1"]; result.Rows.Add(newRow); listed.Add((uint)dr["m_ID"]); } } } // Add unlisted SQL spells foreach (DataRow dr in sql.Rows) { if (!listed.Contains((uint)dr["Id"])) { newRow = result.NewRow(); newRow["ID"] = dr["Id"]; newRow["Name"] = dr["Comment"]; result.Rows.Add(newRow); } } FullDbcTable = result.Copy(); return(result); }
public JsonResult GetLookupForReport(LookupQuery queryInfo) { var selector = new Func <Courier, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = o.User != null ? CaculatorHelper.GetFullName(o.User.FirstName, o.User.MiddleName, o.User.LastName) : "" }); var queryData = _courierService.GetLookupForReport(queryInfo, selector); queryData.Insert(0, new LookupItemVo() { DisplayName = "Select All", KeyId = 0 }); var clientsJson = Json(queryData.OrderBy(o => o.KeyId), JsonRequestBehavior.AllowGet); return(clientsJson); }
public JsonResult GetLookupForTracking(LookupQuery queryInfo) { var selector = new Func <Courier, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = o.User != null ? Framework.Utility.CaculatorHelper.GetFullName(o.User.FirstName, o.User.MiddleName, o.User.LastName) : "" }); var queryData = _courierService.GetLookupForTracking(queryInfo, selector); queryData.Insert(0, new LookupItemVo() { DisplayName = "---All---", KeyId = 0 }); var clientsJson = Json(queryData, JsonRequestBehavior.AllowGet); return(clientsJson); }
public JsonResult GetLookupWithHeader(LookupQuery queryInfo) { var selector = new Func <Courier, LookupItemVo>(o => new LookupItemVo { KeyId = o.Id, DisplayName = o.User != null ? Framework.Utility.CaculatorHelper.GetFullName(o.User.FirstName, o.User.MiddleName, o.User.LastName) : "" }); var result = base.GetLookupForEntity(queryInfo, selector); var autoAssignItem = new LookupItemVo { KeyId = 0, DisplayName = "---Select courier---" }; ((List <LookupItemVo>)result.Data).Insert(0, autoAssignItem); return(result); }
protected override string BuildLookupCondition(LookupQuery query) { var where = new StringBuilder(); @where.Append("("); var innerWhere = new List <string>(); var queryDisplayName = String.Format("Title.Contains(\"{0}\")", query.Query); innerWhere.Add(queryDisplayName); @where.Append(String.Join(" OR ", innerWhere.ToArray())); @where.Append(")"); if (query.HierachyItems != null) { foreach (var parentItem in query.HierachyItems.Where(parentItem => parentItem.Value != string.Empty && parentItem.Value != "-1" && parentItem.Value != "0" && !parentItem.IgnoredFilter)) { var filterValue = parentItem.Value.Replace(",", string.Format(" OR {0} = ", parentItem.Name)); @where.Append(string.Format(" AND ( {0} = {1})", parentItem.Name, filterValue)); } } return(@where.ToString()); }
public TrinityItem() { EntryId = LookupQuery.GetNextId(Export.C.Item); }
public void IsOrdered_False() { Assert.False(LookupQuery.IsOrdered(new Object[0].OrderBy(model => 0).AsQueryable())); }
public TrinityQuest() { EntryId = LookupQuery.GetNextId(Export.C.Quest); CustomDisplayFields = Profile.Active.GetCustomDisplayFields(Export.C.Quest); }
public virtual List <LookupItemVo> GetLookup(LookupQuery query, Func <TEntity, LookupItemVo> selector) { var result = QueryableRepository.GetLookup(query, selector); return(result); }
public TrinityItem() { EntryId = LookupQuery.GetNextId(Export.C.Item); ValueBuy.PropertyChanged += ValueBuy_PropertyChanged; CustomDisplayFields = Profile.Active.GetCustomDisplayFields(Export.C.Item); }
public TrinityCreature() { Entry = LookupQuery.GetNextId(Export.C.Creature); CustomDisplayFields = Profile.Active.GetCustomDisplayFields(Export.C.Creature); }
public TrinityQuest() { EntryId = LookupQuery.GetNextId(Export.C.Quest); }
/// <summary> /// Lookup a document from an index. /// </summary> /// <param name="indexName"></param> /// <param name="query"></param> /// <returns></returns> public Task <IApiResponse <LookupQueryResult> > LookupAsync(string indexName, LookupQuery query) { var request = new ApiRequest("indexes/{0}/docs/" + query.Key, HttpMethod.Get); if (!String.IsNullOrEmpty(query.Select)) { request.AddQueryParameter("$select", query.Select); } return(_connection.Execute <LookupQueryResult>(request.WithUriParameter(indexName))); }
public TrinityCreature() { Entry = LookupQuery.GetNextId(Export.C.Creature); }
/// <summary> /// Get data for lookup /// </summary> /// <param name="query"></param> /// <param name="selector"></param> /// <returns></returns> public virtual IHttpActionResult GetLookupForEntity(LookupQuery query, Func <TEntity, LookupItemVo> selector) { var queryData = _masterfileService.GetLookup(query, selector); return(Ok(queryData)); }