Beispiel #1
0
        public void WorkAsync(WorkAsyncInfo info)
        {
            if (info.Host == null)
            {
                throw new NullReferenceException("WorkAsyncInfo Host property is null!");
            }

            _infoPanel = InformationPanel.GetInformationPanel(info.Host, info.Message, info.MessageWidth, info.MessageHeight);
            _worker    = new BackgroundWorker
            {
                WorkerReportsProgress      = info.ProgressChanged != null,
                WorkerSupportsCancellation = info.IsCancelable
            };
            _worker.DoWork += info.PerformWork;

            if (_worker.WorkerReportsProgress && info.ProgressChanged != null)
            {
                _worker.ProgressChanged += info.PerformProgressChange;
            }

            if (info.PostWorkCallBack != null)
            {
                _worker.RunWorkerCompleted += (s, e) =>
                {
                    if (info.Host.Controls.Contains(_infoPanel))
                    {
                        _infoPanel.Dispose();
                        info.Host.Controls.Remove(_infoPanel);
                    }
                    info.PostWorkCallBack(e);
                };
            }

            _worker.RunWorkerAsync(info.AsyncArgument);
        }
        public void SetWorkingMessage(Control host, string message, int width = 340, int height = 150)
        {
            if (string.IsNullOrEmpty(message))
            {
                return;
            }

            if (host.Controls.Contains(_infoPanel))
            {
                if (_infoPanel.Width != width || _infoPanel.Height != height)
                {
                    _infoPanel.Dispose();
                    host.Controls.Remove(_infoPanel);
                    _infoPanel = InformationPanel.GetInformationPanel(host, message, width, height);
                }
                else
                {
                    InformationPanel.ChangeInformationPanelMessage(_infoPanel, message);
                }
            }
            else
            {
                _infoPanel = InformationPanel.GetInformationPanel(host, message, width, height);
            }
        }
Beispiel #3
0
        public void WorkAsync(Control host, string message, Action <BackgroundWorker, DoWorkEventArgs> work, Action <RunWorkerCompletedEventArgs> callback, Action <ProgressChangedEventArgs> progressChanged, object argument = null, int messageWidth = 340, int messageHeight = 150)
        {
            _infoPanel = InformationPanel.GetInformationPanel(host, message, messageWidth, messageHeight);

            var worker = new BackgroundWorker {
                WorkerReportsProgress = progressChanged != null
            };

            worker.DoWork += (s, e) => work((BackgroundWorker)s, e);

            if (worker.WorkerReportsProgress && progressChanged != null)
            {
                worker.ProgressChanged += (s, e) => progressChanged(e);
            }

            worker.RunWorkerCompleted += (s, e) =>
            {
                if (host.Controls.Contains(_infoPanel))
                {
                    _infoPanel.Dispose();
                    host.Controls.Remove(_infoPanel);
                }
                callback(e);
            };
            worker.RunWorkerAsync(argument);
        }
