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.JsWebApiItem, Dte);

            if (form.ShowDialog() == DialogResult.OK)
            {
                EntityName          = form.Class;
                SelectedProjectItem = GetProjectItem();
                if (SelectedProjectItem != null)
                {
                    CurrentFolder         = Path.GetDirectoryName(SelectedProjectItem.FileNames[0]);
                    GeneratedJsCode       = $"///<reference path='[[{EntityName}]]' />\r\n";
                    GeneratedJsWebApiCode = form.GeneratedJsWebApiCode;
                    if (form.UseTypeScriptDeclaration == "true")
                    {
                        GeneratedJsWebApiCodeTypeScriptDeclaration = form.GeneratedJsWebApiCodeIntellisense2;
                        GeneratedJsCode = GeneratedJsCode.Replace($"[[{EntityName}]]", $"{EntityName}.d.ts");
                    }
                    else
                    {
                        GeneratedJsWebApiCodeIntellisense = form.GeneratedJsWebApiCodeIntellisense;
                        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.AsNewItem)
     {
         DTE = (DTE)automationObject;
         var activeSolutionProjects = DTE.ActiveSolutionProjects as Array;
         if (activeSolutionProjects != null && activeSolutionProjects.Length > 0)
         {
             ActiveProject = activeSolutionProjects.GetValue(0) as Project;
             if (ActiveProject.Kind != "{D954291E-2A0B-460D-934E-DC6B0785DB48}")
             {
                 throw new WizardCancelledException("Late Bound Class only support shared project");
             }
         }
         else
         {
             throw new WizardCancelledException("Cannot find active project");
         }
         var form = new FormProject(FormType.LateBoundClass, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             DeleteFile = LoadDeleteFile(automationObject, form.Class);
             replacementsDictionary.Add("$class$", form.Class);
             replacementsDictionary.Add("$generated$", form.Generated);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #3
0
        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.Report, 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.Add("$ProjectName$", ProjectName);
                    replacementsDictionary.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.Report.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.Console, 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);
             replacementsDictionary.Add("$ProjectName$", form.ProjectName);
             replacementsDictionary.Add("$CrmUrl$", form.CrmConnection.Url);
             replacementsDictionary.Add("$CrmUserName$", form.CrmConnection.UserName);
             replacementsDictionary.Add("$CrmPassword$", form.CrmConnection.Password);
             replacementsDictionary.Add("$ShareProject$", $"{form.RootNamespace.Split(".".ToCharArray())[0]}.{form.RootNamespace.Split(".".ToCharArray())[1]}.Shared");
         }
         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;
         if (Dte.ActiveSolutionProjects is Array activeSolutionProjects && activeSolutionProjects.Length > 0)
         {
             ActiveProject = activeSolutionProjects.GetValue(0) as Project;
         }
         var form = new FormProject(FormType.LateBoundClass, Dte)
         {
             RootNameSpace = replacementsDictionary["$rootnamespace$"]
         };
         var solutionFullName = Dte?.Solution?.FullName;
         var fInfo            = new FileInfo(solutionFullName ?? throw new InvalidOperationException());
         var parts            = fInfo.Name.Split(".".ToCharArray());
         form.SharedNameSpace = GetName(parts);
         if (form.ShowDialog() == DialogResult.OK)
         {
             Class = form.Class;
             replacementsDictionary.Add("$class$", form.Class);
             GeneratedCode = form.Generated;
             replacementsDictionary.Add("$generated$", GeneratedCode);
             CloseWindows();
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #6
0
 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.JsWebApiItem, DTE);
         if (form.ShowDialog() == DialogResult.OK)
         {
             //form.DoGeneratorCode();
             //if (form.MessageError.Length > 0)
             //{
             //    MessageBox.Show(form.MessageError, "ERROR");
             //    throw new WizardCancelledException("Cancel Click");
             //}
             DeleteFile                    = LoadDeleteFile(automationObject, form.Class);
             GeneratedJsForm               = form.GeneratedJsForm;
             GeneratedJsFormIntellisense   = form.GeneratedJsIntellisenseForm;
             GeneratedJsWebApi             = form.GeneratedJsWebApi;
             GeneratedJsWebApiIntellisense = form.GeneratedJsIntellisense;
             replacementsDictionary.Add("$class$", 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.AsNewProject)
     {
         DTE = (DTE)automationObject;
         var form = new FormProject(FormType.ProxyTypes, 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);
             var connection = form.CrmConnectionString2.Split("\t".ToCharArray());
             replacementsDictionary.Add("$CrmUrl$", connection[0]);
             replacementsDictionary.Add("$CrmUserName$", connection[1]);
             replacementsDictionary.Add("$CrmPassword$", connection[2]);
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #8
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 = 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.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");
     }
 }
 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 - 1];
         var form       = new FormProject(FormType.WorkflowItem, Dte, entityName);
         if (form.ShowDialog() == DialogResult.OK)
         {
             replacementsDictionary.Add("$class$", form.ProjectName);
             replacementsDictionary.Add("$EntityName$", entityName);
             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");
         }
         else
         {
             throw new WizardCancelledException("Cancel Click");
         }
     }
     else
     {
         throw new WizardCancelledException("Cancel Click");
     }
 }
