public virtual BqlCommand CreateUnitCostSelectCommand(bool isBaseUOM, CreateUnitCostSelectCommandOrig baseMethod) { BqlCommand command = baseMethod(isBaseUOM); if (!isBaseUOM) { command = BqlCommand.AppendJoin <InnerJoin <InventoryItem, On <InventoryItem.inventoryID, Equal <APVendorPrice.inventoryID> > > >(command); } return(command.OrderByNew(typeof(OrderBy <Desc <APVendorPrice.isPromotionalPrice, Desc <APVendorPrice.siteID, Desc <APVendorPrice.vendorID, Desc <APVendorPrice.breakQty, Asc <InventoryItem.isTemplate> > > > > >))); }
protected virtual BqlCommand GetCommand(PXCache cache, object extRow, List <object> parameters, int?calendarOrganizationID) { BqlCommand cmd = BqlCommand.CreateInstance(OrigSearchType); if (calendarOrganizationID == FinPeriod.organizationID.MasterValue && MasterPeriodBasedOnOrganizationPeriods) { cmd = BqlCommand.AppendJoin <LeftJoin <MasterFinPeriod, On <FinPeriod.masterFinPeriodID, Equal <MasterFinPeriod.finPeriodID> > > >(cmd) .AggregateNew <Aggregate <GroupBy <FinPeriod.masterFinPeriodID, GroupBy <MasterFinPeriod.startDate, GroupBy <MasterFinPeriod.endDate, GroupBy <MasterFinPeriod.noteID> > > > > >(); int?[] basisOrganizationIDs = GetCalendarOrganizationIDProvider().GetKeysWithBasisOrganizationIDs(cache.Graph, cache, extRow).ConsolidatedOrganizationIDs.ToArray(); if (basisOrganizationIDs.Any()) { cmd = cmd.WhereAnd <Where <FinPeriod.organizationID, In <Required <FinPeriod.organizationID> > > >(); parameters.Add(basisOrganizationIDs); } else { cmd = cmd.WhereAnd <Where <FinPeriod.organizationID, NotEqual <Required <FinPeriod.organizationID> > > >(); parameters.Add(calendarOrganizationID); } } else { cmd = cmd.WhereAnd <Where <FinPeriod.organizationID, Equal <Required <FinPeriod.organizationID> > > >(); parameters.Add(calendarOrganizationID); } return(cmd); }
protected override BqlCommand GetBqlCommand(BqlCommand source) { return(BqlCommand.AppendJoin <TJoin>(source)); }
public static void BuildIndex(FullTextIndexRebuildProc graph, RecordType item) { Debug.Print("Start processing {0}", item.Name); Stopwatch sw = new Stopwatch(); graph.Caches.Clear(); graph.Clear(PXClearOption.ClearAll); PXProcessing <RecordType> .SetCurrentItem(item); Type entity = GraphHelper.GetType(item.Entity); PXSearchableAttribute searchableAttribute = null; var list = graph.Caches[entity].GetAttributes("NoteID"); foreach (PXEventSubscriberAttribute att in list) { PXSearchableAttribute attribute = att as PXSearchableAttribute; if (attribute != null) { searchableAttribute = attribute; break; } } if (searchableAttribute == null) { return; } Type viewType; Type joinNote = typeof(LeftJoin <Note, On <Note.noteID, Equal <SearchIndex.noteID> > >); if (searchableAttribute.SelectForFastIndexing != null) { Type noteentity = entity; if (searchableAttribute.SelectForFastIndexing.IsGenericType) { Type[] tables = searchableAttribute.SelectForFastIndexing.GetGenericArguments(); if (tables != null && tables.Length > 0 && typeof(IBqlTable).IsAssignableFrom(tables[0])) { noteentity = tables[0]; } } Type joinSearchIndex = BqlCommand.Compose( typeof(LeftJoin <,>), typeof(SearchIndex), typeof(On <,>), typeof(SearchIndex.noteID), typeof(Equal <>), noteentity.GetNestedType("noteID")); viewType = BqlCommand.AppendJoin(searchableAttribute.SelectForFastIndexing, joinSearchIndex); viewType = BqlCommand.AppendJoin(viewType, joinNote); } else { Type joinSearchIndex = BqlCommand.Compose( typeof(LeftJoin <,>), typeof(SearchIndex), typeof(On <,>), typeof(SearchIndex.noteID), typeof(Equal <>), entity.GetNestedType("noteID")); viewType = BqlCommand.Compose(typeof(Select <>), entity); viewType = BqlCommand.AppendJoin(viewType, joinSearchIndex); viewType = BqlCommand.AppendJoin(viewType, joinNote); } BqlCommand cmd = BqlCommand.CreateInstance(viewType); PXView itemView = new PXView(graph, true, cmd); List <object> resultset; List <Type> fieldList = new List <Type>(searchableAttribute.GetSearchableFields(graph.Caches[entity])); Type entityForNoteId = entity; while (typeof(IBqlTable).IsAssignableFrom(entityForNoteId)) { Type tN = entityForNoteId.GetNestedType("noteID"); if (null != tN) { fieldList.Add(tN); } entityForNoteId = entityForNoteId.BaseType; } fieldList.Add(typeof(SearchIndex.noteID)); fieldList.Add(typeof(SearchIndex.category)); fieldList.Add(typeof(SearchIndex.content)); fieldList.Add(typeof(SearchIndex.entityType)); fieldList.Add(typeof(Note.noteID)); fieldList.Add(typeof(Note.noteText)); sw.Start(); using (new PXFieldScope(itemView, fieldList)) { resultset = itemView.SelectMulti(); } sw.Stop(); Debug.Print("{0} GetResultset in {1} sec. Total records={2}", item.DisplayName, sw.Elapsed.TotalSeconds, resultset.Count); sw.Reset(); sw.Start(); int totalcount = resultset.Count; int cx = 0; int dx = 0; try { Dictionary <Guid, SearchIndex> insertDict = new Dictionary <Guid, SearchIndex>(resultset.Count); foreach (var res in resultset) { cx++; bool isSearchable = searchableAttribute.IsSearchable(graph.Caches[entity], ((PXResult)res)[entity]); if (isSearchable) { dx++; Note note = (Note)((PXResult)res)[typeof(Note)]; SearchIndex si = searchableAttribute.BuildSearchIndex(graph.Caches[entity], ((PXResult)res)[entity], (PXResult)res, ExtractNoteText(note)); SearchIndex searchIndex = (SearchIndex)((PXResult)res)[typeof(SearchIndex)]; if (searchIndex.NoteID != null && searchIndex.NoteID != si.NoteID) { PXSearchableAttribute.Delete(si); } if (searchIndex.NoteID == null) { if (!insertDict.ContainsKey(si.NoteID.Value)) { insertDict.Add(si.NoteID.Value, si); } } else if (si.Content != searchIndex.Content || si.Category != searchIndex.Category || si.EntityType != searchIndex.EntityType) { PXSearchableAttribute.Update(si); } } } sw.Stop(); Debug.Print("{0} Content building in {1} sec. Records processed = {2}. Searchable={3}", item.DisplayName, sw.Elapsed.TotalSeconds, totalcount, dx); sw.Reset(); sw.Start(); PXSearchableAttribute.BulkInsert(insertDict.Values); sw.Stop(); Debug.Print("{0} BulkInsert in {1} sec.", item.DisplayName, sw.Elapsed.TotalSeconds); } catch (Exception ex) { string msg = string.Format("{0} out of {1} processed. {2} are searchable. Error:{3}", cx, totalcount, dx, ex.Message); throw new Exception(msg, ex); } PXProcessing <RecordType> .SetProcessed(); }
public SiteAvail2Attribute(System.Type InventoryType, System.Type SubItemType, System.Type BranchType) { this._inventoryType = InventoryType; this._subItemType = SubItemType; this._branchType = BranchType; this._Attributes[this._SelAttrIndex] = (PXEventSubscriberAttribute)SiteAvail2Attribute.CreateSelector(BqlCommand.AppendJoin <LeftJoin <PX.Objects.CR.Address, On <INSite.FK.Address> > >(SiteAvail2Attribute.Search), BqlTemplate.OfJoin <LeftJoin <INSiteStatus, On <INSiteStatus.siteID, Equal <INSite.siteID>, And <INSiteStatus.inventoryID, Equal <Optional <SiteAvail2Attribute.InventoryPh> >, And <INSiteStatus.subItemID, Equal <Optional <SiteAvail2Attribute.SubItemPh> > > > >, LeftJoin <INItemStats, On <INItemStats.inventoryID, Equal <Optional <SiteAvail2Attribute.InventoryPh> >, And <INItemStats.siteID, Equal <INSite.siteID> > > > > > .Replace <SiteAvail2Attribute.InventoryPh>(InventoryType).Replace <SiteAvail2Attribute.SubItemPh>(SubItemType).ToType(), new System.Type[4] { typeof(INSite.siteCD), typeof(INSiteStatus.qtyOnHand), typeof(INSiteStatus.active), typeof(INSite.descr) }); }