Exemplo n.º 1
0
		private static ICondition CreateFilePropertyCondition()
		{
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			// condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.FileProperty);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);

			// dataleft
			IDataMethod method = new DataMethod("FileHasProperty");

			// file parameters
			IParameter parameter = CurrentFileParameter();
			method.Parameters.Add(parameter);

			//file property name parameter
			parameter = NewParameter("filePropertyName", DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_CUSTOMPROPERTYNAME_DEFAULT);
			method.Parameters.Add(parameter);

			//file property value parameter
			IDataElement dataElement = NewDataElement("filePropertyValue", DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_CUSTOMPROPERTYVALUE_DEFAULT);
			parameter = new Parameter("filePropertyValue", dataElement);
			method.Parameters.Add(parameter);

			//  TODO: AP: Proper assembly reference
			condition.DataLeft = NewDataSourceElement("fileHasProperty", "Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.FileAttributeAnalysis", method);

			//dataright
			condition.DataRight = NewDataElement(DataType.Boolean, Boolean.TrueString);

			return condition;
		}
Exemplo n.º 2
0
		private static ICondition CreateEmbeddedEmailCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.EmbeddedEmail);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");

			//dataleft
			IDataMethod method = new DataMethod("IsEmail");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//  Data source for method
			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.EmailAnalyzer", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("propertyMatchInFileType"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("numberOfOccurrences"), new NonTranslateableLanguageItem(""), DataType.Boolean, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Boolean, true));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 3
0
		private static ICondition CreatePasswordProtectedFileCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.PasswordProtectedFile);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");

			//dataleft
			IDataMethod method = new DataMethod("CannotOpenContentInFileType");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//file types parameter
			method.Parameters.Add(CreateFileTypesParameter());

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.ContentAnalysis", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem(""), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem(""), new NonTranslateableLanguageItem(""), DataType.Boolean, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Boolean, Boolean.TrueString));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Creates a parameter for a given data source
		/// </summary>
		public static IParameter NewDataSourceParameter(string name, string assemblyName, string className, IDataMethod method)
		{
			IDataElement dataElement = NewDataSourceElement(name, assemblyName, className, method);
			IParameter parameter = new Parameter(name, dataElement);
			return parameter;
		}
Exemplo n.º 5
0
		private DataMethod BuildRegex(string regex, DataElement deContexts, DataElement currentFile, Parameter fileTypes)
		{
			DataItem diRegex = DataItem.CreateDataItem(new NonTranslateableLanguageItem(regex), DataType.String, regex);
			DataElement deRegex = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("Regex"), new NonTranslateableLanguageItem(regex), DataType.String, diRegex);

			DataMethod dmRegexLookupcount = new DataMethod("RegExLookupInFileType");
			dmRegexLookupcount.Parameters.Add(new Parameter("file", currentFile));
			dmRegexLookupcount.Parameters.Add(fileTypes);

			dmRegexLookupcount.Parameters.Add(new Parameter("regex", deRegex));

			dmRegexLookupcount.Parameters.Add(new Parameter("contexts", deContexts));
			return dmRegexLookupcount;
		}
