Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontEndLoader"/> class.
        /// </summary>
        public ConnectPage()
        {
            InitializeComponent();
            LoadBulldozerTypes();

            if (BulldozerTypes.Any())
            {
                SelectedImportType = BulldozerTypes.FirstOrDefault();
                InitializeDBConnection();
            }
            else
            {
                btnNext.Visibility   = Visibility.Hidden;
                lblHeader.Visibility = Visibility.Hidden;
                lblNoData.Visibility = Visibility.Visible;
            }

            DataContext = this;
        }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectPage"/> class.
 /// </summary>
 public SelectPage(BulldozerComponent parameter = null)
 {
     InitializeComponent();
     if (parameter != null)
     {
         bulldozer = parameter;
         if (bulldozer.DataNodes.Count > 0)
         {
             bulldozer.DataNodes[0].Checked = true; //preview on load
             PreviewData(bulldozer.DataNodes[0].Id);
         }
         treeView.ItemsSource = new ObservableCollection <DataNode>(bulldozer.DataNodes);
     }
     else
     {
         lblNoData.Visibility      = Visibility.Visible;
         btnNext.Visibility        = Visibility.Hidden;
         grdPreviewData.Visibility = Visibility.Hidden;
     }
 }
Пример #3
0
        /// <summary>
        /// Handles the DoWork event of the bwLoadSchema control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void bwPreview_DoWork(object sender, DoWorkEventArgs e)
        {
            var selectedBulldozer = (string)e.Argument;
            var filePicker        = new OpenFileDialog();

            filePicker.Multiselect = true;

            var supportedExtensions = BulldozerTypes.Where(t => t.FullName.Equals(selectedBulldozer))
                                      .Select(t => t.FullName + " |*" + t.ExtensionType).ToList();

            filePicker.Filter = string.Join("|", supportedExtensions);

            if (filePicker.ShowDialog() == true)
            {
                bulldozer = BulldozerTypes.Where(t => t.FullName.Equals(selectedBulldozer)).FirstOrDefault();
                if (bulldozer != null)
                {
                    bool loadedSuccessfully = false;
                    foreach (var file in filePicker.FileNames)
                    {
                        loadedSuccessfully = bulldozer.LoadSchema(file);
                        if (!loadedSuccessfully)
                        {
                            e.Cancel = true;
                            break;
                        }

                        Dispatcher.BeginInvoke((Action)(() =>
                                                        FilesUploaded.Children.Add(new TextBlock {
                            Text = Path.GetFileName(file)
                        })
                                                        ));
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Пример #4
0
        /// <summary>
        /// Handles the DoWork event of the bwTransformData control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        private void bwImportData_DoWork(object sender, DoWorkEventArgs e)
        {
            var settings = ConfigurationManager.AppSettings.AllKeys
                           .ToDictionary(t => t.ToString(), t => ConfigurationManager.AppSettings[t].ToString());

            try
            {
                e.Result = bulldozer.TransformData(settings);
            }
            catch (Exception ex)
            {
                var exception = ex.ToString();
                if (ex is DbEntityValidationException)
                {
                    var validationErrors = ((DbEntityValidationException)ex).EntityValidationErrors;
                    if (validationErrors.Any())
                    {
                        foreach (var eve in validationErrors)
                        {
                            BulldozerComponent.LogException(string.Format("{0} (Foreign Key: {1})", eve.Entry.Entity.GetType().Name, eve.Entry.Property("ForeignKey").CurrentValue), string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                                                                                                                                                                   eve.Entry.Entity.GetType().Name, eve.Entry.State));
                            foreach (var ve in eve.ValidationErrors)
                            {
                                BulldozerComponent.LogException(ve.PropertyName, string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                                                               ve.PropertyName, ve.ErrorMessage));
                            }
                        }

                        exception = validationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage.ToStringSafe();
                    }
                }
                else if (ex.InnerException != null)
                {
                    exception = ex.InnerException.ToString();
                }

                App.LogException("Transform Data", exception);
            }
        }