internal static ArgumentException ValidateDataClassificationParameters(OrganizationId orgId, IEnumerable <Hashtable> classifications) { if (classifications == null || classifications.Count <Hashtable>() == 0) { return(null); } ArgumentException ex = MessageContainsDataClassificationsPredicate.ValidateDataClassificationStaticParameters(classifications); if (ex != null) { return(ex); } HashSet <string> hashSet = new HashSet <string>(); foreach (Hashtable hashtable in classifications) { TargetDataClassification targetDataClassification = MessageContainsDataClassificationsPredicate.HashtableToDataClassification(hashtable); ArgumentException ex2 = MessageContainsDataClassificationsPredicate.ValidateDataClassificationParameter(targetDataClassification, hashtable); if (ex2 != null) { return(ex2); } if (!hashSet.Add(targetDataClassification.Id)) { return(new ArgumentException(RulesTasksStrings.DuplicateDataClassificationSpecified)); } } try { var source = from value in DlpUtils.QueryDataClassification(hashSet, orgId, null, null, null) select new { InvariantName = value.Name, LocalizedName = value.LocalizedName, Identity = value.Identity.ToString(), ClassificationRuleCollectionId = value.ClassificationRuleCollection.Name }; foreach (Hashtable hashtable2 in classifications) { string classificationName = (string)hashtable2["Name".ToUpper()]; var <> f__AnonymousType = source.FirstOrDefault(dataClassification => dataClassification.InvariantName == classificationName || dataClassification.LocalizedName == classificationName || string.Equals(dataClassification.Identity, classificationName, StringComparison.OrdinalIgnoreCase)); if (< > f__AnonymousType == null) { return(new ArgumentException(RulesTasksStrings.InvalidMessageDataClassification(classificationName))); } hashtable2["Name".ToUpper()] = < > f__AnonymousType.Identity; hashtable2[TargetDataClassification.OpaqueDataKey.ToUpper()] = < > f__AnonymousType.ClassificationRuleCollectionId; } } catch (ArgumentException result) { return(result); } return(null); }
internal override string GetPredicateParameters() { bool flag = true; StringBuilder stringBuilder = new StringBuilder(); List <TargetDataClassification> list = MessageContainsDataClassificationsPredicate.HashtablesToDataClassifications(this.DataClassifications).ToList <TargetDataClassification>(); Dictionary <string, string> dictionary = null; if (this.OrganizationId != null) { dictionary = DlpUtils.QueryDataClassification(from value in list select value.Id, this.OrganizationId, null, null, null).ToDictionary((DataClassificationPresentationObject k) => k.Identity.ToString(), (DataClassificationPresentationObject v) => v.Name); } foreach (TargetDataClassification targetDataClassification in list) { if (flag) { flag = false; } else { stringBuilder.Append(", "); } string input = targetDataClassification.Id; if (dictionary != null) { input = dictionary[targetDataClassification.Id]; } stringBuilder.Append(string.Format("@{{'Name'={0}; 'MinCount'={1};{2}'MinConfidence'={3}; 'MaxConfidence'={4}}}", new object[] { Utils.QuoteCmdletParameter(input), targetDataClassification.MinCount, (targetDataClassification.MaxCount > -1) ? string.Format(" 'MaxCount'={0}; ", targetDataClassification.MaxCount) : " ", targetDataClassification.MinConfidence, targetDataClassification.MaxConfidence })); } return(stringBuilder.ToString()); }
internal static IEnumerable <string> HashtablesToStrings(IEnumerable <Hashtable> parameters, OrganizationId orgId) { IEnumerable <TargetDataClassification> source = MessageContainsDataClassificationsPredicate.HashtablesToDataClassifications(parameters); if (orgId == null) { return(from classification in source select classification.ToString()); } string empty = string.Empty; IEnumerable <string> result; try { Dictionary <string, Tuple <string, string> > resolvedClassifications = DlpUtils.QueryDataClassification(from value in source select value.Id, orgId, null, null, null).ToDictionary((DataClassificationPresentationObject k) => k.Identity.ToString(), (DataClassificationPresentationObject v) => new Tuple <string, string>(v.Name, v.LocalizedName)); result = from classificationObject in source select MessageContainsDataClassificationsPredicate.FormatClassificationString(classificationObject, resolvedClassifications); } catch (KeyNotFoundException) { throw new ArgumentException(RulesTasksStrings.InvalidMessageClassification(empty)); } return(result); }