private Dictionary <object, object> setMappings() { mappingIsSet = true; mappings = new Dictionary <object, object>(); fieldRequiredValidate = true; foreach (UIElement control in FieldMappingsStackPanel.Children) { if (control is Sobiens.Connectors.WPF.Controls.EditItems.FieldMappingControl) { Sobiens.Connectors.WPF.Controls.EditItems.FieldMappingControl fieldMappingControl = control as Sobiens.Connectors.WPF.Controls.EditItems.FieldMappingControl; object value = fieldMappingControl.GetFieldValue(); if (value != null) { mappings.Add(fieldMappingControl.GetField(), value); } } } foreach (UIElement control in FieldMappingsStackPanel.Children) { if (control is EditItemControl) { EditItemControl editItemControl = control as EditItemControl; if (!mappings.ContainsKey(editItemControl.Field)) { if (editItemControl.hasBeenModified) { mappings.Add(editItemControl.Field, editItemControl.Value); } bool isNull = editItemControl.Value == null; if (!isNull) { isNull = string.IsNullOrEmpty(editItemControl.Value.ToString()); } if (editItemControl.Field.Required && isNull) { fieldRequiredValidate = false; } } } } return(mappings); }
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; }