private void ViewFieldsCheckBoxChanged(CheckBox chk, Field field)
        {
            if (chk.IsChecked == true)
            {
                QueryResultMappingSelectField newSelectField = new QueryResultMappingSelectField()
                {
                    FieldName        = field.Name,
                    OutputHeaderName = field.Name,
                    StaticValue      = string.Empty
                };

                localQueryResultMappingSelectFields.Add(newSelectField);
            }
            else
            {
                QueryResultMappingSelectField selectField = localQueryResultMappingSelectFields.Where(t => t.FieldName == field.Name).First();
                if (selectField != null)
                {
                    localQueryResultMappingSelectFields.Remove(selectField);
                }
            }

            QueryResult.Fields = localQueryResultMappingSelectFields.Select(t => t.FieldName).ToArray();
            RefreshSelectedViewFieldsLabel();
        }
Пример #2
0
        private void PopulateMappingFields()
        {
            int top    = 0;
            int height = 20;

            FieldMappingsStackPanel.Children.Clear();
            List <QueryResultMappingSelectField> sourceFields = new List <QueryResultMappingSelectField>();

            foreach (QueryResultMapping sourceQueryResultMapping in SyncTask.SourceQueryResultMapping.Mappings)
            {
                sourceFields.AddRange(sourceQueryResultMapping.SelectFields);
            }


            QueryResultMappingSelectField notMappedField = new QueryResultMappingSelectField()
            {
                FieldName        = string.Empty,
                OutputHeaderName = "--- Not Mapped"
            };
            QueryResultMappingSelectField manuelValue = new QueryResultMappingSelectField()
            {
                FieldName        = string.Empty,
                OutputHeaderName = "--- Apply Manuel Value"
            };

            UpdateSourceFieldComboBox.ItemsSource      = sourceFields.ToList();
            UpdateDestinationFieldComboBox.ItemsSource = DestinationFolderFields.ToList();
            if (string.IsNullOrEmpty(SyncTask.SourceQueryResultMapping.Mappings[0].QueryResult.PrimaryIdFieldName) == false)
            {
                QueryResultMappingSelectField primaryIdQueryResultMappingSelectField = sourceFields.Where(t => t.FieldName.Equals(SyncTask.SourceQueryResultMapping.Mappings[0].QueryResult.PrimaryIdFieldName)).FirstOrDefault();
                UpdateSourceFieldComboBox.SelectedItem = primaryIdQueryResultMappingSelectField;
            }

            sourceFields.Insert(0, manuelValue);
            sourceFields.Insert(0, notMappedField);

            FieldCollection destinationFields = new FieldCollection();

            destinationFields.AddRange(DestinationFolderFields);

            foreach (Field field in destinationFields)
            {
                if (field.FromBaseType == true && field.Name.Equals("Title", StringComparison.InvariantCultureIgnoreCase) == false)
                {
                    continue;
                }

                Label label = new Label()
                {
                    Content = field.DisplayName.removeTextInsideParenthesis()
                };

                label.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                label.VerticalAlignment   = System.Windows.VerticalAlignment.Top;

                label.Margin = new Thickness(0, top, 5, 0);
                FieldMappingsStackPanel.Children.Add(label);
                ComboBox sourceComboBox = new ComboBox();
                sourceComboBox.Name        = field.Name + "_SourceComboBox";
                sourceComboBox.ItemsSource = sourceFields;
                sourceComboBox.Tag         = field;

                QueryResultMappingSelectField matchField = null;

                /*
                 * if (RequiredMappings.ContainsKey(field.Name) == true)
                 * {
                 *  string sourceFieldName = RequiredMappings[field.Name];
                 *  matchField = sourceFields.Where(t => t.FieldName.Equals(sourceFieldName)).FirstOrDefault();
                 *  sourceComboBox.IsReadOnly = true;
                 *  sourceComboBox.IsEnabled = false;
                 * }
                 * else
                 */
                if (SyncTask.DestinationFieldMappings.Count > 0)
                {
                    for (int i = 0; i < SyncTask.DestinationFieldMappings.Count; i++)
                    {
                        if (SyncTask.DestinationFieldMappings[i].FieldName.Equals(field.Name, StringComparison.InvariantCultureIgnoreCase) == true)
                        {
                            string sourceFieldName = SyncTask.SourceFieldHeaderMappings[i];
                            matchField = sourceFields.Where(t => t.FieldName.Equals(sourceFieldName)).FirstOrDefault();
                        }
                    }
                }
                else
                {
                    matchField = sourceFields.Where(t => t.FieldName.Equals(field.Name)).FirstOrDefault();
                }

                if (matchField != null)
                {
                    sourceComboBox.SelectedItem = matchField;
                }
                else
                {
                    sourceComboBox.SelectedItem = notMappedField;
                }

                sourceComboBox.SelectionChanged   += SourceComboBox_SelectionChanged;
                sourceComboBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                sourceComboBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                sourceComboBox.Margin = new Thickness(160, top, 0, 0);//

                FieldMappingsStackPanel.Children.Add(sourceComboBox);

                TextBox manuelValueTextBox = new TextBox();
                manuelValueTextBox.Name = field.Name + "_ManuelValueTextBox";
                manuelValueTextBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
                manuelValueTextBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                manuelValueTextBox.Margin     = new Thickness(350, top, 0, 0);
                manuelValueTextBox.Width      = 100;
                manuelValueTextBox.Height     = height;
                manuelValueTextBox.Visibility = Visibility.Hidden;
                FieldMappingsStackPanel.Children.Add(manuelValueTextBox);

                top += height + 5;
            }

            FieldMappingsStackPanel.Height = top;
        }
