예제 #1
0
        private static bool IsSupportedFileType(IActionPropertySet value)
        {
            CleanPropertiesDisplayTranslator strings = CleanPropertiesDisplayTranslator.Instance;
			if (!value.SystemProperties.ContainsKey(strings.SysProp_FileType))
				throw new CleanUserActionException("The system properties could not be found.");

            if (value.SystemProperties[strings.SysProp_FileType].DataType != typeof(string))
                throw new CleanUserActionException("The system properties could not be found.");

            string fileTypeAsString = (string)value.SystemProperties[strings.SysProp_FileType].Value;
			switch (fileTypeAsString.ToLower(System.Globalization.CultureInfo.CurrentCulture))
			{
				case "worddocument":
                case "doc":
                case ".doc":
                case "excelsheet":
				case "xls":
				case ".xls":
                case "powerpoint":
				case "ppt":
				case ".ppt":
                    return true;
                default:
                    return false;
            }
        }
예제 #2
0
        public ActionData(IFile file, IActionPropertySet inputSet, OptionList options)
        {           
            m_file = file;
            m_actionProps = new ActionPropertySet(inputSet);

            IActionProperty actionPropertyName = new ActionProperty("FileName", typeof(System.String), PropertyDisplayType.Default, false, false, m_file.FileName, true);
            IActionProperty actionPropertyDisplay = new ActionProperty("DisplayName", typeof(System.String), PropertyDisplayType.Default, false, false, m_file.DisplayName, true);
            IActionProperty actionPropertyType = new ActionProperty("FileType", typeof(System.String), PropertyDisplayType.Default, false, false, FileTypeBridge.GetFileType(m_file.FileType), true);

            m_actionProps.SystemProperties["FileName"] = actionPropertyName;
            m_actionProps.SystemProperties["DisplayName"] = actionPropertyDisplay;
            m_actionProps.SystemProperties["FileType"] = actionPropertyType;

            m_properties["FileName"] = actionPropertyName.Value.ToString();
            m_properties["DisplayName"] = actionPropertyDisplay.Value.ToString();
            m_properties["FileType"] = actionPropertyType.Value.ToString();

			foreach (KeyValuePair<string, IActionProperty> prop in m_actionProps)
			{
				if (options.Contains(prop.Key))
					prop.Value.Value = options[prop.Key].Checked;
			}

			if (m_actionProps.ContainsKey("HandleFootnotesHiddenData") && options.Contains("Footnotes") && options["Footnotes"].Checked)
			{
				m_actionProps["HandleFootnotesHiddenData"].Value = true;
			}

            FileName = m_file.FileName;
        }
예제 #3
0
		private static bool IsSupportedFileType(IActionPropertySet value)
		{
			CleanPropertiesDisplayTranslator strings = CleanPropertiesDisplayTranslator.Instance;
			if (!value.SystemProperties.ContainsKey(strings.SysProp_FileType))
				throw new CleanUserActionException("The system properties could not be found.");

			if (value.SystemProperties[strings.SysProp_FileType].DataType != typeof(string))
				throw new CleanUserActionException("The system properties could not be found.");

			string[] foundTypes = ((string) value.SystemProperties[strings.SysProp_FileType].Value).Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
			foreach (string fileTypeAsString in foundTypes)
			{
				switch (fileTypeAsString.ToLower(System.Globalization.CultureInfo.CurrentCulture))
				{
				case "worddocument":
				case "doc":
				case ".doc":
				case "docx":
				case ".docx":
				case "docm":
				case ".docm":
				case "dotx":
				case ".dotx":
				case "dotm":
				case ".dotm":
				case "excelsheet":
				case "xls":
				case ".xls":
				case "xlsx":
				case ".xlsx":
				case "xlsm":
				case ".xlsm":
				case "xltx":
				case ".xltx":
				case "xltm":
				case ".xltm":
				case "powerpoint":
				case "ppt":
				case ".ppt":
				case "pptx":
				case ".pptx":
				case "pptm":
				case ".pptm":
				case "potx":
				case ".potx":
				case "potm":
				case ".potm":
				case "ppsx":
				case ".ppsx":
				case "ppsm":
				case ".ppsm":
				case ".rtf":
				case "rtf":
					break;
				default:
					return false;
				}
			}
			return true;
		}
예제 #4
0
		public Stream Execute(Stream input, IActionPropertySet properties, ref Dictionary<string, string> streamProperties)
		{
			execCount++;
			streamProperties["ExecuteCalled"] = execCount.ToString();
			streamProperties["ExecuteOnObject"] = this.GetType().FullName;
			StreamWriter sw = new StreamWriter(new MemoryStream());
			sw.WriteLine(this.GetType().FullName);
			sw.Flush();
			sw.BaseStream.Position = 0;
			return sw.BaseStream;
		}
        /// <summary>
        /// Set the resource action properties from the action properties
        /// </summary>
        /// <param name="actionProperties"></param>
        public void SetActionProperties(IActionPropertySet actionProperties)
        {
            if( actionProperties == null)
                return;

            foreach (KeyValuePair<string, IActionProperty> kvp in actionProperties)
            {
                IResourceActionProperty resourceActionProperty = new ResourceActionProperty();
                (resourceActionProperty as ResourceActionProperty).SetActionProperty(kvp.Key, kvp.Value);
                Add(resourceActionProperty);
            }
        }
예제 #6
0
		public CleanActionPropertySet(IActionPropertySet properties)
		{
			foreach (string key in properties.Keys)
			{
				Add(key, properties[key]);
			}
			foreach (string key in properties.SystemProperties.Keys)
			{
				m_systemProperties.Add(key, properties.SystemProperties[key]);
			}
			AddPropertiesToRatedLists();
		}
예제 #7
0
		internal PolicyResponseAction(ICachedAction cachedAction, string name, string description, bool isExceptionAction)
        {
            m_Action = cachedAction.Action;
            m_Precedence = cachedAction.Precedence;
            m_AllowOverride = cachedAction.AllowOverride;
            m_ActionProperties = cachedAction.Properties;
            m_Type = cachedAction.Type;
            m_isExceptionAction = isExceptionAction;
            m_Name = name;
            m_Description = description;

            m_CustomProperties.Add("ExceptionAction", m_isExceptionAction.ToString());


        }
예제 #8
0
		private static bool IsSupportedFileType(IActionPropertySet value)
		{
			PDFCleanPropertiesDisplayTranslator strings = PDFCleanPropertiesDisplayTranslator.Instance;
			if (!value.SystemProperties.ContainsKey(strings.SysProp_FileType))
				throw new Exception("The system properties could not be found.");

			if (value.SystemProperties[strings.SysProp_FileType].DataType != typeof(string))
				throw new Exception("The system properties could not be found.");

			string[] foundTypes = ((string) value.SystemProperties[strings.SysProp_FileType].Value).Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
			foreach (string fileTypeAsString in foundTypes)
			{
				switch (fileTypeAsString.ToLower(System.Globalization.CultureInfo.CurrentCulture))
				{
				case ".pdf":
				case "pdf":
					break;
				default:
					return false;
				}
			}
			return true;
		}
예제 #9
0
		public ActionPropertySet MergeProperties(ActionPropertySet[] sets)
		{
			if(sets == null)
				throw new ArgumentNullException("sets", "ActionPropertySet[] must not be null");
			IActionPropertySet[] propSets = new IActionPropertySet[sets.Length];
			for(int i = 0; i < sets.Length; i++)
			{
				propSets[i] = sets[i];
			}

			return new ActionPropertySet(actionObject.MergeProperties(propSets));
		}
		public static bool RunningInServerCtxt(IActionPropertySet set)
		{
			bool retVal = false;
			IActionProperty iap = null;

			if (set.SystemProperties.TryGetValue("RunAt", out iap))
			{
				try
				{
					retVal = RunAt.Server == (RunAt)Enum.Parse(typeof(RunAt), iap.Value.ToString(), true);
				}
				catch
				{
					retVal = false;
				}
			}

			return retVal;
		}
 public LightSpeedCleanActionPropertySet(IActionPropertySet aps)
     : base( aps )
 {
     
 }
예제 #12
0
        /// <summary>
        /// Helper to Try and set the apply to all action property in a property set
        /// </summary>
        /// <param name="propertySet">The property set to attempt the 'set' on</param>
        /// <param name="value">The value for the action property</param>
        /// <returns>true if successful, false otherwise</returns>
		private static bool TrySetApplyToAll(IActionPropertySet propertySet, bool value)
		{
			return TrySetProperty(propertySet, PropertyNames.ApplyToAll, value);
		}
예제 #13
0
		/// <summary>
		/// Helper to try and get a boolean property value
		/// </summary>
		/// <param name="propertySet">The property set to attempt the 'get' on</param>
		/// <param name="propName">The name of the property</param>
		/// <param name="defaultValue">A default value to return if the property does not exist</param>
		/// <returns>The value of the boolean property or the defaultValue</returns>
		private static bool TryGetProperty(IActionPropertySet propertySet, string propName, bool defaultValue)
		{
			IActionProperty prop;
			if (propertySet.TryGetValue(propName, out prop))
			{
				return Convert.ToBoolean(prop.Value, CultureInfo.InvariantCulture);
			}
			return defaultValue;
		}
예제 #14
0
        /// <summary>
        /// The Q. user action does not alter the input stream, but moves it to a quarantine location.
        /// </summary>
        /// <param name="input">input stream, unused</param>
        /// <param name="properties">Action properties, unused</param>
        /// <param name="streamProperties">Dictionary containing details about the name and original location of the file.</param>
        /// <returns>The stream passed in as <paramref name="input"/>, unused.</returns>
        public System.IO.Stream Execute(System.IO.Stream input, IActionPropertySet properties, ref Dictionary<string, string> streamProperties)
        {
            #region to be re-used eslewhere

			string sSourceFile = streamProperties["FileName"];

			// TODO:  This is dangerous.  This should only be allowed to proceed if sSourceFile and sTargetFile are
			//   absolute paths.  Otherwise it's likely to be attempting to move a file it's not intending to.

			string sTarget = GetTargetFile(sSourceFile);

            try
            {
                System.IO.File.Move(sSourceFile, sTarget);
                streamProperties["Quarantinefail"] = bool.FalseString;
            }
            catch (System.IO.FileNotFoundException fnfEx)
            {
                streamProperties["Quarantinefail"] = bool.TrueString;
            }
 
            #endregion

            IActionProperty quarantineFlag = properties[QuarantineActionStringTable.Quarantine];

            quarantineFlag.Value = true;

            return null;
        }
예제 #15
0
		private String ConvertToPdf(IActionData3 inputData, IActionPropertySet properties)
		{
			try
			{
				var systemProperties = properties.SystemProperties;
				IActionProperty filetypeProperty;
				if (systemProperties.TryGetValue(SystemPropertiesStringTable.SysProp_FileType, out filetypeProperty))
				{
					if (!m_supportedFileCollection.Supports(filetypeProperty.Value as string))
					{
						return null;
					}
				}

				if ((bool) properties[PdfActionStringTable.PasswordRequired].Value)
				{
					string password = properties[PdfActionStringTable.Password].Value.ToString();
					if (string.IsNullOrEmpty(password))
					{
						throw new ArgumentException(LanguageResources.ERROR_PASSWORD_REQUIRED);
					}
					if ((bool) properties[PdfActionStringTable.EnforceStrongPassword].Value && !StrongPassword.IsStrongPassword(password))
					{
						throw new ArgumentException(LanguageResources.ERROR_STRONG_PASSWORD_REQUIRED);
					}
				}

				m_fileType = filetypeProperty.Value as string;
				m_streamProperties = inputData.Properties;
				m_actionPropertySet = properties;
				m_inputFile = inputData.FileName;

				ThreadState thstate = new ThreadState();
				Thread thread = new Thread(new ParameterizedThreadStart(InternalExecute));
				thread.Name = MethodBase.GetCurrentMethod().DeclaringType.Name + "." + MethodBase.GetCurrentMethod().Name;
				thread.SetApartmentState(ApartmentState.STA);
				thread.Start(thstate);
				thread.Join();
				if (thstate.ThreadStateResult)
				{
					return m_outputFile;
				}
				if (thstate.ExceptionCaught != null)
				{
					throw thstate.ExceptionCaught;
				}
				return null;
			}
			catch (Exception e)
			{
				Logger.LogError(e);
				throw;
			}
		}