Exemplo n.º 6
0
		/// <summary>
		/// An expression for selection based on file type containing a WSRestrictionLevel custom property. This
		/// is needed for backwards compatibility with documents worked on by older versions of our software
		/// </summary>
		/// <returns></returns>
		private static ICondition CreateDocumentRestrictionsCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.DocumentRestrictions);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");

			//dataleft
			IDataMethod method = new DataMethod("RestrictionPropertyMatchInFileType");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//file types parameter
			method.Parameters.Add(CreateFileTypesParameter());

			//custom property type parameter
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyType"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(CustomPropertyType), CustomPropertyType.Text)));
			parameter = new Parameter("customPropertyType", dataElement);
			method.Parameters.Add(parameter);

			//custom property name parameter
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyName"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, "WSRestrictionLevel"));
			parameter = new Parameter("customPropertyName", dataElement);
			method.Parameters.Add(parameter);

			//custom property value parameter
			IDataItem dataItem = DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Convert.ToString((int) DocumentRestriction.External, System.Globalization.CultureInfo.InvariantCulture));
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyValue"), new NonTranslateableLanguageItem(""), DataType.String, dataItem);
			parameter = new Parameter("customPropertyValue", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.RestrictionAnalyzer", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("propertyMatchInFileType"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("numberOfOccurrences"), new NonTranslateableLanguageItem(""), DataType.Boolean, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Boolean, true));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 7
0
		private static ICondition CreateRegexInFileContextCondition()
		{
			//file type contains regex in file context condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataLengthComparer", new TranslateableLanguageItem(""), OperatorType.GreaterThan);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.RegexInFileContext);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);

			//dataleft
			IDataMethod method = new DataMethod("RegExLookupInFileType");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//file types parameter
			method.Parameters.Add(CreateFileTypesParameter());

			//regex parameter
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("regex"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_REGEX_DEFAULT));
			parameter = new Parameter("regex", dataElement);
			method.Parameters.Add(parameter);

			//context parameter
			IPolicyObjectCollection<IDataItem> collection = new PolicyObjectCollection<IDataItem>();
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(FileContextType), FileContextType.Paragraph)));
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("context"), new NonTranslateableLanguageItem(""), DataType.StringArray, collection);
			parameter = new Parameter("context", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.ContentAnalysis", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("regexInFileContext"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("numberOfOccurrences"), new NonTranslateableLanguageItem(""), DataType.Long, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Long, 0));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 8
0
 private void CopyValue(Parameter rhs, bool readOnly, bool createNewId)
 {
     DataElement elem = rhs.Value as DataElement;
     m_value = elem.DeepCopy(readOnly, createNewId) as IDataElement;
 }
Exemplo n.º 9
0
		private static ICondition CreateHiddenDataInFileTypeCondition()
		{
			//hidden data in file type condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataLengthComparer", new TranslateableLanguageItem(""), OperatorType.GreaterThan);

			//condition attributes            
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.HiddenDataInFile);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);

			//dataleft
			IDataMethod method = new DataMethod("RegExLookupInFileType");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//file types parameter
			method.Parameters.Add(CreateFileTypesParameter());

			//content parameter - will be empty, and is not editable by the user
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("content"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, ""));
			parameter = new Parameter("", dataElement);
			method.Parameters.Add(parameter);

			//hidden data parameter
			IPolicyObjectCollection<IDataItem> collection = new PolicyObjectCollection<IDataItem>();
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(FileHiddenDataType), FileHiddenDataType.TrackChange)));
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("hidden data type"), new NonTranslateableLanguageItem(""), DataType.StringArray, collection);
			parameter = new Parameter("hidden data type", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.ContentAnalysis", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("hiddenDataInFile"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("numberOfOccurrences"), new NonTranslateableLanguageItem(""), DataType.Long, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Long, 0));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 10
0
		private static ICondition CreateTotalAttachmentSizeCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.GreaterThan);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.TotalAttachmentSize);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");

			//dataleft
			IDataMethod method = new DataMethod("TotalAttachmentSize");

			//size parameter
			IDataMethod sizeMethod = new DataMethod("TotalAttachmentSize");
			IDataSource dataSource = new DataSource("this", "this", sizeMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("size"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("size", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.FileAttributeAnalysis", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("sizeMethod"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("sizeDataElement"), new NonTranslateableLanguageItem(""), DataType.Double, DataItem.CreateDataItem(new NonTranslateableLanguageItem("size"), DataType.Double, 0));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 11
0
		private static ICondition CreateEmailAddressesCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.EmailAdresses);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");


			//data left
			IDataMethod method = new DataMethod("AddressMatch");

			//file parameter to allow filtering on types within the condition code, not actually displayed in the designer
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//source and destination
			IDataMethod destinationMethod = new DataMethod("Destination");
			dataSource = new DataSource("this", "this", destinationMethod);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("destination"), new NonTranslateableLanguageItem(""),
				DataType.Object, dataSource);
			parameter = new Parameter("destination", dataElement);
			method.Parameters.Add(parameter);

			IDataMethod sourceMethod = new DataMethod("Source");
			dataSource = new DataSource("this", "this", sourceMethod);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("source"), new NonTranslateableLanguageItem(""),
				DataType.Object, dataSource);
			parameter = new Parameter("source", dataElement);
			method.Parameters.Add(parameter);


			//addressType fields parameter
			IPolicyObjectCollection<IDataItem> collection = new PolicyObjectCollection<IDataItem>();
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(AddressTypes),
				AddressTypes.To)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(AddressTypes),
				AddressTypes.Cc)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(AddressTypes),
				AddressTypes.Bcc)));

			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("addressTypes"), new NonTranslateableLanguageItem(""), DataType.StringArray, collection);

			parameter = new Parameter("addressTypes", dataElement);
			method.Parameters.Add(parameter);


			//address parameter
			collection = new PolicyObjectCollection<IDataItem>();
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("address"), new NonTranslateableLanguageItem(Properties.Resources.IDS_EXPRESSION_CONTENTPARAM_DEFAULT), DataType.StringArray, collection);
			parameter = new Parameter("address", dataElement);
			method.Parameters.Add(parameter);



			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.EmailAnalyzer", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("emailAddresses"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("addressMatch"), new NonTranslateableLanguageItem(""), DataType.Boolean, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Boolean, Boolean.TrueString));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 12
