public static bool UpdateAndPublishSingle(CrmServiceClient client, List <Entity> webResources) { //CRM 2011 < UR12 try { var requests = CreateUpdateRequests(webResources); foreach (var request in requests) { client.Execute(request); OutputLogger.WriteToOutputWindow(Resource.Message_UploadedWebResource, MessageType.Info); } var publishXml = CreatePublishXml(webResources); var publishRequest = CreatePublishRequest(publishXml); client.Execute(publishRequest); ExLogger.LogToFile(Logger, Resource.Message_PublishedWebResources, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_PublishedWebResources, MessageType.Info); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorUpdatingPublishingWebResources, ex); return(false); } }
public static bool AddAssemblyToSolution(CrmServiceClient client, Guid assemblyId, string uniqueName) { try { var scRequest = new AddSolutionComponentRequest { ComponentType = 91, SolutionUniqueName = uniqueName, ComponentId = assemblyId }; client.Execute(scRequest); ExLogger.LogToFile(Logger, $"{Resource.Message_AssemblyAddedSolution}: {uniqueName} - {assemblyId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_AssemblyAddedSolution}: {uniqueName} - {assemblyId}", MessageType.Info); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorAddingAssemblySolution, ex); return(false); } }
public static bool AddWebResourceToSolution(CrmServiceClient client, string uniqueName, Guid webResourceId) { try { var scRequest = new AddSolutionComponentRequest { ComponentType = 61, SolutionUniqueName = uniqueName, ComponentId = webResourceId }; client.Execute(scRequest); ExLogger.LogToFile(Logger, Resource.Message_NewWebResourceAddedSolution, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_NewWebResourceAddedSolution, MessageType.Info); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorAddingWebResourceSolution, ex); return(false); } }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // Switches to the UI thread in order to consume some services used in command initialization await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); try { if (!(GetGlobalService(typeof(DTE)) is DTE dte)) { throw new ArgumentNullException(Core.Resources.Resource.ErrorMessage_ErrorAccessingDTE); } GetUserOptions(dte); StartupTasks.Run(); ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingExtension, LogLevel.Info); AdviseSolutionEvents(); var events = dte.Events; BindSolutionEvents(events); await MenuHandler.InitializeAsync(this, dte); } catch (Exception ex) { ExceptionHandler.LogException(Logger, null, ex); throw; } }
private static void ProcessMetadata(RetrieveAllEntitiesResponse metaDataResponse) { ExLogger.LogToFile(Logger, Resource.Message_ProcessingMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_ProcessingMetadata, MessageType.Info); var entities = metaDataResponse.EntityMetadata; Metadata = new List <CompletionValue>(); var entityTriggerCharacter = UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseEntityTriggerCharacter); var entityFieldCharacter = UserOptionsHelper.GetOption <string>(UserOptionProperties.IntellisenseFieldTriggerCharacter); foreach (var entityMetadata in entities) { Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}", entityMetadata.LogicalName, GetDisplayName(entityMetadata.DisplayName), MetadataType.Entity)); Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}{entityFieldCharacter}?field?", $"{entityTriggerCharacter}{entityMetadata.LogicalName}", GetDisplayName(entityMetadata.DisplayName), MetadataType.None)); foreach (var attribute in entityMetadata.Attributes.Where(attribute => attribute.IsValidForCreate.GetValueOrDefault() || attribute.IsValidForUpdate.GetValueOrDefault() || attribute.IsValidForRead.GetValueOrDefault())) { Metadata.Add(new CompletionValue($"{entityTriggerCharacter}{entityMetadata.LogicalName}_{attribute.LogicalName}", attribute.LogicalName, $"{GetDisplayName(attribute.DisplayName)}: {attribute.AttributeType.GetValueOrDefault()}", MetadataType.Attribute)); } } Metadata = Metadata.OrderBy(m => m.Name).ToList(); }
public static bool ImportSolution(CrmServiceClient client, string path) { var solutionBytes = FileSystem.GetFileBytes(path); if (solutionBytes == null) { return(false); } try { var request = new ImportSolutionRequest { CustomizationFile = solutionBytes, OverwriteUnmanagedCustomizations = true, PublishWorkflows = true, ImportJobId = Guid.NewGuid() }; client.Execute(request); ExLogger.LogToFile(Logger, $"{Resource.Message_ImportedSolution}: {path}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_ImportedSolution}: {path}", MessageType.Info); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorImportingSolution, ex); return(false); } }
private static void ConnectToCrm() { ExLogger.LogToFile(Logger, Resource.Message_OpeningCrmLoginForm, LogLevel.Info); var control = new CrmLoginForm(false); control.ConnectionToCrmCompleted += ControlOnConnectionToCrmCompleted; control.ShowDialog(); }
public static bool UpdateAndPublishMultiple(CrmServiceClient client, List <Entity> webResources) { //CRM 2011 UR12+ try { var emRequest = new ExecuteMultipleRequest { Requests = new OrganizationRequestCollection(), Settings = new ExecuteMultipleSettings { ContinueOnError = false, ReturnResponses = true } }; emRequest.Requests = CreateUpdateRequests(webResources); var publishXml = CreatePublishXml(webResources); emRequest.Requests.Add(CreatePublishRequest(publishXml)); var wasError = false; var emResponse = (ExecuteMultipleResponse)client.Execute(emRequest); foreach (var responseItem in emResponse.Responses) { if (responseItem.Fault == null) { continue; } ExLogger.LogToFile(Logger, Resource.ErrorMessage_ErrorUpdatingPublishingWebResources, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.ErrorMessage_ErrorUpdatingPublishingWebResources, MessageType.Error); wasError = true; } if (wasError) { return(false); } ExLogger.LogToFile(Logger, Resource.Message_UpdatedPublishedWebResources, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_UpdatedPublishedWebResources, MessageType.Info); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorUpdatingPublishingWebResources, ex); return(false); } }
private static void ToggleCrmIntellisense(object sender, EventArgs e, DTE dte) { bool isEnabled; var value = SharedGlobals.GetGlobal("UseCrmIntellisense", dte); if (value == null) { isEnabled = false; SharedGlobals.SetGlobal("UseCrmIntellisense", true, dte); } else { isEnabled = (bool)value; SharedGlobals.SetGlobal("UseCrmIntellisense", !isEnabled, dte); } ExLogger.LogToFile(Logger, $"{Resource.Message_CRMIntellisenseEnabled}: {!isEnabled}", LogLevel.Info); if (!isEnabled) //On { if (HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null) { return; } } else { if (!HostWindow.IsCrmDexWindowOpen(dte) && SharedGlobals.GetGlobal("CrmService", dte) != null) { SharedGlobals.SetGlobal("CrmService", null, dte); } CrmMetadata.Metadata = null; SharedGlobals.SetGlobal("CrmMetadata", null, dte); ExLogger.LogToFile(Logger, Resource.Message_ClearingMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_ClearingMetadata, MessageType.Info); return; } var result = MessageBox.Show(Resource.MessageBox_ConnectToCrm, Resource.MessageBox_ConnectToCrm_Title, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result != MessageBoxResult.Yes) { return; } ConnectToCrm(); }
public static EntityCollection RetrieveSolutionsFromCrm(CrmServiceClient client) { try { var query = new QueryExpression { EntityName = "solution", ColumnSet = new ColumnSet("friendlyname", "solutionid", "uniquename", "version"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "isvisible", Operator = ConditionOperator.Equal, Values = { true } }, new ConditionExpression { AttributeName = "ismanaged", Operator = ConditionOperator.Equal, Values = { false } } } }, Orders = { new OrderExpression { AttributeName = "friendlyname", OrderType = OrderType.Ascending } } }; var solutions = client.RetrieveMultiple(query); ExLogger.LogToFile(Logger, Resource.Message_RetrievedSolutions, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievedSolutions, MessageType.Info); return(solutions); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingSolutions, ex); return(null); } }
public static void DeleteWebResourceFromCrm(CrmServiceClient client, Guid webResourceId) { try { client.Delete("webresource", webResourceId); ExLogger.LogToFile(Logger, $"{Resource.Message_DeletedWebResource}: {webResourceId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_DeletedWebResource}: {webResourceId}", MessageType.Info); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorDeletingWebResource, ex); } }
private static void ShowToolWindow <T>(object sender, EventArgs e, AsyncPackage package) { ExLogger.LogToFile(Logger, $"{Resource.Message_OpeningToolWindow}: {typeof(T)}", LogLevel.Info); var window = package.FindToolWindow(typeof(T), 0, true); if (window?.Frame == null) { throw new NotSupportedException(Resource.ErrorMessage_CannotCreateToolWindow); } var windowFrame = (IVsWindowFrame)window.Frame; ErrorHandler.ThrowOnFailure(windowFrame.Show()); }
public static Entity RetrieveWebResourceContentFromCrm(CrmServiceClient client, Guid webResourceId) { try { var webResource = client.Retrieve("webresource", webResourceId, new ColumnSet("content", "name")); ExLogger.LogToFile(Logger, $"{Resource.Message_RetrievedWebResourceContent}: {webResourceId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_RetrievedWebResourceContent}: {webResourceId}", MessageType.Info); return(webResource); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingWebResourceContent, ex); return(null); } }
public static string RetrieveWebResourceDescriptionFromCrm(CrmServiceClient client, Guid webResourceId) { try { var webResource = client.Retrieve("webresource", webResourceId, new ColumnSet("description")); ExLogger.LogToFile(Logger, $"{Resource.Message_RetrievedWebResourceDescription}: {webResourceId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_RetrievedWebResourceDescription}: {webResourceId}", MessageType.Info); return(webResource.GetAttributeValue <string>("description")); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingWebResourceDescription, ex); return(null); } }
public static Guid CreateWebResourceInCrm(CrmServiceClient client, Entity webResource) { try { var id = client.Create(webResource); ExLogger.LogToFile(Logger, $"{Resource.Message_NewWebResourceCreated}: {id}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_NewWebResourceCreated}: {id}", MessageType.Info); return(id); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorCreatingWebResource, ex); return(Guid.Empty); } }
public static bool PublishAllCustomizations(CrmServiceClient client) { try { ExLogger.LogToFile(Logger, Resource.Message_PublishingAllCustomizations, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_PublishingAllCustomizations, MessageType.Info); var request = new PublishAllXmlRequest(); client.Execute(request); return(true); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorPublishing, ex); return(false); } }
public static Entity RetrieveAssemblyFromCrm(CrmServiceClient client, string assemblyName) { try { var query = new QueryExpression { EntityName = "pluginassembly", ColumnSet = new ColumnSet("pluginassemblyid", "name", "version"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "name", Operator = ConditionOperator.Equal, Values = { assemblyName } } } } }; var assemblies = client.RetrieveMultiple(query); if (assemblies.Entities.Count <= 0) { return(null); } ExLogger.LogToFile(Logger, $"{Resource.Message_RetrievedAssembly}: {assemblies.Entities[0].Id}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_RetrievedAssembly}: {assemblies.Entities[0].Id}", MessageType.Info); return(assemblies.Entities[0]); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingAssembly, ex); return(null); } }
public static Guid UpdateCrmAssembly(CrmServiceClient client, CrmAssembly crmAssembly) { try { var assembly = new Entity("pluginassembly") { ["content"] = Convert.ToBase64String(FileSystem.GetFileBytes(crmAssembly.AssemblyPath)), ["name"] = crmAssembly.Name, ["culture"] = crmAssembly.Culture, ["version"] = crmAssembly.Version, ["publickeytoken"] = crmAssembly.PublicKeyToken, ["sourcetype"] = new OptionSetValue(0), // database ["isolationmode"] = crmAssembly.IsolationMode == IsolationModeEnum.Sandbox ? new OptionSetValue(2) // 2 = sandbox : new OptionSetValue(1) // 1= none }; if (crmAssembly.AssemblyId == Guid.Empty) { var newId = client.Create(assembly); ExLogger.LogToFile(Logger, $"{Resource.Message_CreatedAssembly}: {crmAssembly.Name}|{newId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_CreatedAssembly}: {crmAssembly.Name}|{newId}", MessageType.Info); return(newId); } assembly.Id = crmAssembly.AssemblyId; client.Update(assembly); ExLogger.LogToFile(Logger, $"{Resource.Message_UpdatedAssembly}: {crmAssembly.Name}|{crmAssembly.AssemblyId}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_UpdatedAssembly}: {crmAssembly.Name}|{crmAssembly.AssemblyId}", MessageType.Info); return(crmAssembly.AssemblyId); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorCreatingOrUpdatingAssembly, ex); return(Guid.Empty); } }
public static bool IsAssemblyInSolution(CrmServiceClient client, string assemblyName, string uniqueName) { try { var query = new FetchExpression($@"<fetch> <entity name='solutioncomponent'> <attribute name='solutioncomponentid'/> <link-entity name='pluginassembly' from='pluginassemblyid' to='objectid'> <attribute name='pluginassemblyid'/> <filter type='and'> <condition attribute='name' operator='eq' value='{assemblyName}'/> </filter> </link-entity> <link-entity name='solution' from='solutionid' to='solutionid'> <attribute name='solutionid'/> <filter type='and'> <condition attribute='uniquename' operator='eq' value='{uniqueName}'/> </filter> </link-entity> </entity> </fetch>"); var results = client.RetrieveMultiple(query); var inSolution = results.Entities.Count > 0; ExLogger.LogToFile(Logger, $"{Resource.Message_AssemblyInSolution}: {uniqueName} - {assemblyName} - {inSolution}", LogLevel.Info); OutputLogger.WriteToOutputWindow($"{Resource.Message_AssemblyInSolution}: {uniqueName} - {assemblyName} - {inSolution}", MessageType.Info); return(inSolution); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorCheckingAssemblyInSolution, ex); return(true); } }
public static async Task <string> GetSolutionFromCrm(CrmServiceClient client, CrmSolution selectedSolution, bool managed) { try { // Hardcode connection timeout to one-hour to support large solutions. //TODO: Find a better way to handle this if (client.OrganizationServiceProxy != null) { client.OrganizationServiceProxy.Timeout = new TimeSpan(1, 0, 0); } if (client.OrganizationWebProxyClient != null) { client.OrganizationWebProxyClient.InnerChannel.OperationTimeout = new TimeSpan(1, 0, 0); } var request = new ExportSolutionRequest { Managed = managed, SolutionName = selectedSolution.UniqueName }; var response = await Task.Run(() => (ExportSolutionResponse)client.Execute(request)); ExLogger.LogToFile(Logger, Resource.Message_RetrievedSolution, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievedSolution, MessageType.Info); var fileName = FileHandler.FormatSolutionVersionString(selectedSolution.UniqueName, selectedSolution.Version, managed); var tempFile = FileHandler.WriteTempFile(fileName, response.ExportSolutionFile); return(tempFile); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingSolution, ex); return(null); } }
public static void GetMetadata(CrmServiceClient client) { try { ExLogger.LogToFile(Logger, Resource.Message_RetrievingMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievingMetadata, MessageType.Info); var metaDataRequest = new RetrieveAllEntitiesRequest { EntityFilters = EntityFilters.Entity | EntityFilters.Attributes }; var metaDataResponse = (RetrieveAllEntitiesResponse)client.Execute(metaDataRequest); ExLogger.LogToFile(Logger, Resource.Message_RetrievedMetadata, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievedMetadata, MessageType.Info); ProcessMetadata(metaDataResponse); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.Message_ErrorRetrievingMetadata, ex); } }
public static EntityCollection RetrieveWebResourcesFromCrm(CrmServiceClient client) { EntityCollection results = null; try { var pageNumber = 1; string pagingCookie = null; var moreRecords = true; while (moreRecords) { var query = new QueryExpression { EntityName = "solutioncomponent", ColumnSet = new ColumnSet("solutionid"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "componenttype", Operator = ConditionOperator.Equal, Values = { 61 } } } }, LinkEntities = { new LinkEntity { Columns = new ColumnSet("name", "displayname", "webresourcetype", "ismanaged", "webresourceid", "description"), EntityAlias = "webresource", LinkFromEntityName = "solutioncomponent", LinkFromAttributeName = "objectid", LinkToEntityName = "webresource", LinkToAttributeName = "webresourceid" } }, PageInfo = new PagingInfo { PageNumber = pageNumber, PagingCookie = pagingCookie } }; var partialResults = client.RetrieveMultiple(query); if (partialResults.MoreRecords) { pageNumber++; pagingCookie = partialResults.PagingCookie; } moreRecords = partialResults.MoreRecords; if (partialResults.Entities == null) { continue; } if (results == null) { results = new EntityCollection(); } results.Entities.AddRange(partialResults.Entities); } ExLogger.LogToFile(Logger, Resource.Message_RetrievedWebResources, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievedWebResources, MessageType.Info); return(results); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingWebResources, ex); return(null); } }
private static void ControlOnConnectionToCrmCompleted(object sender, EventArgs eventArgs) { ExLogger.LogToFile(Logger, Resource.Message_ClosingCrmLoginForm, LogLevel.Info); ((CrmLoginForm)sender).Close(); }
protected override void Initialize() { base.Initialize(); _dte = GetGlobalService(typeof(DTE)) as DTE; if (_dte == null) { return; } StartupTasks.Run(_dte); ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingExtension, LogLevel.Info); AdviseSolutionEvents(); var events = _dte.Events; BindSolutionEvents(events); if (!(GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs)) { return; } //Plug-in Deployer CommandID pdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginDeployerWindow); OleMenuCommand pdWindowItem = new OleMenuCommand(ShowToolWindow <PluginDeployerHost>, pdWindowCommandId); mcs.AddCommand(pdWindowItem); //Web Resource Deployer CommandID wrdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidWebResourceDeployerWindow); OleMenuCommand wrdWindowItem = new OleMenuCommand(ShowToolWindow <WebResourceDeployerHost>, wrdWindowCommandId); mcs.AddCommand(wrdWindowItem); //Solution Packager CommandID spWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidSolutionPackagerWindow); OleMenuCommand spWindowItem = new OleMenuCommand(ShowToolWindow <SolutionPackagerHost>, spWindowCommandId); mcs.AddCommand(spWindowItem); //Plug-in Trace Viewer CommandID ptvWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginTraceViewerWindow); OleMenuCommand ptvWindowItem = new OleMenuCommand(ShowToolWindow <PluginTraceViewerHost>, ptvWindowCommandId); mcs.AddCommand(ptvWindowItem); //CRM Intellisense On CommandID crmIntellisenseOnCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOn); OleMenuCommand crmIntellisenseOnItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOnCommandId) { Visible = false }; crmIntellisenseOnItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOnItem); //CRM Intellisense Off CommandID crmIntellisenseOffCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOff); OleMenuCommand crmIntellisenseOffItem = new OleMenuCommand(ToggleCrmIntellisense, crmIntellisenseOffCommandId) { Visible = false }; crmIntellisenseOffItem.BeforeQueryStatus += DisplayCrmIntellisense; mcs.AddCommand(crmIntellisenseOffItem); //NuGet SDK Tools - Core Tools CommandID nugetSdkToolsCoreCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsCore); OleMenuCommand nugetSdkToolsCoreItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsCoreCommandId); mcs.AddCommand(nugetSdkToolsCoreItem); //NuGet SDK Tools - Plug-in Registration Tool CommandID nugetSdkToolsPrtCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsPrt); OleMenuCommand nugetSdkToolsPrtItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsPrtCommandId); mcs.AddCommand(nugetSdkToolsPrtItem); }
public static async System.Threading.Tasks.Task InitializeAsync(AsyncPackage package, DTE dte) { try { if (!(await package.GetServiceAsync((typeof(IMenuCommandService))) is OleMenuCommandService mcs)) { throw new ArgumentNullException(Core.Resources.Resource.ErrorMessage_ErrorAccessingMCS); } ExLogger.LogToFile(Logger, Resource.TraceInfo_InitializingMenu, LogLevel.Info); //Plug-in Deployer var pdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginDeployerWindow); var pdWindowItem = new OleMenuCommand((sender, e) => ShowToolWindow <PluginDeployerHost>(sender, e, package), pdWindowCommandId); mcs.AddCommand(pdWindowItem); //Web Resource Deployer var wrdWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidWebResourceDeployerWindow); var wrdWindowItem = new OleMenuCommand((sender, e) => ShowToolWindow <WebResourceDeployerHost>(sender, e, package), wrdWindowCommandId); mcs.AddCommand(wrdWindowItem); //Solution Packager var spWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidSolutionPackagerWindow); var spWindowItem = new OleMenuCommand((sender, e) => ShowToolWindow <SolutionPackagerHost>(sender, e, package), spWindowCommandId); mcs.AddCommand(spWindowItem); //Plug-in Trace Viewer var ptvWindowCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidPluginTraceViewerWindow); var ptvWindowItem = new OleMenuCommand((sender, e) => ShowToolWindow <PluginTraceViewerHost>(sender, e, package), ptvWindowCommandId); mcs.AddCommand(ptvWindowItem); //CRM Intellisense On var crmIntellisenseOnCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOn); var crmIntellisenseOnItem = new OleMenuCommand((sender, e) => ToggleCrmIntellisense(sender, e, dte), crmIntellisenseOnCommandId) { Visible = false }; crmIntellisenseOnItem.BeforeQueryStatus += (sender, e) => DisplayCrmIntellisense(sender, e, dte); mcs.AddCommand(crmIntellisenseOnItem); //CRM Intellisense Off var crmIntellisenseOffCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidCrmIntellisenseOff); var crmIntellisenseOffItem = new OleMenuCommand((sender, e) => ToggleCrmIntellisense(sender, e, dte), crmIntellisenseOffCommandId) { Visible = false }; crmIntellisenseOnItem.BeforeQueryStatus += (sender, e) => DisplayCrmIntellisense(sender, e, dte); mcs.AddCommand(crmIntellisenseOffItem); //NuGet SDK Tools - Core Tools var nugetSdkToolsCoreCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsCore); var nugetSdkToolsCoreItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsCoreCommandId); mcs.AddCommand(nugetSdkToolsCoreItem); //NuGet SDK Tools - Plug-in Registration Tool var nugetSdkToolsPrtCommandId = new CommandID(PackageGuids.GuidD365DevExCmdSet, PackageIds.CmdidNuGetSdkToolsPrt); var nugetSdkToolsPrtItem = new OleMenuCommand(InstallNuGetCliPackage, nugetSdkToolsPrtCommandId); mcs.AddCommand(nugetSdkToolsPrtItem); } catch (Exception e) { ExceptionHandler.LogException(Logger, null, e); throw; } }
public static EntityCollection RetrieveSolutionsFromCrm(CrmServiceClient client, bool getManaged) { try { var query = new QueryExpression { EntityName = "solution", ColumnSet = new ColumnSet("friendlyname", "solutionid", "uniquename", "version"), Criteria = new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "isvisible", Operator = ConditionOperator.Equal, Values = { true } } } }, LinkEntities = { new LinkEntity { LinkFromEntityName = "solution", LinkFromAttributeName = "publisherid", LinkToEntityName = "publisher", LinkToAttributeName = "publisherid", Columns = new ColumnSet("customizationprefix"), EntityAlias = "publisher" } }, Distinct = true, Orders = { new OrderExpression { AttributeName = "friendlyname", OrderType = OrderType.Ascending } } }; if (!getManaged) { var noManaged = new ConditionExpression { AttributeName = "ismanaged", Operator = ConditionOperator.Equal, Values = { false } }; query.Criteria.Conditions.Add(noManaged); } var solutions = client.RetrieveMultiple(query); ExLogger.LogToFile(Logger, Resource.Message_RetrievedSolutions, LogLevel.Info); OutputLogger.WriteToOutputWindow(Resource.Message_RetrievedSolutions, MessageType.Info); return(solutions); } catch (Exception ex) { ExceptionHandler.LogException(Logger, Resource.ErrorMessage_ErrorRetrievingSolutions, ex); return(null); } }