Пример #1
0
        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);
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
        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);
 }
Пример #5
0
 public CleanData(BinaryCleanActionPropertySet cleanProperties, TempFileForActions tempFile)
 {
     this.cleanProperties = cleanProperties;
     this.tempFile = tempFile;
 }
 public BinaryCleanStrategyProxy(BinaryCleanActionPropertySet cleanProperties)
 {
     m_cleanProperties = cleanProperties;
 }
Пример #7
0
 public virtual void RemoveMetadata(TempFileForActions tempFile, BinaryCleanActionPropertySet cleanProperties)
 {
 }