private async void hyperlinkJavaScript_Click(object sender, RoutedEventArgs e) { OptionSetMetadataListViewItem item = GetItemFromRoutedDataContext <OptionSetMetadataListViewItem>(e); if (item == null) { return; } await CreateJavaScriptFile(new[] { item.OptionSetMetadata }); }
private async void hyperlinkPublishOptionSet_Click(object sender, RoutedEventArgs e) { OptionSetMetadataListViewItem item = GetItemFromRoutedDataContext <OptionSetMetadataListViewItem>(e); if (item == null) { return; } await PublishOptionSetAsync(item.OptionSetMetadata.Name); }
private async Task ShowExistingOptionSets() { if (!this.IsControlsEnabled) { return; } var service = await GetService(); ToggleControls(service.ConnectionData, false, Properties.WindowStatusStrings.LoadingOptionSets); this._itemsSource.Clear(); IEnumerable <OptionSetMetadata> list = Enumerable.Empty <OptionSetMetadata>(); try { if (service != null) { if (!_cacheOptionSetMetadata.ContainsKey(service.ConnectionData.ConnectionId)) { OptionSetRepository repository = new OptionSetRepository(service); var task = repository.GetOptionSetsAsync(); var optionSets = await task; _cacheOptionSetMetadata.Add(service.ConnectionData.ConnectionId, optionSets); } list = _cacheOptionSetMetadata[service.ConnectionData.ConnectionId]; } } catch (Exception ex) { this._iWriteToOutput.WriteErrorToOutput(service.ConnectionData, ex); } string entityName = string.Empty; string textName = string.Empty; this.Dispatcher.Invoke(() => { textName = txtBFilter.Text.Trim().ToLower(); if (!string.IsNullOrEmpty(cmBEntityName.Text) && cmBEntityName.Items.Contains(cmBEntityName.Text) ) { entityName = cmBEntityName.Text.Trim().ToLower(); } }); string filterEntity = null; if (service.ConnectionData.IsValidEntityName(entityName)) { filterEntity = entityName; } if (!string.IsNullOrEmpty(filterEntity)) { var entityId = service.ConnectionData.GetEntityMetadataId(filterEntity); if (entityId.HasValue) { var source = GetMetadataSource(service); var entityMetadata = await source.GetEntityMetadataAsync(entityId.Value); var entityOptionSets = new HashSet <Guid>(entityMetadata .Attributes .OfType <EnumAttributeMetadata>() .Where(a => a.OptionSet != null && a.OptionSet.IsGlobal.GetValueOrDefault()) .Select(a => a.OptionSet.MetadataId.Value) ); list = list.Where(o => entityOptionSets.Contains(o.MetadataId.Value)); } } list = FilterList(list, textName); this.lstVwOptionSets.Dispatcher.Invoke(() => { foreach (var entity in list) { string name = entity.Name; string displayName = CreateFileHandler.GetLocalizedLabel(entity.DisplayName); OptionSetMetadataListViewItem item = new OptionSetMetadataListViewItem(name, displayName, entity); this._itemsSource.Add(item); } if (this.lstVwOptionSets.Items.Count == 1) { this.lstVwOptionSets.SelectedItem = this.lstVwOptionSets.Items[0]; } }); ToggleControls(service.ConnectionData, true, Properties.WindowStatusStrings.LoadingOptionSetsCompletedFormat1, list.Count()); }