/// <summary> /// The prepare progress. /// </summary> /// <param name="progress">The progress.</param> /// <param name="groups">The groups.</param> private void PrepareProgress(ProgressItem progress, GroupDefinition[] groups) { if (progress != null) { if (groups.Length > 0) { progress.SetPromisedChildCount(groups.Length); } else { progress.SetProgress(100); } } }
private Dictionary <TemplateNodeQueryInfo, DataTable> ReadHistTable( ConnectionGroupInfo connectionGroup, ConcreteTemplateNodeDefinition concreteTemplateNode ) { Dictionary <TemplateNodeQueryInfo, DataTable> histTable = new Dictionary <TemplateNodeQueryInfo, DataTable>(); TemplateNodeInfo templateNodeInfo = concreteTemplateNode.TemplateNode; ProgressItem progress = new ProgressItem(); using (SqlProcessor sqlProcessor = MsSqlAuditor.GetNewSqlProcessor(new CancellationToken())) { progress.SetPromisedChildCount(1); MultyQueryResultInfo resultQuery = sqlProcessor.ExecuteMultyQuery( connectionGroup, templateNodeInfo.Queries, progress.GetChild(), Program.Model.Settings.SystemSettings.MaximumDBRequestsThreadCount, true ); if (resultQuery != null) { if (resultQuery.List != null) { if (resultQuery.List.Count != 0) { long requestId = this.Storage.MetaResultTable.GetMaxRequestId() + 1L; DateTime timestamp = DateTime.Now; histTable = PrepareHistoryData(resultQuery); this.Storage.SaveMeta( templateNodeInfo, resultQuery, requestId, timestamp ); } } } } return(histTable); }
private void RefreshQueries( TreeTask treeTask, ConcreteTemplateNodeDefinition nodeDefinition, ProgressItem progress ) { log.DebugFormat("taskInfo.Connection:'{0}';nodeDefinition:'{1}'", treeTask.Info.Connection.ConnectionGroup.ToString() ?? "?", nodeDefinition.TemplateNode.Name ?? "?" ); ErrorLog errorLog = new ErrorLog(); MsSqlAuditorModel model = this._treeControl._model; DateTime startTime = DateTime.Now; Stopwatch durationWatch = new Stopwatch(); durationWatch.Start(); using (SqlProcessor sqlProcessor = model.GetNewSqlProcessor(treeTask.CancellationSource.Token)) { if (!treeTask.Info.Connection.IsLiveConnection) { sqlProcessor.SetSkipMSSQLQueries(); } progress.SetPromisedChildCount(1); TemplateNodeInfo templateNode = nodeDefinition.TemplateNode; ConnectionGroupInfo group = nodeDefinition.Connection; MultyQueryResultInfo result; if (nodeDefinition.Group.Instance != null) { result = sqlProcessor.ExecuteMultyQuery( nodeDefinition.Group, templateNode.Queries, progress.GetChild() ); } else { result = sqlProcessor.ExecuteMultyQuery( group, templateNode.Queries, progress.GetChild(), model.Settings.SystemSettings.MaximumDBRequestsThreadCount ); } if (group != null && group.Connections != null) { group.Connections.ForEach( x => x.ConnectionGroup = x.ConnectionGroup ?? group ); } errorLog.AppendErrorLog(result); IStorageManager storage = model.GetVaultProcessor(group); storage.SaveRequestedData(templateNode, result); durationWatch.Stop(); DateTime duration = new DateTime(durationWatch.Elapsed.Ticks); storage.CurrentStorage.UpdateTreeNodeTimings( templateNode, startTime, duration ); foreach (GroupDefinition database in result.ExtractDatabases()) { ConcreteTemplateNodeDefinition nodeDef = new ConcreteTemplateNodeDefinition( templateNode, database, group ); this._treeControl.VisualizeData(nodeDef); } } }