예제 #16
0
		protected virtual CleanActionPropertySet CreateActionPropertySet(IActionPropertySet aps)
		{
			return new CleanActionPropertySet(aps);
		}
예제 #17
0
		/// <summary>
		/// Returns the named action property from the given set
		/// </summary>
		/// <param name="propertySet">The set of properties to search</param>
		/// <param name="propName">The name of the desired property</param>
		/// <returns>The property if it exists; null otherwise</returns>
		private IActionProperty GetActionProperty(IActionPropertySet properties, string propName)
		{
			if (properties != null)
			{
				IActionProperty prop;
				properties.TryGetValue(propName, out prop);
				return prop;
			}
			return null;
		}
예제 #18
0
        /// <summary>
        /// Helper to try and get the Execute Action property value
        /// </summary>
        /// <param name="propertySet">The property set to attempt the 'get' on</param>
        /// <param name="defaultValue">A default value to return if the property does not exist</param>
        /// <returns>The value of the execute property or the defaultValue</returns>
        private static bool TryGetExecute(IActionPropertySet propertySet, bool defaultValue)
        {
			return TryGetProperty(propertySet, PropertyNames.Execute, defaultValue);
        }
 protected override CleanActionPropertySet CreateActionPropertySet(IActionPropertySet aps)
 {
     return new LightSpeedCleanActionPropertySet(aps);
 }
예제 #20
0
		/// <summary>
		/// Helper to try and set a boolean property in a property set, if it exists
		/// </summary>
		/// <param name="propertySet">The property set to attempt the 'set' on</param>
		/// <param name="propName">The name of the property</param>
		/// <param name="value">The new value for the property</param>
		/// <returns>True if successful, false otherwise</returns>
		private static bool TrySetProperty(IActionPropertySet propertySet, string propName, bool value)
		{
			IActionProperty prop;
			if (propertySet.TryGetValue(propName, out prop))
			{
				prop.Value = value;
				return true;
			}
			return false;
		}
예제 #21
0
        /// <summary>
        /// Helper to try and get the ApplyToAll Action property value
        /// </summary>
        /// <param name="propertySet">The property set to attempt the 'get' on</param>
        /// <param name="defaultValue">A default value to return if the property does not exist</param>
        /// <returns>The value of the ApplyToAll property or the defaultValue</returns>
		private static bool TryGetApplyToAll(IActionPropertySet propertySet, bool defaultValue)
		{
			return TryGetProperty(propertySet, PropertyNames.ApplyToAll, defaultValue);
		}
예제 #22
0
        /// <summary>
        /// Merges the filetype and all boolean properties from the source to the target property set
        /// </summary>
        /// <param name="source">The properties to merge from</param>
        /// <param name="target">The properties to merge to</param>
        /// <param name="assign">Whether to replace or merge (OR) boolean values in the target set</param>
        private static void MergePropertySets(IActionPropertySet source, IActionPropertySet target, bool assign)
        {
            IActionProperty sourceProp;
			source.SystemProperties.TryGetValue(PropertyNames.FileType, out sourceProp);
            if (sourceProp != null)
            {
                string sourceFileType = sourceProp.Value as string;
                if (!string.IsNullOrEmpty(sourceFileType))
                {
                    IActionProperty targetProp;
                    if (target.SystemProperties.TryGetValue(PropertyNames.FileType, out targetProp))
                    {
                        if (!(targetProp.Value as string).Contains(sourceFileType))
                        {
                            targetProp.Value += ";" + sourceFileType;
                        }
                    }
                    else
                    {
                        target.SystemProperties.Add(PropertyNames.FileType, sourceProp.Clone());
                    }
                }
            }

			foreach (IActionProperty property in source.Values)
			{
				IActionProperty targetProperty;
				if (!target.TryGetValue(property.DefaultDisplayName, out targetProperty))
				{
					target.Add(property.DefaultDisplayName, property.Clone());
					continue;
				}
				if (property.DataType != typeof(bool))
				{
					continue;
				}
				bool sourceValue = (bool) property.Value;
				if (assign)
				{
					targetProperty.Value = sourceValue;
				}
                else if (sourceValue)
				{
					targetProperty.Value = true;
				}
			}
        }
