예제 #1
0
		public string Execute(IActionData3 input, ActionPropertySet aProperties)
		{
			PDFCleanActionPropertySet cleanProperties = new PDFCleanActionPropertySet(aProperties);
			Dictionary<string, string> streamProperties = input.Properties;

			PDFCleanPropertiesDisplayTranslator strings = PDFCleanPropertiesDisplayTranslator.Instance;
			if (!streamProperties.ContainsKey(strings.StrmProp_DisplayName))
			{
				ErrorMessage errorMessage = new ErrorMessage("UNABLE_TO_GET_FILE_IN_STREAM", "Workshare.Policy.Actions.Properties.LanguageResources", Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new Exception(errorMessage.DisplayString);
			}

			if (aProperties.SystemProperties.ContainsKey(strings.SysProp_FileType))
			{
				if (!m_supportedFiles.Supports(aProperties.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.FileName, ref streamProperties, strings);
		}
예제 #2
0
		public PDFCleanUIController(PDFCleanUserControl control, PDFCleanActionPropertySet properties, string fileType)
		{
			if (!FileTypeValid(fileType))
			{
				Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage("NOT_VALID_PDF_DOC", "Workshare.Policy.Actions.Properties.LanguageResources", Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new Exception(errorMessage.DisplayString);
			}
			m_control = control;
			m_fileType = fileType;
			m_properties = properties;
			m_lowSurface = m_control.lowRiskTableLayoutPanel;
			m_medSurface = m_control.mediumRiskTableLayoutPanel;
			m_highSurface = m_control.highRiskTableLayoutPanel;
			m_internalController.ApplyToAll += m_internalController_ApplyToAll;
		}
예제 #3
0
        internal override  ActionPropertySet BuildActionProperties(string sourceFilePath)
        {
            var temp = new PDFCleanActionPropertySet();
            var result = new ActionPropertySet(temp);

            result[PDFCleanOption.Bookmarks].Value = true;
            result[PDFCleanOption.Properties].Value = true;
            result[PDFCleanOption.Attachments].Value = true;
            result[PDFCleanOption.Markups].Value = true;

            foreach (PdfMetadataType mdt in m_metadataExclusions)
            {
                string contentType = mdt.ToString();
                IActionProperty prop = null;
                if (result.TryGetValue(contentType, out prop))
                {
                    result[contentType].Value = false;
                }
            }
            
            if (!string.IsNullOrEmpty(sourceFilePath))
            {
                var fileType = ValidateFileType(sourceFilePath);
                result.SystemProperties.Add("FileType", new ActionProperty("FileType", FileTypeBridge.GetFileType(fileType)));
            }

            return result;
        }
예제 #4
0
		private void InitializeLanguageSupport()
		{
			IActionPropertySet aProperties = new PDFCleanActionPropertySet();
			string[] propertynames = new string[aProperties.Count];
			aProperties.Keys.CopyTo(propertynames, 0);
			m_languageSupport = new DotNETLanguageSupport(GetType(), "Name", propertynames, "Workshare.Policy.Actions.Properties.LanguageResources", "en-GB", new string[] { "de-DE", "ja-JP" });
		}
예제 #5
0
		private static string CallCleanThread(PDFCleanActionPropertySet cleanProperties, string input, ref Dictionary<string, string> streamProperties, PDFCleanPropertiesDisplayTranslator strings)
		{
            var password = String.Empty;    
            if (streamProperties.ContainsKey("OpenPassword"))
            {
	            password = streamProperties["OpenPassword"];
	        }
		    
            RunCleanThread(new CleanData()
                { 
                    CleanProperties = cleanProperties, 
                    File = input, 
                    OpenPassword = password 
                });

			return input;
		}
예제 #6
0
		private bool SatisfiesTargetApplication(PDFCleanActionPropertySet.TargetApplication targetApplication, string fileType)
		{
			foreach (string ft in fileType.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
			{
				switch (ft.ToLowerInvariant())
				{
				case ".pdf":
					if ((targetApplication & PDFCleanActionPropertySet.TargetApplication.PDFApp) == PDFCleanActionPropertySet.TargetApplication.PDFApp)
					{
						return true;
					}
					break;
				default:
					return false;
				}
			}
			return false;
		}