0
		private static ICondition CreatePiiInFileCondition()
		{
			ICondition condition = new Condition(Guid.NewGuid(), "IDataLengthComparer", new TranslateableLanguageItem(""), OperatorType.GreaterThan);

			// condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.PiiInFile);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);

			// dataleft
			IDataMethod method = new DataMethod("PiiLookupInFile");

			// file parameters
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//file types parameter
			method.Parameters.Add(CreateFileTypesParameter());

			//pii parameter
			IPolicyObjectCollection<IDataItem> collection = new PolicyObjectCollection<IDataItem>();
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(PiiType), PiiType.SocialSecurityNumber)));
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("pii"), new NonTranslateableLanguageItem(""), DataType.StringArray, collection);
			parameter = new Parameter("Pii", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Conditions.PiiInspection.dll", "Workshare.Policy.Conditions.PiiInspector", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("piiInFile"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("numberOfOccurrences"), new NonTranslateableLanguageItem(""), DataType.Long, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Long, 0));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 13
0
		private Parameter BuildFileTypes()
		{
			IPolicyObjectCollection<IDataItem> collection = new PolicyObjectCollection<IDataItem>();
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem("Word (.doc)"), DataType.String, Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocument)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem("Word (.docx)"), DataType.String, Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocumentX)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem("Word (.docm)"), DataType.String, Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocumentMacroX)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem("Word (.dotx)"), DataType.String, Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocumentTemplateX)));
			collection.Add(DataItem.CreateDataItem(new NonTranslateableLanguageItem("Word (.dotm)"), DataType.String, Enum.GetName(typeof(Workshare.Policy.FileType), Workshare.Policy.FileType.WordDocumentMacroTemplateX)));
			DataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("fileTypes"), new NonTranslateableLanguageItem("Word (.doc), Word (.docx), Word (.docm), Word (.dotx), Word (.dotm)"), DataType.StringArray, collection);
			Parameter parameter = new Parameter("fileTypes", dataElement);
			return parameter;
		}
Exemplo n.º 14
0
 public Parameter(Parameter rhs, bool readOnly, bool createNewId)
     : base(rhs, readOnly, createNewId)
 {
     CopyValue(rhs, readOnly, createNewId);
 }
Exemplo n.º 15
0
		private static ICondition CreateRegexInFileNameCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataLengthComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.RegexInFileName);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);

			//dataleft
			IDataMethod method = new DataMethod("FileName");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.FileAttributeAnalysis", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("regexInFileName"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("fileNameRegex"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_REGEX_DEFAULT));
			condition.DataRight = dataElement;

			return condition;
		}
Exemplo n.º 16
0
 public override IPolicyObject DeepCopy(bool readOnly, bool createNewId)
 {
     Parameter readOnlyCopy = new Parameter(this, readOnly, createNewId);
     return readOnlyCopy;
 }
