protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs e) { if (AdditionalConnectionDetails != null && AdditionalConnectionDetails.Count > 0) { targetEnvironmentTextBox.Text = AdditionalConnectionDetails.Last().ConnectionName; } }
private void tsbSwitchOrgs_Click(object sender, EventArgs e) { if (AdditionalConnectionDetails.Count > 1) { MessageBox.Show(this, @"Switch can only be performed when no more than one target organization is defined", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var tempDetail = sourceDetail; sourceDetail = AdditionalConnectionDetails.FirstOrDefault(); ConnectionDetail = AdditionalConnectionDetails.FirstOrDefault(); AdditionalConnectionDetails.Clear(); if (tempDetail != null) { AdditionalConnectionDetails.Add(tempDetail); } mForm.SwitchSourceAndTarget(tempDetail, sourceDetail); if (sourceDetail != null) { sourceService = sourceDetail.GetCrmServiceClient(); base.UpdateConnection(sourceService, sourceDetail, "", null); RetrieveSolutions(); } }
public override void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName, object parameter) { ConnectionDetail = detail; if (actionName == "AdditionalOrganization") { AdditionalConnectionDetails.Add(detail); if (newService is OrganizationServiceProxy proxy) { proxy.Timeout = detail.Timeout; } else if (newService is OrganizationWebProxyClient client) { client.InnerChannel.OperationTimeout = detail.Timeout; } mForm.DisplayTargetOrganizations(AdditionalConnectionDetails.ToList()); } else { sourceDetail = detail; sourceService = newService; RetrieveSolutions(); mForm.SetSourceOrganization(detail); } }
protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs ee) { ConnectButton.Visible = false; ConnectionLabel.Visible = true; ConnectionLabel.Text = $"Connected to {AdditionalConnectionDetails.First().ConnectionName}"; CompareMenu.Enabled = true; ShowMode.Enabled = true; }
protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs e) { lstTargetEnvironments.Items.Clear(); lstTargetEnvironments.Items.AddRange(AdditionalConnectionDetails.Select(cd => new ListViewItem(cd.ConnectionName) { Tag = cd }).ToArray()); }
private void buttonChangeTarget_Click(object sender, EventArgs e) { LogInfo("Clicked on Target Change button."); if (AdditionalConnectionDetails.Any()) { RemoveAdditionalOrganization(TargetConnection); } AddAdditionalOrganization(); }
public override void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName = "", object parameter = null) { ConnectionDetail = detail; if (actionName == "AdditionalOrganization") { AdditionalConnectionDetails.Clear(); AdditionalConnectionDetails.Add(detail); SetConnectionLabel(detail, "Target"); } else { SetConnectionLabel(detail, "Source"); } base.UpdateConnection(newService, detail, actionName, parameter); }
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}."); } } }); }
public override void UpdateConnection(IOrganizationService newService, ConnectionDetail detail, string actionName = "", object parameter = null) { ConnectionDetail = detail; if (actionName == "AdditionalOrganization") { AdditionalConnectionDetails.Add(detail); if (newService is OrganizationServiceProxy proxy) { proxy.Timeout = detail.Timeout; } else if (newService is OrganizationWebProxyClient) { ((OrganizationWebProxyClient)newService).InnerChannel.OperationTimeout = detail.Timeout; } } else { sourceService = newService; solutionUrlBase = detail.WebApplicationUrl; SetConnectionLabel(detail, "Source"); RetrieveSolutions(); } }
private void TsbTransfertSolutionClick(object sender, EventArgs e) { if (mForm.SelectedSolutions.Count == 0 || !AdditionalConnectionDetails.Any()) { MessageBox.Show(@"You have to select a source solution and a target organization to continue.", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var solutionsToTransfer = PreparareSolutionsToTransfer(); if (solutionsToTransfer.Count == 0) { return; } var requests = new List <OrganizationRequest>(); progressItems = new Dictionary <OrganizationRequest, ProgressItem>(); toProcessList = new List <BaseToProcess>(); foreach (var solution in solutionsToTransfer) { var exportItem = new ExportToProcess { Solution = solution, Previous = toProcessList.OfType <ExportToProcess>().LastOrDefault(), Request = PrepareExportRequest(solution), Detail = sourceDetail }; toProcessList.Add(exportItem); foreach (var detail in AdditionalConnectionDetails) { toProcessList.Add(new ImportToProcess { Solution = solution, Previous = toProcessList.OfType <ImportToProcess>().LastOrDefault(x => x.Detail == detail), Export = exportItem, Request = PrepareImportRequest(detail, solution), Detail = detail }); } } if (!Settings.Instance.Managed && Settings.Instance.Publish) { foreach (var detail in AdditionalConnectionDetails) { toProcessList.Add(new PublishToProcess { Request = PreparePublishRequest(detail), Detail = detail }); } } // Add items to progress form pForm.Items = progressItems.Values.ToList(); pForm.Start(); pForm.Show(dpMain, DockState.DockRight); ToggleWaitMode(true); StartExport(toProcessList.OfType <ExportToProcess>().First()); timer.Elapsed += Timer_Elapsed; timer.Interval = Settings.Instance.RefreshIntervalProp.TotalMilliseconds; timer.Start(); }
private void ComparePluginsButton_Click(object sender, EventArgs ee) { SourceIdColumn.DisplayIndex = 0; OtherIdColumn.DisplayIndex = 1; SourceSizeColumn.DisplayIndex = 2; OtherSizeColumn.DisplayIndex = 3; NameColumn.DisplayIndex = 4; SourceVersionColumn.DisplayIndex = 5; ResultColumn.DisplayIndex = 6; OtherVersionColumn.DisplayIndex = 7; SourceIdColumn.Width = 0; OtherIdColumn.Width = 0; SourceSizeColumn.Width = 0; OtherSizeColumn.Width = 3; NameColumn.Width = 300; SourceVersionColumn.Width = 60; ResultColumn.Width = 40; OtherVersionColumn.Width = 60; ResultList.Items.Clear(); var otherConnection = AdditionalConnectionDetails.First(); var otherService = otherConnection.GetCrmServiceClient(); WorkAsync(new WorkAsyncInfo { Message = "Compare Plug-ins...", Work = (w, e) => { var retrieveSourceAssembliesTask = Task.Run(() => RetrieveAssemblies(Service)); var retrieveOtherAssembliesTask = Task.Run(() => RetrieveAssemblies(otherService)); Task.WaitAll(retrieveSourceAssembliesTask, retrieveOtherAssembliesTask); var sourceAssemblies = retrieveSourceAssembliesTask.Result; var otherAssemblies = retrieveOtherAssembliesTask.Result; var items = new List <ListViewItem>(); foreach (var sourceAssembly in sourceAssemblies) { var name = sourceAssembly.GetAttributeValue <string>("name"); var version = sourceAssembly.GetAttributeValue <string>("version"); var versionParts = version.Split('.'); var versionPattern = $"{versionParts[0]}.{versionParts[1]}."; var otherAssembly = otherAssemblies.FirstOrDefault(a => a.GetAttributeValue <string>("name") == name && a.GetAttributeValue <string>("version").StartsWith(versionPattern)); if (otherAssembly == null) { items.Add(new AssemblyComparerItem(name, sourceAssembly.Id, version, null, null) { Group = ResultList.Groups["PluginsGroup"] }); } else { items.Add(new AssemblyComparerItem(name, sourceAssembly.Id, version, otherAssembly.Id, otherAssembly.GetAttributeValue <string>("version")) { Group = ResultList.Groups["PluginsGroup"] }); otherAssemblies.Remove(otherAssembly); } } foreach (var otherAssembly in otherAssemblies) { items.Add(new AssemblyComparerItem(otherAssembly.GetAttributeValue <string>("name"), null, null, otherAssembly.Id, otherAssembly.GetAttributeValue <string>("version")) { Group = ResultList.Groups["PluginsGroup"] }); } e.Result = items.OrderBy(lvi => lvi.Name).ToArray(); }, PostWorkCallBack = e => { _items = (ListViewItem[])e.Result; ShowMode_SelectedIndexChanged(null, null); }, MessageWidth = 340, MessageHeight = 150 }); }
protected override void ConnectionDetailsUpdated(NotifyCollectionChangedEventArgs e) { mForm.DisplayTargetOrganizations(AdditionalConnectionDetails.ToList()); }
private void TsbTransfertTemplatesClick(object sender, EventArgs e) { if (lvTemplates.SelectedItems.Count > 0 && AdditionalConnectionDetails.Count > 0) { var selectedTemplates = lvTemplates.SelectedItems.Cast <ListViewItem>().Select(item => (Entity)item.Tag).ToList(); lbLogs.Items.Clear(); tsbLoadTemplates.Enabled = false; tsbTransfertTemplates.Enabled = false; btnSelectTarget.Enabled = false; Cursor = Cursors.WaitCursor; var worker = new BackgroundWorker(); worker.DoWork += (s, evt) => { List <Entity> templates = (List <Entity>)evt.Argument; var total = templates.Count; var current = 0; var targetService = AdditionalConnectionDetails.First().GetCrmServiceClient(); foreach (var template in templates) { current++; string etc = template.GetAttributeValue <string>("associatedentitytypecode"); string name = template.GetAttributeValue <string>("name"); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(current * 100 / total, "Processing template '" + name + "'...")); try { int?oldEtc = tManager.GetEntityTypeCode(Service, etc); int?newEtc = tManager.GetEntityTypeCode(targetService, etc); tManager.ReRouteEtcViaOpenXML(template, name, etc, oldEtc, newEtc); var templateToTransfer = new Entity(template.LogicalName); foreach (var attribute in template.Attributes) { templateToTransfer[attribute.Key] = attribute.Value; } templateToTransfer["associatedentitytypecode"] = newEtc; Guid existingId = tManager.TemplateExists(targetService, name); if (existingId != null && existingId != Guid.Empty) { templateToTransfer["documenttemplateid"] = existingId; targetService.Update(templateToTransfer); } else { targetService.Create(templateToTransfer); } Log(name, true); } catch (Exception error) { Log(name, false, error.Message); } } }; worker.ProgressChanged += (s, evt) => { SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(0, evt.UserState.ToString())); }; worker.RunWorkerCompleted += (s, evt) => { if (evt.Error != null) { MessageBox.Show(ParentForm, @"An error has occured while transferring templates: " + evt.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } tsbLoadTemplates.Enabled = true; tsbTransfertTemplates.Enabled = true; btnSelectTarget.Enabled = true; Cursor = Cursors.Default; SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(string.Empty)); }; worker.WorkerReportsProgress = true; worker.RunWorkerAsync(selectedTemplates); } else { MessageBox.Show(@"You have to select at least one source template and a target organization to continue.", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
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); } }
private void MForm_TargetOrganizationRemoved(object sender, TargetOrganizationsEventArgs e) { var toRemove = AdditionalConnectionDetails.FirstOrDefault(c => !e.TargetOrganizations.Contains(c)); RemoveAdditionalOrganization(toRemove); }
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(); }
private void TsbTransferDupeRulesClick(object sender, EventArgs e) { if (lvDedupeRules.SelectedItems.Count > 0 && AdditionalConnectionDetails.Count > 0) { var selectedRules = lvDedupeRules.SelectedItems.Cast <ListViewItem>().Select(item => (IGrouping <Guid, Entity>)item.Tag).ToList(); lbLogs.Items.Clear(); tsbLoadDupeRules.Enabled = false; tsbTransferDupeRules.Enabled = false; btnSelectTarget.Enabled = false; Cursor = Cursors.WaitCursor; var worker = new BackgroundWorker(); worker.DoWork += (s, evt) => { var selections = (List <IGrouping <Guid, Entity> >)evt.Argument; var total = selections.Count; var current = 0; var targetService = AdditionalConnectionDetails.First().GetCrmServiceClient(); foreach (var ruleGroup in selections) { current++; string name = ruleGroup.First().GetAttributeValue <string>("name"); SendMessageToStatusBar(this, new StatusBarMessageEventArgs(current * 100 / total, "Processing rule '" + name + "'...")); try { var ruleToTransfer = new Entity(ruleGroup.First().LogicalName); foreach (var attribute in ruleGroup.First().Attributes) { // skip related condition records if (!attribute.Key.StartsWith("condition.")) { ruleToTransfer[attribute.Key] = attribute.Value; } } // Delete existing conditions (or delete entire rule) Guid existingId = _drManager.DedupeRuleExists(targetService, name); if (existingId != Guid.Empty) { ruleToTransfer["duplicateruleid"] = existingId; targetService.Delete(ruleToTransfer.LogicalName, existingId); } existingId = targetService.Create(ruleToTransfer); ruleToTransfer["duplicateruleid"] = existingId; // iterate conditions and apply those foreach (var condition in ruleGroup) { var dedupeCondition = new Entity("duplicaterulecondition") { ["regardingobjectid"] = new EntityReference(ruleToTransfer.LogicalName, existingId) }; foreach (var attribute in condition.Attributes) { // only use related condition records if (attribute.Key.StartsWith("condition.") && !attribute.Key.EndsWith(".duplicateruleconditionid")) { dedupeCondition[attribute.Key.Replace("condition.", String.Empty)] = ((AliasedValue)attribute.Value).Value; } } targetService.Create(dedupeCondition); } // publish if source as also pubished if (ruleGroup.First().GetAttributeValue <OptionSetValue>("statecode").Value == 1) // active { PublishDuplicateRuleRequest publishReq = new PublishDuplicateRuleRequest { DuplicateRuleId = existingId }; targetService.Execute(publishReq); } Log(name, true); } catch (Exception error) { Log(name, false, error.Message); } } }; worker.ProgressChanged += (s, evt) => { SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(0, evt.UserState.ToString())); }; worker.RunWorkerCompleted += (s, evt) => { if (evt.Error != null) { MessageBox.Show(ParentForm, @"An error has occured while transferring dedupe rules: " + evt.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } tsbLoadDupeRules.Enabled = true; tsbTransferDupeRules.Enabled = true; btnSelectTarget.Enabled = true; Cursor = Cursors.Default; SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(string.Empty)); }; worker.WorkerReportsProgress = true; worker.RunWorkerAsync(selectedRules); } else { MessageBox.Show(@"You have to select at least one source dedupe rule and a target organisation to continue.", @"Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void CompareWebResources(string resourveName, int[] resourceTypes) { SourceIdColumn.DisplayIndex = 0; OtherIdColumn.DisplayIndex = 1; SourceVersionColumn.DisplayIndex = 2; OtherVersionColumn.DisplayIndex = 3; NameColumn.DisplayIndex = 4; SourceSizeColumn.DisplayIndex = 5; ResultColumn.DisplayIndex = 6; OtherSizeColumn.DisplayIndex = 7; SourceIdColumn.Width = 0; OtherIdColumn.Width = 0; SourceVersionColumn.Width = 0; OtherVersionColumn.Width = 0; NameColumn.Width = 300; SourceSizeColumn.Width = 60; ResultColumn.Width = 40; OtherSizeColumn.Width = 60; ResultList.Items.Clear(); var otherConnection = AdditionalConnectionDetails.First(); var otherService = otherConnection.GetCrmServiceClient(); WorkAsync(new WorkAsyncInfo { Message = $"Compare {resourveName} Web Resources...", Work = (w, e) => { var retrieveSourceResourcesTask = Task.Run(() => RetrieveWebResources(Service, resourceTypes)); var retrieveOtherResourcesTask = Task.Run(() => RetrieveWebResources(otherService, resourceTypes)); Task.WaitAll(retrieveSourceResourcesTask, retrieveOtherResourcesTask); var sourceResources = retrieveSourceResourcesTask.Result; var otherResources = retrieveOtherResourcesTask.Result; var items = new List <ListViewItem>(); foreach (var sourceResource in sourceResources) { var name = sourceResource.GetAttributeValue <string>("name"); var content = sourceResource.GetAttributeValue <string>("content"); var otherResource = otherResources.FirstOrDefault(a => a.GetAttributeValue <string>("name") == name); if (otherResource == null) { items.Add(new WebResourceComparerItem(name, sourceResource.Id, content, null, null)); } else { items.Add(new WebResourceComparerItem(name, sourceResource.Id, content, otherResource.Id, otherResource.GetAttributeValue <string>("content"))); otherResources.Remove(otherResource); } } foreach (var otherResource in otherResources) { items.Add(new WebResourceComparerItem(otherResource.GetAttributeValue <string>("name"), null, null, otherResource.Id, otherResource.GetAttributeValue <string>("content"))); } e.Result = items.OrderBy(lvi => lvi.Name).ToArray(); }, PostWorkCallBack = e => { _items = (ListViewItem[])e.Result; ShowMode_SelectedIndexChanged(null, null); }, MessageWidth = 400, MessageHeight = 150 }); }