Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="queries"></param>
        /// <param name="worksheet"></param>
        private void ExecuteQuery(List<Query> queries, bool worksheet)
        {
            if (queries.Count == 0)
                return;
            if (_user == null)
                return;

            _addressQueries = new List<string>();
            bool clearFormat = false;
            List<Report> reportList = new List<Report>();

            int profileCounter = 0;
            int cellOffset = 0;
            foreach (Query query in queries)
            {
                _reportManager = new ReportManager();
                _executionProgressWindow = new ExecutionProgress(_reportManager);
                _executionProgressWindow.Show();

                _currentReport = _reportManager.GetReport(query, _user.AuthToken, profileCounter);
                if (!_currentReport.ValidateResult())
                    continue;

                reportList.Add(_currentReport);

                if (profileCounter == 0 && _currentReport != null && _currentReport.ValidateResult())
                {
                    if (ActiveCellHasQueryResult || worksheet)
                    {

                        clearFormat = Excel2007Addin.Settings.Default.CellFormatting == (int)WPFUIv2.CellFormattingEnum.never ||
                                        (Excel2007Addin.Settings.Default.CellFormatting == (int)WPFUIv2.CellFormattingEnum.ask &&
                                        MessageBox.Show("Do you want to erase the format of your excel query columns?",
                                                      "Document format", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
                        ClearPreviousQueryResult(clearFormat, worksheet, query);
                    }
                }

                if (!worksheet)
                {
                    // If a query is executed containing more than one profile the active cell cursor must be
                    // moved to prevent clearing the prior report in Excel.
                    PresentResult(query, _currentReport, profileCounter, cellOffset);

                    cellOffset += _currentReport.Data.GetLength(1) + 1; // +1 for space

                    if (query.Ids.Count > profileCounter)
                        profileCounter++;
                }
            }

            int i = 0;
            if (_user != null && worksheet)
            {
                foreach (Query query in queries)
                {
                    PresentResultUpdate(query, reportList[i], profileCounter);
                    i++;
                }
            }
        }
 public ExecutionProgress(ReportManager repMan)
 {
     InitializeComponent();
     repMan.executionProgress += new ReportManager.ExecutionProgress(repMan_executionProgress);
     this.Show();
 }