示例#1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="policyObject"></param>
        /// <param name="preDefinedConditionType"></param>
        public static void SetPreDefinedConditionType(IPolicyObject policyObject, ConditionUnitFactory.PreDefinedConditionType preDefinedConditionType)
        {
            if (preDefinedConditionType == ConditionUnitFactory.PreDefinedConditionType.Undefined)
            {
                Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                    "CONDITION_INVALID_PREDEFINED",
                    "Workshare.PolicyDesigner.Properties.Resources",
                    System.Reflection.Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new ArgumentException(errorMessage.DisplayString);

            }
            policyObject[PreDefinedConditionTypeAttribute].Value = Enum.GetName(typeof(ConditionUnitFactory.PreDefinedConditionType), preDefinedConditionType);
        }
		/// <summary>
		/// Creates a visual representation of a condition type
		/// </summary>
		/// <param name="conditionType">The condition type to display</param>
		/// <returns>A ConditionMethodDisplay object</returns>
		public static ConditionDisplayBase CreateConditionMethodDisplay(ConditionUnitFactory.PreDefinedConditionType conditionType, Workshare.Policy.PolicyType type)
		{
			switch (conditionType)
			{
			case ConditionUnitFactory.PreDefinedConditionType.ContentInFileContext:
				return new ConditionDisplayContentInFileContext(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.RegexInFileContext:
				return new ConditionDisplayRegexInFileContext(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.ContentInFileName:
				return new ConditionDisplayContentInFileName(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.RegexInFileName:
				return new ConditionDisplayRegexInFileName(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.FileSize:
				return new ConditionDisplayFileSize(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.FileType:
				return new ConditionDisplayFileType(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.HiddenDataInFile:
				return new ConditionDisplayHiddenDataInFile(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.CustomProperty:
				return new ConditionDisplayCustomProperty(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.PasswordProtectedFile:
				return new ConditionDisplayPasswordProtectedFile(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.DocumentRestrictions:
				return new ConditionDisplayDocumentRestrictions(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.PiiInFile:
				return new ConditionDisplayPiiInFile(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.FileProperty:
				return new ConditionDisplayFileProperty(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.EmbeddedEmail:
				return new ConditionDisplayEmbeddedEmail(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.EmailAdresses:
				return new ConditionDisplayEmailAddresses(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.HiddenDataInPDF:
				return new ConditionDisplayHiddenDataInPDF(null, type);
			case ConditionUnitFactory.PreDefinedConditionType.TotalAttachmentSize:
				return new ConditionDisplayTotalAttachmentSize(null, type);
			default:
				{
					Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
						"CONDITION_INVALID_PREDEFINED",
						"Workshare.PolicyDesigner.Properties.Resources",
						System.Reflection.Assembly.GetExecutingAssembly());
					Logger.LogError(errorMessage.LogString);
					throw new ArgumentException(errorMessage.DisplayString);
				}
			}
		}
		/// <summary>
		/// Displays a condition type
		/// </summary>
		/// <param name="conditionType">The condition type to display</param>
		private void DisplayConditionResource(ConditionUnitFactory.PreDefinedConditionType conditionType, Workshare.Policy.PolicyType type)
		{
			ConditionDisplayBase conditionMethodDisplay = ConditionDisplayFactory.CreateConditionMethodDisplay(conditionType, type);
			if (null != conditionMethodDisplay)
			{
				DataGridViewRow row = new DataGridViewRow();
				DataGridViewRulesBoxCell cell = new DataGridViewRulesBoxCell();
				cell.Value = conditionMethodDisplay;
				row.Cells.Add(cell);
				dataGridView1.Rows.Add(row);
			}
			else
			{
				string msg = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Unable to display condition {0}", Enum.GetName(typeof(ConditionUnitFactory.PreDefinedConditionType), conditionType));
				Logger.LogError(msg);
			}
		}
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="policyObject"></param>
 /// <param name="shortDescription"></param>
 /// <param name="longDescription"></param>
 /// <param name="riskRating"></param>
 void expressionDetailsControl_ShortDescription_Changed(object sender, ICondition condition, string shortDescription, string longDescription, ConditionUnitFactory.RiskRatingType riskRating)
 {
     if (ShortDescription_Changed != null)
     {
         ShortDescription_Changed(sender, condition, shortDescription, longDescription, riskRating);
         selectedConditionsControl1.DoValidation();
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="policyObject"></param>
 /// <param name="shortDescription"></param>
 /// <param name="longDescription"></param>
 /// <param name="riskRating"></param>
 void expressionDetailsControl_LongDescription_Changed(object sender, ICondition condition, string shortDescription, string longDescription, ConditionUnitFactory.RiskRatingType riskRating)
 {
     if (LongDescription_Changed != null)
     {
         LongDescription_Changed(sender, condition, shortDescription, longDescription, riskRating);
     }
 }
		public static string ConvertHiddenDataType(ConditionUnitFactory.FileHiddenDataType val)
		{
			if (!HiddenDataTypes.ContainsKey(val))
			{
				ArgumentException ex = new ArgumentException("Unsupported FileHiddenDataType");
				Logger.LogError(ex.Message);
				throw ex;
			}

			return HiddenDataTypes[val];
		}
		/// <summary>
		/// Returns the display name of an FileContextType
		/// </summary>
		/// <param name="fileContextType">The FileContextType to be displayed</param>
		/// <returns>The display name of the FileContextType</returns>
		public static string GetFileContextString(ConditionUnitFactory.FileContextType fileContextType)
		{
			switch (fileContextType)
			{
			case ConditionUnitFactory.FileContextType.Paragraph:
				return FileContextTypeParagraph;
			case ConditionUnitFactory.FileContextType.Header:
				return FileContextTypeHeader;
			case ConditionUnitFactory.FileContextType.Footer:
				return FileContextTypeFooter;
			case ConditionUnitFactory.FileContextType.Footnote:
				return FileContextTypeFootnote;
			case ConditionUnitFactory.FileContextType.Endnote:
				return FileContextTypeEndnote;
			case ConditionUnitFactory.FileContextType.TextBox:
				return FileContextTypeTextBox;
			case ConditionUnitFactory.FileContextType.CellText:
				return FileContextTypeCellText;
			case ConditionUnitFactory.FileContextType.CustomProperty:
				return FileContextTypeCustomProperty;
			case ConditionUnitFactory.FileContextType.Subject:
				return FileContextTypeSubject;
			case ConditionUnitFactory.FileContextType.Body:
				return FileContextTypeBody;
			case ConditionUnitFactory.FileContextType.HTTPContent:
				return FileContextTypeHttpContent;
			default:
				{
					ErrorMessage errorMessage = new ErrorMessage(
						"FILECONTEXTTYPE_UNSUPPORTED",
						"Workshare.PolicyDesigner.Properties.Resources",
						Assembly.GetExecutingAssembly());
					Logger.LogError(errorMessage.LogString);
					throw new ArgumentException(errorMessage.DisplayString);
				}
			}
		}
示例#8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="policyObject"></param>
        /// <param name="riskRating"></param>
        public static void SetRiskRating(IPolicyObject policyObject, ConditionUnitFactory.RiskRatingType riskRating)
        {
            if (riskRating == ConditionUnitFactory.RiskRatingType.Undefined)
            {
                Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                    "RISKRATING_UNDEFINED",
                    "Workshare.PolicyDesigner.Properties.Resources",
                    System.Reflection.Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new ArgumentException(errorMessage.DisplayString);
            }
            policyObject[RiskRatingAttribute].Value = Enum.GetName(typeof(ConditionUnitFactory.RiskRatingType), riskRating);
        }
		public static bool IsHiddenDataValidForFileType(ConditionUnitFactory.FileHiddenDataType hiddenDataType, List<Policy.FileType> fileTypes)
		{
			List<ConditionUnitFactory.FileHiddenDataType> hiddenData = GetHiddenDataForFileType(fileTypes);
			if (hiddenData.Contains(hiddenDataType))
			{
				return true;
			}

			return false;
		}