예제 #23
0
        /// <summary>
        /// Helper to Try and set the execute action property in a property set
        /// </summary>
        /// <param name="propertySet">The property set to attempt the 'set' on</param>
        /// <param name="value">The value for the action property</param>
        /// <returns>true if successful, false otherwise</returns>
        private static bool TrySetExecute(IActionPropertySet propertySet, bool value)
        {
			return TrySetProperty(propertySet, PropertyNames.Execute, value);
        }
예제 #24
0
        private void InitSystemPropertiesForStream(IActionPropertySet propertySet, Dictionary<string, string> props)
        {
            System.IO.FileInfo fi = new System.IO.FileInfo(props["FileName"]);

            IActionProperty actionProperty = new ActionProperty("FileType", typeof(string), PropertyDisplayType.Default, false, false, fi.Extension, true);
            propertySet.SystemProperties.Add("FileType", actionProperty);

            actionProperty = new ActionProperty("CurrentUser", typeof(string), PropertyDisplayType.Default, false, false, "test\\user", true);
            propertySet.SystemProperties.Add("CurrentUser", actionProperty);

            actionProperty = new ActionProperty("Date", typeof(string), PropertyDisplayType.Default, false, false, System.DateTime.Now.ToUniversalTime().ToString(), true);
            propertySet.SystemProperties.Add("Date", actionProperty);

            actionProperty = new ActionProperty("RecipientList", typeof(string[]), PropertyDisplayType.Default, false, false, new string[] { "*****@*****.**", "*****@*****.**" }, true);
            propertySet.SystemProperties.Add("RecipientList", actionProperty);

            actionProperty = new ActionProperty("RunAt", typeof(RunAt), PropertyDisplayType.Default, false, false, RunAt.Client, true);
            propertySet.SystemProperties.Add("RunAt", actionProperty);
        }
 public void AddActionPropertySet(IActionPropertySet actionPropertySet)
 {
     m_propertiesList.Add(new ActionPropertySet(actionPropertySet));
 }
 public BinaryCleanActionPropertySet(IActionPropertySet properties):base(properties)
 {
 }
예제 #27
0
		public IActionPropertySet MergeProperties(IActionPropertySet[] sets)
		{
			ActionPropertySet merged = new ActionPropertySet();
			merged["ThisWasMerged"] = new ActionProperty("yaya", "sisterhood");
			return merged;
		}
예제 #28
0
 public IActionPropertySet MergeProperties(IActionPropertySet[] sets)
 {
     return new QuarantineUserActionProperySet();
 }
