private void EditItem(ItemPropertyMapping itemPropertyMapping, FolderSetting folderSetting) { ContentType selectedContentType = null; if (folderSetting.Folder != null) { //SiteSetting siteSetting = this.SiteSettings[folderSetting.Folder.SiteSettingID];//JD ISiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(folderSetting.Folder.SiteSettingID); IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType); List <ContentType> contentTypes = serviceManager.GetContentTypes(siteSetting, folderSetting.Folder, false); selectedContentType = contentTypes.Single(t => t.ID.Equals(itemPropertyMapping.ContentTypeID)); } ItemPropertyMappingForm itemPropertyMappingForm = new ItemPropertyMappingForm(); itemPropertyMappingForm.Initialize(ApplicationContext.Current.GetApplicationFields(null), selectedContentType, itemPropertyMapping.ApplicationPropertyName, itemPropertyMapping.ServicePropertyName); if (itemPropertyMappingForm.ShowDialog(this.ParentWindow, Languages.Translate("Add Mapping"), 200, 300) == true) { itemPropertyMapping.ApplicationPropertyName = itemPropertyMappingForm.SelectedApplicationPropertyID; itemPropertyMapping.ServicePropertyName = itemPropertyMappingForm.SelectedServicePropertyID; this.RefreshMappingListView(); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { ContentType selectedContentType; if (GeneralLocationTypeRadioButton.IsChecked == true) { selectedContentType = null; } else { selectedContentType = ContentTypeComboBox.SelectedValue as ContentType; if (selectedContentType == null) { MessageBox.Show(Languages.Translate("Please select a content type or use general location instead of specific")); } } ItemPropertyMappingForm itemPropertyMapping = new ItemPropertyMappingForm(); itemPropertyMapping.Initialize(ConfigurationManager.GetInstance().GetApplicationItemProperties(this.SelectedApplicationType), selectedContentType); if (itemPropertyMapping.ShowDialog(this.ParentWindow, Languages.Translate("Add Mapping"), 300, 350) == true) { ItemPropertyMapping newItemPropertyMapping = new ItemPropertyMapping(); newItemPropertyMapping.ID = Guid.NewGuid(); if (selectedContentType != null) { newItemPropertyMapping.ContentTypeID = selectedContentType.ID; } newItemPropertyMapping.ApplicationPropertyName = itemPropertyMapping.SelectedApplicationPropertyID; newItemPropertyMapping.ServicePropertyName = itemPropertyMapping.SelectedServicePropertyID; FolderSetting folderSetting; if (this.SelectedFolder == null) { folderSetting = this.FolderSettings.GetDefaultFolderSetting(this.SelectedApplicationType); folderSetting.ItemPropertyMappings.Add(newItemPropertyMapping); } else { folderSetting = this.FolderSettings.GetFolderSetting(this.SelectedApplicationType, this.SelectedFolder); if (folderSetting != null) { folderSetting.ItemPropertyMappings.Add(newItemPropertyMapping); } else { folderSetting = new FolderSetting(); folderSetting.ApplicationType = this.SelectedApplicationType; folderSetting.BasicFolderDefinition = this.SelectedFolder.GetBasicFolderDefinition(); folderSetting.Folder = this.SelectedFolder; folderSetting.ItemPropertyMappings.Add(newItemPropertyMapping); this.FolderSettings.Add(folderSetting); } } this.RefreshMappingListView(); } }