Beispiel #4
0
        private void TsbTransfertSolutionClick(object sender, EventArgs e)
        {
            if (lstSourceSolutions.SelectedItems.Count == 1 && targetService != null)
            {
                importId = Guid.NewGuid();

                var item = lstSourceSolutions.SelectedItems[0];

                infoPanel = InformationPanel.GetInformationPanel(this, "Initializing...", 340, 120);

                var requests = new List <OrganizationRequest>();
                requests.Add(new ExportSolutionRequest
                {
                    Managed      = chkExportAsManaged.Checked,
                    SolutionName = item.Text,
                    ExportAutoNumberingSettings          = chkAutoNumering.Checked,
                    ExportCalendarSettings               = chkCalendar.Checked,
                    ExportCustomizationSettings          = chkCustomization.Checked,
                    ExportEmailTrackingSettings          = chkEmailTracking.Checked,
                    ExportGeneralSettings                = chkGeneral.Checked,
                    ExportIsvConfig                      = chkIsvConfig.Checked,
                    ExportMarketingSettings              = chkMarketing.Checked,
                    ExportOutlookSynchronizationSettings = chkOutlookSynchronization.Checked,
                    ExportRelationshipRoles              = chkRelationshipRoles.Checked
                });
                requests.Add(new ImportSolutionRequest
                {
                    ConvertToManaged = chkConvertToManaged.Checked,
                    OverwriteUnmanagedCustomizations = chkOverwriteUnmanagedCustomizations.Checked,
                    PublishWorkflows = chkActivate.Checked,
                    ImportJobId      = importId
                });

                if (!chkExportAsManaged.Checked && chkPublish.Checked)
                {
                    requests.Add(new PublishAllXmlRequest());
                }

                btnDownloadLog.Enabled       = false;
                tsbLoadSolutions.Enabled     = false;
                tsbTransfertSolution.Enabled = false;
                btnSelectTarget.Enabled      = false;
                Cursor = Cursors.WaitCursor;

                var worker = new BackgroundWorker();
                worker.DoWork               += WorkerDoWorkExport;
                worker.ProgressChanged      += WorkerProgressChanged;
                worker.RunWorkerCompleted   += WorkerRunWorkerCompleted;
                worker.WorkerReportsProgress = true;
                worker.RunWorkerAsync(requests);
            }
            else
            {
                MessageBox.Show("You have to select a source solution and a target organization to continue.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #5
0
        public void WorkAsync(Control host, string message, Action <DoWorkEventArgs> work, Action <RunWorkerCompletedEventArgs> callback, object argument = null, int messageWidth = 340, int messageHeight = 150)
        {
            _infoPanel = InformationPanel.GetInformationPanel(host, message, messageWidth, messageHeight);

            var worker = new BackgroundWorker();

            worker.DoWork += (s, e) => work(e);

            worker.RunWorkerCompleted += (s, e) =>
            {
                if (host.Controls.Contains(_infoPanel))
                {
                    _infoPanel.Dispose();
                    host.Controls.Remove(_infoPanel);
                }
                callback(e);
            };
            worker.RunWorkerAsync(argument);
        }
 private void WorkerProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     InformationPanel.ChangeInformationPanelMessage(infoPanel, e.UserState.ToString());
 }
        private void TsbTransfertSolutionClick(object sender, EventArgs e)
        {
            if (lstSourceSolutions.SelectedItems.Count > 0 && AdditionalConnectionDetails.Any())
            {
                var item = lstSourceSolutions.SelectedItems[0];

                var solutionsToTransfer = new List <string>();
                if (lstSourceSolutions.SelectedItems.Count > 1)
                {
                    // Open dialog to order solutions import
                    foreach (ListViewItem sourceItem in lstSourceSolutions.SelectedItems)
                    {
                        solutionsToTransfer.Add(sourceItem.Text);
                    }

                    var dialog = new SolutionOrderDialog(solutionsToTransfer);
                    if (dialog.ShowDialog(ParentForm) == DialogResult.OK)
                    {
                        solutionsToTransfer = dialog.Solutions;
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    solutionsToTransfer.Add(item.Text);
                }

                infoPanel = InformationPanel.GetInformationPanel(this, "Initializing...", 340, 120);

                var requests = new List <OrganizationRequest>();

                foreach (var solution in solutionsToTransfer)
                {
                    var importId = Guid.NewGuid();

                    requests.Add(new ExportSolutionRequest
                    {
                        Managed      = chkExportAsManaged.Checked,
                        SolutionName = solution,
                        ExportAutoNumberingSettings          = chkAutoNumering.Checked,
                        ExportCalendarSettings               = chkCalendar.Checked,
                        ExportCustomizationSettings          = chkCustomization.Checked,
                        ExportEmailTrackingSettings          = chkEmailTracking.Checked,
                        ExportGeneralSettings                = chkGeneral.Checked,
                        ExportIsvConfig                      = chkIsvConfig.Checked,
                        ExportMarketingSettings              = chkMarketing.Checked,
                        ExportOutlookSynchronizationSettings = chkOutlookSynchronization.Checked,
                        ExportRelationshipRoles              = chkRelationshipRoles.Checked
                    });

                    requests.Add(new ImportSolutionRequest
                    {
                        ConvertToManaged = chkConvertToManaged.Checked,
                        OverwriteUnmanagedCustomizations = chkOverwriteUnmanagedCustomizations.Checked,
                        PublishWorkflows = chkActivate.Checked,
                        ImportJobId      = importId
                    });
                }

                if (!chkExportAsManaged.Checked && chkPublish.Checked)
                {
                    requests.Add(new PublishAllXmlRequest());
                }

                tsbDownloadLogFile.Enabled         = false;
                tsbFindMissingDependencies.Enabled = false;
                tsbLoadSolutions.Enabled           = false;
                tsbTransfertSolution.Enabled       = false;
                btnAddTarget.Enabled = false;
                Cursor = Cursors.WaitCursor;

                using (var worker = new BackgroundWorker())
                {
                    worker.DoWork               += WorkerDoWorkExport;
                    worker.ProgressChanged      += WorkerProgressChanged;
                    worker.RunWorkerCompleted   += WorkerRunWorkerCompleted;
                    worker.WorkerReportsProgress = true;
                    worker.RunWorkerAsync(requests);
                }
            }
            else
            {
                MessageBox.Show("You have to select a source solution and a target organization to continue.", "Warning",
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }