protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs e)
 {
     if (AdditionalConnectionDetails != null && AdditionalConnectionDetails.Count > 0)
     {
         targetEnvironmentTextBox.Text = AdditionalConnectionDetails.Last().ConnectionName;
     }
 }
        protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                var detail = AdditionalConnectionDetails.Last();
                targetService = detail.GetCrmServiceClient();

                tssbTransferData.Text       = $@"Transfer records to {detail.OrganizationFriendlyName}";
                tsmiTansferToNewOrg.Visible = true;

                pnlImportFile.Visible = false;
                pnlImport.BringToFront();
                tsMain.Enabled    = false;
                pnlImport.Visible = true;
                btnImport.Visible = false;

                ExportData(false);
            }
        }
        private void transfer()
        {
            var fileName = Path.Combine(Application.UserAppDataPath, Path.GetRandomFileName());


            if (AdditionalConnectionDetails.Count < 1)
            {
                MessageBox.Show("Please connect the target organisation.");
                return;
            }

            WorkAsync(new WorkAsyncInfo
            {
                Message = $"Transferring access team templates",
                Work    = (worker, args) =>
                {
                    LogInfo("test");
                    execute(Operation.Export, fileName);
                    execute(Operation.Import, fileName, AdditionalConnectionDetails.Last().GetCrmServiceClient());
                },
                PostWorkCallBack = (args) =>
                {
                    if (args.Error != null)
                    {
                        MessageBox.Show(args.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        if (File.Exists(fileName))
                        {
                            File.Delete(fileName);
                        }
                        MessageBox.Show($"Successfully transferred from {ConnectionDetail.ConnectionName} to {AdditionalConnectionDetails.Last().ConnectionName}.");
                    }
                }
            });
        }
        private void execute(Operation operation, string fileName, IOrganizationService service = null)
        {
            ICommand command = CommandFactory.GetInstance(operation);

            command.Service         = service ?? Service;
            command.FileName        = fileName;
            command.LogWriter       = this;
            command.OrganisationUrl = service == null ? ConnectionDetail.WebApplicationUrl : AdditionalConnectionDetails.Last().WebApplicationUrl;
            command.Execute();
        }