public void LoadModels(NetWorkSetting ns) { //Get the current model information from the API. var models = DnsServiceManager.GetModels(ns); foreach (var d in ns.DataMartList) { HubModel[] m = models[d.DataMartId]; if (d.ModelList != null && !d.ModelList.IsEmpty()) { try { //add missing models var newModels = m.Where(x => !d.ModelList.Any(a => a.ModelId == x.Id)).ToArray(); if (newModels.Length > 0) { d.ModelList.AddRange(newModels.Select(nm => new ModelDescription { ModelId = nm.Id, ModelName = nm.Name, ModelDisplayName = nm.Name, ProcessorId = nm.ModelProcessorId })); } //remove old models d.ModelList.RemoveAll(rm => !m.Any(a => a.Id == rm.ModelId)); } catch (ArgumentNullException ex) { // Ignore if nothing to remove, which will throw an exception. } } } }
public void LoadModels(NetWorkSetting ns) { foreach (var d in ns.DataMartList) { d.ModelList = (from m in DnsServiceManager.GetModels(d.DataMartId, ns).EmptyIfNull() join existing in d.ModelList.EmptyIfNull() on m.Id equals existing.ModelId into exts from existing in exts.DefaultIfEmpty() select existing ?? new ModelDescription { ModelId = m.Id, ModelName = m.Name, ProcessorId = m.ModelProcessorId } ).ToList(); } }
private void SettingsForm_Load(object sender, EventArgs e) { try { chkAllowUnattendedOperation.Checked = _DataMartDescription.AllowUnattendedOperation; rbModeProcess.Checked = _DataMartDescription.ProcessQueriesAndUploadAutomatically; rbModeNotify.Checked = _DataMartDescription.NotifyOfNewQueries; rbSemiAutomatic.Checked = _DataMartDescription.ProcessQueriesAndNotUpload; update_processing_mode_controls(); Guid dataMartId = DataMartDescription.DataMartId; dgvModels.DataSource = DnsServiceManager.GetModels(dataMartId, NetworkSetting).Where(m => m.ModelProcessorId != Guid.Empty).ToArray(); btnEdit.Enabled = dgvModels.DataSource != null && (dgvModels.DataSource as HubModel[]).Length > 0; } catch (Exception ex) { log.Error(ex.Message, ex); } }
private void SettingsForm_Load(object sender, EventArgs e) { try { chkAllowUnattendedOperation.Checked = _dataMartDescription.AllowUnattendedOperation; rbModeProcess.Checked = _dataMartDescription.ProcessQueriesAndUploadAutomatically; rbModeNotify.Checked = _dataMartDescription.NotifyOfNewQueries; rbSemiAutomatic.Checked = _dataMartDescription.ProcessQueriesAndNotUpload; update_processing_mode_controls(); Guid dataMartId = DataMartDescription.DataMartId; var models = DnsServiceManager.GetModels(NetworkSetting); if (models.ContainsKey(dataMartId)) { dgvModels.DataSource = (models[dataMartId] ?? Array.Empty <HubModel>()).Where(m => m.ModelProcessorId != Guid.Empty).ToArray(); } else { dgvModels.DataSource = Array.Empty <HubModel>(); } btnEdit.Enabled = dgvModels.DataSource != null && (dgvModels.DataSource as HubModel[]).Length > 0; _cache = new Lib.Caching.DataMartCacheManager(NetworkSetting.NetworkId, DataMartDescription.DataMartId); chkEncryptCacheItems.Checked = _dataMartDescription.EncryptCacheItems; chkExplicitCacheRemoval.Checked = _dataMartDescription.EnableExplictCacheRemoval; nmCacheRetentionPeriod.Value = _dataMartDescription.DaysToRetainCacheItems; chkEnableCache.Checked = _dataMartDescription.EnableResponseCaching; chkEnableCache_CheckedChanged(null, EventArgs.Empty); chkEnableCache.CheckedChanged += chkEnableCache_CheckedChanged; } catch (Exception ex) { log.Error(ex.Message, ex); } }