Пример #1
0
        private void ToolStripButtonExport_Click(object sender, EventArgs e)
        {
            var fileName = (Controller?.Source?.ConnectionName ?? string.Empty).Replace(" ", "") + "To" + (Controller?.Target?.ConnectionName ?? string.Empty).Replace(" ", "") + ".csv";

            if (!string.IsNullOrWhiteSpace(saveFileDialog1.FileName))
            {
                var directory = Path.GetDirectoryName(saveFileDialog1.FileName);
                fileName = Path.Combine(directory, fileName);
            }

            saveFileDialog1.FileName = fileName;

            if (saveFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var file   = saveFileDialog1.FileName;
            var export = new List <CarfupStep>();

            export.AddRange(StepsCrmSource);
            export.AddRange(StepsCrmTarget);

            var csv = export.OrderBy(s => s.AssemblyName)
                      .ThenBy(s => s.PluginTypeName)
                      .ThenBy(s => s.StepName)
                      .Select(s => s.ToCsv()).ToList();

            csv.Insert(0, CarfupStep.GetCsvColumns());
            File.WriteAllText(file, string.Join(Environment.NewLine, csv));
        }
Пример #2
0
        public Guid?CreateStep(CarfupStep selectedStep, bool toTarget = true)
        {
            var pluginTypeRetrievedLogAction    = (toTarget) ? LogAction.PluginTypeRetrievedSourceToTarget : LogAction.PluginTypeRetrievedTargetToSource;
            var sdkMessageRetrievedLogAction    = (toTarget) ? LogAction.SdkMessageRetrievedSourceToTarget : LogAction.SdkMessageRetrievedTargetToSource;
            var messageFilterRetrievedLogAction = (toTarget) ? LogAction.MessageFilterRetrievedSourceToTarget : LogAction.MessageFilterRetrievedTargetToSource;
            var service = (toTarget) ? TargetService : SourceService;

            // retrieving the 3 data mandatory to have a proper step created
            var pluginType    = Controller.DataManager.GetPluginType(service, selectedStep.PluginTypeName);
            var sdkMessage    = Controller.DataManager.GetSdkMessage(service, selectedStep.StepMessageName);
            var messageFilter = Controller.DataManager.GetMessageFilter(service, selectedStep.EntityName);

            if (pluginType == null)
            {
                Log.LogData(EventType.Exception, pluginTypeRetrievedLogAction);
                MessageBox.Show(@"Sorry, but we didn't find the necessary Plugin Type information in the destination system...\r\rThis can occur because you didn't load the same assembly in the destination system.");
                return(null);
            }

            if (sdkMessage == null)
            {
                Log.LogData(EventType.Exception, sdkMessageRetrievedLogAction);
                MessageBox.Show(@"Sorry, but we didn't find the necessary SDK Message information in the destination system...");
                return(null);
            }

            if (messageFilter == null)
            {
                Log.LogData(EventType.Exception, messageFilterRetrievedLogAction);
                MessageBox.Show(@"Sorry, but we didn't find the necessary Message Filter information in the destination system...");
                return(null);
            }


            Log.LogData(EventType.Event, pluginTypeRetrievedLogAction);
            Log.LogData(EventType.Event, sdkMessageRetrievedLogAction);
            Log.LogData(EventType.Event, messageFilterRetrievedLogAction);

            // Preparing the object step
            Entity newStepToCreate = new Entity("sdkmessageprocessingstep");

            newStepToCreate["plugintypeid"]       = new EntityReference("plugintype", pluginType.Id);
            newStepToCreate["sdkmessageid"]       = new EntityReference("sdkmessage", sdkMessage.Id);
            newStepToCreate["sdkmessagefilterid"] = new EntityReference("sdkmessagefilter", messageFilter.Id);
            newStepToCreate["name"]  = selectedStep.StepName;
            newStepToCreate["mode"]  = selectedStep.StepMode;
            newStepToCreate["rank"]  = selectedStep.StepRank;
            newStepToCreate["stage"] = selectedStep.StepStage;
            newStepToCreate["supporteddeployment"] = selectedStep.StepSupportedDeployment;
            newStepToCreate["invocationsource"]    = selectedStep.StepInvocationSource;
            newStepToCreate["configuration"]       = selectedStep.StepConfiguration;
            newStepToCreate["filteringattributes"] = selectedStep.StepFilteringAttributes;
            newStepToCreate["description"]         = selectedStep.StepDescription;
            newStepToCreate["asyncautodelete"]     = selectedStep.StepAsyncAutoDelete;
            newStepToCreate["customizationlevel"]  = selectedStep.StepCustomizationLevel;

            return(service.Create(newStepToCreate));
        }
        public void Compare_EntireOrg_Should_Compare()
        {
            var settings    = new PluginSettings();
            var sourceStep  = OrgComparisonMethod.Instance.GetSteps(null, settings, null);
            var targetSteps = OrgComparisonMethod.Instance.GetSteps(null, settings, null);

            Comparer.Compare(sourceStep, targetSteps);

            sourceStep.AddRange(targetSteps);

            var csv = sourceStep.OrderBy(s => s.AssemblyName)
                      .ThenBy(s => s.PluginTypeName)
                      .ThenBy(s => s.StepName)
                      .Select(s => s.ToCsv()).ToList();

            csv.Insert(0, CarfupStep.GetCsvColumns());
            File.WriteAllText(@"C:\Temp\UnitTest.csv", string.Join(Environment.NewLine, csv));
        }
        public StepDiffDetails(CarfupStep step)
        {
            InitializeComponent();
            this.step = step;
            this.Text = $"Step Details : {step.StepName}";

            foreach (var s in step.GetType().GetProperties().OrderBy(x => x.Name))
            {
                if (s.GetValue(step, null) is Entity)
                {
                    continue;
                }

                dataGridViewStepDetails.Rows.Add(new string[] { s.Name, s.GetValue(step, null)?.ToString() });
            }

            dataGridViewStepDetails.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
            dataGridViewStepDetails.AutoSizeRowsMode          = DataGridViewAutoSizeRowsMode.AllCells;
            dataGridViewStepDetails.AutoResizeColumns();
        }
Пример #5
0
        public Guid?CreateStep(CarfupStep selectedStep, bool toTarget = true)
        {
            var pluginTypeRetrievedLogAction    = (toTarget) ? LogAction.PluginTypeRetrievedSourceToTarget : LogAction.PluginTypeRetrievedTargetToSource;
            var sdkMessageRetrievedLogAction    = (toTarget) ? LogAction.SdkMessageRetrievedSourceToTarget : LogAction.SdkMessageRetrievedTargetToSource;
            var messageFilterRetrievedLogAction = (toTarget) ? LogAction.MessageFilterRetrievedSourceToTarget : LogAction.MessageFilterRetrievedTargetToSource;
            var service     = (toTarget) ? TargetService : SourceService;
            var serviceFrom = (toTarget) ? SourceService : TargetService;

            // retrieving the 3 data mandatory to have a proper step created
            var pluginTypeName = selectedStep.PluginTypeName == null
                ? Controller.DataManager.GetPluginTypeName(serviceFrom, selectedStep.Plugin.Id).GetAttributeValue <string>("name")
                : selectedStep.PluginTypeName;

            var pluginType    = Controller.DataManager.GetPluginType(service, pluginTypeName);
            var sdkMessage    = Controller.DataManager.GetSdkMessage(service, selectedStep.StepMessageName);
            var messageFilter = Controller.DataManager.GetMessageFilter(service, selectedStep.EntityName);



            //if (pluginType == null)
            //{
            //    Log.LogData(EventType.Exception, pluginTypeRetrievedLogAction);
            //    MessageBox.Show(@"Sorry, but we didn't find the necessary Plugin Type information in the destination system...\r\rThis can occur because you didn't load the same assembly in the destination system.");
            //    return null;
            //}

            if (sdkMessage == null)
            {
                Log.LogData(EventType.Exception, sdkMessageRetrievedLogAction);
                MessageBox.Show(@"Sorry, but we didn't find the necessary SDK Message information in the destination system...");
                return(null);
            }

            if (messageFilter == null)
            {
                Log.LogData(EventType.Exception, messageFilterRetrievedLogAction);
                MessageBox.Show(@"Sorry, but we didn't find the necessary Message Filter information in the destination system...");
                return(null);
            }


            var sdkMessageImage = Controller.DataManager.GetSdkMessageProcessingStepImage(serviceFrom, selectedStep.StepId);

            Log.LogData(EventType.Event, pluginTypeRetrievedLogAction);
            Log.LogData(EventType.Event, sdkMessageRetrievedLogAction);
            Log.LogData(EventType.Event, messageFilterRetrievedLogAction);

            // Preparing the object step
            Entity newStepToCreate = new Entity("sdkmessageprocessingstep");

            newStepToCreate["plugintypeid"]       = pluginType.ToEntityReference();
            newStepToCreate["sdkmessageid"]       = sdkMessage.ToEntityReference();
            newStepToCreate["sdkmessagefilterid"] = messageFilter.ToEntityReference();
            newStepToCreate["name"]  = selectedStep.StepName;
            newStepToCreate["mode"]  = new OptionSetValue((int)selectedStep.StepMode);
            newStepToCreate["rank"]  = selectedStep.StepRank;
            newStepToCreate["stage"] = new OptionSetValue((int)selectedStep.StepStage);
            newStepToCreate["supporteddeployment"] = new OptionSetValue((int)selectedStep.StepSupportedDeployment);
            newStepToCreate["invocationsource"]    = selectedStep.StepInvocationSource;
            newStepToCreate["configuration"]       = selectedStep.StepConfiguration;
            newStepToCreate["filteringattributes"] = selectedStep.StepFilteringAttributes;
            newStepToCreate["description"]         = selectedStep.StepDescription;
            newStepToCreate["asyncautodelete"]     = selectedStep.StepAsyncAutoDelete;
            newStepToCreate["customizationlevel"]  = selectedStep.StepCustomizationLevel;

            var createdStep = service.Create(newStepToCreate);

            if (sdkMessageImage != null)
            {
                Entity newStepImageToCreate = new Entity("sdkmessageprocessingstepimage");
                newStepImageToCreate["messagepropertyname"] = sdkMessageImage.GetAttributeValue <string>("messagepropertyname");
                newStepImageToCreate["customizationlevel"]  = sdkMessageImage.GetAttributeValue <int?>("customizationlevel");
                newStepImageToCreate["ismanaged"]           = sdkMessageImage.GetAttributeValue <bool?>("ismanaged");
                newStepImageToCreate["imagetype"]           = sdkMessageImage.GetAttributeValue <OptionSetValue>("imagetype");
                newStepImageToCreate["name"]                       = sdkMessageImage.GetAttributeValue <string>("name");
                newStepImageToCreate["entityalias"]                = sdkMessageImage.GetAttributeValue <string>("entityalias");
                newStepImageToCreate["attributes"]                 = sdkMessageImage.GetAttributeValue <string>("attributes");
                newStepImageToCreate["description"]                = sdkMessageImage.GetAttributeValue <string>("description");
                newStepImageToCreate["relatedattributename"]       = sdkMessageImage.GetAttributeValue <string>("relatedattributename");
                newStepImageToCreate["sdkmessageprocessingstepid"] = new EntityReference("sdkmessageprocessingstep", createdStep);

                service.Create(newStepImageToCreate);
            }

            return(createdStep);
        }
        public StepRegistrationForm(OrganizationData orgData, CarfupStep step = null)
        {
            currentStep = step;
            orgData     = orgData;

            InitializeComponent();

            // Init of the fields
            //Initialize the auto-complete on the Message field
            var msgList = new AutoCompleteStringCollection();

            foreach (SdkMessage msg in orgData.cMessages)
            {
                msgList.Add(msg.Name);
            }
            txtMessageName.AutoCompleteCustomSource = msgList;

            cmbUsers.Sorted = false;
            foreach (SystemUser user in orgData.cUsers)
            {
                // Added this check to to prevent OutofMemoryExcetion - When an org is imported, the administrator
                // does not have a name associated with it, Adding Null Names to ComboBox throws OutofMemoryExcetion
                if (null != user && !user.IsDisabled.Value && user.FullName != null)
                {
                    cmbUsers.Items.Add(user.FullName);
                }
                // Special case to add System user
                if (user.FullName == "SYSTEM" && user.IsDisabled.Value)
                {
                    cmbUsers.Items.Add(user.FullName);
                }
            }

            if (cmbUsers.Items.Count != 0)
            {
                cmbUsers.SelectedIndex = 0;
            }

            if (currentStep != null)
            {
                m_stepName            = orgData.cMessages.FirstOrDefault(x => x.SdkMessageId == currentStep.StepMessageId).Name;
                txtMessageName.Text   = m_stepName;
                txtPrimaryEntity.Text = currentStep.EntityName;
                txtName.Text          = currentStep.StepName;
                txtRank.Text          = currentStep.StepRank.ToString();

                if (currentStep.RunAsUserId == Guid.Empty)
                {
                    cmbUsers.SelectedIndex = 0;
                }
                else
                {
                    cmbUsers.SelectedItem = orgData.cUsers.FirstOrDefault(x => x.SystemUserId == currentStep.RunAsUserId).FullName;
                }

                switch (currentStep.StepStage)
                {
                case SdkMessageProcessingStep_Stage.Prevalidation:
                    radStagePreValidation.Checked = true;
                    break;

                case SdkMessageProcessingStep_Stage.Preoperation:
                    radStagePreOperation.Checked = true;
                    break;

                case SdkMessageProcessingStep_Stage.Postoperation:
                    radStagePostOperation.Checked = true;
                    break;

                case SdkMessageProcessingStep_Stage.Postoperation_Deprecated:
                    radStagePostOperationDeprecated.Checked = true;
                    break;

                default:
                    throw new NotImplementedException("StepStage = " + currentStep.StepStage.ToString());
                }

                switch (currentStep.StepMode)
                {
                case SdkMessageProcessingStep_Mode.Asynchronous:

                    radModeAsync.Checked = true;
                    break;

                case SdkMessageProcessingStep_Mode.Synchronous:

                    radModeSync.Checked = true;
                    break;

                default:
                    throw new NotImplementedException("Mode = " + currentStep.StepMode.ToString());
                }

                switch (currentStep.StepSupportedDeployment)
                {
                case SdkMessageProcessingStep_SupportedDeployment.Both:

                    chkDeploymentOffline.Checked = true;
                    chkDeploymentServer.Checked  = true;
                    break;

                case SdkMessageProcessingStep_SupportedDeployment.ServerOnly:

                    chkDeploymentOffline.Checked = false;
                    chkDeploymentServer.Checked  = true;
                    break;

                //case SdkMessageProcessingStep_SupportedDeployment.OfflineOnly:

                //    chkDeploymentOffline.Checked = true;
                //    chkDeploymentServer.Checked = false;
                //    break;

                default:
                    throw new NotImplementedException("Deployment = " + currentStep.StepSupportedDeployment.ToString());
                }

                //switch (currentStep.StepInvocationSource)
                //{
                //    case null:
                //    case invo.Parent:

                //        radInvocationParent.Checked = true;
                //        break;

                //    case CrmPluginStepInvocationSource.Child:

                //        radInvocationChild.Checked = true;
                //        break;

                //    default:
                //        throw new NotImplementedException("InvocationSource = " + m_currentStep.InvocationSource.ToString());
                //}

                txtDescription.Text = currentStep.StepDescription;

                txtSecureConfig.Text = currentStep.StepSecureConfiguration;

                string stepName;
                //if (this.m_currentStep.IsProfiled && org.Plugins[this.m_currentStep.PluginId].IsProfilerPlugin)
                //{
                //    //If the current step is a profiler step, the form that is displayed should use the configuration from the original step.
                //    // ProfilerConfiguration profilerConfig = OrganizationHelper.RetrieveProfilerConfiguration(this.m_currentStep);
                //    // stepName = profilerConfig.OriginalEventHandlerName;
                //    // txtUnsecureConfiguration.Text = profilerConfig.Configuration;
                //}
                //else
                //{
                //txtUnsecureConfiguration.Text = currentStep.secure;
                stepName = currentStep.StepName;
                //}

                if (stepName == GenerateDescription())
                {
                    m_stepName = GenerateDescription();
                }
                else
                {
                    m_stepName   = null;
                    txtName.Text = stepName;
                }

                //if (MessageEntity != null)
                //{
                //    crmFilteringAttributes.EntityName = MessageEntity.PrimaryEntity;
                //}

                //crmFilteringAttributes.Attributes = m_currentStep.FilteringAttributes;
                chkDeleteAsyncOperationIfSuccessful.Checked = currentStep.StepAsyncAutoDelete;
                chkDeleteAsyncOperationIfSuccessful.Enabled = (currentStep.StepMode == SdkMessageProcessingStep_Mode.Asynchronous);

                Text             = "Update Existing Step";
                btnRegister.Text = "Update";
            }
        }