Exemplo n.º 1
0
        private void BtnDeactivateFormulas_Click(object sender, EventArgs e)
        {
            var fetchXml = string.Empty;

            if (string.IsNullOrEmpty(txtInput.Text))
            {
                fetchXml = CrmHelper.GetFormulaFetchForMigrationEntities();
            }
            else
            {
                fetchXml = txtInput.Text;
            }

            var result = CrmConnManager.LService.RetrieveMultiple(new FetchExpression(fetchXml)).Entities;

            txtLog.AppendText($"Number of active formulas: {result.Count}");

            int count = 0;;

            foreach (var en in result)
            {
                if (count++ % 50 == 0)
                {
                    txtLog.AppendText($"Deactivated formulas count: {count}");
                }

                var id = en.Id;

                var entityName = en.GetAttributeValue <string>("north52_sourceentityname");
                var name       = en.GetAttributeValue <string>("north52_name");

                var formula = new CrmFormula()
                {
                    Id   = id,
                    Name = name,
                    Type = new MigrationHelper.Option()
                    {
                        Value = en.GetAttributeValue <OptionSetValue>("north52_formulatype").Value,
                        Name  = en.FormattedValues["north52_formulatype"]
                    },
                    StatusCode = new MigrationHelper.Option()
                    {
                        Value = en.GetAttributeValue <OptionSetValue>("statuscode").Value,
                        Name  = en.FormattedValues["statuscode"]
                    },
                    StateCode = new MigrationHelper.Option()
                    {
                        Value = en.GetAttributeValue <OptionSetValue>("statecode").Value,
                        Name  = en.FormattedValues["statecode"]
                    },
                };

                //txtLog.AppendText($"Formula Name: {entityName}:{formula.Name}, Type: {formula.Type.Name} {Environment.NewLine}");


                CrmHelper.DeactivateRecord("north52_formula", formula.Id, CrmConnManager.LService);
            }
        }
Exemplo n.º 2
0
        private void BtnDeactivateFormulas_Click(object sender, EventArgs e)
        {
            var sb    = new StringBuilder();
            int count = 0;

            foreach (var f in mgr.FormulaDiffRecords)
            {
                if (f.RFormula != null)
                {
                    var ff = f.RFormula;
                    if (!ff.Type.Name.StartsWith("Client") && ff.StateCode.Value == 0)
                    {
                        CrmHelper.DeactivateRecord("north52_formula", ff.Id, CrmConnManager.RService);
                    }
                }
            }

            MessageBox.Show(sb.ToString());
        }