public static UnifiedPolicyForSaveDataSet CreateDataSet(object partitionId, IEnumerable <UnifiedPolicyTrace> policyTraceList, int?fssCopyId = null) { if (partitionId == null) { throw new ArgumentNullException("partitionId"); } UnifiedPolicyForSaveDataSet unifiedPolicyForSaveDataSet = UnifiedPolicyForSaveDataSet.CreateSkeletonUnifiedPolicyForSaveDataSetObject(); unifiedPolicyForSaveDataSet.PhysicalPartionId = (int)partitionId; if (fssCopyId != null) { unifiedPolicyForSaveDataSet.FssCopyId = fssCopyId; } foreach (UnifiedPolicyTrace unifiedPolicyTrace in policyTraceList) { UnifiedPolicyForSaveDataSet.SerializeObjectToDataTable <UnifiedPolicyTrace>(unifiedPolicyTrace, UnifiedPolicyDataSetSchema.UnifiedPolicyObjectTableProperty, ref unifiedPolicyForSaveDataSet); foreach (UnifiedPolicyRule unifiedPolicyRule in unifiedPolicyTrace.Rules) { UnifiedPolicyForSaveDataSet.SetCommonProperties(unifiedPolicyTrace, unifiedPolicyRule); UnifiedPolicyForSaveDataSet.SerializeObjectToDataTable <UnifiedPolicyRule>(unifiedPolicyRule, UnifiedPolicyDataSetSchema.UnifiedPolicyRuleTableProperty, ref unifiedPolicyForSaveDataSet); foreach (UnifiedPolicyRuleAction unifiedPolicyRuleAction in unifiedPolicyRule.Actions) { UnifiedPolicyForSaveDataSet.SetCommonProperties(unifiedPolicyTrace, unifiedPolicyRuleAction); UnifiedPolicyForSaveDataSet.SerializeObjectToDataTable <UnifiedPolicyRuleAction>(unifiedPolicyRuleAction, UnifiedPolicyDataSetSchema.UnifiedPolicyRuleActionTableProperty, ref unifiedPolicyForSaveDataSet); } foreach (UnifiedPolicyRuleClassification unifiedPolicyRuleClassification in unifiedPolicyRule.Classifications) { UnifiedPolicyForSaveDataSet.SetCommonProperties(unifiedPolicyTrace, unifiedPolicyRuleClassification); UnifiedPolicyForSaveDataSet.SerializeObjectToDataTable <UnifiedPolicyRuleClassification>(unifiedPolicyRuleClassification, UnifiedPolicyDataSetSchema.UnifiedPolicyRuleClassificationTableProperty, ref unifiedPolicyForSaveDataSet); } } } return(unifiedPolicyForSaveDataSet); }
private static UnifiedPolicyForSaveDataSet CreateSkeletonUnifiedPolicyForSaveDataSetObject() { UnifiedPolicyForSaveDataSet unifiedPolicyForSaveDataSet = new UnifiedPolicyForSaveDataSet(); foreach (TvpInfo tvpInfo in UnifiedPolicyForSaveDataSet.tvpPrototypeList) { unifiedPolicyForSaveDataSet[tvpInfo.TableName] = tvpInfo.Tvp.Clone(); } return(unifiedPolicyForSaveDataSet); }
private static void SerializeObjectToDataTable <T>(T source, HygienePropertyDefinition tableDefinition, ref UnifiedPolicyForSaveDataSet saveDataSet) where T : ConfigurablePropertyBag { if (source == null) { throw new ArgumentNullException("source"); } DataTable dataTable = saveDataSet[tableDefinition] as DataTable; if (dataTable == null) { throw new ArgumentNullException("table"); } HygienePropertyDefinition[] columns = UnifiedPolicyForSaveDataSet.mapTableToTvpColumnInfo[tableDefinition]; DataRow row = dataTable.NewRow(); UnifiedPolicyForSaveDataSet.PopulateRow(row, columns, source); dataTable.Rows.Add(row); }
public void Save(UnifiedPolicyTraceBatch traceBatch) { if (traceBatch == null) { throw new ArgumentNullException("traceBatch"); } IHashBucket hashBucket = this.DataProvider as IHashBucket; if (hashBucket != null) { Dictionary <object, List <UnifiedPolicyTrace> > dictionary = DalHelper.SplitByPhysicalInstance <UnifiedPolicyTrace>(hashBucket, UnifiedPolicyCommonSchema.OrganizationalUnitRootProperty, traceBatch.ToList <UnifiedPolicyTrace>(), UnifiedPolicyCommonSchema.HashBucketProperty); foreach (object obj in dictionary.Keys) { dictionary[obj].Sort(); UnifiedPolicyForSaveDataSet instance = UnifiedPolicyForSaveDataSet.CreateDataSet(obj, dictionary[obj], traceBatch.PersistentStoreCopyId); this.DataProvider.Save(instance); } } }