private DataTable GetReportTableAllForExports(string sortField, bool isDesc, bool useUserFilter, bool includeHiddenFields)
        {
            SqlCommand command = GetExportsSqlCommand(ref sortField, ref isDesc, useUserFilter, includeHiddenFields);

            _report.LastSqlExecuted = DataUtils.GetCommandTextSql(command);
            _report.Collection.Save();
            BaseCollection.FixCommandParameters(command);

            DataTable table = new DataTable();

            using (SqlConnection connection = new SqlConnection(_loginUser.ConnectionString))
            {
                connection.Open();
                command.Connection = connection;
                using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                {
                    try
                    {
                        adapter.Fill(table);
                    }
                    catch (Exception ex)
                    {
                        ExceptionLogs.LogException(_loginUser, ex, "Report Data");
                        throw;
                    }
                }
                connection.Close();
            }
            return(table);
        }
Esempio n. 2
0
        private static DataTable GetSummaryData(LoginUser loginUser, SummaryReport summaryReport, bool useDefaultOrderBy, Report report = null)
        {
            SqlCommand command = new SqlCommand();

            SummaryReportSql.GetSummaryCommand(loginUser, command, summaryReport, false, false, useDefaultOrderBy);
            BaseCollection.FixCommandParameters(command);
            if (report != null)
            {
                report.LastSqlExecuted = DataUtils.GetCommandTextSql(command);
                report.Collection.Save();
            }

            DataTable table = new DataTable();

            using (SqlConnection connection = new SqlConnection(loginUser.ConnectionString))
            {
                connection.Open();
                command.Connection = connection;
                using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                {
                    try
                    {
                        adapter.Fill(table);
                    }
                    catch (Exception ex)
                    {
                        ExceptionLogs.LogException(loginUser, ex, "GetSummaryData");
                        throw;
                    }
                }
                connection.Close();
            }
            return(table);
        }
Esempio n. 3
0
        //For Exports
        private DataTable GetReportTablePageForExports(string sortField, bool isDesc, bool useUserFilter, bool includeHiddenFields)
        {
            SqlCommand command = GetExportsSqlCommand(ref sortField, ref isDesc, useUserFilter, includeHiddenFields);

            _report.LastSqlExecuted = DataUtils.GetCommandTextSql(command);
            _report.Collection.Save();
            BaseCollection.FixCommandParameters(command);

            DataTable table = new DataTable();

            using (SqlConnection connection = new SqlConnection(_loginUser.ConnectionString))
            {
                connection.Open();
                SqlTransaction transaction = connection.BeginTransaction(IsolationLevel.ReadUncommitted);

                command.Connection  = connection;
                command.Transaction = transaction;
                try
                {
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        adapter.Fill(table);
                    }
                    transaction.Commit();
                    table = DataUtils.DecodeDataTable(table);
                    table = DataUtils.StripHtmlDataTable(table);
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    ExceptionLogs.LogException(_loginUser, ex, "Report Data", DataUtils.GetCommandTextSql(command));
                    throw;
                }
                connection.Close();
            }

            //On exports it is always false
            //if (!includeHiddenFields)
            if (table.Columns.Contains("RowNum"))
            {
                table.Columns.Remove("RowNum");
            }

            AddReportTicketsViewTempTable(command);

            return(table);
        }