示例#1
0
        public ActionResult ReportQueueRefresh(JQueryDataTableParamModel param)
        {
            //WebLog.LogClass.WriteToLog("RefreshTable");
            CardPerso.Administration.ServiceClass sc = new CardPerso.Administration.ServiceClass();
            var UserId = sc.UserGuid(User.Identity.Name);

            DataSet ds = new DataSet();

            using (SqlConnection conn =
                       new SqlConnection(ConfigurationManager.ConnectionStrings["ConString"].ConnectionString))
            {
                conn.Open();
                using (SqlCommand comm = conn.CreateCommand())
                {
                    comm.CommandText = $"SELECT UserId, ReportType, ReportStatus, ReportDate, id, ReportParameters, (select count(*) from ReportQuery where id<r.id and ReportStatus=1) as waitcnt FROM ReportQuery r WHERE UserId = '{UserId}' ORDER BY ReportDate DESC";
                    SqlDataAdapter da = new SqlDataAdapter(comm);
                    da.Fill(ds);
                }
                conn.Close();
            }

            IList <Report> reports = new List <Report>();

            foreach (DataRow r in ds.Tables[0].Rows)
            {
                reports.Add(new Report()
                {
                    Date = $"{r["ReportDate"]:dd.MM.yyyy HH:mm:ss}", Status = Convert.ToInt32(r["ReportStatus"]),
                    Type = Convert.ToInt32(r["ReportType"]), Parameters = Convert.ToString(r["ReportParameters"]),
                    id   = Convert.ToInt32(r["id"]), WaitCnt = Convert.ToInt32(r["WaitCnt"])
                });