1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
public ActionResult Index()
{
var queries = new query();
var items = GetIndex();
var items2 = GetAppli();
queries.Query1 = (from i in items
select new Suivi
{ CD_CR = i.Field<String>("CD_CR"), LB_CR = i.Field<String>("LB_CR"), CD_APPLI = i.Field<String>("CD_APPLI"), LB_APPLI = i.Field<String>("LB_APPLI"), STATUT = i.Field<String>("STATUT") }).ToList();
queries.Query2 = (from i in items2
select new Suivi {LB_APPLI = i.Field<String>("LB_APPLI")}).ToList();
return View(queries);
}
private List<DataRow> GetIndex()
{
List<DataRow> liste = null;
string query = "select CD_CR, LB_CR, CD_APPLI, LB_APPLI,"
+ "case when (CD_APPLI = 'ESPAS' and exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT = 'KO')) then 'KO' when (CD_APPLI = 'ESPAS' and not exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT in('KO','NEXEC'))) then 'OK' when CD_APPLI = 'ESPAS' and (not exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT ='KO')) and (exists (select 1 from dbo.LOGS l where l.PERIODE =(select MAX(PERIODE) from dbo.LOGS) and l.STATUT ='NEXEC')) then 'EN COURS' else NULL end STATUT from dbo.REF_CR, dbo.REF_APPLI order by CD_CR,ORDRE_APPLI";
string connString = "Data Source=.;Initial Catalog=SUIVI_DWH;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand objCommand = new SqlCommand(query, conn))
{
objCommand.CommandType = CommandType.Text;
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(objCommand);
conn.Open();
adp.Fill(dt);
if (dt != null)
{
liste = dt.AsEnumerable().ToList();
}
}
}
return liste;
}
private List<DataRow> GetAppli()
{
List<DataRow> liste = null;
string query = "select distinct LB_APPLI, ORDRE_APPLI from dbo.REF_APPLI order by ORDRE_APPLI";
string connString = "Data Source=.;Initial Catalog=SUIVI_DWH;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlCommand objCommand = new SqlCommand(query, conn))
{
objCommand.CommandType = CommandType.Text;
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(objCommand);
conn.Open();
adp.Fill(dt);
if (dt != null)
{
liste = dt.AsEnumerable().ToList();
}
}
}
return liste;
} |
Partager