Exemplo n.º 17
0
		private static ICondition CreateCustomPropertyCondition()
		{
			//condition
			ICondition condition = new Condition(Guid.NewGuid(), "IDataComparer", new TranslateableLanguageItem(""), OperatorType.Equals);

			//condition attributes
			CustomAttributes.SetPreDefinedConditionType(condition, PreDefinedConditionType.CustomProperty);
			CustomAttributes.SetIgnore(condition, false);
			CustomAttributes.SetLongDescription(condition, "");
			CustomAttributes.SetRiskRating(condition, RiskRatingType.Medium);
			CustomAttributes.SetConditionSummary(condition, "");

			//dataleft
			IDataMethod method = new DataMethod("PropertyMatch");

			//file parameter
			IDataMethod fileMethod = new DataMethod("CurrentFile");
			IDataSource dataSource = new DataSource("this", "this", fileMethod);
			IDataElement dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("file"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			IParameter parameter = new Parameter("file", dataElement);
			method.Parameters.Add(parameter);

			//custom property type parameter
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyType"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Enum.GetName(typeof(CustomPropertyType), CustomPropertyType.Text)));
			parameter = new Parameter("customPropertyType", dataElement);
			method.Parameters.Add(parameter);

			//custom property name parameter
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyName"), new NonTranslateableLanguageItem(""), DataType.String, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_CUSTOMPROPERTYNAME_DEFAULT));
			parameter = new Parameter("customPropertyName", dataElement);
			method.Parameters.Add(parameter);

			//custom property value parameter
			IDataItem dataItem = DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.String, Properties.Resources.IDS_EXPRESSION_PARAM_CUSTOMPROPERTYVALUE_DEFAULT);
			//CustomAttributes.SetCustomPropertyType(dataItem, CustomPropertyType.Text);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem("customPropertyValue"), new NonTranslateableLanguageItem(""), DataType.String, dataItem);
			parameter = new Parameter("customPropertyValue", dataElement);
			method.Parameters.Add(parameter);

			dataSource = new DataSource("Workshare.Policy.Condition.ContentAnalysis.dll", "Workshare.Policy.Condition.CustomPropertyAnalyzer", method);
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem(""), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);
			condition.DataLeft = dataElement;

			//dataright
			dataElement = new DataElement(Guid.NewGuid(), new NonTranslateableLanguageItem(""), new NonTranslateableLanguageItem(""), DataType.Boolean, DataItem.CreateDataItem(new NonTranslateableLanguageItem(""), DataType.Boolean, Boolean.TrueString));
			condition.DataRight = dataElement;

			return condition;
		}
        public void TestParameterCopyConstructors()
        {
            IParameter parameter = ReadParameterAttributesHelper();
            Assert.AreEqual("This is my first custom property", parameter["custom1"].Value);
            Assert.AreEqual("This is my second custom property", parameter["custom2"].Value);

            Parameter parameterCopy = new Parameter(parameter.Name.Value, parameter.Value);
            Assert.AreEqual("", parameterCopy["custom1"].Value);
            Assert.AreEqual("", parameterCopy["custom2"].Value);
        }
        public void TestWriteParameterAttributes()
        {
            Guid languageId = new Guid("{CBEB31FA-7FE8-4E27-A01A-1D19AFCA604C}");
            PolicyLanguage language = new PolicyLanguage(languageId, "en");
            language[new Guid("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}")] = "Test data element";
            language[new Guid("{EBF8443B-4912-44F2-89BE-A0A055332D1B}")] = "This is my first custom property";
            language[new Guid("{8053E60C-EED7-464D-84EA-ECB51C291237}")] = "This is my second custom property";

            XmlPolicyLanguageStore languageStore = XmlPolicyLanguageStore.Instance;
            languageStore.AddLanguage(language);

            XMLPolicyCatalogueStore catalogueStore = XMLPolicyCatalogueStore.Instance;
            catalogueStore.Reset();

            Guid catalogueGuid = new Guid("{8CF1172E-476C-46A5-AECF-A7A8BC5ACE30}");
            PolicyCatalogue policyCatalogue = new PolicyCatalogue(catalogueGuid, languageId, catalogueStore);

            DataMethod dataMethod = new DataMethod("TestMethod");
            DataElement parameterDataElement = new DataElement(new TranslateableLanguageItem("A data item"), new NonTranslateableLanguageItem(""), DataType.String, "Test");
            Parameter parameter = new Parameter("Run", parameterDataElement);
            parameter["custom1"] = new TranslateableLanguageItem("{EBF8443B-4912-44F2-89BE-A0A055332D1B}");
            parameter["custom2"] = new TranslateableLanguageItem("{8053E60C-EED7-464D-84EA-ECB51C291237}");
            dataMethod.Parameters.Add(parameter);

            DataSource dataSource = new DataSource("TestMe.dll", "Test.Me", dataMethod);
            DataElement dataElement = new DataElement(new Guid("{8E915159-5F01-41B3-9FFF-20731544ADFA}"), new TranslateableLanguageItem("{B067FF7F-2DA0-4AA1-A69F-DEFCD8B4CE90}"), new NonTranslateableLanguageItem(""), DataType.Object, dataSource);

            IPolicyCatalogueWriter policyCatalogueWriter = catalogueStore.GetWriter(catalogueGuid, languageId);
            policyCatalogueWriter.WriteName("Test catalogue");
            policyCatalogueWriter.WriteDataElement(dataElement);
            policyCatalogueWriter.Close();

            TestHelpers.CompareXml(m_testPath + "ExpectedWriteParameterAttributes.xml", catalogueStore.GetXMLRepresentation(catalogueGuid));
        }