Example #10
0
 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.WebResource, 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);
             replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
             replacementsDictionary.Add("$ProjectName$", form.ProjectName);
         }
         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;
            var form = new FormProject(FormType.WebResource, 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("$packagename$", form.AssemblyName.ToLower());
                    var parts = replacementsDictionary["$RootNamespace$"].Split(".".ToCharArray());
                    replacementsDictionary.Add("$ProjectNameJs$", $"{parts[1]}");
                    replacementsDictionary.Add("$WebApiClientMin$", GetWebApiClientMin(parts[1]));
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitAnalyzersVersion$", form.PLDynamicsCrmDevKitAnalyzersVersion);
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.WebResource.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }
Example #12
0
        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.ProxyTypes, 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);
                    replacementsDictionary.Add("$ProjectName$", ProjectName);
                    var connection = form.CrmConnectionString2.Split("\t".ToCharArray());
                    var url        = string.Empty;
                    if (!connection[0].Contains(".dynamics.com"))
                    {
                        url = connection[0] + "/XRMServices/2011/Organization.svc";
                    }
                    else
                    {
                        url = connection[0];
                    }
                    replacementsDictionary.Add("$CrmUrl$", url);
                    var crmUserName = connection[1];
                    if (crmUserName.Contains("\\"))
                    {
                        var arr = crmUserName.Split("\\".ToCharArray());
                        crmUserName = $"{arr[1]} /domain:{arr[0]}";
                    }
                    replacementsDictionary.Add("$CrmUserName$", crmUserName);
                    replacementsDictionary.Add("$CrmPassword$", connection[2]);
                    replacementsDictionary.Add("$versionCoreTools$", form.CoreToolsVersion.Version);
                    replacementsDictionary.Add("$CrmConnectionString$", form.CrmConnectionString);
                    replacementsDictionary.Add("$PLDynamicsCrmDevKitCliVersion$", form.PLDynamicsCrmDevKitCliVersion);
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.ProxyTypes.ToString()} project exist!", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            Utility.TryDeleteDirectory(replacementsDictionary["$destinationdirectory$"]);
            throw new WizardCancelledException("Cancel Click");
        }
Example #13
0
        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.DataProvider, 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);
                    replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace(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);
                    NewFolder = Utility.GetFolderProject(solutionFullName, ProjectName);
                    replacementsDictionary.Remove("$destinationdirectory$");
                    replacementsDictionary["$destinationdirectory$"] = NewFolder;
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.DataProvider.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)
            {
                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.UiTest, 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.Add("$AssemblyName$", form.AssemblyName);
                    replacementsDictionary.Add("$RootNamespace$", form.RootNamespace);
                    replacementsDictionary.Add("$SafeNamespace$", Utility.SafeNamespace(form.RootNamespace));
                    replacementsDictionary.Add("$version$", form.CrmVersion);
                    replacementsDictionary.Add("$NetVersion$", form.NetVersion);
                    replacementsDictionary.Add("$NugetNetVersion$", form.NugetNetVersion);
                    replacementsDictionary.Add("$ProjectName$", form.ProjectName);
                    replacementsDictionary.Add("$CrmUrl$", form.CrmConnection.Url);
                    replacementsDictionary.Add("$CrmUserName$", form.CrmConnection.UserName);
                    replacementsDictionary.Add("$CrmPassword$", form.CrmConnection.Password);
                    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));
                    return;
                }
                else
                {
                    MessageBox.Show($@"{FormType.UiTest.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.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");
     }
 }
 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");
     }
 }
        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");
        }
        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");
        }
        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();
            }
        }
Example #23
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");
     }
 }