private List <string> GetAllForms(string entity, JsForm2 jsForm)
        {
            var forms = jsForm.GetForms().ToList();

            if (forms.Count == 0)
            {
                return(new List <string>());
            }
            forms = forms.Distinct().ToList();
            forms.Sort();
            return(forms);
        }
        private void GeneratorJsForm2(string entity, int i, int count)
        {
            var forms                     = new List <string>();
            var isDebugForm               = true;
            var webApi                    = false;
            var isDebugWebApi             = false;
            var fileTypeScriptDeclaration = $"{currentDirectory}\\{json.rootfolder}\\{entity}.d.ts";

            if (File.Exists(fileTypeScriptDeclaration))
            {
                var lines = File.ReadAllLines(fileTypeScriptDeclaration);
                if (lines.Count() != 0)
                {
                    var json    = lines[lines.Length - 1];
                    var comment = SimpleJson.DeserializeObject <CommentTypeScriptDeclaration>(json.Substring("//".Length).Replace("'", "\""));
                    forms         = comment.JsForm;
                    isDebugForm   = comment.IsDebugForm;
                    webApi        = comment.JsWebApi;
                    isDebugWebApi = comment.IsDebugWebApi;
                }
            }
            if (forms.Count == 0)
            {
                var parts2       = json.rootnamespace.Split(".".ToCharArray());
                var projectName2 = parts2.Length > 1 ? parts2[1] : parts2[0];
                var jsForm2      = new JsForm(XrmHelper.GetIOrganizationService(crmServiceClient), projectName2, entity);
                forms = GetAllForms(entity, jsForm2);
            }
            if (forms.Count == 0)
            {
                if (File.Exists(fileTypeScriptDeclaration))
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorGreen, entity, ".d.ts");
                }
                if (File.Exists($"{currentDirectory}\\{json.rootfolder}\\{entity}.form.js"))
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorGreen, entity, ".form.js");
                }
                return;
            }
            if (File.Exists($"{currentDirectory}\\{json.rootfolder}\\{entity}.js"))
            {
                var text = File.ReadAllText($"{currentDirectory}\\{json.rootfolder}\\{entity}.js");
                text = text.Replace("\r\n", string.Empty);
                if (text.Length == 0 || text == $"//@ts-check///<reference path=\"{entity}.d.ts\" />")
                {
                    Utility.TryDeleteFile($"{currentDirectory}\\{json.rootfolder}\\{entity}.js");
                }
            }
            var parts       = json.rootnamespace.Split(".".ToCharArray());
            var projectName = parts.Length > 1 ? parts[1] : parts[0];
            var jsForm      = new JsForm2(XrmHelper.GetIOrganizationService(crmServiceClient), projectName, entity);

            if (json.debug.Length > 0)
            {
                isDebugForm = json.debug == "yes" ? true : false;
            }
            jsForm.GeneratorCode(forms, isDebugForm, webApi, isDebugWebApi);
            if (!File.Exists($"{currentDirectory}\\{json.rootfolder}\\{entity}.js"))
            {
                var text = jsForm.Form;
                text = text.Replace($"[[{entity}]]", $"{entity}.d.ts");
                Utility.ForceWriteAllText($"{currentDirectory}\\{json.rootfolder}\\{entity}.js", text);
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Created ", CliLog.ColorGreen, entity, ".js");
            }
            var old = string.Empty;

            if (File.Exists(fileTypeScriptDeclaration))
            {
                old = File.ReadAllText(fileTypeScriptDeclaration);
            }
            var @new = jsForm.FormCodeTypeScriptDeclaration2;

            if (RemoveForCompare(old) != RemoveForCompare(@new))
            {
                if (File.Exists(fileTypeScriptDeclaration))
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Updated ", CliLog.ColorGreen, entity, ".d.ts");
                }
                else
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Created ", CliLog.ColorGreen, entity, ".d.ts");
                }
                Utility.ForceWriteAllText(fileTypeScriptDeclaration, jsForm.FormCodeTypeScriptDeclaration2);
            }
            else
            {
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorGreen, entity, ".d.ts");
            }
            var fileForm = $"{currentDirectory}\\{json.rootfolder}\\{entity}.form.js";

            old = string.Empty;
            if (File.Exists(fileForm))
            {
                old = File.ReadAllText(fileForm);
            }
            @new = jsForm.FormCode;
            if (RemoveForCompare(old) != RemoveForCompare(@new))
            {
                if (File.Exists(fileForm))
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Updated ", CliLog.ColorGreen, entity, ".form.js");
                }
                else
                {
                    CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorMagenta, "Created ", CliLog.ColorGreen, entity, ".form.js");
                }
                Utility.ForceWriteAllText(fileForm, jsForm.FormCode);
            }
            else
            {
                CliLog.WriteLine(CliLog.ColorWhite, "|", CliLog.ColorBlue, string.Format("{0,0}{1," + count.ToString().Length + "}", "", i) + ": ", CliLog.ColorGreen, entity, ".form.js");
            }
        }