protected static List<ContentType> GetListOfEnabledElementsToClean(CleanActionPropertySet 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) &&
                        !elements.Contains(internalKvp.Key))
                    {
                        elements.Add(internalKvp.Key);
                    }
                }
            }
            return elements;
        }
Esempio n. 2
0
		protected List<ContentType> GetListOfEnabledElementsToClean(CleanActionPropertySet 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;
                bool enabled;
                if (bool.TryParse(property.Value.ToString(), out enabled) && enabled)
				{
					foreach (KeyValuePair<ContentType, string> internalKvp in fcsContentTypeDict)
					{
						if (string.Equals(internalKvp.Value, outerKvp.Key, StringComparison.InvariantCultureIgnoreCase)
							&& !elements.Contains(internalKvp.Key))
						{
							elements.Add(internalKvp.Key);
						}
					}
				}
			}
			return elements;
		}
Esempio n. 3
0
        internal virtual ActionPropertySet BuildActionProperties(string sourceFilePath)
        {
            ActionPropertySet result = new ActionPropertySet();

            CleanActionPropertySet temp = new CleanActionPropertySet();
            var dict = temp.GetFCSContentTypeDict();
            foreach (string key in temp.Keys)
            {
                result.Add(new ActionProperty(key, temp[key].Value));
            }

            foreach (MetadataType mdt in m_metadataExclusions)
            {
                ContentType ct = Utils.ConvertContentType(mdt);
                string contentType;
                if (dict.TryGetValue(ct, out contentType))
                {
                    result[contentType].Value = false;
                }
            }

            foreach (CommonFieldType cft in m_fieldExclusions)
            {
                string fieldType = "ExcludeFieldCodes" + Utils.ConvertFieldType(cft);
                result[fieldType].Value = true;
            }

            result[CleanOption.UseWordOptimizingAddin].Value = true;
            result[CleanOption.ExcludeCustomProperties].Value = Normalize(CustomPropertyExclusionList);
            result[CleanOption.ExcludeFieldCodes].Value = Normalize(AdvancedFieldExclusionList);
            result[CleanOption.DeleteFieldCodes].Value = Normalize(FieldDeletionList);
            result[CleanOption.ExcludeDocumentVariables].Value = Normalize(DocumentVariableExclusionList);
            result[CleanOption.HandleFootnotesHiddenData].Value = TreatFootNotesAsMetadata;
            //result.Add(new ActionProperty("EnableFootnotes", true)); // always set this so that the cleaning is controlled by the excluded metadata types

            if (!string.IsNullOrEmpty(sourceFilePath))
            {
                var fileType = ValidateFileType(sourceFilePath);
                result.SystemProperties.Add("FileType", new ActionProperty("FileType", FileTypeBridge.GetFileType(fileType)));
            }

            return result;
        }