地铁二期项目正式开始

OCXOptController.cs 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Data;
  7. using YTSoft.Common;
  8. namespace YTSoft.BaseCallCenter.MVCWeb.Controllers
  9. {
  10. public class OCXOptController : BaseController
  11. {
  12. //
  13. // GET: /OCXOpt/
  14. public ActionResult OCXOptAjax()
  15. {
  16. return View();
  17. }
  18. /// <summary>
  19. /// 通话处理
  20. /// </summary>
  21. /// <param name="OCXOptCallAjax"></param>
  22. /// <returns></returns>
  23. [ActionName("OCXOptCallAjax")]
  24. [HttpGet]
  25. public string OCXOptCallAjax(string optaction,string timeno,string callid,string userid,string usercode,string username,string extnumber,string callernum,string path)
  26. {
  27. //&timeno=" + timeno+"&callid=" + callID + "&userid=" + userid + "&usercode=" + usercode
  28. //+ "&username=" + username + "&extnumber" + extnumber + "&callernum=" + callerNum
  29. AddAction("T_Call_CallRecords", callid, "通话处理",string.Format("事件:{0},callid={1},userid={5},usercode={2},extnumber={3},callernum={4}", optaction, callid, usercode, extnumber, callernum, userid),"关键信息");
  30. string res = "error";
  31. try
  32. {
  33. switch (optaction)
  34. {
  35. case "gethflist":
  36. //res=LoadHFList(context)
  37. break;
  38. case "getlist":
  39. //res=LoadList(context));
  40. break;
  41. case "getcallinlist":
  42. //来电弹屏通话记录
  43. //res=LoadCallInList(context));
  44. break;
  45. case "getgdlist":
  46. //
  47. //res=LoadGDList(context));
  48. break;
  49. case "deletelist":
  50. //res=Delete(context));
  51. break;
  52. case "clear":
  53. break;
  54. case "insertCallLogs":
  55. res = InsertCallLogs();
  56. break;
  57. case "getCallIdByPhone":
  58. //根据来电号码获取
  59. res = getCallIdByPhone(callernum);
  60. break;
  61. case "zhenlingEvent":
  62. //振铃事件
  63. res=zhenlingEvent(callid, userid, usercode, username, extnumber, callernum);
  64. break;
  65. case "zhaijiEvent":
  66. //摘机事件
  67. res=zhaijiEvent(callid);
  68. break;
  69. case "guajiEvent":
  70. //挂机事件
  71. res=guajiEvent(callid);
  72. break;
  73. case "luyinEvent":
  74. //录音开始事件
  75. res=luyinEvent(callid,path);
  76. break;
  77. case "callout":
  78. //外呼
  79. res = callout(callernum, userid, usercode, username, extnumber, callid);
  80. break;
  81. case "callouthf":
  82. //外呼回访
  83. res=callouthf(callernum, userid, usercode, username, extnumber, callid);
  84. break;
  85. }
  86. }
  87. catch
  88. { }
  89. return res;
  90. }
  91. #region 外呼回访
  92. public string callouthf(string phone, string userid, string usercode, string username, string extnumber, string hfid)
  93. {
  94. string res = "1||" + DateTime.Now.ToString("yyyyMMddHHmmssms");
  95. try
  96. {
  97. //处理判断本地或外地 zhgjie
  98. try
  99. {
  100. if (phone.Trim() != "")
  101. {
  102. //判断号码前是否存在0
  103. if (phone.Trim().Substring(0, 1) != "0")
  104. {
  105. //判断是否手机
  106. if (phone.Trim().Length > 10)
  107. {
  108. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  109. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phone.Substring(0, 7));
  110. if (mobileModel != null)
  111. {
  112. if (mobileModel.F_ZipCode != "0371")
  113. {
  114. phone = "0" + phone;
  115. }
  116. }
  117. }
  118. }
  119. }
  120. }
  121. catch
  122. { }
  123. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  124. model.CallId = DateTime.Now.ToString("yyyyMMddHHmmssms");
  125. model.CallNumber = phone;
  126. model.CallType = 1;
  127. if (!string.IsNullOrEmpty(userid))
  128. {
  129. model.UserId = Convert.ToInt32(userid);
  130. }
  131. if (!string.IsNullOrEmpty(usercode))
  132. {
  133. model.UserCode = usercode.Trim();
  134. }
  135. if (!string.IsNullOrEmpty(username))
  136. {
  137. model.UserName = HttpUtility.UrlDecode(username.Trim());
  138. //model.UserName=context.Request.Form["txtAgentName"]
  139. }
  140. if (!string.IsNullOrEmpty(extnumber))
  141. {
  142. model.ExtNumber = extnumber.Trim();
  143. //model.UserName=context.Request.Form["txtAgentName"]
  144. }
  145. model.CallState = 0;
  146. model.DealType = 7;
  147. model.IsDeal = 1;
  148. model.OperateType = 7;//回访
  149. model.OperateObject = "";
  150. model.OperateTime = DateTime.Now;
  151. try
  152. {
  153. if (hfid != "")
  154. {
  155. model.OperateObject = hfid;
  156. }
  157. }
  158. catch
  159. {
  160. }
  161. string cid = model.CallId;
  162. new BLL.T_Call_CallRecords().Add(model);
  163. try
  164. {
  165. //更新回访状态
  166. new BLL.T_Call_TaskTelNum().UpdateHC(Convert.ToInt32(hfid), 1);
  167. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(hfid), 0);
  168. //string workorderid = CommonRequest.GetQueryString("workorderid");
  169. //if (workorderid != "")
  170. //{
  171. // Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  172. // modelorder.CallId = model.CallId;
  173. // modelorder.F_WORKORDERID = Convert.ToInt32(workorderid);
  174. // modelorder.F_WORKORDERSTATEID = 6;
  175. // new BLL.T_Call_WorkOrder().Add(modelorder);
  176. //}
  177. }
  178. catch { }
  179. if (phone.Length > 5)
  180. {
  181. res = "2|" + phone + "|" + cid;
  182. }
  183. else
  184. {
  185. res = "1|" + phone + "|" + cid;
  186. }
  187. }
  188. catch { }
  189. return res;
  190. }
  191. #endregion
  192. #region 话机外呼
  193. public string callout(string phone,string userid,string usercode,string username,string extnumber,string workorderid)
  194. {
  195. string res = "1||" + DateTime.Now.ToString("yyyyMMddHHmmssms");
  196. try
  197. {
  198. //处理判断本地或外地 zhgjie
  199. try
  200. {
  201. if (phone.Trim() != "")
  202. {
  203. //判断号码前是否存在0
  204. if (phone.Trim().Substring(0, 1) != "0")
  205. {
  206. //判断是否手机
  207. if (phone.Trim().Length > 10)
  208. {
  209. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  210. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phone.Substring(0, 7));
  211. if (mobileModel != null)
  212. {
  213. if (mobileModel.F_ZipCode != "0371")
  214. {
  215. phone = "0" + phone;
  216. }
  217. }
  218. }
  219. }
  220. }
  221. }
  222. catch
  223. { }
  224. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  225. model.CallId = DateTime.Now.ToString("yyyyMMddHHmmssms");
  226. model.CallNumber = phone;
  227. model.CallType = 1;
  228. if (!string.IsNullOrEmpty(userid))
  229. {
  230. model.CallId = DateTime.Now.ToString("yyyyMMddHHmmssms") + userid;
  231. model.UserId = Convert.ToInt32(userid);
  232. }
  233. if (!string.IsNullOrEmpty(usercode))
  234. {
  235. model.UserCode = usercode.Trim();
  236. }
  237. if (!string.IsNullOrEmpty(username))
  238. {
  239. model.UserName = HttpUtility.UrlDecode(username.Trim());
  240. }
  241. if (!string.IsNullOrEmpty(extnumber))
  242. {
  243. model.ExtNumber = extnumber.Trim();
  244. //model.UserName=context.Request.Form["txtAgentName"]
  245. }
  246. model.CallState = 0;
  247. model.DealType = 6;
  248. model.IsDeal = 1;
  249. string cid = model.CallId;
  250. new BLL.T_Call_CallRecords().Add(model);
  251. try
  252. {
  253. if (workorderid != null)
  254. {
  255. if (workorderid != "")
  256. {
  257. Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  258. modelorder.CallId = model.CallId;
  259. modelorder.F_WORKORDERID = Convert.ToInt32(workorderid);
  260. modelorder.F_WORKORDERSTATEID = 6;
  261. new BLL.T_Call_WorkOrder().Add(modelorder);
  262. }
  263. }
  264. }
  265. catch { }
  266. if (phone.Length > 5)
  267. {
  268. res = "2|" + phone + "|" + cid;
  269. }
  270. else
  271. {
  272. res = "1|" + phone + "|" + cid;
  273. }
  274. }
  275. catch { }
  276. return res;
  277. }
  278. #endregion
  279. #region 电话操作日志
  280. public string InsertCallLogs()
  281. {
  282. string res = "error";
  283. return res;
  284. }
  285. #endregion
  286. #region 根据来电号码获取callid
  287. public string getCallIdByPhone(string telphone)
  288. {
  289. string res = "";
  290. try
  291. {
  292. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByTelphone(telphone);
  293. if (model != null)
  294. {
  295. res = model.CallId.Trim();
  296. }
  297. }
  298. catch (Exception ex)
  299. {
  300. res = "";
  301. }
  302. return res;
  303. }
  304. #endregion
  305. #region 来电归属地查询
  306. public string GetPhoneLocation(string phoneNumber, bool isPhone)
  307. {
  308. string location = "未知";
  309. try
  310. {
  311. //如果是手机号码
  312. if (isPhone)
  313. {
  314. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  315. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phoneNumber.Substring(0, 7));
  316. return mobileModel != null ? (mobileModel.F_CityDes + mobileModel.F_CardDes) : location;
  317. }
  318. else//如果是电话号码
  319. {
  320. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  321. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 4) + "'");
  322. if (mobileModel == null || mobileModel.Count <= 0)
  323. mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 3) + "'");
  324. return mobileModel.Count > 0 ? mobileModel[0].F_TitleName : location;
  325. }
  326. }
  327. catch (System.Exception ex)
  328. {
  329. return location;
  330. }
  331. }
  332. #endregion
  333. #region 自动添加工单
  334. public bool SubmitOSubmit(string phone,string recordid,string callid,string locationaddress,string userid,string username,string usercode, out int workorderid)
  335. {
  336. bool bl = false;
  337. workorderid = 0;
  338. try
  339. {
  340. Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  341. List<Model.T_Wo_WorkOrderBase> modellist = new BLL.T_Wo_WorkOrderBase().GetModelList(" F_RANGEID="+ recordid);
  342. if (modellist != null && modellist.Count > 0)
  343. {
  344. model = modellist[0];
  345. #region 工单信息
  346. if (string.IsNullOrEmpty(model.F_LINKMAN))
  347. {
  348. //model.F_WORKORDERTYPEID = Convert.ToInt32(typeid);//类型ID
  349. model.F_WORKORDERSTATEID = 0;//状态ID
  350. model.F_REPAIRREQUEST = "未处理";
  351. model.F_CODE = "";//工单编号
  352. model.F_WORKORDERNAME = "";//工单名称
  353. model.F_NUMBER = model.F_CODE;
  354. //model.F_CUSTOMERNAME = txtCustomerName.Text.Trim();//客户姓名
  355. model.F_CUSTOMERTELEPHONE = phone.Trim();//客户电话
  356. model.F_USERID = Convert.ToInt32(userid);//坐席id
  357. model.F_LINKMAN = usercode.Trim();//坐席工号
  358. model.F_REPAIRMANNAME = username.Trim();//坐席名称
  359. model.F_LINKMANTELEPHONE = phone.Trim();//联系人电话
  360. //model.F_ADSLACCOUNT = hfCallId.Value.Trim();
  361. model.F_BANDWIDTH = "";
  362. model.F_STANDARDADDRESS = locationaddress.Trim();
  363. //model.F_INSTALLADDRESS = F_INSTALLADDRESS;
  364. model.F_KSHADDRESSCODE = callid;
  365. model.F_RANGEID = Convert.ToInt32(recordid);
  366. model.F_PROVINCE = "";
  367. model.F_CITY = "";
  368. model.F_AREA = "";
  369. model.F_ROAD = "";
  370. model.F_HOUSING = "";
  371. model.F_REPAIRMANID = 1;
  372. model.F_WORKORDERFROM = "语音工单";
  373. //model.F_WORKORDERLEVELID = F_WORKORDERLEVELID;
  374. model.F_FILEFLAG = 0;
  375. model.F_CREATEBY = Convert.ToInt32(userid.Trim());
  376. model.F_CREATEDATE = DateTime.Now;
  377. model.F_RETURNVISITFLAG = 0;
  378. model.F_RETURNVISITSTATE = 0;
  379. model.F_RETURNVISITRESULT = 0;
  380. model.F_RETURNVISITCONTENT = "";
  381. model.F_DELETEFLAG = 0;
  382. model.F_ALLUSETIMES = 0;
  383. model.F_STARTTIME = DateTime.Now;
  384. model.F_OVERTIMES = 0;
  385. model.F_FORMID = 0;
  386. model.F_HASTENCOUNTS = 0;
  387. model.F_RANGEX = 0;
  388. model.F_RANGEY = 0;
  389. model.F_REPAIRCLOSEMANID = 0;
  390. model.F_REPAIRCLOSEMANNAME = "";
  391. model.F_REPAIRCLOSEREASONS = "";
  392. model.F_REPAIRCLOSEREPTID = 0;
  393. model.F_REPAIRCLOSEREPT = "";
  394. new BLL.T_Wo_WorkOrderBase().Update(model);
  395. }
  396. workorderid = model.F_WORKORDERID;
  397. #endregion
  398. }
  399. else {
  400. #region 工单信息
  401. //model.F_WORKORDERTYPEID = Convert.ToInt32(typeid);//类型ID
  402. model.F_WORKORDERSTATEID = 0;//状态ID
  403. model.F_REPAIRREQUEST = "未处理";
  404. model.F_CODE = "";//工单编号
  405. model.F_WORKORDERNAME = "";//工单名称
  406. model.F_NUMBER = model.F_CODE;
  407. //model.F_CUSTOMERNAME = txtCustomerName.Text.Trim();//客户姓名
  408. model.F_CUSTOMERTELEPHONE = phone.Trim();//客户电话
  409. model.F_USERID = Convert.ToInt32(userid);//坐席id
  410. model.F_LINKMAN = usercode.Trim();//坐席工号
  411. model.F_REPAIRMANNAME = username.Trim();//坐席名称
  412. model.F_LINKMANTELEPHONE = phone.Trim();//联系人电话
  413. //model.F_ADSLACCOUNT = hfCallId.Value.Trim();
  414. model.F_BANDWIDTH = "";
  415. model.F_STANDARDADDRESS = locationaddress.Trim();
  416. //model.F_INSTALLADDRESS = F_INSTALLADDRESS;
  417. model.F_KSHADDRESSCODE = callid;
  418. model.F_RANGEID = Convert.ToInt32(recordid);
  419. model.F_PROVINCE = "";
  420. model.F_CITY = "";
  421. model.F_AREA = "";
  422. model.F_ROAD = "";
  423. model.F_HOUSING = "";
  424. model.F_REPAIRMANID = 1;
  425. model.F_WORKORDERFROM = "语音工单";
  426. //model.F_WORKORDERLEVELID = F_WORKORDERLEVELID;
  427. model.F_FILEFLAG = 0;
  428. model.F_CREATEBY = Convert.ToInt32(userid.Trim());
  429. model.F_CREATEDATE = DateTime.Now;
  430. model.F_RETURNVISITFLAG = 0;
  431. model.F_RETURNVISITSTATE = 0;
  432. model.F_RETURNVISITRESULT = 0;
  433. model.F_RETURNVISITCONTENT = "";
  434. model.F_DELETEFLAG = 0;
  435. model.F_ALLUSETIMES = 0;
  436. model.F_STARTTIME = DateTime.Now;
  437. model.F_OVERTIMES = 0;
  438. model.F_FORMID = 0;
  439. model.F_HASTENCOUNTS = 0;
  440. model.F_RANGEX = 0;
  441. model.F_RANGEY = 0;
  442. model.F_REPAIRCLOSEMANID = 0;
  443. model.F_REPAIRCLOSEMANNAME = "";
  444. model.F_REPAIRCLOSEREASONS = "";
  445. model.F_REPAIRCLOSEREPTID = 0;
  446. model.F_REPAIRCLOSEREPT = "";
  447. #endregion
  448. workorderid = new BLL.T_Wo_WorkOrderBase().Add(model);//添加基本信息
  449. }
  450. if (workorderid > 0)
  451. {
  452. bl = true;
  453. }
  454. else
  455. {
  456. bl = false;
  457. }
  458. }
  459. catch (Exception ex)
  460. {
  461. }
  462. return bl;
  463. }
  464. #endregion
  465. #region 处理振铃事件
  466. public string zhenlingEvent(string callid, string userid, string usercode, string username, string extnumber, string callernum)
  467. {
  468. string res = "error";
  469. try
  470. {
  471. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  472. if (vmodel != null)
  473. {
  474. #region 存在通话记录
  475. AddAction("T_Call_CallRecords", callid, "步骤2", string.Format("存在通话记录 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4}", "zhenlingEvent", callid, usercode, extnumber, callernum), "关键信息");
  476. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  477. model.CallId = callid;
  478. if (!string.IsNullOrEmpty(userid))
  479. {
  480. model.UserId = Convert.ToInt32(userid);
  481. }
  482. if (!string.IsNullOrEmpty(usercode))
  483. {
  484. model.UserCode = usercode.Trim();
  485. }
  486. if (!string.IsNullOrEmpty(username))
  487. {
  488. model.UserName = HttpUtility.UrlDecode(username.Trim());
  489. //model.UserName=context.Request.Form["txtAgentName"]
  490. }
  491. if (!string.IsNullOrEmpty(extnumber))
  492. {
  493. model.ExtNumber = extnumber.Trim();
  494. //model.UserName=context.Request.Form["txtAgentName"]
  495. }
  496. model.DealType = 5;
  497. bool bl = new BLL.T_Call_CallRecords().UpdateCallInRingTelRecord(model);
  498. if (bl)
  499. {
  500. AddAction("T_Call_CallRecords", callid, "步骤3", string.Format("更新成功 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4},userid={5}", "zhenlingEvent", callid, usercode, extnumber, callernum, userid), "关键信息");
  501. string phone = callernum;
  502. #region 来电归属地查询
  503. string location = "";
  504. //来电归属地查询
  505. if (phone.Trim().Length == 11 && phone.Substring(0, 1) != "0")
  506. {
  507. location = GetPhoneLocation(phone, true);
  508. }
  509. else
  510. {
  511. location = GetPhoneLocation(phone, false);
  512. }
  513. #endregion
  514. #region 创建工单
  515. int workorderid = 0;
  516. bool wobl = SubmitOSubmit(phone, vmodel.CallRecordsId.ToString(), callid, location, userid, username, usercode, out workorderid);
  517. if (wobl)
  518. {
  519. try
  520. {
  521. Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  522. modelorder.CallId = callid;
  523. modelorder.F_WORKORDERID = workorderid;
  524. modelorder.F_WORKORDERSTATEID = 0;
  525. new BLL.T_Call_WorkOrder().Add(modelorder);
  526. }
  527. catch { }
  528. res = workorderid.ToString();
  529. }
  530. #endregion
  531. }
  532. else
  533. {
  534. AddAction("T_Call_CallRecords", callid, "步骤3", string.Format("更新失败 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4},userid={5}", "zhenlingEvent", callid, usercode, extnumber, callernum, userid), "关键信息");
  535. }
  536. #endregion
  537. }
  538. else
  539. {
  540. AddAction("T_Call_CallRecords", callid, "步骤2", string.Format("不存在通话记录 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4},userid={5}", "zhenlingEvent", callid, usercode, extnumber, callernum, userid), "关键信息");
  541. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  542. model.CallId = callid;
  543. model.CallNumber = callernum.Trim();
  544. model.CallType = 0;
  545. if (!string.IsNullOrEmpty(userid))
  546. {
  547. //model.CallId = DateTime.Now.ToString("yyyyMMddHHmmssms") + CommonRequest.GetQueryString("userid");
  548. model.UserId = Convert.ToInt32(userid);
  549. }
  550. if (!string.IsNullOrEmpty(usercode))
  551. {
  552. model.UserCode = usercode.Trim();
  553. }
  554. if (!string.IsNullOrEmpty(username))
  555. {
  556. model.UserName = HttpUtility.UrlDecode(username.Trim());
  557. //model.UserName=context.Request.Form["txtAgentName"]
  558. }
  559. if (!string.IsNullOrEmpty(extnumber))
  560. {
  561. model.ExtNumber = extnumber.Trim();
  562. //model.UserName=context.Request.Form["txtAgentName"]
  563. }
  564. model.CallState = 0;
  565. model.DealType = 6;
  566. model.IsDeal = 1;
  567. string cid = model.CallId;
  568. int b = new BLL.T_Call_CallRecords().Add(model);
  569. if (b > 0)
  570. {
  571. AddAction("T_Call_CallRecords", callid, "步骤3", string.Format("添加成功 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4},userid={5}", "zhenlingEvent", callid, usercode, extnumber, callernum, userid), "关键信息");
  572. string phone = callernum;
  573. #region 来电归属地查询
  574. string location = "";
  575. //来电归属地查询
  576. if (phone.Trim().Length == 11 && phone.Substring(0, 1) != "0")
  577. {
  578. location = GetPhoneLocation(phone, true);
  579. }
  580. else
  581. {
  582. location = GetPhoneLocation(phone, false);
  583. }
  584. #endregion
  585. #region 创建工单
  586. int workorderid = 0;
  587. bool wobl = SubmitOSubmit(phone, b.ToString(), callid, location, userid, username, usercode, out workorderid);
  588. if (wobl)
  589. {
  590. try
  591. {
  592. Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  593. modelorder.CallId = callid;
  594. modelorder.F_WORKORDERID = workorderid;
  595. modelorder.F_WORKORDERSTATEID = 0;
  596. new BLL.T_Call_WorkOrder().Add(modelorder);
  597. }
  598. catch { }
  599. res = workorderid.ToString();
  600. }
  601. #endregion
  602. }
  603. else
  604. {
  605. AddAction("T_Call_CallRecords", callid, "步骤3", string.Format("添加失败 事件:{0},callid={1},usercode={2},extnumber={3},callernum={4},userid={5}", "zhenlingEvent", callid, usercode, extnumber, callernum, userid), "关键信息");
  606. }
  607. }
  608. }
  609. catch (Exception ex)
  610. {
  611. LogHelper.Default.WriteError("振铃事件:", ex);
  612. }
  613. return res;
  614. }
  615. #endregion
  616. #region 处理摘机事件
  617. public string zhaijiEvent(string callid)
  618. {
  619. string res = "error";
  620. try
  621. {
  622. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  623. model.CallId = callid;
  624. model.CallState = 1;
  625. model.DealType = 6;
  626. bool bl = new BLL.T_Call_CallRecords().UpdateCallInAnswerTelRecord(model);
  627. if (bl)
  628. {
  629. res = "success";
  630. //更新回访状态
  631. #region
  632. /*
  633. try
  634. {
  635. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  636. string type = vmodel.OperateType.ToString();
  637. if (type == "7")
  638. {
  639. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  640. }
  641. }
  642. catch
  643. {
  644. }
  645. */
  646. #endregion
  647. }
  648. }
  649. catch (Exception ex)
  650. {
  651. res = ex.ToString();
  652. }
  653. return res;
  654. }
  655. #endregion
  656. #region 处理挂机事件
  657. public string guajiEvent(string callid)
  658. {
  659. string res = "error";
  660. try
  661. {
  662. bool bl = new BLL.T_Call_CallRecords().UpdateCallInHookTelRecord(callid);
  663. if (bl)
  664. {
  665. res = "success";
  666. }
  667. }
  668. catch (Exception ex)
  669. {
  670. res = ex.ToString();
  671. }
  672. return res;
  673. }
  674. #endregion
  675. #region 处理录音开始事件
  676. public string luyinEvent(string callid,string path)
  677. {
  678. string res = "error";
  679. try
  680. {
  681. Model.T_Call_CallRecords model = new Model.T_Call_CallRecords();
  682. model.CallId = callid;
  683. model.CallState = 1;
  684. model.DealType = 6;
  685. model.FilePath = path;
  686. bool bl = new BLL.T_Call_CallRecords().UpdateCallInPathTelRecord(model);
  687. if (bl)
  688. {
  689. res = "success";
  690. //更新回访状态
  691. try
  692. {
  693. Model.T_Call_CallRecords vmodel = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  694. string type = vmodel.OperateType.ToString();
  695. if (type == "7")
  696. {
  697. new BLL.T_Call_TaskTelNum().UpdateYJ(Convert.ToInt32(vmodel.OperateObject.ToString()), 1);
  698. }
  699. }
  700. catch
  701. {
  702. }
  703. }
  704. }
  705. catch (Exception ex)
  706. {
  707. res = ex.ToString();
  708. }
  709. return res;
  710. }
  711. #endregion
  712. }
  713. }