public override Stream Execute(IActionData3 input, ActionPropertySet properties) { Dictionary<string, string> streamProperties = input.Properties; BinaryCleanActionPropertySet cleanProperties = new BinaryCleanActionPropertySet(properties); CleanPropertiesDisplayTranslator strings = CleanPropertiesDisplayTranslator.Instance; if (!streamProperties.ContainsKey(strings.StrmProp_DisplayName)) { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage("UNABLE_TO_GET_FILE_IN_STREAM", "Workshare.Policy.Actions.Properties.LanguageResources", Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); throw new CleanUserActionException(errorMessage.DisplayString); } if (properties.SystemProperties.ContainsKey(strings.SysProp_FileType)) { if (!m_supportedFiles.Supports(properties.SystemProperties[strings.SysProp_FileType].Value as string)) { Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage("UNABLE_TO_CLEAN_NON_SUPPORTED_FILETYPE", "Workshare.Policy.Actions.Properties.LanguageResources", Assembly.GetExecutingAssembly()); Logger.LogError(errorMessage.LogString); return null; } } return CallCleanThread(cleanProperties, input.Content, ref streamProperties, strings); }
private Stream CallCleanThread(BinaryCleanActionPropertySet cleanProperties, Stream input, ref Dictionary<string, string> streamProperties, CleanPropertiesDisplayTranslator strings) { string filename = streamProperties[strings.StrmProp_DisplayName]; using (TempFileForActions tempFile = new TempFileForActions(System.IO.Path.GetFileName(filename), input)) { CleanData cleanData = new CleanData(cleanProperties, tempFile); Thread staThread = new Thread(new ParameterizedThreadStart(DoClean)); staThread.SetApartmentState(ApartmentState.STA); staThread.Start(cleanData); staThread.Join(); if (cleanData.ex != null) throw cleanData.ex; input.Dispose(); // Clean it out of memory return tempFile.GetMemoryStream(); } }
protected static List<ContentType> GetListOfEnabledElementsToClean(BinaryCleanActionPropertySet elementsToClean) { Dictionary<ContentType, string> fcsContentTypeDict = elementsToClean.GetFCSContentTypeDict(); List<ContentType> elements = new List<ContentType>(); elements.Add(ContentType.ContentRule);//we need this for multiple types to work correctly in cleaning foreach (KeyValuePair<string, IActionProperty> outerKvp in elementsToClean) { IActionProperty property = outerKvp.Value; foreach (KeyValuePair<ContentType, string> internalKvp in fcsContentTypeDict) { if (String.Compare(internalKvp.Value, outerKvp.Key, true, System.Globalization.CultureInfo.InvariantCulture) == 0 && ((bool)property.Value) == true && !elements.Contains(internalKvp.Key)) { elements.Add(internalKvp.Key); } } } return elements; }
public override void RemoveMetadata(TempFileForActions tempFile, BinaryCleanActionPropertySet cleanProperties) { List<ContentType> listContentTypes = GetListOfEnabledElementsToClean(cleanProperties); CleanFile(tempFile.TempFile, listContentTypes); }
public CleanData(BinaryCleanActionPropertySet cleanProperties, TempFileForActions tempFile) { this.cleanProperties = cleanProperties; this.tempFile = tempFile; }
public BinaryCleanStrategyProxy(BinaryCleanActionPropertySet cleanProperties) { m_cleanProperties = cleanProperties; }
public virtual void RemoveMetadata(TempFileForActions tempFile, BinaryCleanActionPropertySet cleanProperties) { }