public override List <ApplicationItemProperty> GetApplicationFields(string filePath) { List <ApplicationItemProperty> returnApplicationItemProperties = new List <ApplicationItemProperty>(); List <ApplicationItemProperty> applicationItemProperties = ConfigurationManager.GetInstance().GetApplicationItemProperties(ApplicationTypes.Outlook); Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MailItem mailItem = null; if (filePath == null) { mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlook.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem); } else { mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlook.CreateItemFromTemplate(filePath); } Microsoft.Office.Interop.Outlook.ItemProperties properties = mailItem.ItemProperties; for (int i = 0; i < properties.Count; i++) { Microsoft.Office.Interop.Outlook.ItemProperty property = properties[i]; ApplicationItemProperty applicationItemProperty = applicationItemProperties.FirstOrDefault(item => item.Name == property.Name); if (applicationItemProperty != null) { ApplicationItemProperty returnApplicationItemProperty = new ApplicationItemProperty( applicationItemProperty.Name, applicationItemProperty.DisplayName, applicationItemProperty.Type); returnApplicationItemProperty.Value = Convert.ChangeType(property.Value, applicationItemProperty.Type); returnApplicationItemProperties.Add(returnApplicationItemProperty); } } #region Writing the xml for field definitions /* * System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter("c:\\fields.xml", Encoding.UTF8); * // start writing! * writer.WriteStartDocument(); * writer.WriteStartElement("Outlook"); * writer.WriteStartElement("MailItem"); * writer.WriteStartElement("ItemProperties"); * System.Xml.XmlDocument document = new System.Xml.XmlDocument(); * System.Xml.XmlNode mainNode = document.CreateNode(System.Xml.XmlNodeType.Element, "MailItem", "Outlook"); * for (int i = 0; i < properties.Count; i++) * { * writer.WriteStartElement("Property"); * writer.WriteAttributeString("Name", properties[i].Name); * writer.WriteAttributeString("DisplayName", properties[i].Name); * writer.WriteAttributeString("Type", properties[i].Type.ToString()); * writer.WriteEndElement(); * } * writer.WriteEndElement(); * writer.WriteEndElement(); * writer.WriteEndElement(); * writer.WriteEndDocument(); * writer.Close(); */ #endregion return(returnApplicationItemProperties); }
public FieldMappingControl(List <ApplicationItemProperty> properties, Field field, ApplicationItemProperty defaultApplicationItemProperty) { InitializeComponent(); _field = field; _properties = properties; var defaultMapping = new { Name = "_Manual_Entry_", DisplayName = Languages.Translate("- Static -") }; FieldMappingSelectionComboBox.Items.Add(defaultMapping); foreach (ApplicationItemProperty property in properties) { if (field.Type == FieldTypes.Boolean && property.Type == typeof(bool) || (field.Type == FieldTypes.Choice || field.Type == FieldTypes.ContentType || field.Type == FieldTypes.ContentTypeId || field.Type == FieldTypes.ContentType || field.Type == FieldTypes.File || field.Type == FieldTypes.Note || field.Type == FieldTypes.Text || field.Type == FieldTypes.User) || (field.Type == FieldTypes.Counter || field.Type == FieldTypes.Number) && property.Type == typeof(decimal) || field.Type == FieldTypes.DateTime && property.Type == typeof(DateTime)) { var propertyMapping = new { Name = property.Name, DisplayName = Languages.Translate(property.DisplayName) }; FieldMappingSelectionComboBox.Items.Add(propertyMapping); if (defaultApplicationItemProperty != null && defaultApplicationItemProperty.Name == propertyMapping.Name) //&& defaultApplicationItemProperty.DisplayName == propertyMapping.DisplayName)JD translation pb? { defaultMapping = propertyMapping; } } } if (FieldMappingSelectionComboBox.Items.Count == 1) { FieldMappingSelectionComboBox.Visibility = Visibility.Hidden; //hide selector if only one choice } FieldMappingSelectionComboBox.SelectedItem = defaultMapping; FieldMappingSelectionComboBox.SelectionChanged += new SelectionChangedEventHandler(FieldMappingSelectionComboBox_SelectionChanged); }
private void setContentType(ContentType contentType) { IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(_siteSetting.SiteSettingType); string[] folderFieldInLimitedView = new string[] { "FileLeafRef" }; double height = 10; fieldRequiredPresnet = false; FieldMappingsStackPanel.Children.Clear(); //Get default mappings ItemPropertyMappings itemPropertyMappings = null; if (_folderSettings != null) { itemPropertyMappings = _folderSettings.GetItemPropertyMappings(contentType.ID); } List <Field> filtredField = contentType.Fields; if (_siteSetting.limitFolderEditableProperties & isFolder) { filtredField = contentType.Fields.Where(f => folderFieldInLimitedView.Contains(f.Name)).ToList(); } foreach (Field field in filtredField) { if (!_displayFileName && field.Name == "FileLeafRef") { continue; } Label label = new Label() { Content = field.DisplayName.removeTextInsideParenthesis() }; label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; label.VerticalAlignment = System.Windows.VerticalAlignment.Top; if (field.Required && !field.ReadOnly) { label.Foreground = new SolidColorBrush(Colors.Red); label.Content += "*"; fieldRequiredPresnet = true; } label.Margin = new Thickness(0, height, 5, 0); FieldMappingsStackPanel.Children.Add(label); //if (field.ReadOnly == false) //{ EditItemControl editItemControl = EditItemManager.GetEditItemControl(_webURL, field, null, contentType, _siteSetting, _rootFolder); editItemControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; editItemControl.VerticalAlignment = System.Windows.VerticalAlignment.Top; editItemControl.Margin = new Thickness(160, height, 0, 0);// FieldMappingsStackPanel.Children.Add(editItemControl); if (_properties != null && _properties.Count > 0) { //Set default mapping value ApplicationItemProperty defaultApplicationItemProperty = null; if (itemPropertyMappings != null) { ItemPropertyMapping mapping = itemPropertyMappings.Where(m => m.ServicePropertyName == field.Name).FirstOrDefault(); if (mapping != null) { defaultApplicationItemProperty = _properties.Where(p => p.Name == mapping.ApplicationPropertyName).FirstOrDefault(); editItemControl.IsEnabled = false; } else { mapping = _defaultFolderSetting.ItemPropertyMappings.Where(m => m.ServicePropertyName == field.Name).FirstOrDefault(); if (mapping != null) { defaultApplicationItemProperty = _properties.Where(p => p.Name == mapping.ApplicationPropertyName).FirstOrDefault(); editItemControl.IsEnabled = false; } } } EditItems.FieldMappingControl fieldMappingControl = new EditItems.FieldMappingControl(_properties, field, defaultApplicationItemProperty); fieldMappingControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; fieldMappingControl.VerticalAlignment = System.Windows.VerticalAlignment.Top; fieldMappingControl.Margin = new Thickness(350, height, 0, 0); FieldMappingsStackPanel.Children.Add(fieldMappingControl); } height = height + editItemControl.GetHeight() + 5; if (_defaultValues != null) { object[] args = { serviceManager, field, editItemControl }; Dispatcher.BeginInvoke(new setDefaultValuesDelegate(setDefaultValues), args); } //} } labelfieldRequired.Visibility = fieldRequiredPresnet ? Visibility.Visible : Visibility.Hidden; }
private List <ApplicationItemProperty> GetApplicationItemPropertiesFromAssembly(ApplicationTypes applicationType) { List <ApplicationItemProperty> applicationItemProperties = new List <ApplicationItemProperty>(); Assembly _assembly; Stream _imageStream; StreamReader _textStreamReader; _assembly = Assembly.GetExecutingAssembly(); _imageStream = _assembly.GetManifestResourceStream("Sobiens.Connectors.Common.Resources." + applicationType.ToString() + "Settings.xml"); _textStreamReader = new StreamReader(_imageStream); string xml = _textStreamReader.ReadToEnd(); XElement solutionXml = XElement.Parse(xml); XNamespace m_Namespace = solutionXml.GetDefaultNamespace(); var properties = from element in solutionXml.Elements(m_Namespace + "ItemProperties").Elements(m_Namespace + "Property") //where element.Attributes(m_Namespace + "Hidden").First().Value == "False" select element; foreach (XElement property in properties) { string name = string.Empty; string displayName = string.Empty; Type type = null; bool hidden = true; foreach (XAttribute attribute in property.Attributes()) { switch (attribute.Name.LocalName) { case "Name": name = attribute.Value; break; case "DisplayName": displayName = attribute.Value; break; case "Type": switch (attribute.Value) { case "olNumber": type = typeof(decimal); break; case "olText": type = typeof(string); break; case "olDateTime": type = typeof(DateTime); break; case "olYesNo": type = typeof(bool); break; case "olOutlookInternal": default: break; //Not Supported } break; case "Hidden": if (bool.TryParse(attribute.Value, out hidden) == false) { hidden = true; } break; default: continue; } } if (hidden == false && type != null && string.IsNullOrEmpty(name) == false && string.IsNullOrEmpty(displayName) == false) { ApplicationItemProperty itemProperty = new ApplicationItemProperty(name, displayName, type); applicationItemProperties.Add(itemProperty); } } return(applicationItemProperties); }