private static Criteria ToCriteria(MetaQuery metaQuery) { switch (metaQuery.ValueType) { case QueryValueType.String: return(new CustomMetaValueCriteria(new CustomMetaKeyCriteria(metaQuery.Field), metaQuery.Value, GetOperator(metaQuery.Operation))); case QueryValueType.Date: DateTime dateValue; if (DateTime.TryParse(metaQuery.Value, out dateValue)) { return(new CustomMetaValueCriteria(new CustomMetaKeyCriteria(metaQuery.Field), dateValue, GetOperator(metaQuery.Operation))); } break; case QueryValueType.Number: float numberValue; if (float.TryParse(metaQuery.Value, out numberValue)) { return(new CustomMetaValueCriteria(new CustomMetaKeyCriteria(metaQuery.Field), numberValue, GetOperator(metaQuery.Operation))); } break; } return(null); }
/// <summary> /// /// </summary> /// <param name="mainTableId"></param> /// <param name="preferredLang">The code ("no","en",...) of the language the client wants as main language in paxiom. May be null or empty, indicating the client dont care, in which case a "random" language is choosen.</param> /// <param name="getAllLangs"></param> /// <param name="config"></param> /// <param name="selectedDbInfo"></param> /// <param name="aModus"></param> public PXSqlMeta_24(string mainTableId, string preferredLang, bool getAllLangs, SqlDbConfig config, InfoForDbConnection selectedDbInfo, PCAxis.Sql.Parser.Instancemodus aModus, bool useTempTables) : base(config, selectedDbInfo, aModus, false) { log.Info("PXSqlMeta(string mainTableId(=" + mainTableId + "), StringCollection desiredLanguages, SqlDbConfig config, Instancemodus aModus(=" + aModus.ToString() + "))"); this.mMainTableId = mainTableId; this.mConfig = (SqlDbConfig_24)config; mMetaQuery = new MetaQuery(this.mConfig, this.SelectedDbInfo, useTempTables); SetLanguageCodesNoPxs(preferredLang, getAllLangs); BuildMeta(); }
public ICollection <Device> FilteredListUser(IBusinessLogicFacade bl) { var metaViewModel = MetaQuery.Select(i => { var deviceMeta = new DeviceMeta(); i.ApplyValues(deviceMeta); return(deviceMeta); }).ToList(); return(bl.GetFilteredDevicesUser(metaViewModel, DeviceType, Order, OrderBy, OnlyActive, IsVerwalterView) .ToList()); }
public MetaQuery GetQuery() { MetaQuery query = new MetaQuery(); if (Categories != null && Categories.Length > 0) { for (int i = 0; i < Categories.Length; i++) { query.Add(Categories[i], MetaValues.True); } } return(query); }
public PXSqlVariable(string name, PXSqlMeta_23 meta, bool isContVar, bool isTimeVar, bool isClassVar) { this.Name = name; this.IsTimevariable = isTimeVar; this.IsContentVariable = isContVar; this.IsClassificationVariable = isClassVar; this.IsStub = false; this.IsHeading = false; this.Values = new PxSqlValues(); this.PresText = new Dictionary <string, string>(); this.meta = meta; this.metaQuery = meta.MetaQuery; // should be moved to classvar this.IsEliminatedByValue = false; this.selectedValueset = PXSqlKeywords.FICTIONAL_ID_ALLVALUESETS; }
public NLPActionResult CompleteQuery(MetaQuery metaQuery) { st.Say("You entered a query against an entity"); st.Say($" {metaQuery}"); if (metaQuery.Filter == TokenExpression.True) { var entity = metaQuery.MetaEntity; st.Say("You entered a word or phrase that matches an entity (table) name " + entity.Name); st.Say("You can also enter phrases that match fields (or calculated values) for that entity"); st.Say("And AboditNLP can understad those expressions and create SQL or other database queries from them"); foreach (var field in entity.Fields) { // .TokenExpression.Type.Name st.Say($" {field.Unit?.Name ?? field.TokenExpression?.Type?.Name} : {field.TokenExpression.Serialize()}"); st.Say($" Words: {string.Join(", ", field.MetaSynSets.SelectMany(m => m.Words).Distinct())}"); } st.Say("Try asking for 'products wider than 3m'"); } else { st.Say("You can convert this query to SQL or other database query languages"); var visitor = new Abodit.Expressions.Visitor.Sql.ConvertToSqlStringVisitor <DataTable>(); var filter = visitor.Visit(metaQuery.Filter); st.Say($"Filter for this would be {filter}"); if (metaQuery.Sorts.Any()) { var sorts = metaQuery.SortsWithMetaEntitySorts.Select(sort => visitor.Visit(sort.SortExpression)) .ToList(); st.Say($"Sort order for this would be {string.Join(",", sorts)}"); } } return(NLPActionResult.None); }
public PXSqlMeta_24(PxsQuery mPxsObject, string preferredLang, SqlDbConfig config, InfoForDbConnection selectedDbInfo, PCAxis.Sql.Parser.Instancemodus aModus, bool useTempTables) : base(config, selectedDbInfo, aModus, true) { log.Debug("PXSqlMeta(PxsQuery mPxsObject, SqlDbConfig config, Instancemodus aModus"); //disse er trukket hit for å kunne kjøre med String hovedtabellId. this.mMainTableId = mPxsObject.Query.TableSource; //TODO; denne burde kunne fjernes this.mPxsSubTableId = mPxsObject.Query.SubTable; this.mConfig = (SqlDbConfig_24)config; mMetaQuery = new MetaQuery(this.mConfig, this.SelectedDbInfo, useTempTables); this.mPxsFile = this.rearrangePxsQuery(mPxsObject); SetLanguageCodesFromPxs(preferredLang); BuildMeta(); // }
/// <summary> /// Reads the values from the database. /// </summary> /// <param name="mMetaQuery">The handle of the database</param> public PXMetaAdmValues(MetaQuery mMetaQuery) { Dictionary <string, MetaAdmRow> altIBasen = mMetaQuery.GetMetaAdmAllRows(); SqlDbConfig_23 dbConfig = mMetaQuery.DB; SqlDbConfig_23.DbKeywords Keywords = dbConfig.Keywords; if (altIBasen.ContainsKey(Keywords.DataNotAvailable)) { _DataNotAvailable = altIBasen[Keywords.DataNotAvailable].Value; } else { throw new ApplicationException("Keyword:" + Keywords.DataNotAvailable + " not found in table with modelname MetaAdm."); } if (altIBasen.ContainsKey(Keywords.DataNoteSum)) { _DataNoteSum = altIBasen[Keywords.DataNoteSum].Value; } else { throw new ApplicationException("Keyword:" + Keywords.DataNoteSum + " not found in table with modelname MetaAdm."); } if (altIBasen.ContainsKey(Keywords.DataSymbolNIL)) { _DataSymbolNIL = altIBasen[Keywords.DataSymbolNIL].Value; } else { throw new ApplicationException("Keyword:" + Keywords.DataSymbolNIL + " not found in table with modelname MetaAdm."); } if (altIBasen.ContainsKey(Keywords.DataSymbolSum)) { _DataSymbolSum = altIBasen[Keywords.DataSymbolSum].Value; } else { throw new ApplicationException("Keyword:" + Keywords.DataSymbolSum + " not found in table with modelname MetaAdm."); } if (altIBasen.ContainsKey(Keywords.DefaultCodeMissingLine)) { _DefaultCodeMissingLine = altIBasen[Keywords.DefaultCodeMissingLine].Value; } else { throw new ApplicationException("Keyword:" + Keywords.DefaultCodeMissingLine + " not found in table with modelname MetaAdm."); } //Optional //PXCodepage if (Keywords.Optional_PXCodepage != null) { if (altIBasen.ContainsKey(Keywords.Optional_PXCodepage)) { _PXCodepage = altIBasen[Keywords.Optional_PXCodepage].Value; } else { throw new ApplicationException("Keyword:" + Keywords.Optional_PXCodepage + " not found in table with modelname MetaAdm."); } } //PXDescriptionDefault if (Keywords.Optional_PXDescriptionDefault != null) { if (altIBasen.ContainsKey(Keywords.Optional_PXDescriptionDefault)) { _PXDescriptionDefault = altIBasen[Keywords.Optional_PXDescriptionDefault].Value.Equals(dbConfig.Codes.Yes); } else { throw new ApplicationException("Keyword:" + Keywords.Optional_PXDescriptionDefault + " not found in table with modelname MetaAdm."); } } //AllwaysUseMaintablePrestextSInDynamicTitle if (Keywords.Optional_AllwaysUseMaintablePrestextSInDynamicTitle != null) { if (altIBasen.ContainsKey(Keywords.Optional_AllwaysUseMaintablePrestextSInDynamicTitle)) { _AllwaysUseMaintablePrestextSInDynamicTitle = altIBasen[Keywords.Optional_AllwaysUseMaintablePrestextSInDynamicTitle].Value.Equals(dbConfig.Codes.Yes); } else { throw new ApplicationException("Keyword:" + Keywords.Optional_PXDescriptionDefault + " not found in table with modelname MetaAdm."); } } //PXCharset if (Keywords.Optional_PXCharset != null) { if (altIBasen.ContainsKey(Keywords.Optional_PXCharset)) { _PXCharset = altIBasen[Keywords.Optional_PXCharset].Value; } else { throw new ApplicationException("Keyword:" + Keywords.Optional_PXCharset + " not found in table with modelname MetaAdm."); } } //PXAxisVersion if (Keywords.Optional_PXAxisVersion != null) { if (altIBasen.ContainsKey(Keywords.Optional_PXAxisVersion)) { _PXAxisVersion = altIBasen[Keywords.Optional_PXAxisVersion].Value; } else { throw new ApplicationException("Keyword:" + Keywords.Optional_PXAxisVersion + " not found in table with modelname MetaAdm."); } } }
private static async Task Main(string[] args) { // First configure the HttpClient // There are many ways to do this, but this sample takes a minimalistic approach. // This is just the minimal setup to get things going without exceptions under normal conditions. // In a real application, you would use Polly and IHttpClientFactory to add resiliency etc. using var http = new HttpClient(); // From here on out, you can create GW2SDK services, pass the HttpClient and a JSON reader object. // The default JSON reader should work fine, but can be replaced with a custom implementation. var meta = new MetaQuery(http); var build = await AnsiConsole.Status() .StartAsync( "Retrieving the current game version...", async ctx => await meta.GetBuild() ); AnsiConsole.MarkupLine($"Gw2: [white on dodgerblue2]{build.Value.Id}[/]"); var metadata = await AnsiConsole.Status() .StartAsync( "Retrieving API endpoints...", async ctx => { var v1 = await meta.GetApiVersion("v1"); var v2 = await meta.GetApiVersion(); return(v1: v1.Value, v2: v2.Value); } ); var showDisabled = AnsiConsole.Confirm("Show disabled routes?", false); var showAuthorized = AnsiConsole.Confirm("Show routes that require an account?"); var routes = new Table().MinimalBorder() .AddColumn("Route") .AddColumn("Authorization") .AddColumn("Localization"); foreach (var route in metadata.v1.Routes) { var pathTemplate = route.Active switch { false => ":no_entry: [dim bold]{0}[/]", true when Routes.IsSupported(route) => ":rocket: [bold blue]{0}[/]", _ => ":construction: {0}" }; if (route.Active || showDisabled) { routes.AddRow( string.Format(pathTemplate, route.Path.EscapeMarkup()), "⸻", route.Multilingual ? string.Join(", ", metadata.v1.Languages) : "⸻" ); } } foreach (var route in metadata.v2.Routes) { if (!showAuthorized && route.RequiresAuthorization) { continue; } var pathTemplate = route.Active switch { false => ":no_entry: [dim]{0}[/]", true when Routes.IsSupported(route) => ":rocket: [bold blue]{0}[/]", _ => ":construction: {0}" }; if (route.Active || showDisabled) { routes.AddRow( string.Format(pathTemplate, route.Path.EscapeMarkup()), route.RequiresAuthorization ? "Access token" : "⸻", route.Multilingual ? string.Join(", ", metadata.v2.Languages) : "⸻" ); } } var changes = new Table().MinimalBorder().AddColumn("Change").AddColumn("Description"); foreach (var schema in metadata.v2.SchemaVersions) { var formatted = DateTimeOffset.Parse(schema.Version).ToString("D"); changes.AddRow(formatted.EscapeMarkup(), schema.Description.EscapeMarkup()); } AnsiConsole.WriteLine( "Highlighted routes are supported by GW2SDK. Dim routes are disabled." ); AnsiConsole.Write(routes); AnsiConsole.Write(new Rule("Notable changes").LeftAligned()); AnsiConsole.Write(changes); } }
private void SetFootNotes() { /* the CNMM has many footnote types, Paxiom has fewer. * "Upgrade" from "VALUE" or from "Variable" to "Table" where possible*/ mMenuSelNotes = new PXSqlMenuSelNotes(); mMaintValueNotes = new PXSqlMainTablesValueNotes(); mValueNotes = new PXSqlValueNotes(); mContValueNotes = new PXSqlContValueNotes(); mContTimeNotes = new PXSqlContTimeNotes(); mContentsNotes = new PXSqlContentsNotes(); mContVblNotes = new PXSqlContVblNotes(); mVariableNotes = new PXSqlVariableNotes(); mCellNotes = new PXSqlCellNotes(); mPaxiomNotes = new PaxiomNotes(); if (this.MainTable.ContainsOnlyMetaData) { mPaxiomNotes.addTableNote(new PXSqlNote(this)); } foreach (RelevantFootNotesRow footNoteRow in MetaQuery.GetRelevantFoonotes(mMainTableId)) { if (!this.showFootnotesCodes.Contains(footNoteRow.ShowFootNote)) { continue; } // MainTableNotes switch (footNoteRow.FootNoteType) { case PXSqlNoteType.MainTable: SetMainTableNotes(footNoteRow); break; case PXSqlNoteType.SubTable: SetSubTableNotes(footNoteRow); break; case PXSqlNoteType.Contents: SetContentsNotes(footNoteRow); break; case PXSqlNoteType.Variable: SetVariableNotes(footNoteRow); break; case PXSqlNoteType.Value: SetValueNotes(footNoteRow); break; case PXSqlNoteType.MainTableValue: SetMaintValueNotes(footNoteRow); break; case PXSqlNoteType.ContentsVbl: SetContVblNotes(footNoteRow); break; case PXSqlNoteType.ContentsValue: SetContValueNotes(footNoteRow); break; case PXSqlNoteType.ContentsTime: SetContTimeNotes(footNoteRow); break; case PXSqlNoteType.CellNote: SetCellNotesNotes(footNoteRow); break; } } //TODO; refactor: Make new class for mVariableNotes and mContentsNotes type data #region mVariableNotes // rearranges the note according to notenumbe Dictionary <String, List <PXSqlNote> > varNotesByNoteNo = GetNotesByNoteNo(mVariableNotes); StringCollection outputVariables = this.mVariables.GetSelectedClassificationVarableIds(); foreach (String noteno in varNotesByNoteNo.Keys) { StringCollection varsWhichHasANote = new StringCollection(); foreach (PXSqlNote anote in varNotesByNoteNo[noteno]) { if (!varsWhichHasANote.Contains(anote.Variable)) { varsWhichHasANote.Add(anote.Variable); } } if (containsAll(outputVariables, varsWhichHasANote)) { mPaxiomNotes.addTableNote(varNotesByNoteNo[noteno][0]); } else { mPaxiomNotes.addVariableNotes(varNotesByNoteNo[noteno]); } } #endregion #region mContentsNotes // rearranges the note according to notenumbe Dictionary <String, List <PXSqlNote> > conentsNotesByNoteNo = GetNotesByNoteNo(mContentsNotes); StringCollection outputContentsValues = new StringCollection(); foreach (String contentsValue in this.Contents.Keys) { outputContentsValues.Add(contentsValue); } foreach (String noteno in conentsNotesByNoteNo.Keys) { StringCollection usedValues = new StringCollection(); foreach (PXSqlNote anote in conentsNotesByNoteNo[noteno]) { if (!usedValues.Contains(anote.Contents)) { usedValues.Add(anote.Contents); } } if (containsAll(outputContentsValues, usedValues)) { mPaxiomNotes.addTableNote(conentsNotesByNoteNo[noteno][0]); } else { mPaxiomNotes.addContentsNotes(conentsNotesByNoteNo[noteno]); } } #endregion }