protected void WipeAudit(PXGraph processingGraph, Type childTable, IEnumerable <PXPersonalDataFieldAttribute> fields, IEnumerable <object> childs) { foreach (object child in childs) { string restrict = null; foreach (string key in processingGraph.Caches[childTable].Keys) { restrict += processingGraph.Caches[childTable].GetValue(child, key).ToString() + PXAuditHelper.SEPARATOR; } restrict = restrict.TrimEnd(PXAuditHelper.SEPARATOR); List <Tuple <long, long> > modifications = new List <Tuple <long, long> >(); foreach (PXDataRecord record in PXDatabase.SelectMulti <AuditHistory>( new PXDataField <AuditHistory.batchID>(), new PXDataField <AuditHistory.changeID>(), new PXDataField <AuditHistory.modifiedFields>(), new PXDataFieldValue <AuditHistory.combinedKey>(restrict)) .Where(_ => fields.Any(field => _.GetString(2).Contains(field.FieldName)))) { modifications.Add(new Tuple <long, long>(record.GetInt64(0).Value, record.GetInt64(1).Value)); } foreach (var modification in modifications) { PXDatabase.Delete <AuditHistory>( new PXDataFieldRestrict <AuditHistory.batchID>(modification.Item1), new PXDataFieldRestrict <AuditHistory.changeID>(modification.Item2) ); } } }
private Dictionary <Guid, WZScenario> GetWizardScenarios() { Dictionary <Guid, WZScenario> result = new Dictionary <Guid, WZScenario>(); foreach (PXDataRecord record in PXDatabase.SelectMulti(typeof(WZScenario), new PXDataField <WZScenario.scenarioID>(), new PXDataField <WZScenario.nodeID>(), new PXDataField <WZScenario.name>(), new PXDataField <WZScenario.rolename>(), new PXDataField <WZScenario.status>(), new PXDataField <WZScenario.scenarioOrder>())) { WZScenario row = new WZScenario { ScenarioID = (Guid)record.GetGuid(0), NodeID = (Guid)record.GetGuid(1), Name = record.GetString(2), Rolename = record.GetString(3), Status = record.GetString(4), ScenarioOrder = record.GetInt32(5) }; result.Add((Guid)row.ScenarioID, row); } result = result.OrderBy(x => x.Value.ScenarioOrder).ToDictionary(x => x.Key, x => x.Value); return(result); }
protected virtual void ValidateINUnit(InventoryItem item) { if (item == null) { return; } using (PXDataRecord record = PXDatabase.SelectSingle <INUnit>(new PXDataField <INUnit.toUnit>(), new PXDataFieldValue <INUnit.unitType>(INUnitType.InventoryItem), new PXDataFieldValue <INUnit.inventoryID>(item.InventoryID), new PXDataFieldValue <INUnit.toUnit>(PXDbType.NVarChar, 6, item.BaseUnit, PXComp.NE))) { if (record != null) { throw new PXException(Messages.WrongInventoryItemToUnitValue, record.GetString(0), item.InventoryCD, item.BaseUnit); } } IEnumerable <PXDataRecord> baseConversions = PXDatabase.SelectMulti <INUnit>(new PXDataField <INUnit.toUnit>(), new PXDataFieldValue <INUnit.unitType>(INUnitType.InventoryItem), new PXDataFieldValue <INUnit.inventoryID>(item.InventoryID), new PXDataFieldValue <INUnit.fromUnit>(PXDbType.NVarChar, item.BaseUnit), new PXDataFieldValue <INUnit.toUnit>(PXDbType.NVarChar, item.BaseUnit)); if (baseConversions.Count() != 1) { throw new PXException(Messages.BaseConversionNotFound, item.BaseUnit, item.BaseUnit, item.InventoryCD); } }
public void Prefetch() { MultiSelectAttributes = PXDatabase.SelectMulti <CSAttribute>( new PXDataField <CSAttribute.attributeID>(), new PXDataField <CSAttribute.controlType>()) .Where(r => r.GetInt32(1) == 6) .Select(r => r.GetString(0)).ToList(); var attributesWithValues = PXDatabase.SelectMulti <CSAttributeDetail>( new PXDataField <CSAttributeDetail.attributeID>(), new PXDataField <CSAttributeDetail.valueID>(), new PXDataField <CSAttributeDetail.sortOrder>()) .Where(r => MultiSelectAttributes.Contains(r.GetString(0))) .Select(r => new CSAttributeDetail { AttributeID = r.GetString(0), ValueID = r.GetString(1), SortOrder = r.GetInt16(2) }).ToList(); AllValues = new Dictionary <string, Dictionary <string, short> >(); foreach (var attribute in MultiSelectAttributes) { Dictionary <string, short> valuesWithSortOrder = new Dictionary <string, short>(); foreach (var attributeWithValues in attributesWithValues.Where(a => a.AttributeID == attribute)) { valuesWithSortOrder[attributeWithValues.ValueID] = attributeWithValues.SortOrder ?? 0; } AllValues[attribute] = valuesWithSortOrder; } }
private void LoadTemplates(string graphTypeName) { templates.Clear(); if (!string.IsNullOrEmpty(graphTypeName)) { CRFilterTemplate currentTemplate; try { foreach (PXDataRecord item in PXDatabase.SelectMulti <CRFilterTemplate>( new PXDataField("FilterTemplateID"), new PXDataField("Name"), new PXDataFieldValue("GraphType", PXDbType.NVarChar, 255, graphTypeName, PXComp.EQ))) { currentTemplate = new CRFilterTemplate(); currentTemplate.FilterTemplateID = (int?)item["FilterTemplateID"]; currentTemplate.Name = item["Name"].ToString(); templates.Add(currentTemplate); } } catch (ExecutionEngineException) { throw; } catch (OutOfMemoryException) { throw; } catch (StackOverflowException) { throw; } catch (Exception) { templates.Clear(); } } }
public void Prefetch() { foreach (PXDataRecord record in PXDatabase.SelectMulti(typeof(AP1099Box), new PXDataField(typeof(AP1099Box.boxNbr).Name), new PXDataField(typeof(AP1099Box.descr).Name))) { AP1099Boxes[record.GetInt16(0).Value] = record.GetString(1); } }
public void Prefetch() { foreach (PXDataRecord record in PXDatabase.SelectMulti <PMCostCode>( new PXDataField <PMCostCode.costCodeID>(), new PXDataFieldValue <PMCostCode.isDefault>(true, PXComp.EQ))) { DefaultCostCodeID = record.GetInt32(0).GetValueOrDefault(); } }
private void RestoreObfuscatedEntries(PXGraph processingGraph, Type childTable, IEnumerable <PXPersonalDataFieldAttribute> fields, IEnumerable <object> childs) { foreach (object child in childs) { var entityNoteID = processingGraph.Caches[childTable].GetValue(child, nameof(INotable.NoteID)) as Guid?; List <PXDataFieldParam> assignsDB = new List <PXDataFieldParam>(); foreach (PXDataRecord record in PXDatabase.SelectMulti <SMPersonalData>( new PXDataField <SMPersonalData.field>(), new PXDataField <SMPersonalData.value>(), new PXDataFieldValue <SMPersonalData.table>(childTable.FullName), new PXDataFieldValue <SMPersonalData.entityID>(entityNoteID))) { assignsDB.Add(new PXDataFieldAssign(record.GetString(0), record.GetString(1))); } List <PXDataFieldParam> assignsEntity = new List <PXDataFieldParam>(); foreach (var field in fields) { var defaultAttr = processingGraph.Caches[childTable] .GetAttributesOfType <PXDefaultAttribute>(null, field.FieldName) ?.FirstOrDefault(); var defaultValue = field.DefaultValue ?? defaultAttr?.Constant; assignsEntity.Add(new PXDataFieldAssign(field.FieldName, defaultValue)); } assignsDB.Add(new PXDataFieldAssign(nameof(IPseudonymizable.PseudonymizationStatus), SetPseudonymizationStatus)); List <PXDataFieldParam> restricts = new List <PXDataFieldParam>(); foreach (string key in processingGraph.Caches[childTable].Keys) { restricts.Add(new PXDataFieldRestrict(key, processingGraph.Caches[childTable].GetValue(child, key))); } var isSuccess = PXDatabase.Update( childTable, InterruptRestorationHandler(processingGraph.Caches[childTable], restricts) .Union(assignsDB) .Union(assignsEntity) .Distinct(_ => _.Column.Name.ToLower()) .Union(restricts) .ToArray() ); if (isSuccess) { PXDatabase.Delete <SMPersonalData>( new PXDataFieldRestrict <SMPersonalData.table>(childTable.FullName), new PXDataFieldRestrict <SMPersonalData.entityID>(entityNoteID)); } } }
public void Prefetch() { //read database here foreach (PXDataRecord rec in PXDatabase.SelectMulti <SOSetup>( new PXDataField <SOSetup.autoReleaseIN>(), // definition for fields that system should select new PXDataField <SOSetup.useShippedNotInvoiced>() )) { //populate your collection from the database here values.Add(rec.GetBoolean(0) == true); // 0 - SOSetup.autoReleaseIN values.Add(rec.GetBoolean(1) == true); // 1 - SOSetup.useShippedNotInvoiced } }
public void Prefetch() { attributes.Clear(); foreach (PXDataRecord res in PXDatabase.SelectMulti <CSAttribute>( new PXDataField <CSAttribute.attributeID>(), new PXDataField <CSAttribute.controlType>())) { if (res.GetInt32(1) == 2) // If this Attribute's type is Combo { attributes.Add(res.GetString(0)); } } }
public void Prefetch() { foreach (PXDataRecord record in PXDatabase.SelectMulti <CSAttribute>( new PXDataField <CSAttribute.attributeID>(), new PXDataField <CSAttribute.description>(), new PXDataFieldOrder <CSAttribute.attributeID>() )) { string id = record.GetString(0); string description = record.GetString(1); IDbyDescription[description] = id; DescriptionByID[id] = description; } }
public void Prefetch() { Exchanges = new List <int>(); foreach (PXDataRecord rec in PXDatabase.SelectMulti <EMailAccount>( new PXDataField <EMailAccount.emailAccountID>( ), new PXDataFieldValue <EMailAccount.emailAccountType>(EmailAccountTypesAttribute.Exchange))) { int?id = rec.GetInt32(0); if (id.HasValue) { Exchanges.Add(id.Value); } } }
public void Prefetch() { Books = PXDatabase .SelectMulti <FABook>( new PXDataField <FABook.bookID>(), new PXDataField <FABook.bookCode>(), new PXDataField <FABook.updateGL>(), new PXDataField <FABook.description>()) .Select(row => new FABook { BookID = row.GetInt32(0), BookCode = row.GetString(1).Trim(), UpdateGL = row.GetBoolean(2), Description = row.GetString(3)?.Trim() }) .ToDictionary(book => (int)book.BookID); }
public void Prefetch() { Periods.Clear(); foreach (PXDataRecord record in PXDatabase.SelectMulti <FinPeriod>( new PXDataFieldOrder <FinPeriod.finPeriodID>(), new PXDataField <FinPeriod.startDate>(), new PXDataField <FinPeriod.endDate>())) { FinPeriod period = new FinPeriod { StartDate = record.GetDateTime(0), EndDate = record.GetDateTime(1) }; Periods.Add(period); } }
public void Prefetch() { Periods.Clear(); foreach (PXDataRecord record in PXDatabase.SelectMulti <FinPeriod>( new PXDataFieldOrder <FinPeriod.finPeriodID>(), new PXDataField <FinPeriod.startDate>(), new PXDataField <FinPeriod.endDate>(), new PXDataFieldValue <FinPeriod.organizationID>(PXDbType.Int, 4, FinPeriod.organizationID.MasterValue))) { FinPeriod period = new FinPeriod { StartDate = record.GetDateTime(0), EndDate = record.GetDateTime(1) }; Periods.Add(period); } }
public void Prefetch() { //The system will automatically call Prefetch() the first time we retrieve this class from our slot (via the GetSlot() function below) //In this example, we load some data off the DB and cache it in the dictionary, but any sort of loading/pre-computation/caching could be performed inside this function _itemCategories.Clear(); //Load category names and store into a dictionary for quick retrieval var categoryNames = new Dictionary <int?, string>(); foreach (PXDataRecord record in PXDatabase.SelectMulti <INCategory>( new PXDataField <INCategory.categoryID>(), new PXDataField <INCategory.description>())) { int? categoryID = record.GetInt32(0); string description = record.GetString(1); categoryNames.Add(categoryID, description); } //Build comma-delemited list of categories for each item foreach (PXDataRecord record in PXDatabase.SelectMulti <INItemCategory>( new PXDataField <INItemCategory.inventoryID>(), new PXDataField <INItemCategory.categoryID>())) { int?inventoryID = record.GetInt32(0); int?categoryID = record.GetInt32(1); string categoryName = String.Empty; if (categoryNames.TryGetValue(categoryID, out categoryName)) { string categoryList = String.Empty; if (!_itemCategories.TryGetValue(inventoryID, out categoryList)) { _itemCategories.Add(inventoryID, categoryName); } else { _itemCategories[inventoryID] = categoryList + ", " + categoryName; } } } }
public void Prefetch() { attributes.Clear(); foreach (PXDataRecord rec in PXDatabase.SelectMulti <CSAttributeGroup>( new PXDataField <CSAttributeGroup.attributeID>(), new PXDataField <CSAttributeGroup.entityType>(), new PXDataField <CSAttributeGroup.entityClassID>())) { if (rec.GetString(1) == KCConstants.InventoryItemEntityType) { AttributeDTO attribute = new AttributeDTO { AttributeId = rec.GetString(0), ItemClassId = int.Parse(rec.GetString(2)) }; attributes.Add(attribute); } } }
public void Prefetch() { EntitiesInUse.Clear(); using (new PXConnectionScope()) { PXDataField[] fields = GetCacheKeys <Table>().Select(key => new PXDataField(key)).ToArray(); foreach (PXDataRecord record in PXDatabase.SelectMulti <Table>(fields)) { var keys = new object[record.FieldCount]; for (var i = 0; i < keys.Length; i++) { keys[i] = record.GetValue(i); } EntitiesInUse.Add(GetHash <Table>(keys)); } } }
public void Prefetch() { Func <CSAttributeDetail, bool> func = null; MultiSelectAttributes = PXDatabase.SelectMulti <CSAttribute>(new PXDataField[] { new PXDataField <CSAttribute.attributeID>(), new PXDataField <CSAttribute.controlType>() }).Where((PXDataRecord r) => { int?num = r.GetInt32(1); return(num.GetValueOrDefault() == 6 & num.HasValue); }).Select((PXDataRecord r) => r.GetString(0)).ToList(); List <CSAttributeDetail> list = ( from r in PXDatabase.SelectMulti <CSAttributeDetail>(new PXDataField[] { new PXDataField <CSAttributeDetail.attributeID>(), new PXDataField <CSAttributeDetail.valueID>(), new PXDataField <CSAttributeDetail.sortOrder>() }) where MultiSelectAttributes.Contains(r.GetString(0)) select new CSAttributeDetail() { AttributeID = r.GetString(0), ValueID = r.GetString(1), SortOrder = r.GetInt16(2) }).ToList(); AllValues = new Dictionary <string, Dictionary <string, short> >(); foreach (string multiSelectAttribute in MultiSelectAttributes) { Dictionary <string, short> strs = new Dictionary <string, short>(); List <CSAttributeDetail> cSAttributeDetails = list; Func <CSAttributeDetail, bool> func1 = func; if (func1 == null) { Func <CSAttributeDetail, bool> attributeID = (CSAttributeDetail a) => a.AttributeID == multiSelectAttribute; Func <CSAttributeDetail, bool> func2 = attributeID; func = attributeID; func1 = func2; } foreach (CSAttributeDetail cSAttributeDetail in cSAttributeDetails.Where(func1)) { strs[cSAttributeDetail.ValueID] = cSAttributeDetail.SortOrder.GetValueOrDefault(); } AllValues[multiSelectAttribute] = strs; } }
public override void Initialize() { _count = PXDatabase.SelectMulti <Users>().Count(); }
public void Prefetch() { string emptyInventoryCD = PMInventorySelectorAttribute.EmptyComponentCD; CostBudgetUpdateMode = CostBudgetUpdateModes.Detailed; RevenueBudgetUpdateMode = CostBudgetUpdateModes.Summary; foreach (PXDataRecord record in PXDatabase.SelectMulti <PMSetup>( new PXDataField <PMSetup.visibleInAP>(), new PXDataField <PMSetup.visibleInAR>(), new PXDataField <PMSetup.visibleInCA>(), new PXDataField <PMSetup.visibleInCR>(), new PXDataField <PMSetup.visibleInEA>(), new PXDataField <PMSetup.visibleInGL>(), new PXDataField <PMSetup.visibleInIN>(), new PXDataField <PMSetup.visibleInPO>(), new PXDataField <PMSetup.visibleInSO>(), new PXDataField <PMSetup.visibleInTA>(), new PXDataField <PMSetup.emptyItemCode>(), new PXDataField <PMSetup.costBudgetUpdateMode>(), new PXDataField <PMSetup.revenueBudgetUpdateMode>())) { if (record.GetBoolean(0).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.AP); } if (record.GetBoolean(1).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.AR); } if (record.GetBoolean(2).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.CA); } if (record.GetBoolean(3).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.CR); } if (record.GetBoolean(4).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.EA); } if (record.GetBoolean(5).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.GL); } if (record.GetBoolean(6).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.IN); } if (record.GetBoolean(7).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.PO); } if (record.GetBoolean(8).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.SO); } if (record.GetBoolean(9).GetValueOrDefault() == true) { VisibleModules.Add(GL.BatchModule.TA); } emptyInventoryCD = record.GetString(10); CostBudgetUpdateMode = record.GetString(11); RevenueBudgetUpdateMode = record.GetString(12); } foreach (PXDataRecord record in PXDatabase.SelectMulti <CT.Contract>( new PXDataField <CT.Contract.contractID>(), new PXDataFieldValue <CT.Contract.nonProject>(true, PXComp.EQ))) { NonProjectID = record.GetInt32(0).GetValueOrDefault(); } foreach (PXDataRecord record in PXDatabase.SelectMulti <IN.InventoryItem>( new PXDataField <IN.InventoryItem.inventoryID>(), new PXDataFieldValue <IN.InventoryItem.inventoryCD>(emptyInventoryCD, PXComp.EQ))) { EmptyInventoryID = record.GetInt32(0).GetValueOrDefault(); } }