示例#1
0
        public List <CrcReportHistory> GetUsersRecentRuns(string username, int max)
        {
            string    sql = SqlPatternUsersRecentRuns();
            DataTable res = new DataTable();

            using (SqlConnection conn = new SqlConnection(GetReportServerConnectionString()))
            {
                SqlCommand comm = new SqlCommand(String.Format(sql, max), conn);

                comm.Parameters.Add("@UserName", SqlDbType.NVarChar, 520).Value = username;
                SqlDataAdapter adapt = new SqlDataAdapter(comm);
                adapt.Fill(res);
            }
            var histList = new List <CrcReportHistory>();

            foreach (DataRow rowLoop in res.Rows)
            {
                var h = new CrcReportHistory()
                {
                    ReportName  = CrcReportDefinition.ReportNameFromPath(rowLoop["ReportPath"].ToString()),
                    ReportPath  = rowLoop["ReportPath"].ToString(),
                    UserName    = rowLoop["UserName"].ToString(),
                    Parameters  = rowLoop["Parameters"].ToString(),
                    TimeStart   = (DateTime)rowLoop["TimeStart"],
                    RunDuration = (int)rowLoop["TimeDataRetrieval"],
                    RowCount    = (long)rowLoop["RowCount"]
                };
                histList.Add(h);
            }
            return(histList);
        }
        public List<CrcReportHistory> GetUsersRecentRuns(string username, int max)
        {
            string sql = SqlPatternUsersRecentRuns();
            DataTable res = new DataTable();
            using (SqlConnection conn = new SqlConnection(GetReportServerConnectionString()))
            {
                SqlCommand comm = new SqlCommand(String.Format(sql,max), conn);

                comm.Parameters.Add("@UserName", SqlDbType.NVarChar, 520).Value = username;
                SqlDataAdapter adapt = new SqlDataAdapter(comm);
                adapt.Fill(res);
            }
            var histList = new List<CrcReportHistory>();
            foreach (DataRow rowLoop in res.Rows)
            {
                var h = new CrcReportHistory()
                {
                    ReportName = CrcReportDefinition.ReportNameFromPath(rowLoop["ReportPath"].ToString()),
                    ReportPath = rowLoop["ReportPath"].ToString(),
                    UserName = rowLoop["UserName"].ToString(),
                    Parameters = rowLoop["Parameters"].ToString(),
                    TimeStart = (DateTime)rowLoop["TimeStart"],
                    RunDuration = (int)rowLoop["TimeDataRetrieval"],
                    RowCount = (long)rowLoop["RowCount"]
                };
                histList.Add(h);
            }
            return histList;
        }