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
|
public static List<Call> GetAll(CallStatus? status)
{
Resp resp = HttpContext.Current.Session["resp"] as Resp;
List<Call> calls = new List<Call>();
Logger.Instance.LogMessage("Call", Logger.ErrorLevel.Verbose, "Chargement de tous les appels");
using (OleDbConnection cnx = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyHFSQL"].ConnectionString))
{
cnx.Open();
using (OleDbCommand cmd = cnx.CreateCommand())
{
cmd.CommandText = "select APPEL_Id, APPEL_Date, APPEL_Heure, APPEL_Duree, APPEL_TiersCode, APPEL_ContactId, APPEL_ContactNom, APPEL_ContactTel, APPEL_Createur, APPEL_Resume, APPEL_NoContrat, APPEL_Statut from FIC_APPELS where APPEL_Createur = ?";
cmd.Parameters.AddWithValue("@resp", resp.ID);
if (status != null)
{
cmd.CommandText += " and APPEL_Statut = ?";
cmd.Parameters.AddWithValue("@status", (int)status);
}
cmd.CommandType = CommandType.Text;
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
calls.Add(new Call() { ID = dr.GetInt32(0), Date = dr.GetDateTime(1), Time = dr.GetTimeSpan(2), Duration = (decimal)dr.GetInt32(3) / 3600, CustomerCode = dr.GetString(4), ContactCode = dr.GetInt32(5), ContactName = dr.GetString(6), Phone = dr.GetString(7), RespCode = dr.GetString(8), Summary = Rtf.RtfToText(dr.GetString(9)), ContractCode = dr.GetString(10), Status = (CallStatus)dr.GetInt32(11) });
}
dr.Close();
cmd.Dispose();
}
cnx.Close();
cnx.Dispose();
}
return calls;
} |