鄂尔多斯-招源科技

CallRecords.cs 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.TaskName = row["TaskName"] == DBNull.Value ? "" : row["TaskName"].ToString();
  26. model.CallNumber = row["Callee"] == DBNull.Value ? "" : row["Callee"].ToString();
  27. model.Usercode = row["AgentId"] == DBNull.Value ? "" : row["AgentId"].ToString();
  28. model.StartDate = row["StartDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["StartDate"].ToString());
  29. model.GetInAgentDate = row["GetInAgentDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["GetInAgentDate"].ToString());
  30. model.EndDate = row["EndDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["EndDate"].ToString());
  31. model.RecordPath = row["RecordPath"] == DBNull.Value ? "" : row["RecordPath"].ToString();
  32. model.Username = row["Username"] == DBNull.Value ? "" : row["Username"].ToString();
  33. model.CallType = row["CallType"] == DBNull.Value ? 1 : Convert.ToInt32(row["CallType"].ToString());
  34. model.TalkTime = row["TalkTime"] == DBNull.Value ? 0 : Convert.ToInt32(row["TalkTime"]);
  35. }
  36. return model;
  37. }
  38. public Model.CallResult GetModel(string callId)
  39. {
  40. string sql = "select itemid,RecordPath from CallResult where id=@callid";
  41. var ds = DbHelperSQL.Query(sql, new SqlParameter[] {
  42. new SqlParameter("@callid",callId)
  43. });
  44. var model = new Model.CallResult();
  45. if (ds.Tables.Count > 0)
  46. {
  47. if (ds.Tables[0].Rows.Count > 0)
  48. {
  49. model.TaskId = ds.Tables[0].Rows[0]["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["itemid"]);
  50. model.RecordPath = ds.Tables[0].Rows[0]["RecordPath"] == DBNull.Value ? "" : ds.Tables[0].Rows[0]["RecordPath"].ToString();
  51. }
  52. }
  53. return model;
  54. }
  55. #endregion BasicMethod
  56. #region ExtensionMethod
  57. #endregion ExtensionMethod
  58. }
  59. }