鄂尔多斯-招源科技

CallRecords.cs 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 DataRowToModelQC(DataRow row)
  39. {
  40. Model.CallResult model = new Model.CallResult();
  41. if (row != null)
  42. {
  43. model.Id = row["Id"] == DBNull.Value ? 0 : Convert.ToInt32(row["Id"]);
  44. model.TaskName = row["TaskName"] == DBNull.Value ? "" : row["TaskName"].ToString();
  45. model.TaskId = row["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(row["itemid"]);
  46. model.CallNumber = row["Callee"] == DBNull.Value ? "" : row["Callee"].ToString();
  47. model.Usercode = row["AgentId"] == DBNull.Value ? "" : row["AgentId"].ToString();
  48. model.StartDate = row["StartDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["StartDate"].ToString());
  49. model.GetInAgentDate = row["GetInAgentDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["GetInAgentDate"].ToString());
  50. model.EndDate = row["EndDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["EndDate"].ToString());
  51. model.RecordPath = row["RecordPath"] == DBNull.Value ? "" : row["RecordPath"].ToString();
  52. model.Username = row["Username"] == DBNull.Value ? "" : row["Username"].ToString();
  53. model.CallType = row["CallType"] == DBNull.Value ? 1 : Convert.ToInt32(row["CallType"].ToString());
  54. model.TalkTime = row["TalkTime"] == DBNull.Value ? 0 : Convert.ToInt32(row["TalkTime"]);
  55. model.QCState = row["QCState"] == DBNull.Value ? 0 : Convert.ToInt32(row["QCState"].ToString());
  56. model.QCScore = row["QCScore"] == DBNull.Value ? 0 : Convert.ToInt32(row["QCScore"].ToString());
  57. model.QCRemark = row["QCRemark"] == DBNull.Value ? "" : row["QCRemark"].ToString();
  58. model.QCUserId = row["QCUserId"] == DBNull.Value ? 0 : Convert.ToInt32(row["QCUserId"].ToString());
  59. model.QCUserCode = row["QCUserCode"] == DBNull.Value ? "" : row["QCUserCode"].ToString();
  60. model.QCUserName = row["QCUserName"] == DBNull.Value ? "" : row["QCUserName"].ToString();
  61. model.QCTime = row["QCTime"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["QCTime"].ToString());
  62. }
  63. return model;
  64. }
  65. public Model.CallResult GetModel(string callId)
  66. {
  67. string sql = "select itemid,RecordPath from CallResult where id=@callid";
  68. var ds = DbHelperSQL.Query(sql, new SqlParameter[] {
  69. new SqlParameter("@callid",callId)
  70. });
  71. var model = new Model.CallResult();
  72. if (ds.Tables.Count > 0)
  73. {
  74. if (ds.Tables[0].Rows.Count > 0)
  75. {
  76. model.TaskId = ds.Tables[0].Rows[0]["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["itemid"]);
  77. model.RecordPath = ds.Tables[0].Rows[0]["RecordPath"] == DBNull.Value ? "" : ds.Tables[0].Rows[0]["RecordPath"].ToString();
  78. }
  79. }
  80. return model;
  81. }
  82. public bool UpdateQC(Model.CallResult model)
  83. {
  84. StringBuilder strSql = new StringBuilder();
  85. strSql.Append("update CallResult set ");
  86. strSql.Append("QCState=@QCState,");
  87. strSql.Append("QCScore=@QCScore,");
  88. strSql.Append("QCRemark=@QCRemark,");
  89. strSql.Append("QCUserId=@QCUserId,");
  90. strSql.Append("QCUserCode=@QCUserCode,");
  91. strSql.Append("QCUserName=@QCUserName,");
  92. strSql.Append("QCTime=@QCTime ");
  93. strSql.Append(" where Id=@Id");
  94. SqlParameter[] parameters = {
  95. new SqlParameter("@QCState", SqlDbType.SmallInt,2),
  96. new SqlParameter("@QCScore", SqlDbType.Decimal,9),
  97. new SqlParameter("@QCRemark", SqlDbType.Text),
  98. new SqlParameter("@QCUserId", SqlDbType.Int),
  99. new SqlParameter("@QCUserName", SqlDbType.NVarChar,50),
  100. new SqlParameter("@QCTime", SqlDbType.DateTime),
  101. new SqlParameter("@Id", SqlDbType.Int)};
  102. parameters[0].Value = model.QCState;
  103. parameters[1].Value = model.QCScore;
  104. parameters[2].Value = model.QCRemark;
  105. parameters[3].Value = model.QCUserId;
  106. parameters[4].Value = model.QCUserName;
  107. parameters[5].Value = model.QCTime;
  108. parameters[9].Value = model.Id;
  109. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  110. if (rows > 0)
  111. {
  112. return true;
  113. }
  114. else
  115. {
  116. return false;
  117. }
  118. }
  119. #endregion BasicMethod
  120. #region ExtensionMethod
  121. #endregion ExtensionMethod
  122. }
  123. }