No Description

T_AutomaticCall_Phone.cs 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. /** 版本信息模板在安装目录下,可自行修改。
  2. * T_AutomaticCall_Phone.cs
  3. *
  4. * 功 能: N/A
  5. * 类 名: T_AutomaticCall_Phone
  6. *
  7. * Ver 变更日期 负责人 变更内容
  8. * ───────────────────────────────────
  9. * V0.01 2022/3/2 09:32:28 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_AutomaticCall_Phone
  26. /// </summary>
  27. public partial class T_AutomaticCall_Phone
  28. {
  29. public T_AutomaticCall_Phone()
  30. {}
  31. #region BasicMethod
  32. /// <summary>
  33. /// 增加一条数据
  34. /// </summary>
  35. public int Add(CallCenterApi.Model.T_AutomaticCall_Phone model)
  36. {
  37. StringBuilder strSql=new StringBuilder();
  38. strSql.Append("insert into T_AutomaticCall_Phone(");
  39. strSql.Append("taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime)");
  40. strSql.Append(" values (");
  41. strSql.Append("@taskId,@fix,@phone,@createTime,@createBy,@callState,@salesOffice,@broadbandAccount,@accessTime,@channel,@service,@package,@fusion,@phoneState,@orderNature,@address,@result1,@result2,@result3,@isconnect,@calltime)");
  42. strSql.Append(";select @@IDENTITY");
  43. SqlParameter[] parameters = {
  44. new SqlParameter("@taskId", SqlDbType.Int,4),
  45. new SqlParameter("@fix", SqlDbType.NVarChar,10),
  46. new SqlParameter("@phone", SqlDbType.NVarChar,50),
  47. new SqlParameter("@createTime", SqlDbType.DateTime),
  48. new SqlParameter("@createBy", SqlDbType.NVarChar,50),
  49. new SqlParameter("@callState", SqlDbType.Int,4),
  50. new SqlParameter("@salesOffice", SqlDbType.NVarChar,100),
  51. new SqlParameter("@broadbandAccount", SqlDbType.NVarChar,100),
  52. new SqlParameter("@accessTime", SqlDbType.NVarChar,50),
  53. new SqlParameter("@channel", SqlDbType.NVarChar,100),
  54. new SqlParameter("@service", SqlDbType.NVarChar,100),
  55. new SqlParameter("@package", SqlDbType.NVarChar,200),
  56. new SqlParameter("@fusion", SqlDbType.NVarChar,50),
  57. new SqlParameter("@phoneState", SqlDbType.NVarChar,50),
  58. new SqlParameter("@orderNature", SqlDbType.NVarChar,50),
  59. new SqlParameter("@address", SqlDbType.NVarChar,500),
  60. new SqlParameter("@result1", SqlDbType.NVarChar,50),
  61. new SqlParameter("@result2", SqlDbType.NVarChar,50),
  62. new SqlParameter("@result3", SqlDbType.NVarChar,50),
  63. new SqlParameter("@isconnect", SqlDbType.Int,4),
  64. new SqlParameter("@calltime", SqlDbType.DateTime)};
  65. parameters[0].Value = model.taskId;
  66. parameters[1].Value = model.fix;
  67. parameters[2].Value = model.phone;
  68. parameters[3].Value = model.createTime;
  69. parameters[4].Value = model.createBy;
  70. parameters[5].Value = model.callState;
  71. parameters[6].Value = model.salesOffice;
  72. parameters[7].Value = model.broadbandAccount;
  73. parameters[8].Value = model.accessTime;
  74. parameters[9].Value = model.channel;
  75. parameters[10].Value = model.service;
  76. parameters[11].Value = model.package;
  77. parameters[12].Value = model.fusion;
  78. parameters[13].Value = model.phoneState;
  79. parameters[14].Value = model.orderNature;
  80. parameters[15].Value = model.address;
  81. parameters[16].Value = model.result1;
  82. parameters[17].Value = model.result2;
  83. parameters[18].Value = model.result3;
  84. parameters[19].Value = model.isconnect;
  85. parameters[20].Value = model.calltime;
  86. object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
  87. if (obj == null)
  88. {
  89. return 0;
  90. }
  91. else
  92. {
  93. return Convert.ToInt32(obj);
  94. }
  95. }
  96. /// <summary>
  97. /// 更新一条数据
  98. /// </summary>
  99. public bool Update(CallCenterApi.Model.T_AutomaticCall_Phone model)
  100. {
  101. StringBuilder strSql=new StringBuilder();
  102. strSql.Append("update T_AutomaticCall_Phone set ");
  103. strSql.Append("taskId=@taskId,");
  104. strSql.Append("fix=@fix,");
  105. strSql.Append("phone=@phone,");
  106. strSql.Append("createTime=@createTime,");
  107. strSql.Append("createBy=@createBy,");
  108. strSql.Append("callState=@callState,");
  109. strSql.Append("salesOffice=@salesOffice,");
  110. strSql.Append("broadbandAccount=@broadbandAccount,");
  111. strSql.Append("accessTime=@accessTime,");
  112. strSql.Append("channel=@channel,");
  113. strSql.Append("service=@service,");
  114. strSql.Append("package=@package,");
  115. strSql.Append("fusion=@fusion,");
  116. strSql.Append("phoneState=@phoneState,");
  117. strSql.Append("orderNature=@orderNature,");
  118. strSql.Append("address=@address,");
  119. strSql.Append("result1=@result1,");
  120. strSql.Append("result2=@result2,");
  121. strSql.Append("result3=@result3,");
  122. strSql.Append("isconnect=@isconnect,");
  123. strSql.Append("calltime=@calltime");
  124. strSql.Append(" where F_Id=@F_Id");
  125. SqlParameter[] parameters = {
  126. new SqlParameter("@taskId", SqlDbType.Int,4),
  127. new SqlParameter("@fix", SqlDbType.NVarChar,10),
  128. new SqlParameter("@phone", SqlDbType.NVarChar,50),
  129. new SqlParameter("@createTime", SqlDbType.DateTime),
  130. new SqlParameter("@createBy", SqlDbType.NVarChar,50),
  131. new SqlParameter("@callState", SqlDbType.Int,4),
  132. new SqlParameter("@salesOffice", SqlDbType.NVarChar,100),
  133. new SqlParameter("@broadbandAccount", SqlDbType.NVarChar,100),
  134. new SqlParameter("@accessTime",SqlDbType.NVarChar,50),
  135. new SqlParameter("@channel", SqlDbType.NVarChar,100),
  136. new SqlParameter("@service", SqlDbType.NVarChar,100),
  137. new SqlParameter("@package", SqlDbType.NVarChar,200),
  138. new SqlParameter("@fusion", SqlDbType.NVarChar,50),
  139. new SqlParameter("@phoneState", SqlDbType.NVarChar,50),
  140. new SqlParameter("@orderNature", SqlDbType.NVarChar,50),
  141. new SqlParameter("@address", SqlDbType.NVarChar,500),
  142. new SqlParameter("@result1", SqlDbType.NVarChar,50),
  143. new SqlParameter("@result2", SqlDbType.NVarChar,50),
  144. new SqlParameter("@result3", SqlDbType.NVarChar,50),
  145. new SqlParameter("@isconnect", SqlDbType.Int,4),
  146. new SqlParameter("@calltime", SqlDbType.DateTime),
  147. new SqlParameter("@F_Id", SqlDbType.Int,4)};
  148. parameters[0].Value = model.taskId;
  149. parameters[1].Value = model.fix;
  150. parameters[2].Value = model.phone;
  151. parameters[3].Value = model.createTime;
  152. parameters[4].Value = model.createBy;
  153. parameters[5].Value = model.callState;
  154. parameters[6].Value = model.salesOffice;
  155. parameters[7].Value = model.broadbandAccount;
  156. parameters[8].Value = model.accessTime;
  157. parameters[9].Value = model.channel;
  158. parameters[10].Value = model.service;
  159. parameters[11].Value = model.package;
  160. parameters[12].Value = model.fusion;
  161. parameters[13].Value = model.phoneState;
  162. parameters[14].Value = model.orderNature;
  163. parameters[15].Value = model.address;
  164. parameters[16].Value = model.result1;
  165. parameters[17].Value = model.result2;
  166. parameters[18].Value = model.result3;
  167. parameters[19].Value = model.isconnect;
  168. parameters[20].Value = model.calltime;
  169. parameters[21].Value = model.F_Id;
  170. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  171. if (rows > 0)
  172. {
  173. return true;
  174. }
  175. else
  176. {
  177. return false;
  178. }
  179. }
  180. /// <summary>
  181. /// 删除一条数据
  182. /// </summary>
  183. public bool Delete(int F_Id)
  184. {
  185. StringBuilder strSql=new StringBuilder();
  186. strSql.Append("delete from T_AutomaticCall_Phone ");
  187. strSql.Append(" where F_Id=@F_Id");
  188. SqlParameter[] parameters = {
  189. new SqlParameter("@F_Id", SqlDbType.Int,4)
  190. };
  191. parameters[0].Value = F_Id;
  192. int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
  193. if (rows > 0)
  194. {
  195. return true;
  196. }
  197. else
  198. {
  199. return false;
  200. }
  201. }
  202. /// <summary>
  203. /// 批量删除数据
  204. /// </summary>
  205. public bool DeleteList(string F_Idlist )
  206. {
  207. StringBuilder strSql=new StringBuilder();
  208. strSql.Append("delete from T_AutomaticCall_Phone ");
  209. strSql.Append(" where F_Id in ("+F_Idlist + ") ");
  210. int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
  211. if (rows > 0)
  212. {
  213. return true;
  214. }
  215. else
  216. {
  217. return false;
  218. }
  219. }
  220. /// <summary>
  221. /// 得到一个对象实体
  222. /// </summary>
  223. public CallCenterApi.Model.T_AutomaticCall_Phone GetModel(int F_Id)
  224. {
  225. StringBuilder strSql=new StringBuilder();
  226. strSql.Append("select top 1 F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime from T_AutomaticCall_Phone ");
  227. strSql.Append(" where F_Id=@F_Id");
  228. SqlParameter[] parameters = {
  229. new SqlParameter("@F_Id", SqlDbType.Int,4)
  230. };
  231. parameters[0].Value = F_Id;
  232. CallCenterApi.Model.T_AutomaticCall_Phone model=new CallCenterApi.Model.T_AutomaticCall_Phone();
  233. DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
  234. if(ds.Tables[0].Rows.Count>0)
  235. {
  236. return DataRowToModel(ds.Tables[0].Rows[0]);
  237. }
  238. else
  239. {
  240. return null;
  241. }
  242. }
  243. /// <summary>
  244. /// 得到一个对象实体
  245. /// </summary>
  246. public CallCenterApi.Model.T_AutomaticCall_Phone DataRowToModel(DataRow row)
  247. {
  248. CallCenterApi.Model.T_AutomaticCall_Phone model=new CallCenterApi.Model.T_AutomaticCall_Phone();
  249. if (row != null)
  250. {
  251. if(row["F_Id"]!=null && row["F_Id"].ToString()!="")
  252. {
  253. model.F_Id=int.Parse(row["F_Id"].ToString());
  254. }
  255. if(row["taskId"]!=null && row["taskId"].ToString()!="")
  256. {
  257. model.taskId=int.Parse(row["taskId"].ToString());
  258. }
  259. if(row["fix"]!=null)
  260. {
  261. model.fix=row["fix"].ToString();
  262. }
  263. if(row["phone"]!=null)
  264. {
  265. model.phone=row["phone"].ToString();
  266. }
  267. if(row["createTime"]!=null && row["createTime"].ToString()!="")
  268. {
  269. model.createTime=DateTime.Parse(row["createTime"].ToString());
  270. }
  271. if(row["createBy"]!=null)
  272. {
  273. model.createBy=row["createBy"].ToString();
  274. }
  275. if(row["callState"]!=null && row["callState"].ToString()!="")
  276. {
  277. model.callState=int.Parse(row["callState"].ToString());
  278. }
  279. if(row["salesOffice"]!=null)
  280. {
  281. model.salesOffice=row["salesOffice"].ToString();
  282. }
  283. if(row["broadbandAccount"]!=null)
  284. {
  285. model.broadbandAccount=row["broadbandAccount"].ToString();
  286. }
  287. if(row["accessTime"]!=null && row["accessTime"].ToString()!="")
  288. {
  289. model.accessTime=row["accessTime"].ToString();
  290. }
  291. if(row["channel"]!=null)
  292. {
  293. model.channel=row["channel"].ToString();
  294. }
  295. if(row["service"]!=null)
  296. {
  297. model.service=row["service"].ToString();
  298. }
  299. if(row["package"]!=null)
  300. {
  301. model.package=row["package"].ToString();
  302. }
  303. if(row["fusion"]!=null)
  304. {
  305. model.fusion=row["fusion"].ToString();
  306. }
  307. if(row["phoneState"]!=null)
  308. {
  309. model.phoneState=row["phoneState"].ToString();
  310. }
  311. if(row["orderNature"]!=null)
  312. {
  313. model.orderNature=row["orderNature"].ToString();
  314. }
  315. if(row["address"]!=null)
  316. {
  317. model.address=row["address"].ToString();
  318. }
  319. if(row["result1"]!=null)
  320. {
  321. model.result1=row["result1"].ToString();
  322. }
  323. if(row["result2"]!=null)
  324. {
  325. model.result2=row["result2"].ToString();
  326. }
  327. if(row["result3"]!=null)
  328. {
  329. model.result3=row["result3"].ToString();
  330. }
  331. if(row["isconnect"]!=null && row["isconnect"].ToString()!="")
  332. {
  333. model.isconnect=int.Parse(row["isconnect"].ToString());
  334. }
  335. if(row["calltime"]!=null && row["calltime"].ToString()!="")
  336. {
  337. model.calltime=DateTime.Parse(row["calltime"].ToString());
  338. }
  339. }
  340. return model;
  341. }
  342. /// <summary>
  343. /// 获得数据列表
  344. /// </summary>
  345. public DataSet GetList(string strWhere)
  346. {
  347. StringBuilder strSql=new StringBuilder();
  348. strSql.Append("select F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime ");
  349. strSql.Append(" FROM T_AutomaticCall_Phone ");
  350. if(strWhere.Trim()!="")
  351. {
  352. strSql.Append(" where "+strWhere);
  353. }
  354. return DbHelperSQL.Query(strSql.ToString());
  355. }
  356. /// <summary>
  357. /// 获得前几行数据
  358. /// </summary>
  359. public DataSet GetList(int Top,string strWhere,string filedOrder)
  360. {
  361. StringBuilder strSql=new StringBuilder();
  362. strSql.Append("select ");
  363. if(Top>0)
  364. {
  365. strSql.Append(" top "+Top.ToString());
  366. }
  367. strSql.Append(" F_Id,taskId,fix,phone,createTime,createBy,callState,salesOffice,broadbandAccount,accessTime,channel,service,package,fusion,phoneState,orderNature,address,result1,result2,result3,isconnect,calltime ");
  368. strSql.Append(" FROM T_AutomaticCall_Phone ");
  369. if(strWhere.Trim()!="")
  370. {
  371. strSql.Append(" where "+strWhere);
  372. }
  373. strSql.Append(" order by " + filedOrder);
  374. return DbHelperSQL.Query(strSql.ToString());
  375. }
  376. /// <summary>
  377. /// 获取记录总数
  378. /// </summary>
  379. public int GetRecordCount(string strWhere)
  380. {
  381. StringBuilder strSql=new StringBuilder();
  382. strSql.Append("select count(1) FROM T_AutomaticCall_Phone ");
  383. if(strWhere.Trim()!="")
  384. {
  385. strSql.Append(" where "+strWhere);
  386. }
  387. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  388. if (obj == null)
  389. {
  390. return 0;
  391. }
  392. else
  393. {
  394. return Convert.ToInt32(obj);
  395. }
  396. }
  397. /// <summary>
  398. /// 分页获取数据列表
  399. /// </summary>
  400. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  401. {
  402. StringBuilder strSql=new StringBuilder();
  403. strSql.Append("SELECT * FROM ( ");
  404. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  405. if (!string.IsNullOrEmpty(orderby.Trim()))
  406. {
  407. strSql.Append("order by T." + orderby );
  408. }
  409. else
  410. {
  411. strSql.Append("order by T.F_Id desc");
  412. }
  413. strSql.Append(")AS Row, T.* from T_AutomaticCall_Phone T ");
  414. if (!string.IsNullOrEmpty(strWhere.Trim()))
  415. {
  416. strSql.Append(" WHERE " + strWhere);
  417. }
  418. strSql.Append(" ) TT");
  419. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  420. return DbHelperSQL.Query(strSql.ToString());
  421. }
  422. /*
  423. /// <summary>
  424. /// 分页获取数据列表
  425. /// </summary>
  426. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  427. {
  428. SqlParameter[] parameters = {
  429. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  430. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  431. new SqlParameter("@PageSize", SqlDbType.Int),
  432. new SqlParameter("@PageIndex", SqlDbType.Int),
  433. new SqlParameter("@IsReCount", SqlDbType.Bit),
  434. new SqlParameter("@OrderType", SqlDbType.Bit),
  435. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  436. };
  437. parameters[0].Value = "T_AutomaticCall_Phone";
  438. parameters[1].Value = "F_Id";
  439. parameters[2].Value = PageSize;
  440. parameters[3].Value = PageIndex;
  441. parameters[4].Value = 0;
  442. parameters[5].Value = 0;
  443. parameters[6].Value = strWhere;
  444. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  445. }*/
  446. #endregion BasicMethod
  447. #region ExtensionMethod
  448. public DataSet exportList(string strWhere)
  449. {
  450. //// "电话号码", "营业部","用户分类","问题1","结果1","问题2","结果2","问题3","结果3","是否接通","呼叫时间"
  451. //StringBuilder strSql = new StringBuilder();
  452. StringBuilder tablenew = new StringBuilder();
  453. tablenew.Append("select * from (select salesOffice, orderNature,phone,question1, callState,");
  454. tablenew.Append("( case when isconnect = 1 then case result1 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end ) result1,question2, ");
  455. tablenew.Append(" (case when isconnect = 1 then case result2 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end ) result2,question3,");
  456. // tablenew.Append(" case when question3 IS NULL then '' else case result3 when 1 then '十分满意' when 2 then '满意' when 3 then '不满意' else '未评价' end end else '' end result3 ");
  457. tablenew.Append("(case when question3 IS NULL then '' else case when isconnect = 1 then case result3 when 1 then '1' when 2 then '2' when 3 then '3' else '未评价' end else '' end end ) result3 ,");
  458. tablenew.Append(" (case when isconnect =1 then '是' else '否' end ) connect, calltime,phone.taskId,isconnect,Isnull(phone.totalTime,0) totalTime from T_AutomaticCall_Phone phone left join T_AutomaticCall_Task task on phone.taskid = task.taskid) as t");
  459. if (strWhere.Trim() != "")
  460. {
  461. tablenew.Append(" where " + strWhere);
  462. }
  463. tablenew.Append(" order by calltime desc");
  464. return DbHelperSQL.Query(tablenew.ToString());
  465. }
  466. #endregion ExtensionMethod
  467. }
  468. }