Example #1
0
        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();
        }
Example #2
0
        private void Compare()
        {
            if (ComparisonMethod.RequiresItemSelection &&
                SolutionAssemblyPluginStepsName == null)
            {
                MessageBox.Show($@"Please select a {ComparisonMethod.Name} first.");
                return;
            }

            string[] diffCrmSourceTarget = null;
            string[] 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..."));
                    diffCrmSourceTarget = StepsCrmSource.Select(x => x.StepName).Except(StepsCrmTarget.Select(x => x.StepName)).ToArray();
                    diffCrmTargetSource = StepsCrmTarget.Select(x => x.StepName).Except(StepsCrmSource.Select(x => x.StepName)).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());
                }
            });
        }