private object GetObfuscateValue(Type table, PXPersonalDataFieldAttribute field) { var tableStruct = PXDatabase.GetTableStructure(table.Name); var column = tableStruct.getColumnByName(field.FieldName); if (column.SystemType == typeof(string)) { string returnVal = field.IsKey ? Guid.NewGuid().ToString() : "*****"; return(returnVal.Substring(0, Math.Min(column.Size, returnVal.Length))); } return(column.GetDefaultValue()); }
public void ProcessImpl(IEnumerable <IBqlTable> entities, bool topLayer, Guid?topParentNoteID) { var processingGraph = PXGraph.CreateInstance <GDPRPersonalDataProcessBase>(); foreach (IBqlTable entity in entities) { var mapping = PXPersonalDataTableAttribute.GetEntitiesMapping(entity.GetType()); AddCachesIntoGraph(processingGraph, mapping.Keys); var entityCache = processingGraph.Caches[entity.GetType()]; entityCache.Current = entity; if (topLayer) { topParentNoteID = entityCache.GetValue(entity, nameof(INotable.NoteID)) as Guid?; var info = GenerateSearchInfo(processingGraph, entity); // as no wway to search -> restore if (info == null) { continue; } var combinedKey = String.Join <string>(PXAuditHelper.SEPARATOR.ToString(), entityCache.Keys.Select(_ => entityCache.GetValue(entity, _).ToString())); TopLevelProcessor(combinedKey, topParentNoteID, info); LogOperation(entity.GetType(), combinedKey); } foreach (KeyValuePair <Type, List <BqlCommand> > tableLink in mapping) { var childTable = tableLink.Key; var selects = tableLink.Value; foreach (BqlCommand select in selects) { var currentSelect = select; var bqlPseudonymizationStatus = processingGraph.Caches[childTable].GetBqlField(nameof(IPseudonymizable.PseudonymizationStatus)); if (bqlPseudonymizationStatus != null) { if (GetPseudonymizationStatus == typeof(PXPseudonymizationStatusListAttribute.notPseudonymized)) { currentSelect = currentSelect.WhereAnd(BqlCommand.Compose(typeof(Where <, ,>), bqlPseudonymizationStatus, typeof(Equal <>), GetPseudonymizationStatus, typeof(Or <,>), bqlPseudonymizationStatus, typeof(IsNull))); // for just added columns in cst } else { currentSelect = currentSelect.WhereAnd(BqlCommand.Compose(typeof(Where <,>), bqlPseudonymizationStatus, typeof(Equal <>), GetPseudonymizationStatus)); } } var view = new PXView(processingGraph, false, currentSelect); var result = view.SelectMulti(); if (result.Count == 0) { continue; } var childs = result.Select(_ => _ is PXResult ? (_ as PXResult)[0] : _); List <PXPersonalDataFieldAttribute> fields = null; var isKeyValueTable = PXPersonalDataFieldAttribute.GetPersonalDataFields(childTable, out fields); fields = fields.Where(_ => !(_ is PXPersonalDataTableAnchorAttribute)).ToList(); if (fields.Count > 0) { if (!processingGraph.Caches[childTable].Fields.Contains(nameof(INotable.NoteID)) || !processingGraph.Caches[childTable].Fields.Contains(nameof(IPseudonymizable.PseudonymizationStatus))) { continue; } if (!isKeyValueTable) { ChildLevelProcessor(processingGraph, childTable, fields, childs, topParentNoteID); } else { ChildLevelProcessor(processingGraph, childTable, fields.Where(_ => _ is PXPersonalDataFieldAttribute.Value), childs, topParentNoteID); } } ProcessImpl(childs.Cast <IBqlTable>(), false, topParentNoteID); } } } }