예제 #29
0
        public void AddClientActionControl(UIContentItem contentItem)
        {
            m_contentItems.Add(contentItem);
            IActionPropertySet propertySet = contentItem.ActionPropertySet;
            ClientActionControl clientActionControl = contentItem.ClientActionControl;
            m_containsApplyToAll = true; 
            // Doctor the action property set to make the "ApplyToAll" property invisible.
            try
            {
				IActionProperty prop;
				propertySet.TryGetValue("ApplyToAll", out prop);
				ActionPropertyFacade applyToAllProperty = (ActionPropertyFacade) prop;
				if (applyToAllProperty == null)
                {
                    m_containsApplyToAll = false;
                    m_selectAllState = true;
                    m_selectAllOverride = true;
                }
                else 
                {
                    applyToAllProperty.Visible = false;
                    m_selectAllOverride = false;
					if ((applyToAllProperty.Override == false) && ((bool)applyToAllProperty.Value))
					{
						m_selectAllState = true;
						m_selectAllOverride = true;
                }
            }
			}
            catch (InvalidCastException ice)
            {
				Logger.LogError("Invalid cast: UIContentItem.PropertySet[\"ApplyToAll\"] not ActionPropertyFacade");
				Logger.LogError(ice);
            }


            // Build the APPLYTOALL ClientActionControl
            if (m_applyToAllClientActionControl == null)
            {
                // HACK: Stops us creating the UIContentItem.ClientActionControl ....
                m_applyToAllClientActionControl = m_containsApplyToAll
                                                      ? contentItem.Action.Action2.ClientActionControl
                                                      : clientActionControl;
                m_applyToAllClientActionControl.Size = new Size(350, m_applyToAllClientActionControl.Height);
                m_applyToAllClientActionControl.Dock = DockStyle.Top;
                clientActionControlContainerPanel.Controls.Add(m_applyToAllClientActionControl);
                m_applyToAllClientActionControl.ApplyToAllClicked += clientActionControl_ApplyToAllClicked;
                m_applyToAllClientActionControl.Visible = false;
                m_controls.Add(m_applyToAllClientActionControl);
            }

            if (m_containsApplyToAll)
            {
                if (m_applyToAllActionPropertySet == null)
                {
                    m_applyToAllActionPropertySet = new ActionPropertySet();
                }
                MergePropertySets(propertySet, m_applyToAllActionPropertySet, m_contentItems.Count == 0);
            }
            else
            {
                m_applyToAllActionPropertySet = propertySet;
            }
			
			// Now we have the final propertySet we can assign it.
			clientActionControl.ActionProperties = propertySet;

            // Build the APPLYTOALL Execute Checkbox
            if (m_applyToAllExecuteCheckBox == null)
            {
                m_applyToAllExecuteCheckBox = new CheckBox();
                m_applyToAllExecuteCheckBox.Text = Properties.Resources.APPLY_ACTION_TEXT;
                m_applyToAllExecuteCheckBox.Dock = DockStyle.Left;
                m_applyToAllExecuteCheckBox.AutoSize = true;
                m_applyToAllExecuteCheckBox.Name = "APPLYTOALL";
                m_applyToAllExecuteCheckBox.Visible = executePanel.Controls.Count == 0;
                m_applyToAllExecuteCheckBox.CheckedChanged += executeCheckBox_CheckedChanged;
                // Hook up the execute
                executePanel.Controls.Add(m_applyToAllExecuteCheckBox);
				IActionProperty executeProperty;
				m_applyToAllActionPropertySet.TryGetValue(PropertyNames.Execute, out executeProperty);
                if (executeProperty != null)
                {
                    ExecutePropertyController.Hook(executeProperty, m_applyToAllExecuteCheckBox, "CheckedChanged", "Checked");
                }

                m_applyToAllClientActionControl.Tag = m_applyToAllExecuteCheckBox;
                m_applyToAllExecuteCheckBox.Tag = m_applyToAllClientActionControl;
            }

            if (!m_containsApplyToAll)
                return;
            
            // Check to see if the client action control instance already exists as some of the actions
            // have implemented a singleton for the ClientActionControl. This has consequences when attempting
            // sync of ActionProperty's.
			if (m_controls.Contains(clientActionControl))
			{
				m_singleton = true;
			}
            CheckBox executeCheckBox = new CheckBox();
            executeCheckBox.Text = Properties.Resources.APPLY_ACTION_TEXT;
            executeCheckBox.Dock = DockStyle.Left;
            executeCheckBox.AutoSize = true;
            executeCheckBox.Name = contentItem.Id;
            executeCheckBox.Visible = executePanel.Controls.Count == 0;
            executeCheckBox.CheckedChanged += executeCheckBox_CheckedChanged;
            
            // Hook up the execute
            executePanel.Controls.Add(executeCheckBox);
			IActionProperty execProperty;
			propertySet.TryGetValue(PropertyNames.Execute, out execProperty);
            if (execProperty != null)
            {
                ExecutePropertyController.Hook(execProperty, executeCheckBox, "CheckedChanged", "Checked");
            }

            
            // Add client action control to the checkbox TAG
            executeCheckBox.Tag = clientActionControl;

            if (m_singleton)
                return;
            clientActionControl.Name = contentItem.Id;
            clientActionControl.Tag = executeCheckBox;
            clientActionControl.Size = new Size(350, clientActionControl.Height);
            clientActionControl.Dock = DockStyle.Top;
            clientActionControlContainerPanel.Controls.Add(clientActionControl);
            m_controls.Add(clientActionControl);
            clientActionControl.Visible = false;
            // We're only doing this here to ensure the control has a stab at setup before the initial display.  
            // For some ClientActionControl implementations this does not work as the Visible property for controls
            // is linked to Parent.Visisble and makes the control !Visible regardless of any assignment.
            
        }