protected override bool OnClick(ClickEvent e) { OperationStarted?.Invoke(); Action?.Invoke(); OperationEnded?.Invoke(); return(true); }
private async Task <DataModel> GetModelFromFileAsync(string text) { try { OperationStarted?.Invoke("Reading model data...", new EventArgs()); var model = DataModel.FromJsonFile(text); return(await Task.FromResult(model)); } catch (Exception exc) { throw new Exception($"Error reading model data: {exc.Message}", exc); } finally { OperationComplete?.Invoke(this, new EventArgs()); } }
private async Task <DataModel> GetAssemblyModelAsync(string text) { try { // help from https://docs.microsoft.com/en-us/dotnet/framework/deployment/best-practices-for-assembly-loading OperationStarted?.Invoke("Analyzing assembly...", new EventArgs()); var assembly = Assembly.LoadFrom(text); var result = new AssemblyModelBuilder().GetDataModel(assembly); return(await Task.FromResult(result)); } catch (Exception exc) { throw new Exception($"Error analyzing assembly: {exc.Message}"); } finally { OperationComplete?.Invoke(this, new EventArgs()); } }
private async Task <DataModel> GetConnectionModelAsync(string text) { try { OperationStarted?.Invoke("Analyzing database...", new EventArgs()); using (var cn = GetConnection(text)) { return(await new SqlServerModelBuilder().GetDataModelAsync(cn)); } } catch (Exception exc) { throw new Exception($"Error analyzing database: {exc.Message}", exc); } finally { OperationComplete?.Invoke(this, new EventArgs()); } }
private async Task ExecuteInner(EventArgs e, string statusBarMessage, bool commit, string successMessage = null) { try { OperationStarted?.Invoke(statusBarMessage, e); using (var cn = GetConnection.Invoke(tbDest.Text)) { await SqlDialect.ExecuteAsync(cn, tbScriptOutput.Text, commit); if (commit) { ScriptExecuted?.Invoke(this, new EventArgs()); if (_manualEdits) { MessageBox.Show("Changes applied successfully.", "Script Executed", MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (!string.IsNullOrEmpty(successMessage)) { MessageBox.Show(successMessage, "SQL Test", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!_manualEdits && commit) { await GenerateScriptAsync(); } } } catch (Exception exc) { if (MessageBox.Show(exc.Message + "\r\n\r\nClick OK to create test case.", "Script Error", MessageBoxButtons.OKCancel) == DialogResult.OK) { frmSaveTestCase.PromptSaveZipFile(false, exc.Message, _sourceModel, _destModel, _diff); } } finally { OperationComplete?.Invoke(this, new EventArgs()); } }
public void PerformAsyncOperation <T, TResult>( AsyncOperationType type, Func <T, TResult> func, T param, Action <Exception, TResult> completeAction) { OperationStarted?.Invoke(this, new PriceEventArgs <AsyncOperationType>(type)); var task = new Task <TResult>(() => func(param)); if (taskScheduler == null) { task.ContinueWith(t => ProcessTaskResult(t, completeAction, type)); } else { task.ContinueWith(t => ProcessTaskResult(t, completeAction, type), taskScheduler); } task.Start(TaskScheduler.Default); }
protected void SetProcessing(bool processing) { bool oldProcessing = this.processing; this.processing = processing; SetEnabled(); if (processing) { if (!oldProcessing) { OperationStarted?.Invoke(this, null); } } else { if (oldProcessing) { OperationCompleted?.Invoke(this, null); } } }
public void OnOperationStarted(IPackageManager sender, string operation) { OperationStarted?.Invoke(this, new OutputEventArgs(operation)); }
protected void TriggerOperationStarted() => OperationStarted?.Invoke();
protected virtual void OnOperationStarted(ProgressBackgroundEventArgs e) { OperationStarted?.Invoke(this, e); }
/// <summary> Invokes the event OperationStarted. </summary> /// <param name="message"> A message describing the operation. </param> public static void OnOperationStarted(string message) { OperationStarted?.Invoke(message); }
private void LoadObjects(DbObjectSearch search = null) { try { pbLoading.Visible = true; OperationStarted?.Invoke(this, "Loading objects..."); tvwObjects.BeginUpdate(); tvwObjects.Nodes.Clear(); var schemas = _objects .Where(obj => !string.IsNullOrEmpty(obj.Schema) && (search?.IsIncluded(obj) ?? true)) .GroupBy(obj => obj.Schema).OrderBy(grp => grp.Key); FolderNode folderNode = null; foreach (var schemaGrp in schemas) { var schemaNode = new SchemaNode(schemaGrp.Key, schemaGrp.Count()); tvwObjects.Nodes.Add(schemaNode); var tables = schemaGrp.OfType <Table>().OrderBy(obj => obj.Name); if (tables.Any()) { folderNode = new FolderNode("Tables", tables.Count()); schemaNode.Nodes.Add(folderNode); foreach (var table in tables) { var tableNode = new TableNode(table); if (_aliasManager.ContainsTable(table.ToString(), out string alias)) { tableNode.Alias = alias; } folderNode.Nodes.Add(tableNode); var foreignKeys = table.GetParentForeignKeys(_objects); tableNode.Columns.AddRange(table.Columns.Select(col => { var node = new ColumnNode(col, foreignKeys, table.IdentityColumn); if (IsUniqueMultiColumn(table, col)) { node.NodeFont = new Font(tvwObjects.Font, FontStyle.Bold); } return(node); })); var childFKs = table.GetChildForeignKeys(_objects); if (childFKs.Any()) { var childFolderNode = new TreeNode($"Child Tables ({childFKs.Count()})") { ImageKey = "join", SelectedImageKey = "join" }; tableNode.Nodes.Add(childFolderNode); foreach (var childFK in childFKs) { var fkNode = new TableNode(childFK); childFolderNode.Nodes.Add(fkNode); } } } folderNode.Expand(); } var views = schemaGrp.OfType <SqlSchema.Library.Models.View>().OrderBy(obj => obj.Name); if (views.Any()) { folderNode = new FolderNode("Views", views.Count()); schemaNode.Nodes.Add(folderNode); foreach (var view in views) { var viewNode = new ViewNode(view); folderNode.Nodes.Add(viewNode); } } var functions = schemaGrp.OfType <TableFunction>().OrderBy(obj => obj.Name); if (functions.Any()) { folderNode = new FolderNode("Functions", functions.Count()); schemaNode.Nodes.Add(folderNode); foreach (var func in functions) { var functionNode = new FunctionNode(func); folderNode.Nodes.Add(functionNode); } } var procs = schemaGrp.OfType <Procedure>().OrderBy(obj => obj.Name); if (procs.Any()) { folderNode = new FolderNode("Procedures", procs.Count()); schemaNode.Nodes.Add(folderNode); foreach (var proc in procs) { var procNode = new ProcedureNode(proc); folderNode.Nodes.Add(procNode); } } schemaNode.Expand(); } } finally { tvwObjects.EndUpdate(); pbLoading.Visible = false; OperationEnded?.Invoke(this, new EventArgs()); } }
void ICondaEnvironmentManagerUI.OnOperationStarted(ICondaEnvironmentManager mgr, string operation) { OperationStarted?.Invoke(this, new OutputEventArgs(operation)); }
public void OnOperationStarted(string operation) { OperationStarted?.Invoke(this, new OutputEventArgs(operation)); }
public void DoWork(Dispatcher mainThreadDispatcher) { mainThreadDispatcher.InvokeAsync(() => OperationStarted?.Invoke(this, new OperationEventArgs())); DoWorkInternal(); mainThreadDispatcher.InvokeAsync(() => OperationFinished?.Invoke(this, new OperationEventArgs())); }