Excavator holds the base methods and properties needed to convert data to Rock
Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
        /// </summary>
        public ProgressPage(ExcavatorComponent parameter = null)
        {
            InitializeComponent();
            if (parameter != null)
            {
                excavator = parameter;
                excavator.ProgressUpdated += new ReportProgress(UpdateInterface);

                BackgroundWorker bwImportData = new BackgroundWorker();
                bwImportData.DoWork               += bwImportData_DoWork;
                bwImportData.RunWorkerCompleted   += bwImportData_RunWorkerCompleted;
                bwImportData.WorkerReportsProgress = true;
                bwImportData.RunWorkerAsync();
            }
        }
Exemple #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectPage"/> class.
 /// </summary>
 public SelectPage( ExcavatorComponent parameter = null )
 {
     InitializeComponent();
     if ( parameter != null )
     {
         excavator = parameter;
         treeView.ItemsSource = new ObservableCollection<DatabaseNode>( excavator.TableNodes );
     }
     else
     {
         lblNoData.Visibility = Visibility.Visible;
         btnNext.Visibility = Visibility.Hidden;
         grdPreviewData.Visibility = Visibility.Hidden;
     }
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
        /// </summary>
        public ProgressPage( ExcavatorComponent parameter = null )
        {
            InitializeComponent();
            if ( parameter != null )
            {
                excavator = parameter;
                excavator.ProgressUpdated += new ReportProgress( UpdateInterface );

                BackgroundWorker bwImportData = new BackgroundWorker();
                bwImportData.DoWork += bwImportData_DoWork;
                bwImportData.RunWorkerCompleted += bwImportData_RunWorkerCompleted;
                bwImportData.WorkerReportsProgress = true;
                bwImportData.RunWorkerAsync();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
 /// </summary>
 public ConfigurationPage( ExcavatorComponent parameter = null )
 {
     InitializeComponent();
     if ( parameter != null )
     {
         excavator = parameter;
         txtImportUser.Text = ConfigurationManager.AppSettings["ImportUser"];
         txtPasswordKey.Text = ConfigurationManager.AppSettings["PasswordKey"];
         txtDataEncryption.Text = ConfigurationManager.AppSettings["DataEncryptionKey"];
     }
     else
     {
         lblNoData.Visibility = Visibility.Visible;
         btnNext.Visibility = Visibility.Hidden;
     }
 }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
 /// </summary>
 public ConfigurationPage(ExcavatorComponent parameter = null)
 {
     InitializeComponent();
     if (parameter != null)
     {
         excavator              = parameter;
         txtImportUser.Text     = ConfigurationManager.AppSettings["ImportUser"];
         txtPasswordKey.Text    = ConfigurationManager.AppSettings["PasswordKey"];
         txtDataEncryption.Text = ConfigurationManager.AppSettings["DataEncryptionKey"];
     }
     else
     {
         lblNoData.Visibility = Visibility.Visible;
         btnNext.Visibility   = Visibility.Hidden;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectPage"/> class.
 /// </summary>
 public SelectPage(ExcavatorComponent parameter = null)
 {
     InitializeComponent();
     if (parameter != null)
     {
         excavator = parameter;
         if (excavator.TableNodes.Count > 0)
         {
             excavator.TableNodes[0].Checked = true; //preview on load
             PreviewData(excavator.TableNodes[0].Id);
         }
         treeView.ItemsSource = new ObservableCollection <DatabaseNode>(excavator.TableNodes);
     }
     else
     {
         lblNoData.Visibility      = Visibility.Visible;
         btnNext.Visibility        = Visibility.Hidden;
         grdPreviewData.Visibility = Visibility.Hidden;
     }
 }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SelectPage"/> class.
 /// </summary>
 public SelectPage( ExcavatorComponent parameter = null )
 {
     InitializeComponent();
     if ( parameter != null )
     {
         excavator = parameter;
         if ( excavator.TableNodes.Count > 0 )
         {
             excavator.TableNodes[0].Checked = true; //preview on load
             PreviewData( excavator.TableNodes[0].Id );
         }
         treeView.ItemsSource = new ObservableCollection<DatabaseNode>( excavator.TableNodes );
     }
     else
     {
         lblNoData.Visibility = Visibility.Visible;
         btnNext.Visibility = Visibility.Hidden;
         grdPreviewData.Visibility = Visibility.Hidden;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
        /// </summary>
        public ConfigurationPage(ExcavatorComponent parameter = null)
        {
            InitializeComponent();
            if (parameter != null)
            {
                excavator              = parameter;
                txtImportUser.Text     = ConfigurationManager.AppSettings["ImportUser"];
                txtPasswordKey.Text    = ConfigurationManager.AppSettings["PasswordKey"];
                txtDataEncryption.Text = ConfigurationManager.AppSettings["DataEncryptionKey"];

                int reportingNumber;
                Int32.TryParse(ConfigurationManager.AppSettings["ReportingNumber"], out reportingNumber);
                excavator.ReportingNumber = reportingNumber > 0 ? reportingNumber : 100;
            }
            else
            {
                lblNoData.Visibility = Visibility.Visible;
                btnNext.Visibility   = Visibility.Hidden;
            }
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontEndLoader"/> class.
        /// </summary>
        public ConnectPage()
        {
            InitializeComponent();
            LoadExcavatorTypes();

            if (ExcavatorTypes.Any())
            {
                SelectedImportType = ExcavatorTypes.FirstOrDefault();
                InitializeDBConnection();
            }
            else
            {
                btnNext.Visibility          = Visibility.Hidden;
                lblNoData.Visibility        = Visibility.Visible;
                lblDatabaseTypes.Visibility = Visibility.Hidden;
                lstDatabaseTypes.Visibility = Visibility.Hidden;
            }

            DataContext = this;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ConfigurationPage"/> class.
        /// </summary>
        public ConfigurationPage( ExcavatorComponent parameter = null )
        {
            InitializeComponent();
            if ( parameter != null )
            {
                excavator = parameter;
                txtImportUser.Text = ConfigurationManager.AppSettings["ImportUser"];
                txtPasswordKey.Text = ConfigurationManager.AppSettings["PasswordKey"];
                txtDataEncryption.Text = ConfigurationManager.AppSettings["DataEncryptionKey"];

                int reportingNumber;
                Int32.TryParse( ConfigurationManager.AppSettings["ReportingNumber"], out reportingNumber );
                excavator.ReportingNumber = reportingNumber > 0 ? reportingNumber : 100;
            }
            else
            {
                lblNoData.Visibility = Visibility.Visible;
                btnNext.Visibility = Visibility.Hidden;
            }
        }
Exemple #11
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 selectedExcavator = (string)e.Argument;
            var filePicker        = new OpenFileDialog();

            filePicker.Multiselect = true;

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

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

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

                        Dispatcher.BeginInvoke((Action)(() =>
                                                        FilesUploaded.Children.Add(new TextBlock {
                            Text = System.IO.Path.GetFileName(file)
                        })
                                                        ));
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrontEndLoader"/> class.
        /// </summary>
        public ConnectPage()
        {
            InitializeComponent();

            frontEndLoader = new FrontEndLoader();
            if (frontEndLoader.excavatorTypes.Any())
            {
                ExcavatorImportDlls = frontEndLoader.excavatorTypes.GroupBy(t => t.FullName).Select(g => g.FirstOrDefault());
                SelectedImportType  = frontEndLoader.excavatorTypes.FirstOrDefault();
                InitializeDBConnection();
            }
            else
            {
                btnNext.Visibility          = Visibility.Hidden;
                lblNoData.Visibility        = Visibility.Visible;
                lblDatabaseTypes.Visibility = Visibility.Hidden;
                lstDatabaseTypes.Visibility = Visibility.Hidden;
                lblNoData.Content          += string.Format(" ({0})", ConfigurationManager.AppSettings["ExtensionPath"]);
            }

            DataContext = this;
        }
Exemple #13
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 = excavator.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)
                        {
                            ExcavatorComponent.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)
                            {
                                ExcavatorComponent.LogException(ve.PropertyName, string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                                                               ve.PropertyName, ve.ErrorMessage));
                            }
                        }
                        exception = validationErrors.FirstOrDefault().ValidationErrors.ToString();
                    }
                }
                else if (ex.InnerException != null)
                {
                    exception = ex.InnerException.ToString();
                }

                App.LogException("Transform Data", exception);
            }
        }
Exemple #14
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 selectedExcavator = (string)e.Argument;
            var filePicker = new OpenFileDialog();
            filePicker.Multiselect = true;

            var supportedExtensions = ExcavatorTypes.Where( t => t.FullName.Equals( selectedExcavator ) )
                .Select( t => t.FullName + " |*" + t.ExtensionType ).ToList();
            filePicker.Filter = string.Join( "|", supportedExtensions );

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

                        Dispatcher.BeginInvoke( (Action)( () =>
                            FilesUploaded.Children.Add( new TextBlock { Text = System.IO.Path.GetFileName( file ) } )
                        ) );
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }
Exemple #15
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 mdfPicker = new OpenFileDialog();
            mdfPicker.Filter = "SQL Database files|*.mdf";
            mdfPicker.AddExtension = false;

            if ( mdfPicker.ShowDialog() == true )
            {
                var database = new Database( mdfPicker.FileName );
                if ( database != null )
                {
                    var dbType = (string)e.Argument;
                    excavator = frontEndLoader.excavatorTypes.Where( t => t.FullName.Equals( dbType ) ).FirstOrDefault();
                    if ( excavator != null )
                    {
                        bool loadedSuccessfully = excavator.LoadSchema( database );
                        e.Cancel = !loadedSuccessfully;
                    }
                }
            }
            else
            {
                e.Cancel = true;
            }
        }