public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewProject)
            {
                return;
            }
            Dte = (DTE)automationObject;
            var form = new FormProject(FormType.SolutionPackager, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ProjectName = form.ProjectName;
                if (!Utility.ExistProject(Dte, ProjectName))
                {
                    replacementsDictionary.Add("$CrmName$", form.CrmName);
                    NetVersion = form.NetVersion;
                    replacementsDictionary.Add("$DevKitVersion$", Const.Version);
                    replacementsDictionary.Remove("$projectname$");
                    replacementsDictionary.Add("$projectname$", ProjectName);
                    replacementsDictionary.Add("$version$", form.CrmVersion);
                    replacementsDictionary.Add("$NetVersion$", form.NetVersion);
                    replacementsDictionary.Add("$NugetNetVersion$", form.NugetNetVersion);
                    replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace(form.RootNamespace));
                    replacementsDictionary.Add("$ProjectName$", ProjectName);
                    replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
                    var solutionFullName = Dte?.Solution?.FullName;
                    replacementsDictionary.Add("$ShareProject$", Utility.GetSharedProject(solutionFullName));
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitAnalyzersVersion$", form.PLDynamicsCrmDevKitAnalyzersVersion);
                    replacementsDictionary.Add("$versionCoreTools$", form.CoreToolsVersion.Version);
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.SolutionPackager.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewProject)
     {
         DTE = (DTE)automationObject;
         var form = new FormProject(FormType.CustomAction, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             ProjectName = form.ProjectName;
             replacementsDictionary.Remove("$projectname$");
             replacementsDictionary.Add("$projectname$", ProjectName);
             replacementsDictionary.Add("$version$", form.CrmVersion);
             replacementsDictionary.Add("$NetVersion$", form.NetVersion);
             replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
             replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
             replacementsDictionary.Add("$ProjectName$", ProjectName);
             replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
             var ProjectPath = $"{replacementsDictionary["$solutiondirectory$"]}\\{ProjectName}";
             replacementsDictionary.Remove("$destinationdirectory$");
             replacementsDictionary.Add("$destinationdirectory$", ProjectPath);
             if (replacementsDictionary.ContainsKey("$destinationdirectory$"))
             {
                 _destDirectory = replacementsDictionary["$destinationdirectory$"];
             }
             if (replacementsDictionary.ContainsKey("$ProjectName$"))
             {
                 _keyName = replacementsDictionary["$ProjectName$"] + ".snk";
             }
             replacementsDictionary.Add("$ShareProject$", $"{form.RootNamespace.Split(".".ToCharArray())[0]}.{form.RootNamespace.Split(".".ToCharArray())[1]}.Shared");
             replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         Dte = (DTE)automationObject;
         var form = new FormProject(FormType.JsTestItem, Dte);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$LogicalName$", form.Class.ToLower());
             replacementsDictionary.Add("$EntityName$", form.Class);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         Dte = (DTE)automationObject;
         var form = new FormProject(FormType.ResourceString, Dte);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$LanguageCode$", form.LanguageCode);
             replacementsDictionary.Add("$ResourceStringName$", form.ResourceStringName);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewProject)
     {
         DTE = (DTE)automationObject;
         var form = new FormProject(FormType.UiTest, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             ProjectName = form.ProjectName;
             replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
             replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary,
                        WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         Dte = (DTE)automationObject;
         var    projects = (object[])Dte.ActiveSolutionProjects;
         var    project  = (Project)projects[0];
         string entityName;
         if (project.Name.Split('.').Length == 3)
         {
             entityName = "none";
         }
         else
         if (project.Name.Split('.').Length == 4)
         {
             entityName = project.Name.Split('.')[3];
         }
         else
         {
             entityName = "none";
         }
         var form = new FormProject(FormType.UiTestItem, Dte, entityName);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$class$", form.ProjectName);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #7
0
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         DTE = (DTE)automationObject;
         var projects   = (object[])DTE.ActiveSolutionProjects;
         var project    = (Project)projects[0];
         var entityName = project.Name.Split('.')[3];
         var form       = new FormProject(FormType.WorkflowItem, DTE, entityName);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$class$", form.ProjectName);
             replacementsDictionary.Add("$EntityName$", entityName);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewProject)
     {
         DTE = (DTE)automationObject;
         var form = new FormProject(FormType.Test, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             ProjectName = form.ProjectName;
             replacementsDictionary.Add("$version$", form.CrmVersion);
             replacementsDictionary.Add("$NetVersion$", form.NetVersion);
             replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
             replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
             if (form.ProxyTypes != null)
             {
                 replacementsDictionary.Add("$ProxyTypes$", "true");
                 replacementsDictionary.Add("$ProjectProxyTypesName$", form.ProxyTypes.Name);
                 replacementsDictionary.Add("$ProjectProxyTypesGuid$", form.ProxyTypes.Id);
             }
             else
             {
                 replacementsDictionary.Add("$ProxyTypes$", "false");
             }
             replacementsDictionary.Add("$ProjectTestName$", form.SelectedProjectData.Name);
             replacementsDictionary.Add("$ProjectTestGuid$", form.SelectedProjectData.Id);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #9
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewItem)
            {
                return;
            }
            Dte = (DTE)automationObject;
            var form = new FormProject(FormType.JsFormItem, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                EntityName = form.Class;

                SelectedProjectItem = GetProjectItem();
                if (SelectedProjectItem != null)
                {
                    CurrentFolder       = Path.GetDirectoryName(SelectedProjectItem.FileNames[0]);
                    GeneratedJsCode     = form.GeneratedJsForm;
                    GeneratedJsFormCode = form.GeneratedJsFormCode;
                    if (form.UseTypeScriptDeclaration == "true")
                    {
                        GeneratedJsFormCodeTypeScriptDeclaration = form.GeneratedJsFormCodeIntellisense2;
                        GeneratedJsCode = GeneratedJsCode.Replace($"[[{EntityName}]]", $"{EntityName}.d.ts");
                    }
                    else
                    {
                        GeneratedJsFormCodeIntellisense = form.GeneratedJsFormCodeIntellisense;
                        GeneratedJsCode = GeneratedJsCode.Replace($"[[{EntityName}]]", $"{EntityName}.intellisense.js");
                    }
                }
            }
            else
            {
                throw new WizardCancelledException("Cancel Click");
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewProject)
            {
                return;
            }
            Dte = (DTE)automationObject;
            var form = new FormProject(FormType.Portal, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ProjectName = form.ProjectName;
                if (!Utility.ExistProject(Dte, ProjectName))
                {
                    var solutionFullName = Dte?.Solution?.FullName;
                    var dir  = Path.GetDirectoryName(solutionFullName);
                    var file = $"{dir}\\PL.DynamicsCrm.DevKit.Cli.json";
                    if (!File.Exists(file))
                    {
                        var json = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.PL.DynamicsCrm.DevKit.Cli.json");
                        if (Utility.SharedProjectExist(Dte))
                        {
                            var temp = ProjectName.Substring(0, ProjectName.Length - FormType.Shared.ToString().Length);
                            json = json
                                   .Replace("???.Plugin.*.dll", $"{temp}Plugin.*.dll")
                                   .Replace("???.CustomAction.*.dll", $"{temp}CustomAction.*.dll")
                                   .Replace("???.Workflow.*.dll", $"{temp}Workflow.*.dll")
                                   .Replace("???.DataProvider.*.dll", $"{temp}DataProvider.*.dll")
                                   .Replace("???.*.Test.dll", $"{temp}*.Test.dll")
                            ;
                        }
                        File.WriteAllText(file, json);
                    }
                    replacementsDictionary.Add("$CrmName$", form.CrmName);
                    replacementsDictionary.Add("$DevKitVersion$", Const.Version);
                    replacementsDictionary.Add("$version$", form.CrmVersion);
                    replacementsDictionary.Add("$NetVersion$", form.NetVersion);
                    replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace(form.RootNamespace));
                    replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
                    replacementsDictionary.Add("$ProjectName$", form.ProjectName);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitAnalyzersVersion$", form.PLDynamicsCrmDevKitAnalyzersVersion);

                    var cliJson = SimpleJson.DeserializeObject <CliJson>(File.ReadAllText(file));
                    var update  = cliJson.portals.FirstOrDefault(x => x.profile == "DEBUG");
                    if (update != null)
                    {
                        update.name = form.PortalName;
                        var updateJson = SimpleJson.SerializeObject(cliJson);
                        updateJson = updateJson.Replace("[entity]", "__entity__");
                        updateJson = Utility.FormatJson(updateJson);
                        updateJson = updateJson.Replace("__entity__", "[entity]");
                        File.WriteAllText(file, updateJson);
                    }
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.WebResource.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }
Example #11
0
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         Dte = (DTE)automationObject;
         var projects    = (object[])Dte.ActiveSolutionProjects;
         var project     = (Project)projects[0];
         var entityName  = project.Name.Split('.')[project.Name.Split('.').Length - 2];
         var logicalName = entityName.ToLower();
         var form        = new FormProject(FormType.TestItem, Dte, entityName);
         if (form.ShowDialog() == DialogResult.OK)
         {
             var entityName2 = form.EntityNameTest;// logicalName.ToLower()=="customaction" ? "None" : entityName;
             if (entityName2 == "None")
             {
                 logicalName = "none";
             }
             else
             {
                 logicalName = entityName.ToLower();
             }
             replacementsDictionary.Add("$class$", form.Class);
             replacementsDictionary.Add("$entityname$", entityName);
             replacementsDictionary.Add("$message$", form.Message);
             replacementsDictionary.Add("$stage_string$", form.StageString);
             replacementsDictionary.Add("$execution$", form.Execution);
             var cols = project.Name.Split(".".ToCharArray());
             replacementsDictionary.Add("$namespace2$", $"{cols[0]}.{cols[1]}.{cols[2]}");
             replacementsDictionary.Add("$namespace3$", $"{cols[0]}.{cols[1]}");
             replacementsDictionary.Add("$PrimaryEntityName$", entityName);
             replacementsDictionary.Add("$FilteringAttributes$", form.FilteringAttributes);
             replacementsDictionary.Add("$logicalname$", logicalName);
             if (project.Name.Contains(".Plugin") || project.Name.Contains(".Plugin."))
             {
                 ClassType = "Plugin";
             }
             else if (project.Name.Contains(".CustomAction") || project.Name.EndsWith(".CustomAction."))
             {
                 ClassType = "CustomAction";
             }
             else if (project.Name.Contains(".Workflow") || project.Name.EndsWith(".Workflow."))
             {
                 ClassType = "Workflow";
             }
             else if (project.Name.Contains(".DataProvider") || project.Name.EndsWith(".DataProvider."))
             {
                 ClassType = "DataProvider";
             }
             var solutionFullName = Dte?.Solution?.FullName;
             var fInfo            = new FileInfo(solutionFullName ?? throw new InvalidOperationException());
             var parts            = fInfo.Name.Split(".".ToCharArray());
             replacementsDictionary.Add("$DevKitShared$", $"{GetName(parts)}Shared");
             replacementsDictionary.Add("$ProxyTypes$", $"{GetName(parts)}ProxyTypes");
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewProject)
            {
                return;
            }
            Dte = (DTE)automationObject;
            if (!Utility.SharedProjectExist(Dte))
            {
                MessageBox.Show(@"Please add PL.DynamicsCrm.DevKit Shared project and try it again", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
                throw new WizardCancelledException("Shared project should exist");
            }
            if (!Utility.ProxyTypesProjectExist(Dte))
            {
                MessageBox.Show(@"Please add ProxyTypes project and try it again", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
                throw new WizardCancelledException("ProxyTypes project should exist");
            }
            var form = new FormProject(FormType.Test, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ProjectName = form.ProjectName;
                if (!Utility.ExistProject(Dte, ProjectName))
                {
                    var fakeXrmEasy = form.FakeXrmEasy;
                    replacementsDictionary.Add("$FakeXrmEasy$", form.FakeXrmEasyShortName);
                    replacementsDictionary.Add("$FakeXrmEasyVersion$", fakeXrmEasy.Version);
                    replacementsDictionary.Add("$FakeXrmEasyNetVersion$", fakeXrmEasy.NetVersion.Replace(".", string.Empty));

                    var deployment = form.MicrosoftCrmSdkDeployment;
                    replacementsDictionary.Add("$CrmSdkDeploymentVersion$", deployment.Version);
                    replacementsDictionary.Add("$CrmSdkDeploymentNetVersion$", deployment.NetVersion.Replace(".", string.Empty));

                    replacementsDictionary.Add("$versionWorkflow$", form.MicrosoftCrmSdkWorkflow.Version);
                    replacementsDictionary.Add("$NugetNetWorkflowVersion$", form.MicrosoftCrmSdkWorkflow.NetVersion.Replace(".", string.Empty));

                    var xrmToolingCoreAssembly = form.MicrosoftCrmSdkXrmToolingCoreAssembly;
                    replacementsDictionary.Add("$XrmToolingCoreAssemblyVersion$", xrmToolingCoreAssembly.Version);
                    replacementsDictionary.Add("$XrmToolingCoreAssemblyNetVersion$", xrmToolingCoreAssembly.NetVersion.Replace(".", string.Empty));

                    replacementsDictionary.Add("$CrmName$", form.CrmName);
                    replacementsDictionary.Add("$DevKitVersion$", Const.Version);
                    replacementsDictionary.Add("$version$", form.CrmVersion);
                    replacementsDictionary.Add("$NetTestVersion$", form.NetVersion);
                    if (form.CrmName == "2013")
                    {
                        replacementsDictionary["$NetTestVersion$"] = "4.5.2";
                    }
                    replacementsDictionary.Add("$NugetNetVersion$", form.NugetNetVersion);
                    replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    replacementsDictionary.Add("$SafeNamespace$", form.SelectedProjectData.Namespace + ".Test");
                    if (form.ProxyTypes != null)
                    {
                        replacementsDictionary.Add("$ProxyTypes$", "true");
                        replacementsDictionary.Add("$ProjectProxyTypesName$", form.ProxyTypes.Name);
                    }
                    else
                    {
                        replacementsDictionary.Add("$ProxyTypes$", "false");
                    }
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitAnalyzersVersion$", form.PLDynamicsCrmDevKitAnalyzersVersion);
                    replacementsDictionary.Add("$ProjectTestName$", form.SelectedProjectData.Name);
                    replacementsDictionary.Add("$ProjectTestGuid$", form.SelectedProjectData.Id);
                    var solutionFullName = Dte?.Solution?.FullName;
                    replacementsDictionary.Add("$ShareProject$", Utility.GetSharedProject(solutionFullName));
                    var dir          = Path.GetDirectoryName(solutionFullName);
                    var solutionName = Path.GetFileNameWithoutExtension(solutionFullName);
                    var file         = $"{dir}\\VsTest.runsettings";
                    if (!File.Exists(file))
                    {
                        var text = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.VsTest.runsettings");
                        text = text.Replace("[[ProxyTypes.dll]]", form.ProxyTypes.Name + ".dll");
                        text = text.Replace("[[Namespace]]", solutionName);
                        File.WriteAllText(file, text);
                    }
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.Test.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }
 public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     if (runKind == WizardRunKind.AsNewItem)
     {
         DTE = (DTE)automationObject;
         var projects   = (object[])DTE.ActiveSolutionProjects;
         var project    = (Project)projects[0];
         var entityName = string.Empty;
         if (project.Name.Split('.').Length == 3)
         {
             entityName = "none";
         }
         else
         {
             entityName = project.Name.Split('.')[3];
         }
         var logicalName = entityName.ToLower();
         var form        = new FormProject(FormType.TestItem, DTE, entityName);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$class$", form.Class);
             replacementsDictionary.Add("$entityname$", entityName);
             replacementsDictionary.Add("$message$", form.Message);
             replacementsDictionary.Add("$stage_string$", form.StageString);
             replacementsDictionary.Add("$execution$", form.Execution);
             var cols = project.Name.Split(".".ToCharArray());
             replacementsDictionary.Add("$namespace2$", $"{cols[0]}.{cols[1]}.{cols[2]}");
             replacementsDictionary.Add("$namespace3$", $"{cols[0]}.{cols[1]}");
             replacementsDictionary.Add("$PrimaryEntityName$", entityName);
             replacementsDictionary.Add("$FilteringAttributes$", form.FilteringAttributes);
             replacementsDictionary.Add("$logicalname$", logicalName);
             if (project.Name.Contains(".Plugin.") ||
                 project.Name.Contains(".CustomAction.") ||
                 project.Name.EndsWith(".CustomAction"))
             {
                 replacementsDictionary.Add("$FormType$", "true");
                 if (project.Name.Contains(".CustomAction.") ||
                     project.Name.EndsWith(".CustomAction"))
                 {
                     replacementsDictionary.Add("$Plugin$", "false");
                 }
                 else
                 {
                     replacementsDictionary.Add("$Plugin$", "true");
                 }
             }
             else
             {
                 replacementsDictionary.Add("$FormType$", "false");
             }
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
        private void btnConnection_Click(object sender, EventArgs e)
        {
            var form = new FormConnection(Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                progressBar.Visible   = true;
                btnConnection.Enabled = false;
                btnCancel.Enabled     = false;
                List <string>    list  = null;
                List <XrmEntity> list2 = null;
                _xrmHelper = new XrmHelper(form.CrmService);
                var  failed = false;
                Task task   = Task.Factory.StartNew(() =>
                {
                    if (FormType == FormType.PluginItem)
                    {
                        try
                        {
                            list = _xrmHelper.GetSdkMessages(LogicalName);
                        }
                        catch
                        {
                            failed = true;
                        }
                    }
                    else if (FormType == FormType.CustomActionItem)
                    {
                        list2 = _xrmHelper.GetAllCustomActions();
                    }
                });
                while (!task.IsCompleted)
                {
                    Application.DoEvents();
                }
                if (failed)
                {
                    var form2 = new FormProject(FormType.SelectEntity, Dte);
                    form2.LoadSelectEntity(_xrmHelper.GetAllEntities());
                    if (form2.ShowDialog() == DialogResult.OK)
                    {
                        list        = _xrmHelper.GetSdkMessages(form2.SelectedEntity.ToLower());
                        EntityName  = form2.SelectedEntity;
                        LogicalName = form2.SelectedEntity.ToLower();
                    }
                }
                btnConnection.Enabled = true;
                progressBar.Visible   = false;
                if (FormType == FormType.PluginItem)
                {
                    ddlMessage.DataSource = list;
                }
                else if (FormType == FormType.CustomActionItem)
                {
                    ddlMessage.DisplayMember = "LogicalName";
                    ddlMessage.ValueMember   = "Name";
                    ddlMessage.DataSource    = list2;
                }
                btnOk.Enabled        = ddlMessage.Items.Count > 0;
                ddlMessage.Enabled   = btnOk.Enabled;
                ddlStage.Enabled     = btnOk.Enabled;
                ddlExecution.Enabled = btnOk.Enabled;
                btnCancel.Enabled    = true;
                btnOk.Focus();
            }
        }
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            if (runKind != WizardRunKind.AsNewProject)
            {
                return;
            }

            Dte = (DTE)automationObject;
            if (!Utility.SharedProjectExist(Dte))
            {
                MessageBox.Show(@"Please add PL.DynamicsCrm.DevKit Shared project and try it again", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
                throw new WizardCancelledException("Shared project should exist");
            }
            var form = new FormProject(FormType.Workflow, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                ProjectName = form.ProjectName;
                if (!Utility.ExistProject(Dte, ProjectName))
                {
                    replacementsDictionary.Add("$CrmName$", form.CrmName);
                    replacementsDictionary.Add("$DevKitVersion$", Const.Version);
                    replacementsDictionary.Remove("$projectname$");
                    replacementsDictionary.Add("$projectname$", ProjectName);
                    replacementsDictionary.Add("$version$", form.CrmVersion);
                    replacementsDictionary.Add("$NetVersion$", form.NetVersion);
                    replacementsDictionary.Add("$NugetNetVersion$", form.NugetNetVersion);
                    replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    if (form.Others)
                    {
                        replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace(form.RootNamespace));
                    }
                    else
                    {
                        replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace2(form.RootNamespace));
                    }
                    replacementsDictionary.Add("$ProjectName$", ProjectName);
                    replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
                    if (replacementsDictionary.ContainsKey("$ProjectName$"))
                    {
                        _keyName = replacementsDictionary["$ProjectName$"] + ".snk";
                    }
                    var solutionFullName = Dte?.Solution?.FullName;
                    replacementsDictionary.Add("$ShareProject$", Utility.GetSharedProject(solutionFullName));
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitAnalyzersVersion$", form.PLDynamicsCrmDevKitAnalyzersVersion);
                    replacementsDictionary.Add("$versionWorkflow$", form.MicrosoftCrmSdkWorkflow.Version);
                    replacementsDictionary.Add("$NugetNetWorkflowVersion$", form.MicrosoftCrmSdkWorkflow.NetVersion.Replace(".", string.Empty));
                    NewFolder = Utility.GetFolderProject(solutionFullName, ProjectName);
                    replacementsDictionary.Remove("$destinationdirectory$");
                    replacementsDictionary["$destinationdirectory$"] = NewFolder;
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.Workflow.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }