public virtual PublishAllXmlResponse PublishAllCustomizations() { Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); PublishAllXmlResponse res = (PublishAllXmlResponse)OrganizationService.Execute(new PublishAllXmlRequest()); Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); return(res); }
public static bool PublishAllCustomizations(CrmServiceClient client) { try { PublishAllXmlRequest request = new PublishAllXmlRequest(); PublishAllXmlResponse response = (PublishAllXmlResponse)client.Execute(request); return(true); } catch (FaultException <OrganizationServiceFault> crmEx) { OutputLogger.WriteToOutputWindow("Error Publishing Customizations To CRM: " + crmEx.Message + Environment.NewLine + crmEx.StackTrace, MessageType.Error); return(false); } catch (Exception ex) { OutputLogger.WriteToOutputWindow("Error Publishing Customizations To CRM: " + ex.Message + Environment.NewLine + ex.StackTrace, MessageType.Error); return(false); } }
public void PublishCustomizations() { Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.EnteredMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); int errorCount = 0; PublishAllXmlResponse response = CrmService.PublishAllCustomizations(); foreach (KeyValuePair <string, object> result in response.Results) { if (result.Value is Exception exception) { errorCount++; Logger.Error(exception); } } if (errorCount > 0) { throw new PlatformException("Error(s) occurred whilst publishing the customizations."); } Logger.Trace(CultureInfo.InvariantCulture, TraceMessageHelper.ExitingMethod, SystemTypeName, MethodBase.GetCurrentMethod().Name); }
public void RegisterDataSource() { var languageCode = GetLanguageCode(); var propertyFalse = new BooleanManagedProperty(false); var propertyTrue = new BooleanManagedProperty(true); var request = new CreateEntityRequest { HasActivities = false, PrimaryAttribute = new StringAttributeMetadata { SchemaName = $"{DataSourceName}Name", RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), MaxLength = 100, DisplayName = new Label(json.displayname, languageCode), ExternalName = json.displayname }, Entity = new EntityMetadata { DataProviderId = new Guid?(new Guid("B2112A7E-B26C-42F7-9B63-9A809A9D716F")), IsActivity = new bool?(false), SchemaName = DataSourceName, DisplayName = new Label(json.displayname, languageCode), DisplayCollectionName = new Label(json.pluralname, languageCode), ExternalCollectionName = json.pluralname.Replace(" ", string.Empty), ExternalName = json.displayname.Replace(" ", string.Empty), OwnershipType = new OwnershipTypes?(OwnershipTypes.OrganizationOwned), IsAvailableOffline = new bool?(false), Description = new Label(string.Empty, languageCode), IsBusinessProcessEnabled = new bool?(false), IsVisibleInMobile = propertyFalse, IsVisibleInMobileClient = propertyFalse, IsReadOnlyInMobileClient = propertyFalse, IsOfflineInMobileClient = propertyFalse, IsAuditEnabled = propertyFalse, IsSLAEnabled = new bool?(false), IsBPFEntity = new bool?(false), IsDuplicateDetectionEnabled = propertyFalse, IsConnectionsEnabled = propertyFalse, IsActivityParty = new bool?(false), IsReadingPaneEnabled = new bool?(false), IsQuickCreateEnabled = new bool?(false), AutoCreateAccessTeams = new bool?(false), CanCreateCharts = propertyFalse, IsMailMergeEnabled = propertyFalse, ChangeTrackingEnabled = new bool?(false), CanChangeTrackingBeEnabled = propertyFalse, IsEnabledForExternalChannels = new bool?(false), EntityHelpUrlEnabled = new bool?(false), IsCustomizable = propertyTrue, IsRenameable = propertyTrue, IsMappable = propertyFalse, SyncToExternalSearchIndex = new bool?(false), CanEnableSyncToExternalSearchIndex = propertyFalse, CanModifyAdditionalSettings = propertyFalse, CanChangeHierarchicalRelationship = propertyFalse } }; if (request.Parameters == null) { request.Parameters = new ParameterCollection(); } if (request.Parameters.ContainsKey("SolutionUniqueName")) { request.Parameters["SolutionUniqueName"] = json.solution; } else { request.Parameters.Add("SolutionUniqueName", json.solution); } var response = (CreateEntityResponse)crmServiceClient.Execute(request); var entityId = response.EntityId; var retrieveEntityRequest = new RetrieveEntityRequest() { EntityFilters = EntityFilters.All, MetadataId = entityId }; EntityMetadata entityMetadata = ((RetrieveEntityResponse)crmServiceClient.Execute(retrieveEntityRequest)).EntityMetadata; //Update field Id var requestId = new RetrieveAttributeRequest() { EntityLogicalName = entityMetadata.LogicalName, LogicalName = string.Format("{0}id", entityMetadata.LogicalName) }; var attributeMetadataId = ((RetrieveAttributeResponse)crmServiceClient.Execute(requestId)).AttributeMetadata; attributeMetadataId.ExternalName = $"{DataSourceName}Id"; var updateRequestId = new UpdateAttributeRequest() { Attribute = attributeMetadataId, EntityName = entityMetadata.LogicalName, MergeLabels = false }; crmServiceClient.Execute(updateRequestId); //Update field name var requestName = new RetrieveAttributeRequest() { EntityLogicalName = entityMetadata.LogicalName, LogicalName = string.Format("{0}name", DataSourceName.ToLower()) }; var attributeMetadataName = ((RetrieveAttributeResponse)crmServiceClient.Execute(requestName)).AttributeMetadata; attributeMetadataName.ExternalName = $"{DataSourceName}Name"; var updateRequestName = new UpdateAttributeRequest() { Attribute = attributeMetadataName, EntityName = entityMetadata.LogicalName, MergeLabels = false }; crmServiceClient.Execute(updateRequestName); try { PublishAllXmlRequest publishAllXmlRequest = new PublishAllXmlRequest(); PublishAllXmlResponse publishAllXmlResponse = (PublishAllXmlResponse)crmServiceClient.Execute(publishAllXmlRequest); } catch { } }