Ejemplo n.º 1
0
        private static void ChooseNextAction(MessagePrompter mp, string extractPath, List <EntityMeta> selectedEntities)
        {
            mp.Prompt("");
            mp.Prompt("Please choose what to do with the gathered attributes. Type in just the number.");
            mp.Prompt("[{0}] Show the attributes that have different display names and labels", (int)ActionList.ShowNonMatchingLabels);
            mp.Prompt("[{0}] Show attributes of the selected entity", (int)ActionList.ShowAllAttributes);
            mp.Prompt("[{0}] Exit", 0);

            var exit = false;

            while (!exit)
            {
                var resp            = mp.Read();
                var resultsFilePath = "";

                switch (Convert.ToInt32(resp))
                {
                case (0):
                    exit = true;
                    break;

                case ((int)ActionList.ShowNonMatchingLabels):
                    resultsFilePath = extractPath + "\\NonMatchingLabels.out";
                    ShowAllAttributes(resultsFilePath, selectedEntities, (att) =>
                                      !String.IsNullOrEmpty(att.Label) &&
                                      !att.IsLabelMatchingDisplayName);
                    mp.Prompt("Results are stored in the '{0}' file.", resultsFilePath);
                    break;

                case ((int)ActionList.ShowAllAttributes):
                    resultsFilePath = extractPath + "\\AllAttributes.out";
                    ShowAllAttributes(resultsFilePath, selectedEntities, (att) =>
                                      !String.IsNullOrEmpty(att.Label) &&
                                      !att.IsLabelMatchingDisplayName);
                    mp.Prompt("Results are stored in the '{0}' file.", resultsFilePath);
                    break;

                default:
                    mp.Prompt("Please choose a number between {0} and {1}.", 1, 2);
                    break;
                }

                mp.Prompt("");
                mp.Prompt("Please choose the next action.");
            }
        }
Ejemplo n.º 2
0
 public CredentialsValidator(MessagePrompter mp)
 {
     Mp = mp;
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            MessagePrompter mp = new MessagePrompter();

            // Get the connection to CRM
            var cv  = new CredentialsValidator(mp);
            var Crm = cv.GetCrmConnectionFromString(ConfigurationManager.ConnectionStrings["EverestOrg"].ConnectionString);

            // Enable debugging trace errors
            if (false)
            {
                Trace.Listeners.Add(new ConsoleTraceListener()
                {
                    Name = "debug"
                });
            }


            // Get the list of entities from CRM and their attributes
            var entityGetter = new EntityMetadataGetter(Crm);

            mp.Prompt("Getting the list of entities from CRM");

            #region Identify which entity to analyse
            var entityName = GetSelectedEntity(entityGetter
                                               .Entities
                                               .OrderBy(x => x.LogicalName)
                                               .Select(x => x.LocalizedName)
                                               .ToList());

            mp.Prompt("You have selected \"{0}\"", entityName);
            #endregion

            // Get the selected entity object
            var selectedEntities = new List <EntityMeta>();
            if (entityName == "ALL")
            {
                selectedEntities = entityGetter.Entities.ToList();
            }
            else
            {
                selectedEntities = entityGetter.Entities.Where(x => x.LocalizedName == entityName).ToList();
            }

            #region Export the Solution from CRM
            //mp.Prompt("Exporting the solution from CRM");

            //var solManager = new SolutionManager(
            //    Crm,
            //    selectedEntities.ToDictionary(x => x.EntityId, x => x.LogicalName.ToLower()));
            //byte[] exportXml = solManager.ExportSolution();

            //var exportPath = @"C:\temp\EntityAttributeComparerSolution.zip";
            //File.WriteAllBytes(exportPath, exportXml);

            //mp.Prompt("Solution exported to {0}.", exportPath);
            #endregion


            #region Extract the customizations.xml from the solution archive
            var zipPath     = @"C:\temp\EntityAttributeComparerSolution.zip";
            var extractPath = @"C:\temp\EntityAttributeComparerSolution";

            ExtractCustomizationsFile(zipPath, extractPath);
            #endregion


            #region Get the labels of the attributes
            //mp.Prompt("Parsing the customizations.xml to gather the attribute labels...");

            var customizationsPath = @"C:\temp\EntityAttributeComparerSolution\customizations.xml";
            var custXmlParser      = new CustomizationsXmlParser(customizationsPath, selectedEntities);
            custXmlParser.GetLabels();

            //mp.Prompt("Parsing complete.");
            #endregion


            ChooseNextAction(mp, extractPath, selectedEntities);
        }