private void ListViewSourceTarget_DoubleClick(object sender, EventArgs e) { var itemFrom = ((ListView)sender).FocusedItem.Tag.ToString(); var step = StepsCrmSource.Where(x => itemFrom == x.StepId.ToString()).FirstOrDefault(); if (step == null) { return; } var stepDetails = new StepDiffDetails(step); stepDetails.Show(); }
private void Compare() { if (ComparisonMethod.RequiresItemSelection && SolutionAssemblyPluginStepsName == null) { MessageBox.Show($@"Please select a {ComparisonMethod.Name} first."); return; } Guid[] diffCrmSourceTarget = null; Guid[] diffCrmTargetSource = null; StepsCrmSource.Clear(); StepsCrmTarget.Clear(); WorkAsync(new WorkAsyncInfo { Message = $"Comparing the 2 {ComparisonMethod.PluralName.Capitalize()}...", Work = (bw, e) => { SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(0, "Fetching steps from source environment...")); StepsCrmSource = ComparisonMethod.GetSteps(SourceService, Settings, SolutionAssemblyPluginStepsName); SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(30, "Fetching steps from target environment...")); StepsCrmTarget = ComparisonMethod.GetSteps(TargetService, Settings, SolutionAssemblyPluginStepsName); foreach (var step in StepsCrmTarget) { step.Environment = "Target"; } SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(60, "Comparing steps...")); Comparer.Compare(StepsCrmSource, StepsCrmTarget); SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(90, "Finding Differences...")); if (compareBy == CompareBy.Guid) { diffCrmSourceTarget = StepsCrmSource.Select(x => x.StepId) .Except(StepsCrmTarget.Select(x => x.StepId)).ToArray(); diffCrmTargetSource = StepsCrmTarget.Select(x => x.StepId) .Except(StepsCrmSource.Select(x => x.StepId)).ToArray(); } else if (compareBy == CompareBy.Name) { diffCrmSourceTarget = StepsCrmSource.Where(xx => (StepsCrmSource.Select(x => x.StepName) .Except(StepsCrmTarget.Select(x => x.StepName))).Contains(xx.StepName)).Select(x => x.StepId).ToArray(); diffCrmTargetSource = StepsCrmTarget.Where(xx => (StepsCrmTarget.Select(x => x.StepName) .Except(StepsCrmSource.Select(x => x.StepName))).Contains(xx.StepName)).Select(x => x.StepId).ToArray(); } SendMessageToStatusBar?.Invoke(this, new StatusBarMessageEventArgs(100, "Done!")); }, PostWorkCallBack = e => { if (e.Error != null) { Log.LogData(EventType.Exception, ComparisonMethod.LogActionOnCompare, e.Error); MessageBox.Show(this, e.Error.Message, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); toolStripButtonExport.Enabled = false; return; } toolStripButtonExport.Enabled = true; if (diffCrmSourceTarget.Length == 0) { listViewSourceTarget.Items.Clear(); labelSourceTargetMatch.Visible = true; } else // there are steps in source but not target { labelSourceTargetMatch.Visible = false; listViewSourceTarget.Visible = true; FillListViewItems(listViewSourceTarget, StepsCrmSource, diffCrmSourceTarget); } if (diffCrmTargetSource.Count() == 0) { listViewTargetSource.Items.Clear(); labelTargetSourceMatch.Visible = true; } else // there are steps in source but not target { labelTargetSourceMatch.Visible = false; listViewTargetSource.Visible = true; FillListViewItems(listViewTargetSource, StepsCrmTarget, diffCrmTargetSource); } Log.LogData(EventType.Event, ComparisonMethod.LogActionOnCompare); }, ProgressChanged = e => { SetWorkingMessage(e.UserState.ToString()); } }); }