/// <summary>
        /// Loads every Solution into Grid
        /// </summary>
        /// <param name="connectionNane">CRM Connection</param>
        private void LoadSolutions(string connectionNane)
        {
            try
            {
                if (Cbx_Connection.SelectedItem != null)
                {
                    Core.Xrm.CrmConnection crmConnection = Core.Data.StorageExtensions.Load(MainWindow.EncryptionKey).SingleOrDefault(x => x.Name == connectionNane);

                    this.Dtg_Solutions.ItemsSource = null;
                    MainWindow.SetProgress(true);

                    this.worker.DoWork             += this.Worker_DoWork;
                    this.worker.RunWorkerCompleted += this.Worker_RunWorkerCompleted;
                    this.worker.RunWorkerAsync();

                    this.selectedCrmConnection = crmConnection;
                    this.Btn_Reload.IsEnabled  = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                if (!Properties.Settings.Default.DisableErrorReports)
                {
                    Diagnostics.ErrorReport errorReport = new Diagnostics.ErrorReport(ex);
                    errorReport.Show();
                }

                MainWindow.SetProgress(false);
                SolutionDownloader.Log.Error(ex.Message, ex);
                Cbx_Connection.IsEnabled = true;
                Btn_Reload.IsEnabled     = true;
            }
        }
        /// <summary>
        /// Background Worker Event DoWork
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Microsoft.Xrm.Tooling.Connector.CrmServiceClient crmServiceClient = null;

            try
            {
                using (Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector())
                {
                    Core.Xrm.CrmConnection crmConnection = this.selectedCrmConnection;

                    crmServiceClient = toolingConnector.GetCrmServiceClient(crmConnection.ConnectionString);

                    // Get Crm Solutions
                    this.crmSolutions.Clear();
                    this.crmSolutions = toolingConnector.GetCrmSolutions(crmServiceClient);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);

                if (!Properties.Settings.Default.DisableErrorReports)
                {
                    throw;
                }
            }
            finally
            {
                if (crmServiceClient != null)
                {
                    crmServiceClient.Dispose();
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloadSolution"/> class.
        /// </summary>
        /// <param name="crmConnection">CRM Connection</param>
        /// <param name="crmSolutions">CRM Solutions to Download</param>
        /// <param name="managed">Determines if the Solution should be Downloaded managed</param>
        /// <param name="unmanaged">Determines if the Solution should be Downloaded unmanaged</param>
        public DownloadSolution(Core.Xrm.CrmConnection crmConnection, List <Core.Xrm.CrmSolution> crmSolutions, bool managed, bool unmanaged)
        {
            this.InitializeComponent();
            this.crmConnection = crmConnection;
            this.crmSolutions  = crmSolutions;
            this.managed       = managed;
            this.unmanaged     = unmanaged;
            this.progress      = 0;
            this.progressStep  = 100 / (decimal)crmSolutions.Count;
            this.Pgb_downloadProgress.Value = 0;

            this.DownloadSolutions();
        }
Example #4
0
        /// <summary>
        /// Background Worker Event DoWork
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Microsoft.Xrm.Tooling.Connector.CrmServiceClient crmServiceClient = null;

            try
            {
                using (Core.Xrm.ToolingConnector toolingConnector = new Core.Xrm.ToolingConnector())
                {
                    List <Core.Xrm.CrmConnection> crmConnections = Core.Data.StorageExtensions.Load(MainWindow.EncryptionKey);
                    Core.Xrm.CrmConnection        crmConnection  = crmConnections.Find(x => x.Name == this.selectedCrmConnection);

                    crmServiceClient = toolingConnector.GetCrmServiceClient(crmConnection.ConnectionString);

                    // Get Crm Solutions
                    this.crmSolutions.Clear();
                    this.crmSolutions = toolingConnector.GetCrmSolutions(crmServiceClient);

                    foreach (Core.Xrm.CrmSolution solution in this.localSolutions)
                    {
                        if (this.crmSolutions.Exists(x => x.UniqueName == solution.UniqueName))
                        {
                            this.crmSolutions.Find(x => x.UniqueName == solution.UniqueName).LocalVersion = solution.LocalVersion;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);

                if (!Properties.Settings.Default.DisableErrorReports)
                {
                    throw;
                }
            }
            finally
            {
                if (crmServiceClient != null)
                {
                    crmServiceClient.Dispose();
                }
            }
        }
Example #5
0
        /// <summary>
        /// Download Button Click Event
        /// </summary>
        /// <param name="sender">Button sender object</param>
        /// <param name="e">Button event args</param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (Lbx_Repos.SelectedItem == null)
            {
                MessageBox.Show("Please connect to CRM first", "No CRM Connection", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            int downloadCounter = 0;
            List <Core.Xrm.CrmConnection> crmConnections = Core.Data.StorageExtensions.Load(MainWindow.EncryptionKey);

            Core.Xrm.CrmConnection crmConnection = crmConnections.Find(x => x.Name == ((Core.Xrm.CrmConnection)Lbx_Repos.SelectedItem).Name);

            if (Dtg_Solutions.ItemsSource == null)
            {
                MessageBox.Show("Please connect to CRM and wait for the Background Job fetching the CRM Solutions", "Solutions are empty", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            List <Core.Xrm.CrmSolution> crmSolutionList = new List <Core.Xrm.CrmSolution>();

            foreach (Core.Xrm.CrmSolution crmSolution in Dtg_Solutions.ItemsSource)
            {
                if (crmSolution.DownloadIsChecked)
                {
                    downloadCounter++;
                    crmSolutionList.Add(crmSolution);
                }
            }

            if (downloadCounter != 0)
            {
                DownloadMultiple downloadMultiple = new DownloadMultiple(crmConnection, crmSolutionList);
                downloadMultiple.ShowDialog();

                this.LoadVersionIntoGrid();
            }
            else
            {
                MessageBox.Show("Please select at least one Solution", "No Solution Selected", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #6
0
        /// <summary>
        /// Loads the CRM Solution for the selected Repo into the grid
        /// </summary>
        private void LoadSolutions()
        {
            this.Btn_Reload.IsEnabled = false;
            try
            {
                if (Lbx_Repos.SelectedItem != null)
                {
                    Lbx_Repos.IsEnabled        = false;
                    this.selectedCrmConnection = null;
                    Core.Xrm.CrmConnection crmConnection = (Core.Xrm.CrmConnection)Lbx_Repos.SelectedItem;

                    Core.Repository.Connector repositoryConnector = new Core.Repository.Connector();
                    this.localSolutions = null;
                    this.localSolutions = repositoryConnector.GetLocalCRMSolutions(((Core.Xrm.CrmConnection)Lbx_Repos.SelectedItem).LocalPath);

                    this.Dtg_Solutions.ItemsSource = null;
                    MainWindow.SetProgress(true);

                    this.worker.DoWork             += this.Worker_DoWork;
                    this.worker.RunWorkerCompleted += this.Worker_RunWorkerCompleted;
                    this.worker.RunWorkerAsync();

                    this.selectedCrmConnection = crmConnection.Name;
                    this.Btn_Reload.IsEnabled  = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                if (!Properties.Settings.Default.DisableErrorReports)
                {
                    Diagnostics.ErrorReport errorReport = new Diagnostics.ErrorReport(ex);
                    errorReport.Show();
                }

                MainWindow.SetProgress(false);
                SolutionSelector.Log.Error(ex.Message, ex);
                Lbx_Repos.IsEnabled  = true;
                Btn_Reload.IsEnabled = true;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DownloadDialog"/> class.
 /// </summary>
 /// <param name="crmConnection">CRM Connection for the Download</param>
 /// <param name="crmSolutions">CRM Solutions to Download</param>
 public DownloadDialog(Core.Xrm.CrmConnection crmConnection, List <Core.Xrm.CrmSolution> crmSolutions)
 {
     this.InitializeComponent();
     this.crmConnection = crmConnection;
     this.crmSolutions  = crmSolutions;
 }
Example #8
0
 /// <summary>
 /// Event Method if the selection of the Connection ComboBox changed
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="SelectionChangedEventArgs"/> instance containing the event data.</param>
 private void Cbx_Connection_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     this.selectedCrmConnection = Core.Data.StorageExtensions.Load(MainWindow.EncryptionKey).SingleOrDefault(x => x.Name == Cbx_Connection.SelectedItem.ToString());
 }