private async Task PerformSaveClick() { var imageType = GetImageType(); this.Image.Name = txtBName.Text.Trim(); this.Image.EntityAlias = txtBEntityAlias.Text.Trim(); this.Image.MessagePropertyName = cmBMessagePropertyName.Text?.Trim() ?? string.Empty; this.Image.RelatedAttributeName = txtBRelatedAttributeName.Text.Trim(); this.Image.Description = txtBDescription.Text.Trim(); this.Image.Attributes1 = txtBAttributes.Text.Trim(); this.Image.ImageType = new OptionSetValue(imageType); ToggleControls(false, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepImageFormat1, _service.ConnectionData.Name); try { this.Image.Id = await _service.UpsertAsync(this.Image); ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepImageCompletedFormat1, _service.ConnectionData.Name); this.DialogResult = true; this.Close(); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepImageFailedFormat1, _service.ConnectionData.Name); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } }
public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { var idEntity = await _service.UpsertAsync(entity); var systemForm = await GetByIdAsync(idEntity, new ColumnSet(SystemForm.Schema.Attributes.objecttypecode, SystemForm.Schema.Attributes.name)); var repositoryPublish = new PublishActionsRepository(_service); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingSystemFormFormat3, _service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name)); await repositoryPublish.PublishDashboardsAsync(new[] { idEntity }); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingSystemFormCompletedFormat3, _service.ConnectionData.Name, systemForm.ObjectTypeCode, systemForm.Name)); if (systemForm.ObjectTypeCode.IsValidEntityName()) { updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, _service.ConnectionData.Name, systemForm.ObjectTypeCode)); await repositoryPublish.PublishEntitiesAsync(new[] { systemForm.ObjectTypeCode }); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, systemForm.ObjectTypeCode)); } return(idEntity); }
private async void btnTransferEntities_Click(object sender, RoutedEventArgs e) { if (!IsControlsEnabled) { return; } if (_entityMetadata == null || !_entityCollection.Any() ) { return; } ToggleControls(false, Properties.WindowStatusStrings.SavingEntitiesFormat1, _entityMetadata.LogicalName); bool hasError = false; foreach (var entity in _entityCollection) { var updateEntity = new Entity(_entityMetadata.LogicalName) { Id = entity.Id, }; foreach (var attribute in entity.Attributes) { if (attribute.Value != null) { if (attribute.Value is EntityReference entityReference && _dictLookupMapping.ContainsKey(entityReference) ) { updateEntity.Attributes[attribute.Key] = _dictLookupMapping[entityReference].CurrentValue; } else { updateEntity.Attributes[attribute.Key] = attribute.Value; } } } try { _iWriteToOutput.WriteToOutput(_service.ConnectionData, Properties.WindowStatusStrings.SavingEntityInstanceFormat2, _entityMetadata.LogicalName, entity.Id); _iWriteToOutput.WriteToOutputEntityInstance(_service.ConnectionData, updateEntity); await _service.UpsertAsync(updateEntity); } catch (Exception ex) { hasError = true; _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex, Properties.WindowStatusStrings.SavingEntityInstanceFailedFormat2, _entityMetadata.LogicalName, entity.Id); } }
public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { var idEntity = await _service.UpsertAsync(entity); var webResource = await GetByIdAsync(idEntity, new ColumnSet(WebResource.Schema.Attributes.name)); var repositoryPublish = new PublishActionsRepository(_service); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingWebResourceFormat2, _service.ConnectionData.Name, webResource.Name)); await repositoryPublish.PublishWebResourcesAsync(new[] { idEntity }); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingWebResourceCompletedFormat2, _service.ConnectionData.Name, webResource.Name)); return(idEntity); }
public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { var idEntity = await _service.UpsertAsync(entity); var siteMap = await GetByIdAsync(idEntity, new ColumnSet(SiteMap.Schema.Attributes.sitemapname)); var repositoryPublish = new PublishActionsRepository(_service); updateStatus(string.Format(Properties.WindowStatusStrings.PublishingSiteMapFormat3, _service.ConnectionData.Name, siteMap.SiteMapName, idEntity.ToString())); await repositoryPublish.PublishSiteMapsAsync(new[] { idEntity }); updateStatus(string.Format(Properties.WindowStatusStrings.PublishingSiteMapCompletedFormat3, _service.ConnectionData.Name, siteMap.SiteMapName, idEntity.ToString())); return(idEntity); }
public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { var idEntity = await _service.UpsertAsync(entity); var savedQuery = await GetByIdAsync(idEntity, new ColumnSet(SavedQuery.Schema.Attributes.returnedtypecode)); if (savedQuery.ReturnedTypeCode.IsValidEntityName()) { updateStatus(string.Format(Properties.WindowStatusStrings.PublishingEntitiesFormat2, _service.ConnectionData.Name, savedQuery.ReturnedTypeCode)); var repositoryPublish = new PublishActionsRepository(_service); await repositoryPublish.PublishEntitiesAsync(new[] { savedQuery.ReturnedTypeCode }); updateStatus(string.Format(Properties.WindowStatusStrings.PublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, savedQuery.ReturnedTypeCode)); } return(idEntity); }
public async Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { var idEntity = await _service.UpsertAsync(entity); var chart = await GetByIdAsync(idEntity, new ColumnSet(SavedQueryVisualization.Schema.Attributes.primaryentitytypecode)); if (chart.PrimaryEntityTypeCode.IsValidEntityName()) { updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesFormat2, _service.ConnectionData.Name, chart.PrimaryEntityTypeCode)); var repositoryPublish = new PublishActionsRepository(_service); await repositoryPublish.PublishEntitiesAsync(new[] { chart.PrimaryEntityTypeCode }); updateStatus(string.Format(Properties.OutputStrings.InConnectionPublishingEntitiesCompletedFormat2, _service.ConnectionData.Name, chart.PrimaryEntityTypeCode)); } return(idEntity); }
public Task <Guid> UpsertAsync(Entity entity, Action <string> updateStatus) { return(_service.UpsertAsync(entity)); }
private async Task PerformSaveClick() { if (_assemblyLoad == null) { return; } if (_listMissingCrm.Count > 0) { return; } string workflowActivityGroupName = txtBWorkflowActivityGroupName.Text.Trim(); var updateAssembly = new PluginAssembly(); if (PluginAssembly.PluginAssemblyId.HasValue) { updateAssembly.Id = PluginAssembly.PluginAssemblyId.Value; updateAssembly.PluginAssemblyId = PluginAssembly.PluginAssemblyId; } else { updateAssembly.Name = _assemblyLoad.Name; } updateAssembly.Description = txtBDescription.Text.Trim(); var isolationMode = GetIsolationMode(); var sourceType = GetSourceType(); updateAssembly.IsolationMode = new Microsoft.Xrm.Sdk.OptionSetValue(isolationMode); updateAssembly.SourceType = new Microsoft.Xrm.Sdk.OptionSetValue(sourceType); updateAssembly.Version = _assemblyLoad.Version; updateAssembly.Culture = _assemblyLoad.Culture; updateAssembly.PublicKeyToken = _assemblyLoad.PublicKeyToken; if (sourceType == (int)PluginAssembly.Schema.OptionSets.sourcetype.Database_0 && _assemblyLoad.Content != null && _assemblyLoad.Content.Length > 0 ) { updateAssembly.Content = Convert.ToBase64String(_assemblyLoad.Content); } if (sourceType == (int)PluginAssembly.Schema.OptionSets.sourcetype.Disk_1) { updateAssembly.Path = txtBFileNameOnServer.Text.Trim(); } else { updateAssembly.Path = string.Empty; } var listToRegister = _listLocalAssembly.Where(p => p.IsChecked).ToList(); _service.ConnectionData.AddAssemblyMapping(_assemblyLoad.Name, _assemblyLoad.FilePath); _service.ConnectionData.Save(); ToggleControls(false, Properties.WindowStatusStrings.UpdatingPluginAssemblyFormat1, _service.ConnectionData.Name); try { this.PluginAssembly.Id = await _service.UpsertAsync(updateAssembly); if (listToRegister.Any()) { var assemblyRef = this.PluginAssembly.ToEntityReference(); ToggleControls(false, Properties.WindowStatusStrings.RegisteringNewPluginTypesFormat2, _service.ConnectionData.Name, listToRegister.Count); foreach (var pluginType in listToRegister) { var pluginTypeEntity = new PluginType() { Name = pluginType.Name, TypeName = pluginType.Name, FriendlyName = pluginType.Name, PluginAssemblyId = assemblyRef, }; if (pluginType.IsWorkflowActivity) { pluginTypeEntity.WorkflowActivityGroupName = workflowActivityGroupName; } ToggleControls(false, Properties.WindowStatusStrings.RegisteringPluginTypeFormat2, _service.ConnectionData.Name, pluginType); try { pluginTypeEntity.Id = await _service.CreateAsync(pluginTypeEntity); ToggleControls(true, Properties.WindowStatusStrings.RegisteringPluginTypeCompletedFormat2, _service.ConnectionData.Name, pluginType); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.RegisteringPluginTypeFailedFormat2, _service.ConnectionData.Name, pluginType); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } } ToggleControls(true, Properties.WindowStatusStrings.RegisteringNewPluginTypesCompletedFormat2, _service.ConnectionData.Name, listToRegister.Count); } ToggleControls(true, Properties.WindowStatusStrings.UpdatingPluginAssemblyCompletedFormat1, _service.ConnectionData.Name); this.DialogResult = true; this.Close(); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.UpdatingPluginAssemblyFailedFormat1, _service.ConnectionData.Name); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } }
private async Task PerformSaveClick() { string messageName = cmBMessageName.Text?.Trim(); string primaryEntity = cmBPrimaryEntity.Text?.Trim(); string secondaryEntity = cmBSecondaryEntity.Text?.Trim(); if (string.IsNullOrEmpty(messageName)) { MessageBox.Show(Properties.MessageBoxStrings.MessageNameIsEmpty, Properties.MessageBoxStrings.ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (!int.TryParse(txtBExecutionOrder.Text.Trim(), out int rank)) { string text = string.Format(Properties.MessageBoxStrings.TextCannotBeParsedToIntFormat1, txtBExecutionOrder.Text); MessageBox.Show(text, Properties.MessageBoxStrings.ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrEmpty(primaryEntity)) { primaryEntity = "none"; } if (string.IsNullOrEmpty(secondaryEntity)) { secondaryEntity = "none"; } var messageFilterCount = _filters.Count(f => string.Equals(f.SdkMessageId.Name, messageName, StringComparison.InvariantCultureIgnoreCase) && string.Equals(f.PrimaryObjectTypeCode, primaryEntity, StringComparison.InvariantCultureIgnoreCase) && string.Equals(f.SecondaryObjectTypeCode, secondaryEntity, StringComparison.InvariantCultureIgnoreCase) ); if (messageFilterCount != 1) { string text = string.Format(Properties.MessageBoxStrings.MessageFilterNotFindedForMessageNameAndEntitiesFormat3, messageName, primaryEntity, secondaryEntity); MessageBox.Show(text, Properties.MessageBoxStrings.ErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error); return; } var messageFilter = _filters.Single(f => string.Equals(f.SdkMessageId.Name, messageName, StringComparison.InvariantCultureIgnoreCase) && string.Equals(f.PrimaryObjectTypeCode, primaryEntity, StringComparison.InvariantCultureIgnoreCase) && string.Equals(f.SecondaryObjectTypeCode, secondaryEntity, StringComparison.InvariantCultureIgnoreCase) ); this.Step.Name = txtBName.Text.Trim(); this.Step.Description = txtBDescription.Text.Trim(); this.Step.SdkMessageFilterId = messageFilter.ToEntityReference(); this.Step.SdkMessageId = messageFilter.SdkMessageId; this.Step.Rank = rank; this.Step.Configuration = txtBUnSecureConfiguration.Text.Trim(); var stage = GetStage(); var invocationsource = GetInvocationSource(); this.Step.Stage = new OptionSetValue(stage); if (stage == (int)SdkMessageProcessingStep.Schema.OptionSets.stage.Post_operation_40) { var mode = GetMode(); this.Step.Mode = new OptionSetValue(mode); if (mode == (int)SdkMessageProcessingStep.Schema.OptionSets.mode.Asynchronous_1) { this.Step.AsyncAutoDelete = chBDeleteAsyncOperationIfSuccessful.IsChecked.GetValueOrDefault(); } else { this.Step.AsyncAutoDelete = false; } } else { this.Step.Mode = new OptionSetValue((int)SdkMessageProcessingStep.Schema.OptionSets.mode.Synchronous_0); this.Step.AsyncAutoDelete = false; } if (!messageFilter.Availability.HasValue || messageFilter.Availability == (int)SdkMessageFilter.Schema.OptionSets.availability.Both) { var supporteddeployment = GetDeployment(); this.Step.SupportedDeployment = new OptionSetValue(supporteddeployment); } else if (messageFilter.Availability == (int)SdkMessageFilter.Schema.OptionSets.availability.Server) { this.Step.SupportedDeployment = new OptionSetValue((int)SdkMessageProcessingStep.Schema.OptionSets.supporteddeployment.Server_Only_0); } else if (messageFilter.Availability == (int)SdkMessageFilter.Schema.OptionSets.availability.Client) { this.Step.SupportedDeployment = new OptionSetValue((int)SdkMessageProcessingStep.Schema.OptionSets.supporteddeployment.Microsoft_Dynamics_365_Client_for_Outlook_Only_1); } #pragma warning disable CS0612 // Type or member is obsolete this.Step.InvocationSource = new OptionSetValue(invocationsource); #pragma warning restore CS0612 // Type or member is obsolete if (string.Equals(messageFilter.SdkMessageId.Name, "Update", StringComparison.InvariantCultureIgnoreCase)) { this.Step.FilteringAttributes = txtBFilteringBAttributes.Text.Trim(); } else { this.Step.FilteringAttributes = string.Empty; } this.Step.ImpersonatingUserId = _impersonatingUser; string secureConfig = txtBSecureConfiguration.Text.Trim(); EntityReference configToDelete = null; if (string.IsNullOrEmpty(secureConfig)) { if (this.Step.SdkMessageProcessingStepSecureConfigId != null) { configToDelete = this.Step.SdkMessageProcessingStepSecureConfigId; this.Step.SdkMessageProcessingStepSecureConfigId = null; } } else { SdkMessageProcessingStepSecureConfig config = new SdkMessageProcessingStepSecureConfig() { SecureConfig = secureConfig, }; if (this.Step.SdkMessageProcessingStepSecureConfigId != null) { config.Id = this.Step.SdkMessageProcessingStepSecureConfigId.Id; } ToggleControls(false, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepSecureConfigFormat1, _service.ConnectionData.Name); try { config.Id = await _service.UpsertAsync(config); ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepSecureConfigCompletedFormat1, _service.ConnectionData.Name); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepSecureConfigFailedFormat1, _service.ConnectionData.Name); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } if (config.Id != Guid.Empty) { this.Step.SdkMessageProcessingStepSecureConfigId = config.ToEntityReference(); } } ToggleControls(false, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepFormat1, _service.ConnectionData.Name); try { this.Step.Id = await _service.UpsertAsync(this.Step); if (configToDelete != null) { ToggleControls(false, Properties.WindowStatusStrings.DeletingSdkMessageProcessingStepSecureConfigFormat1, _service.ConnectionData.Name); try { await _service.DeleteAsync(configToDelete.LogicalName, configToDelete.Id); ToggleControls(true, Properties.WindowStatusStrings.DeletingSdkMessageProcessingStepSecureConfigCompletedFormat1, _service.ConnectionData.Name); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.DeletingSdkMessageProcessingStepSecureConfigFailedFormat1, _service.ConnectionData.Name); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } } ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepCompletedFormat1, _service.ConnectionData.Name); this.DialogResult = true; this.Close(); } catch (Exception ex) { ToggleControls(true, Properties.WindowStatusStrings.UpdatingSdkMessageProcessingStepFailedFormat1, _service.ConnectionData.Name); _iWriteToOutput.WriteErrorToOutput(_service.ConnectionData, ex); _iWriteToOutput.ActivateOutputWindow(_service.ConnectionData); } }