Пример #3
0
        private void MappingNextButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                List <QueryResultMappingSelectField> destinationFieldMappings = new List <QueryResultMappingSelectField>();
                //sourceSelectFieldNames.Add(new QueryResultMappingSelectField("ID", "ID"));
                //sourceSelectFieldNames.Add(new QueryResultMappingSelectField("Title", "Title"));
                //sourceSelectFieldNames.Add(new QueryResultMappingSelectField("FileRef", "FileRef"));

                List <string> sourceFieldNames = new List <string>();
                //sourceFieldNames.Add("ID");
                //sourceFieldNames.Add("Title");
                //sourceFieldNames.Add("FileRef");

                List <string> destinationFieldNames = new List <string>();
                //destinationFieldNames.Add("SourceItemID");
                //destinationFieldNames.Add("Title");
                //destinationFieldNames.Add("FileRef");

                Logger.Error("12", "SyncCopyListWizardForm");

                foreach (Field destionationField in DestinationFolderFields)
                {
                    if (destionationField.FromBaseType == true && destionationField.Name.Equals("Title", StringComparison.InvariantCultureIgnoreCase) == false)
                    {
                        continue;
                    }

                    /*
                     * if (destionationField.Name.Equals("SourceItemID", StringComparison.InvariantCultureIgnoreCase) == true)
                     *  continue;
                     *
                     * if (destionationField.Name.Equals("Title", StringComparison.InvariantCultureIgnoreCase) == true)
                     *  continue;
                     *
                     * if (destionationField.Name.Equals("FileRef", StringComparison.InvariantCultureIgnoreCase) == true)
                     *  continue;
                     */

                    string textboxName  = destionationField.Name + "_ManuelValueTextBox";
                    string comboBoxName = destionationField.Name + "_SourceComboBox";
                    string manuelValue  = string.Empty;

                    foreach (UIElement element in FieldMappingsStackPanel.Children)
                    {
                        if (element is TextBox == true)
                        {
                            if (((TextBox)element).Name == textboxName)
                            {
                                manuelValue = ((TextBox)element).Text;
                            }
                        }
                    }

                    foreach (UIElement element in FieldMappingsStackPanel.Children)
                    {
                        if (element is ComboBox == true)
                        {
                            if (((ComboBox)element).Name == comboBoxName)
                            {
                                ComboBox comboBox = (ComboBox)element;
                                if (((QueryResultMappingSelectField)comboBox.SelectedItem).OutputHeaderName == "--- Not Mapped")
                                {
                                    continue;
                                }
                                else if (((QueryResultMappingSelectField)comboBox.SelectedItem).OutputHeaderName == "--- Apply Manuel Value")
                                {
                                    //sourceFieldNames.Add(destionationField.Name);
                                    destinationFieldNames.Add(destionationField.Name);
                                    destinationFieldMappings.Add(new QueryResultMappingSelectField(string.Empty, manuelValue, destionationField.Name));
                                }
                                else
                                {
                                    QueryResultMappingSelectField sourceField = ((QueryResultMappingSelectField)comboBox.SelectedItem);
                                    sourceFieldNames.Add(sourceField.OutputHeaderName);
                                    destinationFieldNames.Add(destionationField.Name);
                                    destinationFieldMappings.Add(new QueryResultMappingSelectField(destionationField.Name, sourceField.StaticValue, destionationField.Name));
                                    //destinationFieldMappings.Add(new QueryResultMappingSelectField(sourceField.FieldName, sourceField.StaticValue, sourceField.OutputHeaderName));
                                }
                            }
                        }
                    }
                }
                Logger.Error("13", "SyncCopyListWizardForm");

                Logger.Error("14", "SyncCopyListWizardForm");

                SyncTask.DestinationListName       = DestinationFolder.GetListName();
                SyncTask.DestinationRootFolderPath = DestinationFolder.GetPath();
                SyncTask.DestinationFolderPath     = DestinationFolder.GetPath();
                SyncTask.Name = DestinationFolder.GetListName();
                SyncTask.DestinationPrimaryIdFieldName            = DestinationFolder.PrimaryIdFieldName;
                SyncTask.DestinationPrimaryNameFieldName          = DestinationFolder.PrimaryNameFieldName;
                SyncTask.DestinationPrimaryFileReferenceFieldName = DestinationFolder.PrimaryFileReferenceFieldName;
                //if (string.IsNullOrEmpty(SyncTask.SourceQueryResultMapping.Mappings[0].QueryResult.PrimaryIdFieldName) == false)
                if (AllowUpdateCheckBox.IsChecked == true)
                {
                    QueryResultMappingSelectField sourceQueryResultMappingSelectField = (QueryResultMappingSelectField)UpdateSourceFieldComboBox.SelectedItem;
                    string destinationUniqueFieldName = ((Field)UpdateDestinationFieldComboBox.SelectedItem).Name;
                    SyncTask.SourceUniqueFieldHeaderNames = new string[] { sourceQueryResultMappingSelectField.OutputHeaderName };
                    SyncTask.DestinationUniqueFieldNames  = new string[] { destinationUniqueFieldName };
                    //SyncTask.SourceQueryResultMapping.Mappings[0].QueryResult.PrimaryIdFieldName = sourceQueryResultMappingSelectField.FieldName;
                    if (destinationFieldNames.Contains(destinationUniqueFieldName) == false)
                    {
                        destinationFieldNames.Add(destinationUniqueFieldName);
                        destinationFieldMappings.Add(new QueryResultMappingSelectField(destinationUniqueFieldName, destinationUniqueFieldName));
                        sourceFieldNames.Add(sourceQueryResultMappingSelectField.FieldName);
                    }
                    //SyncTask.DestinationPrimaryIdFieldName = destinationUniqueFieldName;

/*
 *                  if (sourceFieldNames.Contains(sourceQueryResultMappingSelectField.FieldName) == false)
 *                  {
 *                  }
 */
                    //sourceFieldNames.Add(destionationField.Name);

/*
 *                  if (destinationFieldMappings.Where(t => t.FieldName.Equals(sourceQueryResultMappingSelectField.FieldName, StringComparison.InvariantCultureIgnoreCase)).Count() == 0)
 *                  {
 *                      destinationFieldMappings.Add(sourceQueryResultMappingSelectField);
 *                  }
 */
                }
                else
                {
                    SyncTask.SourceUniqueFieldHeaderNames = new string[] {  };
                    SyncTask.DestinationUniqueFieldNames  = new string[] {  };
                }

                SyncTask.DestinationIDFieldHeaderName = DestinationFolder.PrimaryIdFieldName;

                /*
                 * if (DestinationFolder.IsDocumentLibrary == true)
                 * {
                 *  sourceFieldNames.RemoveAt(2);
                 *  destinationFieldNames.RemoveAt(2);
                 *  sourceSelectFieldNames.RemoveAt(2);
                 * }
                 */
                Logger.Error("15", "SyncCopyListWizardForm");

                //SyncTask.SourceFieldHeaderMappings = sourceSelectFieldNames.Select(t => t.OutputHeaderName).ToArray();
                SyncTask.SourceFieldHeaderMappings = sourceFieldNames.ToArray();
                //destinationFieldNames[0] = "SourceItemID";
                SyncTask.DestinationFieldMappings     = destinationFieldMappings; // destinationFieldNames.ToArray();
                SyncTask.IsDestinationDocumentLibrary = DestinationFolder.IsDocumentLibrary;


                SyncTask.DestinationTermStoreName = "Taxonomy_BrjLUNqY3/3gqp8FAbbKiQ==";
                SyncTask.DestinationSiteSetting   = (SiteSetting)DestinationSiteSetting;
                //syncTasks.Add(syncTask);
                //syncTask.ScheduleInterval = 0;
                Logger.Error("16", "SyncCopyListWizardForm");
                CurrentTabIndex = 3;
                WizardTabControl.SelectedIndex = CurrentTabIndex;
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "SyncCopyListWizardForm");
            }
        }