示例#1
0
        /// <summary>
        /// Background Worker Event Worker_RunWorkerCompleted
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="RunWorkerCompletedEventArgs"/> instance containing the event data.</param>
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Diagnostics.ErrorReport errorReport = new Diagnostics.ErrorReport(e.Error, "An error occurred while downloading or extracting the solution");
                errorReport.Show();
            }

            this.loadingPanel.IsLoading = false;
            this.Btn_close.IsEnabled    = true;
            DownloadMultiple.LogToUI("---------------");
            DownloadMultiple.LogToUI("Finished download/extraction");
            DownloadMultiple.LogToUI("---------------");
        }
示例#2
0
        /// <summary>
        /// Will Extract the Solution into the folder
        /// </summary>
        /// <param name="solution">CRM Solution which should be extracted</param>
        private void ProcessSolutions(CrmSolution solution)
        {
            using (ToolingConnector toolingConnector = new ToolingConnector())
            {
                // Delete Solution File if it exists
                if (File.Exists(Path.Combine(this.selectedPath, solution.UniqueName + ".zip")))
                {
                    File.Delete(Path.Combine(this.selectedPath, solution.UniqueName + ".zip"));
                }

                this.crmServiceClient = toolingConnector.GetCrmServiceClient(connectionString: this.CRMConnection.ConnectionString);

                try
                {
                    toolingConnector.DownloadSolution(this.crmServiceClient, solution.UniqueName, this.selectedPath);

                    CrmSolutionPackager crmSolutionPackager = new CrmSolutionPackager();

                    if (Directory.Exists(Path.Combine(this.selectedPath, solution.UniqueName)))
                    {
                        Core.IO.Directory.DeleteDirectory(Path.Combine(this.selectedPath, solution.UniqueName));
                        DownloadMultiple.UpdateUI($"Delete {Path.Combine(this.selectedPath, solution.UniqueName).ToString()}", true);
                    }

                    string log = crmSolutionPackager.ExtractCustomizing(Path.Combine(this.selectedPath, solution.UniqueName + ".zip"), Path.Combine(this.selectedPath, solution.UniqueName), Properties.Settings.Default.SolutionPackagerLogPath, this.localizeSupport);
                    DownloadMultiple.UpdateUI(log, false);
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message, ex);
                    if (!Properties.Settings.Default.DisableErrorReports)
                    {
                        throw;
                    }
                }
                finally
                {
                    if (File.Exists(Path.Combine(this.selectedPath, solution.UniqueName + ".zip").ToString()))
                    {
                        File.Delete(Path.Combine(this.selectedPath, solution.UniqueName + ".zip"));
                        DownloadMultiple.UpdateUI($"Delete {Path.Combine(this.selectedPath, solution.UniqueName + ".zip").ToString()}", true);
                    }
                }
            }
        }
示例#3
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)
        {
            try
            {
                // Create Folder if it does not exists
                if (!Directory.Exists(this.CRMConnection.LocalPath))
                {
                    Directory.CreateDirectory(this.CRMConnection.LocalPath);
                }

                foreach (CrmSolution solution in this.CRMSolutions)
                {
                    if (!this.worker.CancellationPending)
                    {
                        this.ProcessSolutions(solution);
                    }
                    else
                    {
                        e.Cancel = true;
                    }
                }
            }
            catch (Exception ex)
            {
                DownloadMultiple.UpdateUI($"An Error occured: {ex.Message}", false);
                DownloadMultiple.Log.Error(ex.Message, ex);

                // Open Error Report
                if (!Properties.Settings.Default.DisableErrorReports)
                {
                    throw;
                }
            }
            finally
            {
                if (this.crmServiceClient != null)
                {
                    this.crmServiceClient.Dispose();
                }
            }
        }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DownloadMultiple"/> class.
        /// </summary>
        /// <param name="crmConnection"><see cref="Xrm.CrmConnection"/> for the XRM Connector</param>
        /// <param name="crmSolutions"><see cref="List{Xrm.CrmSolution}"/> of all Solutions to Download</param>
        public DownloadMultiple(Core.Xrm.CrmConnection crmConnection, List <Core.Xrm.CrmSolution> crmSolutions)
        {
            this.InitializeComponent();
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
            DownloadMultiple.statusTextBox        = this.tbx_status;
            DownloadMultiple.LogToUI("Started Form");
            this.Btn_close.IsEnabled = false;
            this.CRMConnection       = crmConnection;
            DownloadMultiple.LogToUI($"CRM Connection: {this.CRMConnection.Name}", true);
            this.CRMSolutions = crmSolutions;

            foreach (Core.Xrm.CrmSolution crmSolution in this.CRMSolutions)
            {
                DownloadMultiple.LogToUI($"Added Solution: { crmSolution.UniqueName} to Download List", true);
            }

            this.tbx_download.Text = crmConnection.LocalPath;
            DownloadMultiple.LogToUI($"Pulled Path form config: {crmConnection.LocalPath}", true);

            this.Owner = App.Current.MainWindow;
        }