地铁二期项目正式开始

T_CTI_Task.cs 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlClient;
  6. using System.Data;
  7. using YTSoft.DBUtility;
  8. namespace YTSoft.BaseCallCenter.DAL
  9. {
  10. /// <summary>
  11. /// 数据访问类:T_CTI_Task
  12. /// </summary>
  13. public partial class T_CTI_Task
  14. {
  15. public T_CTI_Task()
  16. { }
  17. #region Method
  18. /// <summary>
  19. /// 是否存在该记录
  20. /// </summary>
  21. public bool Exists(long TaskID)
  22. {
  23. StringBuilder strSql = new StringBuilder();
  24. strSql.Append("select count(1) from T_CTI_Task");
  25. strSql.Append(" where TaskID=@TaskID");
  26. SqlParameter[] parameters = {
  27. new SqlParameter("@TaskID", SqlDbType.BigInt)
  28. };
  29. parameters[0].Value = TaskID;
  30. return DbHelperSQL.Exists(strSql.ToString(), parameters);
  31. }
  32. /// <summary>
  33. /// 增加一条数据
  34. /// </summary>
  35. public long Add(YTSoft.BaseCallCenter.Model.T_CTI_Task model)
  36. {
  37. StringBuilder strSql = new StringBuilder();
  38. strSql.Append("insert into T_CTI_Task(");
  39. strSql.Append("TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount)");
  40. strSql.Append(" values (");
  41. strSql.Append("@TaskName,@TrunkGroupID,@CallerNum,@CallType,@ExInfo,@MaxTrunkCount,@IntensityCoefficient,@ItemTableName,@State,@AddTime,@y_PSort,@y_TkModelId,@y_SXH,@y_FPCount,@y_YJCount,@y_HCCount,@y_HSCount,@y_HTCount,@y_HMCount,@y_OkCount,@y_RFCount,@y_ConsCount,@y_InvlCount,@y_NoAnswerCount,@y_ShutDownCount)");
  42. strSql.Append(";select @@IDENTITY");
  43. SqlParameter[] parameters = {
  44. new SqlParameter("@TaskName", SqlDbType.VarChar,200),
  45. new SqlParameter("@TrunkGroupID", SqlDbType.Int,4),
  46. new SqlParameter("@CallerNum", SqlDbType.VarChar,11),
  47. new SqlParameter("@CallType", SqlDbType.Int,4),
  48. new SqlParameter("@ExInfo", SqlDbType.VarChar,200),
  49. new SqlParameter("@MaxTrunkCount", SqlDbType.Int,4),
  50. new SqlParameter("@IntensityCoefficient", SqlDbType.Float,8),
  51. new SqlParameter("@ItemTableName", SqlDbType.VarChar,100),
  52. new SqlParameter("@State", SqlDbType.Int,4),
  53. new SqlParameter("@AddTime", SqlDbType.DateTime),
  54. new SqlParameter("@y_PSort", SqlDbType.Int,4),
  55. new SqlParameter("@y_TkModelId", SqlDbType.BigInt,8),
  56. new SqlParameter("@y_SXH", SqlDbType.Int,4),
  57. new SqlParameter("@y_FPCount", SqlDbType.Int,4),
  58. new SqlParameter("@y_YJCount", SqlDbType.Int,4),
  59. new SqlParameter("@y_HCCount", SqlDbType.Int,4),
  60. new SqlParameter("@y_HSCount", SqlDbType.Int,4),
  61. new SqlParameter("@y_HTCount", SqlDbType.Int,4),
  62. new SqlParameter("@y_HMCount", SqlDbType.Int,4),
  63. new SqlParameter("@y_OkCount", SqlDbType.Int,4),
  64. new SqlParameter("@y_RFCount", SqlDbType.Int,4),
  65. new SqlParameter("@y_ConsCount", SqlDbType.Int,4),
  66. new SqlParameter("@y_InvlCount", SqlDbType.Int,4),
  67. new SqlParameter("@y_NoAnswerCount", SqlDbType.Int,4),
  68. new SqlParameter("@y_ShutDownCount", SqlDbType.Int,4)};
  69. parameters[0].Value = model.TaskName;
  70. parameters[1].Value = model.TrunkGroupID;
  71. parameters[2].Value = model.CallerNum;
  72. parameters[3].Value = model.CallType;
  73. parameters[4].Value = model.ExInfo;
  74. parameters[5].Value = model.MaxTrunkCount;
  75. parameters[6].Value = model.IntensityCoefficient;
  76. parameters[7].Value = model.ItemTableName;
  77. parameters[8].Value = model.State;
  78. parameters[9].Value = model.AddTime;
  79. parameters[10].Value = model.y_PSort;
  80. parameters[11].Value = model.y_TkModelId;
  81. parameters[12].Value = model.y_SXH;
  82. parameters[13].Value = model.y_FPCount;
  83. parameters[14].Value = model.y_YJCount;
  84. parameters[15].Value = model.y_HCCount;
  85. parameters[16].Value = model.y_HSCount;
  86. parameters[17].Value = model.y_HTCount;
  87. parameters[18].Value = model.y_HMCount;
  88. parameters[19].Value = model.y_OkCount;
  89. parameters[20].Value = model.y_RFCount;
  90. parameters[21].Value = model.y_ConsCount;
  91. parameters[22].Value = model.y_InvlCount;
  92. parameters[23].Value = model.y_NoAnswerCount;
  93. parameters[24].Value = model.y_ShutDownCount;
  94. object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
  95. if (obj == null)
  96. {
  97. return 0;
  98. }
  99. else
  100. {
  101. return Convert.ToInt64(obj);
  102. }
  103. }
  104. /// <summary>
  105. /// 更新一条数据
  106. /// </summary>
  107. public bool Update(YTSoft.BaseCallCenter.Model.T_CTI_Task model)
  108. {
  109. StringBuilder strSql = new StringBuilder();
  110. strSql.Append("update T_CTI_Task set ");
  111. strSql.Append("TaskName=@TaskName,");
  112. strSql.Append("y_TkModelId=@y_TkModelId");
  113. strSql.Append(" where TaskID=@TaskID");
  114. SqlParameter[] parameters = {
  115. new SqlParameter("@TaskName", SqlDbType.VarChar,200),
  116. new SqlParameter("@y_TkModelId", SqlDbType.BigInt,8),
  117. new SqlParameter("@TaskID", SqlDbType.BigInt,8)};
  118. parameters[0].Value = model.TaskName;
  119. parameters[1].Value = model.y_TkModelId;
  120. parameters[2].Value = model.TaskID;
  121. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  122. if (rows > 0)
  123. {
  124. return true;
  125. }
  126. else
  127. {
  128. return false;
  129. }
  130. }
  131. /// <summary>
  132. /// 更新一条数据
  133. /// </summary>
  134. public bool UpdateState(int id,int state)
  135. {
  136. StringBuilder strSql = new StringBuilder();
  137. strSql.Append("update T_CTI_Task set ");
  138. strSql.Append("State=@State");
  139. strSql.Append(" where TaskID=@TaskID");
  140. SqlParameter[] parameters = {
  141. new SqlParameter("@State", SqlDbType.Int,4),
  142. new SqlParameter("@TaskID", SqlDbType.BigInt,8)};
  143. parameters[0].Value = state;
  144. parameters[1].Value = id;
  145. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  146. if (rows > 0)
  147. {
  148. return true;
  149. }
  150. else
  151. {
  152. return false;
  153. }
  154. }
  155. /// <summary>
  156. /// 删除一条数据
  157. /// </summary>
  158. public bool Delete(long TaskID)
  159. {
  160. StringBuilder strSql = new StringBuilder();
  161. strSql.Append("delete from T_CTI_Task ");
  162. strSql.Append(" where TaskID=@TaskID");
  163. SqlParameter[] parameters = {
  164. new SqlParameter("@TaskID", SqlDbType.BigInt)
  165. };
  166. parameters[0].Value = TaskID;
  167. int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
  168. if (rows > 0)
  169. {
  170. return true;
  171. }
  172. else
  173. {
  174. return false;
  175. }
  176. }
  177. /// <summary>
  178. /// 批量删除数据
  179. /// </summary>
  180. public bool DeleteList(string TaskIDlist)
  181. {
  182. StringBuilder strSql = new StringBuilder();
  183. strSql.Append("delete from T_CTI_Task ");
  184. strSql.Append(" where TaskID in (" + TaskIDlist + ") ");
  185. int rows = DbHelperSQL.ExecuteSql(strSql.ToString());
  186. if (rows > 0)
  187. {
  188. return true;
  189. }
  190. else
  191. {
  192. return false;
  193. }
  194. }
  195. /// <summary>
  196. /// 得到一个对象实体
  197. /// </summary>
  198. public YTSoft.BaseCallCenter.Model.T_CTI_Task GetModel(long TaskID)
  199. {
  200. StringBuilder strSql = new StringBuilder();
  201. strSql.Append("select top 1 TaskID,TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount from T_CTI_Task ");
  202. strSql.Append(" where TaskID=@TaskID");
  203. SqlParameter[] parameters = {
  204. new SqlParameter("@TaskID", SqlDbType.BigInt)
  205. };
  206. parameters[0].Value = TaskID;
  207. YTSoft.BaseCallCenter.Model.T_CTI_Task model = new YTSoft.BaseCallCenter.Model.T_CTI_Task();
  208. DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
  209. if (ds.Tables[0].Rows.Count > 0)
  210. {
  211. if (ds.Tables[0].Rows[0]["TaskID"] != null && ds.Tables[0].Rows[0]["TaskID"].ToString() != "")
  212. {
  213. model.TaskID = long.Parse(ds.Tables[0].Rows[0]["TaskID"].ToString());
  214. }
  215. if (ds.Tables[0].Rows[0]["TaskName"] != null && ds.Tables[0].Rows[0]["TaskName"].ToString() != "")
  216. {
  217. model.TaskName = ds.Tables[0].Rows[0]["TaskName"].ToString();
  218. }
  219. if (ds.Tables[0].Rows[0]["TrunkGroupID"] != null && ds.Tables[0].Rows[0]["TrunkGroupID"].ToString() != "")
  220. {
  221. model.TrunkGroupID = int.Parse(ds.Tables[0].Rows[0]["TrunkGroupID"].ToString());
  222. }
  223. if (ds.Tables[0].Rows[0]["CallerNum"] != null && ds.Tables[0].Rows[0]["CallerNum"].ToString() != "")
  224. {
  225. model.CallerNum = ds.Tables[0].Rows[0]["CallerNum"].ToString();
  226. }
  227. if (ds.Tables[0].Rows[0]["CallType"] != null && ds.Tables[0].Rows[0]["CallType"].ToString() != "")
  228. {
  229. model.CallType = int.Parse(ds.Tables[0].Rows[0]["CallType"].ToString());
  230. }
  231. if (ds.Tables[0].Rows[0]["ExInfo"] != null && ds.Tables[0].Rows[0]["ExInfo"].ToString() != "")
  232. {
  233. model.ExInfo = ds.Tables[0].Rows[0]["ExInfo"].ToString();
  234. }
  235. if (ds.Tables[0].Rows[0]["MaxTrunkCount"] != null && ds.Tables[0].Rows[0]["MaxTrunkCount"].ToString() != "")
  236. {
  237. model.MaxTrunkCount = int.Parse(ds.Tables[0].Rows[0]["MaxTrunkCount"].ToString());
  238. }
  239. if (ds.Tables[0].Rows[0]["IntensityCoefficient"] != null && ds.Tables[0].Rows[0]["IntensityCoefficient"].ToString() != "")
  240. {
  241. model.IntensityCoefficient = decimal.Parse(ds.Tables[0].Rows[0]["IntensityCoefficient"].ToString());
  242. }
  243. if (ds.Tables[0].Rows[0]["ItemTableName"] != null && ds.Tables[0].Rows[0]["ItemTableName"].ToString() != "")
  244. {
  245. model.ItemTableName = ds.Tables[0].Rows[0]["ItemTableName"].ToString();
  246. }
  247. if (ds.Tables[0].Rows[0]["State"] != null && ds.Tables[0].Rows[0]["State"].ToString() != "")
  248. {
  249. model.State = int.Parse(ds.Tables[0].Rows[0]["State"].ToString());
  250. }
  251. if (ds.Tables[0].Rows[0]["AddTime"] != null && ds.Tables[0].Rows[0]["AddTime"].ToString() != "")
  252. {
  253. model.AddTime = DateTime.Parse(ds.Tables[0].Rows[0]["AddTime"].ToString());
  254. }
  255. if (ds.Tables[0].Rows[0]["y_PSort"] != null && ds.Tables[0].Rows[0]["y_PSort"].ToString() != "")
  256. {
  257. model.y_PSort = int.Parse(ds.Tables[0].Rows[0]["y_PSort"].ToString());
  258. }
  259. if (ds.Tables[0].Rows[0]["y_TkModelId"] != null && ds.Tables[0].Rows[0]["y_TkModelId"].ToString() != "")
  260. {
  261. model.y_TkModelId = long.Parse(ds.Tables[0].Rows[0]["y_TkModelId"].ToString());
  262. }
  263. if (ds.Tables[0].Rows[0]["y_SXH"] != null && ds.Tables[0].Rows[0]["y_SXH"].ToString() != "")
  264. {
  265. model.y_SXH = int.Parse(ds.Tables[0].Rows[0]["y_SXH"].ToString());
  266. }
  267. if (ds.Tables[0].Rows[0]["y_FPCount"] != null && ds.Tables[0].Rows[0]["y_FPCount"].ToString() != "")
  268. {
  269. model.y_FPCount = int.Parse(ds.Tables[0].Rows[0]["y_FPCount"].ToString());
  270. }
  271. if (ds.Tables[0].Rows[0]["y_YJCount"] != null && ds.Tables[0].Rows[0]["y_YJCount"].ToString() != "")
  272. {
  273. model.y_YJCount = int.Parse(ds.Tables[0].Rows[0]["y_YJCount"].ToString());
  274. }
  275. if (ds.Tables[0].Rows[0]["y_HCCount"] != null && ds.Tables[0].Rows[0]["y_HCCount"].ToString() != "")
  276. {
  277. model.y_HCCount = int.Parse(ds.Tables[0].Rows[0]["y_HCCount"].ToString());
  278. }
  279. if (ds.Tables[0].Rows[0]["y_HSCount"] != null && ds.Tables[0].Rows[0]["y_HSCount"].ToString() != "")
  280. {
  281. model.y_HSCount = int.Parse(ds.Tables[0].Rows[0]["y_HSCount"].ToString());
  282. }
  283. if (ds.Tables[0].Rows[0]["y_HTCount"] != null && ds.Tables[0].Rows[0]["y_HTCount"].ToString() != "")
  284. {
  285. model.y_HTCount = int.Parse(ds.Tables[0].Rows[0]["y_HTCount"].ToString());
  286. }
  287. if (ds.Tables[0].Rows[0]["y_HMCount"] != null && ds.Tables[0].Rows[0]["y_HMCount"].ToString() != "")
  288. {
  289. model.y_HMCount = int.Parse(ds.Tables[0].Rows[0]["y_HMCount"].ToString());
  290. }
  291. if (ds.Tables[0].Rows[0]["y_OkCount"] != null && ds.Tables[0].Rows[0]["y_OkCount"].ToString() != "")
  292. {
  293. model.y_OkCount = int.Parse(ds.Tables[0].Rows[0]["y_OkCount"].ToString());
  294. }
  295. if (ds.Tables[0].Rows[0]["y_RFCount"] != null && ds.Tables[0].Rows[0]["y_RFCount"].ToString() != "")
  296. {
  297. model.y_RFCount = int.Parse(ds.Tables[0].Rows[0]["y_RFCount"].ToString());
  298. }
  299. if (ds.Tables[0].Rows[0]["y_ConsCount"] != null && ds.Tables[0].Rows[0]["y_ConsCount"].ToString() != "")
  300. {
  301. model.y_ConsCount = int.Parse(ds.Tables[0].Rows[0]["y_ConsCount"].ToString());
  302. }
  303. if (ds.Tables[0].Rows[0]["y_InvlCount"] != null && ds.Tables[0].Rows[0]["y_InvlCount"].ToString() != "")
  304. {
  305. model.y_InvlCount = int.Parse(ds.Tables[0].Rows[0]["y_InvlCount"].ToString());
  306. }
  307. if (ds.Tables[0].Rows[0]["y_NoAnswerCount"] != null && ds.Tables[0].Rows[0]["y_NoAnswerCount"].ToString() != "")
  308. {
  309. model.y_NoAnswerCount = int.Parse(ds.Tables[0].Rows[0]["y_NoAnswerCount"].ToString());
  310. }
  311. if (ds.Tables[0].Rows[0]["y_ShutDownCount"] != null && ds.Tables[0].Rows[0]["y_ShutDownCount"].ToString() != "")
  312. {
  313. model.y_ShutDownCount = int.Parse(ds.Tables[0].Rows[0]["y_ShutDownCount"].ToString());
  314. }
  315. return model;
  316. }
  317. else
  318. {
  319. return null;
  320. }
  321. }
  322. /// <summary>
  323. /// 获得数据列表
  324. /// </summary>
  325. public DataSet GetList(string strWhere)
  326. {
  327. StringBuilder strSql = new StringBuilder();
  328. strSql.Append("select * ");
  329. strSql.Append(" FROM vw_CTI_TaskPager ");
  330. if (strWhere.Trim() != "")
  331. {
  332. strSql.Append(" where " + strWhere);
  333. }
  334. return DbHelperSQL.Query(strSql.ToString());
  335. }
  336. /// <summary>
  337. /// 获得前几行数据
  338. /// </summary>
  339. public DataSet GetList(int Top, string strWhere, string filedOrder)
  340. {
  341. StringBuilder strSql = new StringBuilder();
  342. strSql.Append("select ");
  343. if (Top > 0)
  344. {
  345. strSql.Append(" top " + Top.ToString());
  346. }
  347. strSql.Append(" TaskID,TaskName,TrunkGroupID,CallerNum,CallType,ExInfo,MaxTrunkCount,IntensityCoefficient,ItemTableName,State,AddTime,y_PSort,y_TkModelId,y_SXH,y_FPCount,y_YJCount,y_HCCount,y_HSCount,y_HTCount,y_HMCount,y_OkCount,y_RFCount,y_ConsCount,y_InvlCount,y_NoAnswerCount,y_ShutDownCount ");
  348. strSql.Append(" FROM T_CTI_Task ");
  349. if (strWhere.Trim() != "")
  350. {
  351. strSql.Append(" where " + strWhere);
  352. }
  353. strSql.Append(" order by " + filedOrder);
  354. return DbHelperSQL.Query(strSql.ToString());
  355. }
  356. /// <summary>
  357. /// 获取记录总数
  358. /// </summary>
  359. public int GetRecordCount(string strWhere)
  360. {
  361. StringBuilder strSql = new StringBuilder();
  362. strSql.Append("select count(1) FROM T_CTI_Task ");
  363. if (strWhere.Trim() != "")
  364. {
  365. strSql.Append(" where " + strWhere);
  366. }
  367. object obj = DbHelperSQL.GetSingle(strSql.ToString());
  368. if (obj == null)
  369. {
  370. return 0;
  371. }
  372. else
  373. {
  374. return Convert.ToInt32(obj);
  375. }
  376. }
  377. /// <summary>
  378. /// 分页获取数据列表
  379. /// </summary>
  380. public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
  381. {
  382. StringBuilder strSql = new StringBuilder();
  383. strSql.Append("SELECT * FROM ( ");
  384. strSql.Append(" SELECT ROW_NUMBER() OVER (");
  385. if (!string.IsNullOrEmpty(orderby.Trim()))
  386. {
  387. strSql.Append("order by T." + orderby);
  388. }
  389. else
  390. {
  391. strSql.Append("order by T.TaskID desc");
  392. }
  393. strSql.Append(")AS Row, T.* from T_CTI_Task T ");
  394. if (!string.IsNullOrEmpty(strWhere.Trim()))
  395. {
  396. strSql.Append(" WHERE " + strWhere);
  397. }
  398. strSql.Append(" ) TT");
  399. strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
  400. return DbHelperSQL.Query(strSql.ToString());
  401. }
  402. /*
  403. /// <summary>
  404. /// 分页获取数据列表
  405. /// </summary>
  406. public DataSet GetList(int PageSize,int PageIndex,string strWhere)
  407. {
  408. SqlParameter[] parameters = {
  409. new SqlParameter("@tblName", SqlDbType.VarChar, 255),
  410. new SqlParameter("@fldName", SqlDbType.VarChar, 255),
  411. new SqlParameter("@PageSize", SqlDbType.Int),
  412. new SqlParameter("@PageIndex", SqlDbType.Int),
  413. new SqlParameter("@IsReCount", SqlDbType.Bit),
  414. new SqlParameter("@OrderType", SqlDbType.Bit),
  415. new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
  416. };
  417. parameters[0].Value = "T_CTI_Task";
  418. parameters[1].Value = "TaskID";
  419. parameters[2].Value = PageSize;
  420. parameters[3].Value = PageIndex;
  421. parameters[4].Value = 0;
  422. parameters[5].Value = 0;
  423. parameters[6].Value = strWhere;
  424. return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
  425. }*/
  426. #endregion Method
  427. }
  428. }