南阳电信API

T_AutoCall_Result.cs 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /** 版本信息模板在安装目录下,可自行修改。
  2. * T_AutoCall_Result.cs
  3. *
  4. * 功 能: N/A
  5. * 类 名: T_AutoCall_Result
  6. *
  7. * Ver 变更日期 负责人 变更内容
  8. * ───────────────────────────────────
  9. * V0.01 2022/2/23 09:12:42 N/A 初版
  10. *
  11. * Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
  12. *┌──────────────────────────────────┐
  13. *│ 此技术信息为本公司机密信息,未经本公司书面同意禁止向第三方披露. │
  14. *│ 版权所有:动软卓越(北京)科技有限公司              │
  15. *└──────────────────────────────────┘
  16. */
  17. using System;
  18. using System.Data;
  19. using System.Text;
  20. using System.Data.SqlClient;
  21. using CallCenterApi.DB;
  22. namespace CallCenterApi.DAL
  23. {
  24. /// <summary>
  25. /// 数据访问类:T_AutoCall_Result
  26. /// </summary>
  27. public partial class T_AutoCall_Result
  28. {
  29. public T_AutoCall_Result()
  30. {}
  31. #region BasicMethod
  32. /// <summary>
  33. /// 得到最大ID
  34. /// </summary>
  35. public int GetMaxId()
  36. {
  37. return DbHelperSQL.GetMaxID("F_Id", "T_AutoCall_Result");
  38. }
  39. /// <summary>
  40. /// 是否存在该记录
  41. /// </summary>
  42. public bool Exists(int Id)
  43. {
  44. StringBuilder strSql=new StringBuilder();
  45. strSql.Append("select count(1) from T_AutoCall_Result");
  46. strSql.Append(" where F_Id=@Id");
  47. SqlParameter[] parameters = {
  48. new SqlParameter("@Id", SqlDbType.Int,4)
  49. };
  50. parameters[0].Value = Id;
  51. return DbHelperSQL.Exists(strSql.ToString(),parameters);
  52. }
  53. /// <summary>
  54. /// 增加一条数据
  55. /// </summary>
  56. public int Add(CallCenterApi.Model.T_AutoCall_Result model)
  57. {
  58. StringBuilder strSql=new StringBuilder();
  59. strSql.Append("insert into T_AutoCall_Result(");
  60. strSql.Append("taskId,questionId,createTime,result)");
  61. strSql.Append(" values (");
  62. strSql.Append("@taskId,@questionId,@createTime,@result)");
  63. strSql.Append(";select @@IDENTITY");
  64. SqlParameter[] parameters = {
  65. new SqlParameter("@taskId", SqlDbType.Int,4),
  66. new SqlParameter("@questionId", SqlDbType.Int,4),
  67. new SqlParameter("@createTime", SqlDbType.DateTime),
  68. new SqlParameter("@result", SqlDbType.NVarChar,50)};
  69. parameters[0].Value = model.taskId;
  70. parameters[1].Value = model.questionId;
  71. parameters[2].Value = model.createTime;
  72. parameters[3].Value = model.result;
  73. object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
  74. if (obj == null)
  75. {
  76. return 0;
  77. }
  78. else
  79. {
  80. return Convert.ToInt32(obj);
  81. }
  82. }
  83. /// <summary>
  84. /// 更新一条数据
  85. /// </summary>
  86. public bool Update(CallCenterApi.Model.T_AutoCall_Result model)
  87. {
  88. StringBuilder strSql=new StringBuilder();
  89. strSql.Append("update T_AutoCall_Result set ");
  90. strSql.Append("taskId=@taskId,");
  91. strSql.Append("questionId=@questionId,");
  92. strSql.Append("createTime=@createTime,");
  93. strSql.Append("result=@result");
  94. strSql.Append(" where F_Id=@F_Id");
  95. SqlParameter[] parameters = {
  96. new SqlParameter("@taskId", SqlDbType.Int,4),
  97. new SqlParameter("@questionId", SqlDbType.Int,4),
  98. new SqlParameter("@createTime", SqlDbType.DateTime),
  99. new SqlParameter("@result", SqlDbType.NVarChar,50),
  100. new SqlParameter("@F_Id", SqlDbType.Int,4)};
  101. parameters[0].Value = model.taskId;
  102. parameters[1].Value = model.questionId;
  103. parameters[2].Value = model.createTime;
  104. parameters[3].Value = model.result;
  105. parameters[4].Value = model.F_Id;
  106. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  107. if (rows > 0)
  108. {
  109. return true;
  110. }
  111. else
  112. {
  113. return false;
  114. }
  115. }
  116. /// <summary>
  117. /// 删除一条数据
  118. /// </summary>
  119. public bool Delete(int Id)
  120. {
  121. StringBuilder strSql=new StringBuilder();
  122. strSql.Append("delete from T_AutoCall_Result ");
  123. strSql.Append(" where F_Id=@Id");
  124. SqlParameter[] parameters = {
  125. new SqlParameter("@Id", SqlDbType.Int,4)
  126. };
  127. parameters[0].Value = Id;
  128. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  129. if (rows > 0)
  130. {
  131. return true;
  132. }
  133. else
  134. {
  135. return false;
  136. }
  137. }
  138. /// <summary>
  139. /// 批量删除数据
  140. /// </summary>
  141. public bool DeleteList(string Idlist )
  142. {
  143. StringBuilder strSql=new StringBuilder();
  144. strSql.Append("delete from T_AutoCall_Result ");
  145. strSql.Append(" where F_Id in (" + Idlist + ") ");
  146. int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
  147. if (rows > 0)
  148. {
  149. return true;
  150. }
  151. else
  152. {
  153. return false;
  154. }
  155. }
  156. /// <summary>
  157. /// 得到一个对象实体
  158. /// </summary>
  159. public CallCenterApi.Model.T_AutoCall_Result GetModel(int Id)
  160. {
  161. StringBuilder strSql=new StringBuilder();
  162. strSql.Append("select top 1 Id,taskId,questionId,createTime,result from T_AutoCall_Result ");
  163. strSql.Append(" where F_Id=@Id");
  164. SqlParameter[] parameters = {
  165. new SqlParameter("@Id", SqlDbType.Int,4)
  166. };
  167. parameters[0].Value = Id;
  168. CallCenterApi.Model.T_AutoCall_Result model=new CallCenterApi.Model.T_AutoCall_Result();
  169. DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
  170. if(ds.Tables[0].Rows.Count>0)
  171. {
  172. return DataRowToModel(ds.Tables[0].Rows[0]);
  173. }
  174. else
  175. {
  176. return null;
  177. }
  178. }
  179. /// <summary>
  180. /// 得到一个对象实体
  181. /// </summary>
  182. public CallCenterApi.Model.T_AutoCall_Result DataRowToModel(DataRow row)
  183. {
  184. CallCenterApi.Model.T_AutoCall_Result model=new CallCenterApi.Model.T_AutoCall_Result();
  185. if (row != null)
  186. {
  187. if(row["F_Id"] !=null && row["F_Id"].ToString()!="")
  188. {
  189. model.F_Id=int.Parse(row["F_Id"].ToString());
  190. }
  191. if(row["taskId"]!=null && row["taskId"].ToString()!="")
  192. {
  193. model.taskId=int.Parse(row["taskId"].ToString());
  194. }
  195. if(row["questionId"]!=null && row["questionId"].ToString()!="")
  196. {
  197. model.questionId=int.Parse(row["questionId"].ToString());
  198. }
  199. if(row["createTime"]!=null && row["createTime"].ToString()!="")
  200. {
  201. model.createTime=DateTime.Parse(row["createTime"].ToString());
  202. }
  203. if(row["result"]!=null)
  204. {
  205. model.result=row["result"].ToString();
  206. }
  207. }
  208. return model;
  209. }
  210. /// <summary>
  211. /// 获得数据列表
  212. /// </summary>
  213. public DataSet GetList(string strWhere)
  214. {
  215. StringBuilder strSql=new StringBuilder();
  216. strSql.Append("select F_Id,taskId,questionId,createTime,result ");
  217. strSql.Append(" FROM T_AutoCall_Result ");
  218. if(strWhere.Trim()!="")
  219. {
  220. strSql.Append(" where "+strWhere);
  221. }
  222. return DbHelperSQL.Query(strSql.ToString());
  223. }
  224. //public DataSet exportList(string strWhere)
  225. //{
  226. // // 1:十分满意;2:满意;3:不满意
  227. // StringBuilder strSql = new StringBuilder();
  228. // strSql.Append(" select a.salesOffice,a.phone,b.createTime,");
  229. // strSql.Append(" case result when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '' end result ");
  230. // strSql.Append(" from T_AutoCall_PhoneRelate a left join T_AutoCall_Result b on a.F_id = b.F_Id");
  231. // if (strWhere.Trim() != "")
  232. // {
  233. // strSql.Append(" where " + strWhere);
  234. // }
  235. // strSql.Append(" order by b.F_Id desc");
  236. // return DbHelperSQL.Query(strSql.ToString());
  237. //}
  238. public DataSet exportList(string strWhere)
  239. {
  240. // "" "营业部","电话号码","用户分类","问题","结果",
  241. //select a.salesOffice, a.phone,b.F_Id,a.ordernature,d.qescontent,b.taskid,b.questionId,
  242. StringBuilder strSql = new StringBuilder();
  243. //最新的 strSql.Append("select * from ( select (Convert(varchar(100),a.F_Id)+'_'+Convert(varchar(100),d.F_Id)) Id, a.salesOffice, a.phone,a.ordernature,a.F_Id,d.qescontent,a.taskid,d.F_Id questionId, case b.result when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '' end result from T_AutoCall_PhoneRelate a left join T_AutoCall_Question d on d.taskid = a.taskid left join T_AutoCall_Result b on a.F_id = b.F_id and d.F_Id = b.questionId where a.callstate = 1 ) as t");
  244. strSql.Append("select * from ( select a.salesOffice, a.phone,a.ordernature,d.qescontent, case b.result when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '' end result, b.createTime ,a.taskId,d.F_Id from T_AutoCall_PhoneRelate a left join T_AutoCall_Question d on d.taskid = a.taskid left join T_AutoCall_Result b on a.F_id = b.F_id and d.F_Id = b.questionId where a.callstate = 1 ) as t");
  245. // 1:十分满意;2:满意;3:不满意
  246. //StringBuilder strSql = new StringBuilder();
  247. //strSql.Append(" select a.salesOffice, a.phone,a.ordernature,d.qescontent,");
  248. //strSql.Append(" case b.result when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '' end result, b.createTime from T_AutoCall_Result b");
  249. //strSql.Append(" left join T_AutoCall_PhoneRelate a on a.F_id = b.F_id");
  250. //strSql.Append(" left join T_AutoCall_Question d on d.F_Id = b.questionId");
  251. //StringBuilder tablenew = new StringBuilder();
  252. //tablenew.Append("(select phone,salesOffice, orderNature,question1, ");
  253. //tablenew.Append(" case when isconnect = 1 then case result1 when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '未评价' end else '' end result1,question2, ");
  254. //tablenew.Append(" case when isconnect = 1 then case result2 when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '未评价' end else '' end result2,question3");
  255. //tablenew.Append(" case when isconnect = 1 then case result3 when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '未评价' end else '' end result3");
  256. //tablenew.Append(" ,isconnect, calltime from T_AutomaticCall_Phone phone left join T_AutomaticCall_Task task on phone.taskid = task.taskid) as t");
  257. if (strWhere.Trim() != "")
  258. {
  259. strSql.Append(" where " + strWhere);
  260. }
  261. strSql.Append(" order by taskId desc");
  262. return DbHelperSQL.Query(strSql.ToString());
  263. }
  264. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  265. {
  266. StringBuilder strSql = new StringBuilder();
  267. strSql.Append("SELECT * FROM ( ");
  268. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  269. if (!string.IsNullOrEmpty(orderby.Trim()))
  270. {
  271. strSql.Append("order by a." + orderby);
  272. }
  273. else
  274. {
  275. strSql.Append("order by a.F_Id desc");
  276. }
  277. strSql.Append(")AS Row, a.salesOffice, a.phone,case b.result when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '' end result ,b.createTime from T_AutoCall_PhoneRelate a left join T_AutoCall_Result b on a.F_id =b.F_id");
  278. if (!string.IsNullOrEmpty(strWhere.Trim()))
  279. {
  280. strSql.Append(" WHERE " + strWhere);
  281. }
  282. strSql.Append(" ) TT");
  283. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  284. return DbHelperSQL.Query(strSql.ToString());
  285. }
  286. /// <summary>
  287. /// 获得前几行数据
  288. /// </summary>
  289. public DataSet GetList(int Top,string strWhere,string filedOrder)
  290. {
  291. StringBuilder strSql=new StringBuilder();
  292. strSql.Append("select ");
  293. if(Top>0)
  294. {
  295. strSql.Append(" top "+Top.ToString());
  296. }
  297. strSql.Append(" F_Id,taskId,questionId,createTime,result ");
  298. strSql.Append(" FROM T_AutoCall_Result ");
  299. if(strWhere.Trim()!="")
  300. {
  301. strSql.Append(" where "+strWhere);
  302. }
  303. strSql.Append(" order by " + filedOrder);
  304. return DbHelperSQL.Query(strSql.ToString());
  305. }
  306. /// <summary>
  307. /// 获取记录总数
  308. /// </summary>
  309. public int GetRecordCount(string strWhere)
  310. {
  311. StringBuilder strSql=new StringBuilder();
  312. strSql.Append("select count(1) FROM T_AutoCall_Result ");
  313. if(strWhere.Trim()!="")
  314. {
  315. strSql.Append(" where "+strWhere);
  316. }
  317. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  318. if (obj == null)
  319. {
  320. return 0;
  321. }
  322. else
  323. {
  324. return Convert.ToInt32(obj);
  325. }
  326. }
  327. /// <summary>
  328. /// 分页获取数据列表
  329. /// </summary>
  330. //public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  331. //{
  332. // StringBuilder strSql=new StringBuilder();
  333. // strSql.Append("SELECT * FROM ( ");
  334. // strSql.Append(" SELECT ROW_NUMBER() OVER (");
  335. // if (!string.IsNullOrEmpty(orderby.Trim()))
  336. // {
  337. // strSql.Append("order by T." + orderby );
  338. // }
  339. // else
  340. // {
  341. // strSql.Append("order by T.F_Id desc");
  342. // }
  343. // strSql.Append(")AS Row, T.* from T_AutoCall_Result T ");
  344. // if (!string.IsNullOrEmpty(strWhere.Trim()))
  345. // {
  346. // strSql.Append(" WHERE " + strWhere);
  347. // }
  348. // strSql.Append(" ) TT");
  349. // strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  350. // return DbHelperSQL.Query(strSql.ToString());
  351. //}
  352. /*
  353. /// <summary>
  354. /// 分页获取数据列表
  355. /// </summary>
  356. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  357. {
  358. SqlParameter[] parameters = {
  359. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  360. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  361. new SqlParameter("@PageSize", SqlDbType.Int),
  362. new SqlParameter("@PageIndex", SqlDbType.Int),
  363. new SqlParameter("@IsReCount", SqlDbType.Bit),
  364. new SqlParameter("@OrderType", SqlDbType.Bit),
  365. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  366. };
  367. parameters[0].Value = "T_AutoCall_Result";
  368. parameters[1].Value = "Id";
  369. parameters[2].Value = PageSize;
  370. parameters[3].Value = PageIndex;
  371. parameters[4].Value = 0;
  372. parameters[5].Value = 0;
  373. parameters[6].Value = strWhere;
  374. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  375. }*/
  376. #endregion BasicMethod
  377. #region ExtensionMethod
  378. #endregion ExtensionMethod
  379. }
  380. }