private void btnConnection_Click(object sender, EventArgs e) { var form = new FormConnection(DTE); if (form.ShowDialog() == DialogResult.OK) { Cursor = Cursors.WaitCursor; xrmHelper = new XrmHelper(form.CrmService); if (FormType == FormType.PluginItem) { ddlMessage.DataSource = xrmHelper.GetSdkMessages(LogicalName); } else if (FormType == FormType.CustomActionItem) { ddlMessage.DisplayMember = "LogicalName"; ddlMessage.ValueMember = "Name"; ddlMessage.DataSource = xrmHelper.GetAllCustomActions(); } btnOk.Enabled = ddlMessage.Items.Count > 0; Cursor = Cursors.Default; } }
private void btnConnection_Click(object sender, System.EventArgs e) { var form = new FormConnection(DTE); if (form.ShowDialog() == DialogResult.OK) { Cursor = Cursors.WaitCursor; CrmConnection = form.CrmConnection; CrmService = form.CrmService; var xrmHelper = new XrmHelper(CrmService); if (FormType == FormType.Plugin || FormType == FormType.LateBoundClass || FormType == FormType.JsWebApiItem || FormType == FormType.Workflow) { cboEntity.DataSource = xrmHelper.GetAllEntities(); btnOk.Enabled = cboEntity.Items.Count > 0; txtName_TextChanged(null, null); cboEntity_SelectedIndexChanged(null, null); } if (FormType == FormType.ProxyTypes || FormType == FormType.WebResource || FormType == FormType.Console || FormType == FormType.CustomAction) { btnOk.Enabled = true; } Cursor = Cursors.Default; } }
public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { if (runKind != WizardRunKind.AsNewItem) { return; } Dte = (DTE)automationObject; var projects = (object[])Dte.ActiveSolutionProjects; var project = (Project)projects[0]; if (project == null) { return; } var dir = Path.GetDirectoryName(project.FullName); var downloadFile = Path.Combine(dir, "download.webresources.bat"); if (File.Exists(downloadFile)) { MessageBox.Show("You added this file: download.webresources.bat to your active project", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var form = new FormConnection(Dte); if (form.ShowDialog() != DialogResult.OK) { return; } var crmConnectionString = CrmConnectionString(form.CrmConnection); var cliContent = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.PL.DynamicsCrm.DevKit.Cli.json"); var dirSolution = Path.GetDirectoryName(Dte?.Solution?.FullName); var cliFile = Path.Combine(dirSolution, "PL.DynamicsCrm.DevKit.Cli.json"); if (!File.Exists(cliFile)) { File.WriteAllText(cliFile, cliContent); } var downloadFileContent = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.DownloadWebResources.download.webresources.bat"); downloadFileContent = downloadFileContent .Replace("$CrmConnectionString$", crmConnectionString) .Replace("$ProjectName$", Path.GetFileNameWithoutExtension(project.FullName)); if (!File.Exists(downloadFile)) { File.WriteAllText(downloadFile, downloadFileContent); project.ProjectItems.AddFromFile(downloadFile); } var deployFile = Path.Combine(dir, "deploy.debug.bat"); var deployFileContent = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.DownloadWebResources.deploy.debug.bat"); deployFileContent = deployFileContent .Replace("$CrmConnectionString$", crmConnectionString) .Replace("$ProjectName$", Path.GetFileNameWithoutExtension(project.FullName)); if (!File.Exists(deployFile)) { File.WriteAllText(deployFile, deployFileContent); project.ProjectItems.AddFromFile(deployFile); } var packagesFile = Path.Combine(dir, "packages.config"); var nuget = new NuGetHelper(); var version = nuget.PLDynamicsCrmDevKitCliPackage.Version; if (!File.Exists(packagesFile)) { var packagesFileContent = Utility.ReadEmbeddedResource("PL.DynamicsCrm.DevKit.Wizard.data.DownloadWebResources._packages.config"); packagesFileContent = packagesFileContent.Replace("$PLDynamicsCrmDevKitCliVersion$", version); File.WriteAllText(packagesFile, packagesFileContent); project.ProjectItems.AddFromFile(packagesFile); } else { var packagesFileContent = File.ReadAllText(packagesFile); if (packagesFileContent.IndexOf("PL.DynamicsCrm.DevKit.Cli") < 0) { var packageLine = "\t<package id='PL.DynamicsCrm.DevKit.Cli' version='$PLDynamicsCrmDevKitCliVersion$' targetFramework='net452' />\r\n"; packageLine = packageLine.Replace("'", "\"").Replace("$PLDynamicsCrmDevKitCliVersion$", version); packagesFileContent = packagesFileContent.Replace("</packages>", packageLine + "</packages>"); File.WriteAllText(packagesFile, packagesFileContent); } } project.Save(); }
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(); } }