新野县12345_后端

CallRecords.cs 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using CallCenterApi.DB;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace CallCenterApi.DAL
  9. {
  10. public class CallRecords
  11. {
  12. public CallRecords()
  13. { }
  14. #region BasicMethod
  15. /// <summary>
  16. /// 得到一个对象实体
  17. /// </summary>
  18. public Model.CallResult DataRowToModel(DataRow row)
  19. {
  20. Model.CallResult model = new Model.CallResult();
  21. if (row != null)
  22. {
  23. model.Id = row["Id"] == DBNull.Value ? 0 : Convert.ToInt32(row["Id"]);
  24. model.TaskId = row["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(row["itemid"]);
  25. model.CallNumber = row["Callee"] == DBNull.Value ? "" : row["Callee"].ToString();
  26. model.Usercode = row["agentid"] == DBNull.Value ? "" : row["agentid"].ToString();
  27. model.StartDate = row["StartDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["StartDate"].ToString());
  28. model.GetInAgentDate = row["GetInAgentDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["GetInAgentDate"].ToString());
  29. model.EndDate = row["EndDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["EndDate"].ToString());
  30. model.RecordPath = row["RecordPath"] == DBNull.Value ? "" : row["RecordPath"].ToString();
  31. model.Username = row["Username"] == DBNull.Value ? "" : row["Username"].ToString();
  32. model.State = row["calltype"] == DBNull.Value ? "" : row["calltype"].ToString();
  33. model.TalkTime = row["talktime"] == DBNull.Value ? 0 : Convert.ToInt32(row["talktime"]);
  34. }
  35. return model;
  36. }
  37. public Model.CallResult GetModel(string callId)
  38. {
  39. string sql = "select itemid,RecordPath from CallResult where id=@callid";
  40. var ds = DbHelperSQL.Query(sql, new SqlParameter[] {
  41. new SqlParameter("@callid",callId)
  42. });
  43. var model = new Model.CallResult();
  44. if (ds.Tables.Count > 0)
  45. {
  46. if (ds.Tables[0].Rows.Count > 0)
  47. {
  48. model.TaskId = ds.Tables[0].Rows[0]["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["itemid"]);
  49. model.RecordPath = ds.Tables[0].Rows[0]["RecordPath"] == DBNull.Value ? "" : ds.Tables[0].Rows[0]["RecordPath"].ToString();
  50. }
  51. }
  52. return model;
  53. }
  54. #endregion BasicMethod
  55. #region ExtensionMethod
  56. #endregion ExtensionMethod
  57. }
  58. }