| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using CallCenterApi.DB;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- namespace CallCenterApi.DAL
- {
- public class CallRecords
- {
- public CallRecords()
- { }
- #region BasicMethod
- /// <summary>
- /// 得到一个对象实体
- /// </summary>
- public Model.CallResult DataRowToModel(DataRow row)
- {
- Model.CallResult model = new Model.CallResult();
- if (row != null)
- {
- model.Id = row["Id"] == DBNull.Value ? 0 : Convert.ToInt32(row["Id"]);
- model.TaskId = row["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(row["itemid"]);
- model.CallNumber = row["Callee"] == DBNull.Value ? "" : row["Callee"].ToString();
- model.Usercode = row["agentid"] == DBNull.Value ? "" : row["agentid"].ToString();
- model.StartDate = row["StartDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["StartDate"].ToString());
- model.GetInAgentDate = row["GetInAgentDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["GetInAgentDate"].ToString());
- model.EndDate = row["EndDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(row["EndDate"].ToString());
- model.RecordPath = row["RecordPath"] == DBNull.Value ? "" : row["RecordPath"].ToString();
- model.Username = row["Username"] == DBNull.Value ? "" : row["Username"].ToString();
- model.State = row["calltype"] == DBNull.Value ? "" : row["calltype"].ToString();
- model.TalkTime = row["talktime"] == DBNull.Value ? 0 : Convert.ToInt32(row["talktime"]);
- }
- return model;
- }
- public Model.CallResult GetModel(string callId)
- {
- string sql = "select itemid,RecordPath from CallResult where id=@callid";
- var ds = DbHelperSQL.Query(sql, new SqlParameter[] {
- new SqlParameter("@callid",callId)
- });
- var model = new Model.CallResult();
- if (ds.Tables.Count > 0)
- {
- if (ds.Tables[0].Rows.Count > 0)
- {
- model.TaskId = ds.Tables[0].Rows[0]["itemid"] == DBNull.Value ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["itemid"]);
- model.RecordPath = ds.Tables[0].Rows[0]["RecordPath"] == DBNull.Value ? "" : ds.Tables[0].Rows[0]["RecordPath"].ToString();
- }
- }
- return model;
- }
- #endregion BasicMethod
- #region ExtensionMethod
- #endregion ExtensionMethod
- }
- }
|