예제 #1
0
        public void OutputResults(IQueryRunner runner)
        {
            try
            {
                runner.OutputMessage("Query Started");
                var start = DateTime.Now;

                var dq = runner.QueryText;
                runner.ExecuteQueryAsync(dq).ContinueWith((antecendant) =>
                {
                    var end        = DateTime.Now;
                    var durationMs = (end - start).TotalMilliseconds;
                    var res        = antecendant.Result;

                    // TODO write results to Excel
                    runner.Host.OutputStaticResult(res, runner.SelectedWorksheet);
                    //runner.ResultsTable = res;

                    runner.OutputMessage(
                        string.Format("Query Completed ({0} row{1} returned)", res.Rows.Count,
                                      res.Rows.Count == 1 ? "" : "s"), durationMs);
                    runner.ActivateResults();
                    runner.QueryCompleted();
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                runner.ActivateOutput();
                runner.OutputError(ex.Message);
            }
        }
        public void OutputResults(IQueryRunner runner)
        {
            try
            {
                runner.OutputMessage("Query Started");
                var start = DateTime.Now;

                var dq = runner.QueryText;
                runner.ExecuteQueryAsync(dq).ContinueWith((antecendant) =>
                    {
                        var end = DateTime.Now;
                        var durationMs = (end - start).TotalMilliseconds;
                        var res = antecendant.Result;

                        // TODO write results to Excel
                        runner.Host.OutputStaticResult(res, runner.SelectedWorksheet);
                        //runner.ResultsTable = res;

                        runner.OutputMessage(
                            string.Format("Query Completed ({0} row{1} returned)", res.Rows.Count,
                                          res.Rows.Count == 1 ? "" : "s"), durationMs);
                        runner.ActivateResults();
                        runner.QueryCompleted();
                    },TaskScheduler.FromCurrentSynchronizationContext());
            }
            catch (Exception ex)
            {
                runner.ActivateOutput();
                runner.OutputError(ex.Message);
            }
        }