市长热线演示版

callinopt.aspx.cs 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data;
  8. using HySoft.Common;
  9. using HySoft.Workflow.WFEngine;
  10. using WOSBusineSupporter;
  11. using HySoft.BaseCallCenter.Web.workordermanage.workorder;
  12. using HySoft.DBUtility;
  13. namespace HySoft.BaseCallCenter.Web.telmanage
  14. {
  15. public partial class callinopt : System.Web.UI.Page
  16. {
  17. string phone = "";
  18. string callid = "";
  19. string zxflowid = "7";
  20. string bxflowid = "6";
  21. string tsflowid = "5";
  22. string assOpt = "";
  23. protected void Page_Load(object sender, EventArgs e)
  24. {
  25. #region 生成流程操作
  26. InitEngine();
  27. #endregion
  28. if (!IsPostBack)
  29. {
  30. #region 获取用户信息
  31. try
  32. {
  33. LoginUser p_LoginUser = new LoginUser(this.Context);
  34. hfUserId.Value = p_LoginUser.UserID.ToString();
  35. }
  36. catch { }
  37. #endregion
  38. #region 参数获取
  39. if (!string.IsNullOrEmpty(Request.QueryString["phone"]))
  40. {
  41. phone = Request.QueryString["phone"].ToString().Trim();//来电电话
  42. string oldphone = phone;//2015-4-10 张高炯
  43. phone = DealPhone(phone);
  44. txtLaiDian.InnerHtml = phone;
  45. hfPhone.Value = oldphone;
  46. txtTsPhone.Text = phone;
  47. #region 来电归属地查询
  48. string location = "";
  49. //来电归属地查询
  50. if (phone.Trim().Length == 11 && phone.Substring(0, 1) != "0")
  51. {
  52. location = GetPhoneLocation(phone, true);
  53. }
  54. else
  55. {
  56. location = GetPhoneLocation(phone, false);
  57. }
  58. txtLaiDian.InnerText = phone + " " + location;
  59. #endregion
  60. #region 根据电话获取客户信息
  61. getCustomerInfoByPhone(phone);
  62. #endregion
  63. }
  64. if (!string.IsNullOrEmpty(Request.QueryString["callid"]))
  65. {
  66. callid = Request.QueryString["callid"].ToString().Trim();//呼入Id
  67. hfCallId.Value = callid;
  68. GetTelRecord(callid);
  69. }
  70. #endregion
  71. }
  72. }
  73. #region 初始化工作流引擎
  74. private void InitEngine()
  75. {
  76. wosBusineSupporter = new WOSBusineSupporter.WOSBusineSupporter();
  77. wosBusineSupporter.ConnectionString = connStr;
  78. /**/
  79. //SQL数据库存储方式
  80. MSSQLDBWorkflowInstanceFactory instanceFactory = new MSSQLDBWorkflowInstanceFactory();
  81. instanceFactory.ConnectionString = connStr;
  82. MSSQLDBPersistentServer persistenServer = new MSSQLDBPersistentServer();
  83. persistenServer.ConnectionString = connStr;
  84. engine = new SimpleWFEngine(wosBusineSupporter, persistenServer, instanceFactory);
  85. //咨询流程
  86. MSSQLDBWorkflowTypeInfoSupporter sup = new MSSQLDBWorkflowTypeInfoSupporter();
  87. sup.ConnectionString = connStr;
  88. runOprs = null;
  89. sup.GetWorkflowTypeInfo(tsflowid,
  90. out nodeID, out nodeType, out nodeName, out formInfo, out enablcRepeal, out enablcRepealLock, out runOprs, out rollBackOprs, out assignParticipatorArray);
  91. #region 投诉操作
  92. if (runOprs != null)
  93. {
  94. int idcount = 0;
  95. foreach (BusineOpr runopr in runOprs)
  96. {
  97. //zxoptid = runopr.ID;
  98. LinkButton runSavebtn = new LinkButton();
  99. runSavebtn.ID = "runSavebtnts" + idcount.ToString();
  100. runSavebtn.Attributes.Add("class", "btnSubmit");
  101. runSavebtn.OnClientClick = "return validate('" + runopr.ID.Trim() + "')";
  102. runSavebtn.Text = runopr.Name.Trim();
  103. runSavebtn.CommandArgument = runopr.ID + "_" + nodeID;
  104. runSavebtn.Height = 23;
  105. runSavebtn.Click += new EventHandler(btnSubmit_Click);
  106. divOpt0.Controls.Add(runSavebtn);
  107. //添加空格间距
  108. System.Web.UI.HtmlControls.HtmlGenericControl spannull = new System.Web.UI.HtmlControls.HtmlGenericControl("span");
  109. spannull.ID = "btnnullts" + idcount.ToString();
  110. spannull.InnerText = " ";
  111. divOpt0.Controls.Add(spannull);
  112. idcount++;
  113. }
  114. }
  115. #endregion
  116. }
  117. #endregion
  118. #region 来电归属地查询
  119. public string GetPhoneLocation(string phoneNumber, bool isPhone)
  120. {
  121. string location = "未知";
  122. try
  123. {
  124. //如果是手机号码
  125. if (isPhone)
  126. {
  127. BLL.T_Sys_MobileData mobile_Bll = new BLL.T_Sys_MobileData();
  128. Model.T_Sys_MobileData mobileModel = mobile_Bll.GetModel(phoneNumber.Substring(0, 7));
  129. return mobileModel != null ? (mobileModel.F_CityDes + mobileModel.F_CardDes) : location;
  130. }
  131. else//如果是电话号码
  132. {
  133. BLL.T_Sys_TelTitleData numbBll = new BLL.T_Sys_TelTitleData();
  134. List<Model.T_Sys_TelTitleData> mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 4) + "'");
  135. if (mobileModel == null || mobileModel.Count <= 0)
  136. mobileModel = numbBll.GetModelList(" 1=1 and F_KeyPhoneNum='" + phoneNumber.Substring(0, 3) + "'");
  137. return mobileModel.Count > 0 ? mobileModel[0].F_TitleName : location;
  138. }
  139. }
  140. catch (System.Exception ex)
  141. {
  142. return location;
  143. }
  144. }
  145. #endregion
  146. #region 获取通话记录信息
  147. private string GetTelRecord(string callid)
  148. {
  149. string res = "0";
  150. try
  151. {
  152. Model.T_Call_CallRecords model = new BLL.T_Call_CallRecords().GetModelByCallId(callid);
  153. if (model != null)
  154. {
  155. res = model.CallRecordsId.ToString();
  156. hfBusinessType.Value = model.BusinessType.ToString().Trim();
  157. }
  158. }
  159. catch
  160. {
  161. }
  162. return res;
  163. }
  164. #endregion
  165. #region 根据来电号码获取客户信息
  166. private string getCustomerInfoByPhone(string tel)
  167. {
  168. string res = "";
  169. DataTable dt = new DataTable();
  170. DataTable dtc = new DataTable();
  171. try
  172. {
  173. if (tel != "")
  174. {
  175. //先查联系人表存在联系人记录
  176. dt = new BLL.T_Cus_ContactPerson().GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' ").Tables[0];
  177. if (dt.Rows.Count > 0)
  178. {
  179. res = getCustomerInfoById(dt.Rows[0]["F_CustomerId"].ToString().Trim());
  180. //投诉
  181. txtTsName.Text = dt.Rows[0]["F_Name"].ToString().Trim();
  182. }
  183. else
  184. {
  185. dtc = new BLL.T_Cus_CustomerBase().GetList(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' or F_ChargeTelephone like '%" + tel + "%' ").Tables[0];
  186. if (dtc.Rows.Count > 0)
  187. {
  188. res = getCustomerInfoById(dtc.Rows[0]["F_CustomerId"].ToString().Trim());
  189. }
  190. else
  191. {
  192. getUserAccount(tel);
  193. }
  194. }
  195. }
  196. }
  197. catch (Exception ex)
  198. {
  199. res = "";
  200. }
  201. finally
  202. {
  203. dt.Clear();
  204. dt.Dispose();
  205. dtc.Clear();
  206. dtc.Dispose();
  207. }
  208. return res;
  209. }
  210. private string getCustomerInfoById(string id)
  211. {
  212. string res = "";
  213. Model.T_Cus_CustomerBase model = new BLL.T_Cus_CustomerBase().GetModel(Convert.ToInt32(id));
  214. if (model != null)
  215. {
  216. hiddCustomerId.Value = model.F_CustomerId.ToString();
  217. txtCustomerName.Text = model.F_CustomerName;
  218. divCustomerCode.InnerHtml = "<a href=\"javascript:void(null)\" target=\"_self\" onclick=\"ShowCustomer('" + model.F_CustomerId.ToString() + "');\">" + model.F_CustomerCode + "</a>";
  219. hiddSeriveDeptId.Value = model.F_ServiceDeptID.ToString();
  220. hiddProvinceId.Value = model.F_RegionId.ToString();
  221. hiddCityId.Value = model.F_CityID.ToString();
  222. hiddTelephone.Value = model.F_Telephone;
  223. hiddMobile.Value = model.F_Mobile;
  224. hiddChargeTelephone.Value = model.F_ChargeTelephone;
  225. drpServiceDept.Text = model.F_ServiceDept;
  226. drpProvince.Text = model.F_Province;
  227. drpCity.Text = model.F_City;
  228. drpTelephone.Text = model.F_Telephone;
  229. drpMobile.Text = model.F_Mobile;
  230. drpChargeTelephone.Text = model.F_ChargeTelephone;
  231. //投诉
  232. txtTsName.Text = model.F_CustomerName;
  233. txtTsPhone.Text = phone;
  234. }
  235. return res;
  236. }
  237. #endregion
  238. #region 根据来电号码获取系统用户信息
  239. private void getUserAccount(string tel)
  240. {
  241. try
  242. {
  243. DataTable dtUser = new BLL.T_Sys_UserAccount().GetListView(" F_Telephone like '%" + tel + "%' or F_Mobile like '%" + tel + "%' or F_HomePhone like '%" + tel + "%' ").Tables[0];
  244. if (dtUser.Rows.Count > 0)
  245. {
  246. //投诉
  247. txtTsName.Text = dtUser.Rows[0]["F_UserName"].ToString().Trim();
  248. txtLaiDian.InnerText = tel + " " + dtUser.Rows[0]["F_DeptName"].ToString().Trim();
  249. }
  250. }
  251. catch { }
  252. }
  253. #endregion
  254. SimpleWFEngine engine;
  255. WOSBusineSupporter.WOSBusineSupporter wosBusineSupporter;
  256. string connStr = DBUtility.DbHelperSQL.connectionString;
  257. string instanceID = "0";
  258. string nodeID = "0";
  259. BusineTaskType nodeType;
  260. string nodeName = "";
  261. string formInfo = "";
  262. bool enablcRepeal;
  263. bool enablcRepealLock;
  264. BusineOpr[] runOprs = null;
  265. BusineOpr[] rollBackOprs;
  266. AssignParticipator[] assignParticipatorArray;
  267. static string typeid = "0";
  268. static string formid = "0";
  269. static string flowid = "0";
  270. protected void btnSubmit_Click(object sender, EventArgs e)
  271. {
  272. #region 设置黑名单
  273. try
  274. {
  275. if (cbBlack.Checked && !string.IsNullOrEmpty(txtBlackTime.Text.Trim()))
  276. {
  277. string blackTime = txtBlackTime.Text.Trim();
  278. AddBlackPhone(hfPhone.Value, hfCallId.Value, blackTime);
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. }
  284. #endregion
  285. #region 保存客户信息
  286. try
  287. {
  288. if (hiddCustomerId.Value == "" || hiddCustomerId.Value == "0")
  289. {
  290. if (txtCustomerName.Text.Trim() != "")
  291. {
  292. //添加客户
  293. int id = new BLL.T_Cus_CustomerBase().Add(GetCustomerModel());
  294. if (id > 0)
  295. {
  296. hiddCustomerId.Value = id.ToString();
  297. }
  298. }
  299. }
  300. else
  301. {
  302. //修改客户
  303. new BLL.T_Cus_CustomerBase().Update(GetCustomerModel());
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. }
  309. #endregion
  310. #region 保存工单
  311. string errorInfo = "";
  312. try
  313. {
  314. flowid = tsflowid;
  315. typeid = "3";
  316. WorkflowOprErr errbl = engine.CreateWorkflowInstance(flowid, hfUserId.Value.Trim(), out instanceID, out errorInfo);
  317. if (errbl == WorkflowOprErr.OK)
  318. {
  319. //提交保存工单
  320. int f_instanceid = Convert.ToInt32(instanceID);
  321. int workorderid=0;
  322. bool bl = SubmitOSubmit(f_instanceid, flowid, hfTab.Value.Trim(),out workorderid);
  323. try
  324. {
  325. Model.T_Call_WorkOrder modelorder = new Model.T_Call_WorkOrder();
  326. modelorder.CallId = callid;
  327. modelorder.F_WORKORDERID = workorderid;
  328. modelorder.F_WORKORDERSTATEID = 12;
  329. new BLL.T_Call_WorkOrder().Add(modelorder);
  330. }
  331. catch { }
  332. if (bl)
  333. {
  334. LinkButton btn = (LinkButton)sender;
  335. string arrid = btn.CommandArgument;
  336. string optid = "6";
  337. if (arrid != "")
  338. {
  339. nodeID = arrid.Split('_')[1];
  340. optid = arrid.Split('_')[0];
  341. }
  342. //判断操作
  343. if (optid == "18" || optid == "19")
  344. {
  345. string optnodeid = "";
  346. string optnodename = "";
  347. if (optid == "18")
  348. {
  349. optnodeid = "6";
  350. optnodename = "待接单";
  351. SaveConsInfo(workorderid.ToString(), hiddJDUser.Value);
  352. }
  353. if (optid == "19")
  354. {
  355. optnodeid = "4";
  356. optnodename = "待指派";
  357. }
  358. WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, GetAssignParticipatorList(hiddJDUser.Value, instanceID), "工单操作:" + btn.Text, out errorInfo);
  359. //WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, GetAssignParticipatorList(hiddJDUser.Value, optnodeid, optnodename), "工单操作:" + btn.Text, out errorInfo);
  360. if (bRet.ToString() == "OK")
  361. {
  362. SaveHistoryInfo();
  363. }
  364. }
  365. else
  366. {
  367. WorkflowOprErr bRet = engine.RunOpr(instanceID, hfUserId.Value.Trim(), nodeID, optid, null, "工单操作:" + btn.Text, out errorInfo);
  368. SaveHistoryInfo();
  369. }
  370. MessageBoxToWindow("保存提示", "保存成功!", "success");
  371. //ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>TabCloseById('callin_" + callid + phone + "');</script>");
  372. }
  373. else
  374. {
  375. //InsertOptLogs("", "添加工单失败!", 1);
  376. MessageBoxToWindow("保存提示", "新增失败!", "error");
  377. }
  378. }
  379. else
  380. {
  381. MessageBoxToWindow("保存提示", "创建工作流实例失败" + errbl.ToString(), "error");
  382. }
  383. }
  384. catch (Exception ex)
  385. {
  386. //保存工单失败
  387. MessageBoxToWindow("提示", "异常提示!" + ex.Message, "catch");
  388. }
  389. #endregion
  390. }
  391. private AssignParticipator[] GetAssignParticipatorList(string userid, string instanceID)
  392. {
  393. Model.T_Wo_WorkOrderTask obj = new Model.T_Wo_WorkOrderTask();
  394. DataTable dt = new DataTable();
  395. try
  396. {
  397. dt = new BLL.T_Wo_WorkOrderTask().GetList("F_INSTANCEID=" + instanceID + "").Tables[0];
  398. if (dt.Rows.Count > 0)
  399. {
  400. if (dt.Rows[0]["F_AssignParticipator"].ToString() != "null")
  401. {
  402. assOpt = dt.Rows[0]["F_AssignParticipator"].ToString();
  403. }
  404. }
  405. }
  406. catch { }
  407. if (assOpt != "")
  408. {
  409. AssignParticipator[] asslist = new Web.tools.ParseWorkFlowTask().ParseAssignParticipatorOpr(assOpt);
  410. foreach (AssignParticipator ass in asslist)
  411. {
  412. ParticipatorInfo partinfo = new ParticipatorInfo();
  413. List<Model.T_Sys_UserAccount> list = new List<Model.T_Sys_UserAccount>();
  414. list = (new BLL.T_Sys_UserAccount()).GetModelList(" F_UserId=" + userid.Trim() + "");
  415. UserInfo[] userlist = new UserInfo[list.Count];
  416. for (int i = 0; i < userlist.Length; i++)
  417. {
  418. UserInfo user = new UserInfo();
  419. user.ID = list[i].F_UserId.ToString();
  420. user.Name = list[i].F_UserName;
  421. userlist[i] = user;
  422. }
  423. partinfo.UserList = userlist;
  424. ass.ParticipatorInfo = new AssembleWorkFlowTask().AssembleParticipator(partinfo).InnerXml;
  425. }
  426. return asslist;
  427. }
  428. else
  429. {
  430. return null;
  431. }
  432. }
  433. private void SaveHistoryInfo()
  434. {
  435. try
  436. {
  437. Common.LoginUser user = new Common.LoginUser(this.Context);
  438. Model.T_Wo_WorkOrderHistoryInfo modelHistoryInfo = new Model.T_Wo_WorkOrderHistoryInfo();
  439. string sql = "select * from T_Wo_WorkOrderHistory where F_INSTANCEID=" + instanceID + " and F_OPTUSERID=" + user.UserID + " order by F_HISTORYID desc";
  440. DataTable dt = DbHelperSQL.Query(sql).Tables[0];
  441. if (dt.Rows.Count > 0)
  442. {
  443. modelHistoryInfo.F_HISTORYID = Convert.ToInt32(dt.Rows[0]["F_HISTORYID"]);
  444. }
  445. modelHistoryInfo.F_OPTUSERID = user.UserID;
  446. modelHistoryInfo.F_INSTANCEID = Convert.ToInt32(instanceID);
  447. modelHistoryInfo.F_OPTDATE = DateTime.Now;
  448. modelHistoryInfo.F_EXAMINETYPE = F_EXAMINETYPE.Text.Trim();
  449. BLL.T_Wo_WorkOrderHistoryInfo bll_addHistory = new BLL.T_Wo_WorkOrderHistoryInfo();
  450. bll_addHistory.Add(modelHistoryInfo);
  451. }
  452. catch { }
  453. }
  454. /// <summary>
  455. /// 添加施工人员
  456. /// </summary>
  457. /// <returns></returns>
  458. private string SaveConsInfo(string workorderid, string userid)
  459. {
  460. string res = "error";
  461. try
  462. {
  463. Model.T_Wo_WorkOrderConstructor modelConstructor = new Model.T_Wo_WorkOrderConstructor();
  464. BLL.T_Wo_WorkOrderConstructor bll_Constructoradd = new BLL.T_Wo_WorkOrderConstructor();
  465. modelConstructor.F_WORKORDERID = Convert.ToInt32(workorderid);//工单ID
  466. modelConstructor.F_USERID = Convert.ToInt32(userid);
  467. modelConstructor.F_ISMAIN = 1;
  468. int i = bll_Constructoradd.Add(modelConstructor);
  469. if (i > 0)
  470. {
  471. res = "success";
  472. }
  473. }
  474. catch (Exception ex)
  475. {
  476. }
  477. return res;
  478. }
  479. /// <summary>
  480. /// 指派人员
  481. /// </summary>
  482. /// <param name="userid"></param>
  483. /// <param name="optnodeid"></param>
  484. /// <param name="optnodename"></param>
  485. /// <returns></returns>
  486. private AssignParticipator[] GetAssignParticipatorList(string userid,string optnodeid,string optnodename)
  487. {
  488. AssignParticipator[] arr = new AssignParticipator[1];
  489. arr[0] = new AssignParticipator();
  490. arr[0].NodeID = optnodeid;
  491. arr[0].NodeName = optnodename;
  492. ParticipatorInfo partinfo = new ParticipatorInfo();
  493. List<Model.T_Sys_UserAccount> list = new List<Model.T_Sys_UserAccount>();
  494. list = (new BLL.T_Sys_UserAccount()).GetModelList(" F_UserId=" + userid.Trim() + "");
  495. UserInfo[] userlist = new UserInfo[list.Count];
  496. for (int i = 0; i < userlist.Length; i++)
  497. {
  498. UserInfo user = new UserInfo();
  499. user.ID = list[i].F_UserId.ToString();
  500. user.Name = list[i].F_UserName;
  501. userlist[i] = user;
  502. }
  503. partinfo.UserList = userlist;
  504. arr[0].ParticipatorInfo = new AssembleWorkFlowTask().AssembleParticipator(partinfo).InnerXml;
  505. return arr;
  506. }
  507. public bool SubmitOSubmit(int instanceID, string _flowid, string tab,out int workorderid)
  508. {
  509. bool bl = false;
  510. workorderid = 0;
  511. try
  512. {
  513. Model.T_Wo_WorkOrderBase model = new Model.T_Wo_WorkOrderBase();
  514. #region 工单信息
  515. model.F_WORKORDERTYPEID = Convert.ToInt32(typeid);//类型ID
  516. model.F_WORKORDERSTATEID = Convert.ToInt32(nodeID);//状态ID
  517. model.F_CODE = DateTime.Now.ToString("yyyyMMddHHmmssms");//工单编号
  518. model.F_WORKORDERNAME = txtCustomerName.Text.Trim() + "报修工单";//工单名称
  519. model.F_NUMBER = model.F_CODE;
  520. model.F_CUSTOMERNAME = txtCustomerName.Text.Trim();//客户姓名
  521. model.F_CUSTOMERTELEPHONE = this.txtTsPhone.Text.Trim();//客户电话
  522. model.F_LINKMAN = this.txtTsName.Text.Trim();//联系人姓名
  523. model.F_LINKMANTELEPHONE = this.txtTsPhone.Text.Trim();//联系人电话
  524. model.F_ADSLACCOUNT = hfCallId.Value.Trim();
  525. model.F_BANDWIDTH = "";
  526. //model.F_STANDARDADDRESS = F_STANDARDADDRESS;
  527. //model.F_INSTALLADDRESS = F_INSTALLADDRESS;
  528. model.F_KSHADDRESSCODE = "";
  529. model.F_PROVINCE = drpProvince.Text.Trim();
  530. model.F_CITY = drpCity.Text.Trim();
  531. model.F_AREA = "";
  532. model.F_ROAD = "";
  533. model.F_HOUSING = "";
  534. model.F_WORKORDERFROM = "400来电";
  535. //model.F_WORKORDERLEVELID = F_WORKORDERLEVELID;
  536. model.F_FILEFLAG = 0;
  537. model.F_CONTENT = txtTsContent.Value;
  538. model.F_REPAIRREQUEST = txtTsContent.Value;
  539. model.F_REPAIRMANID = 0;
  540. model.F_REPAIRMANNAME = txtTsName.Text;
  541. model.F_REPAIRMANPHONE = txtTsPhone.Text;
  542. if (hiddTsType.Value != "")
  543. {
  544. model.F_WORKORDERLEVELID = Convert.ToInt32(hiddTsType.Value);
  545. }
  546. LoginUser p_LoginUser = new LoginUser(this.Context);
  547. if (p_LoginUser.UserID != 0)
  548. {
  549. model.F_USERNAME = Server.UrlDecode(p_LoginUser.UserName);
  550. model.F_DEPTCODE = p_LoginUser.DeptId.ToString();
  551. model.F_EMPCODE = p_LoginUser.UserCode;
  552. model.F_DEPTID = p_LoginUser.DeptId;
  553. model.F_USERID = p_LoginUser.UserID;
  554. }
  555. model.F_CREATEBY = Convert.ToInt32(hfUserId.Value.Trim());
  556. model.F_CREATEDATE = DateTime.Now;
  557. model.F_RETURNVISITFLAG = 0;
  558. model.F_RETURNVISITSTATE = 0;
  559. model.F_RETURNVISITRESULT = 0;
  560. model.F_RETURNVISITCONTENT = "";
  561. model.F_DELETEFLAG = 0;
  562. model.F_ALLUSETIMES = 0;
  563. model.F_STARTTIME = DateTime.Now;
  564. model.F_OVERTIMES = 0;
  565. model.F_FORMID = 0;
  566. model.F_HASTENCOUNTS = 0;
  567. model.F_RANGEID = Convert.ToInt32(_flowid);
  568. model.F_RANGEX = 0;
  569. model.F_RANGEY = 0;
  570. model.F_INSTANCEID = Convert.ToInt32(instanceID);
  571. model.F_CUSTOMERID = Convert.ToInt32(hiddCustomerId.Value.Trim());
  572. model.F_REPAIRCLOSEMANID = 0;
  573. model.F_REPAIRCLOSEMANNAME = "";
  574. model.F_REPAIRCLOSEREASONS = "";
  575. model.F_REPAIRCLOSEREPTID = 0;
  576. model.F_REPAIRCLOSEREPT = "";
  577. #endregion
  578. #region 关于超时时间
  579. SetWorkOrderBaseOverTime(typeid, model);
  580. #endregion
  581. int resorderbase = new BLL.T_Wo_WorkOrderBase().Add(model);//添加基本信息
  582. workorderid = resorderbase;
  583. if (resorderbase > 0)
  584. {
  585. bl = true;
  586. }
  587. else
  588. {
  589. bl = false;
  590. }
  591. }
  592. catch (Exception ex)
  593. {
  594. //InsertOptLogs("", "添加工单失败,错误信息:" + ex.Message, 2);
  595. MessageBoxToWindow("保存提示", "保存失败!" + ex.Message, "error");
  596. }
  597. return bl;
  598. }
  599. #region 获取超时时间
  600. /// <summary>
  601. /// 设置基本工单信息 超时时间,告警时间
  602. /// </summary>
  603. /// <param name="typeid">工单类型ID</param>
  604. /// <param name="model_orderbase">工单基本表Model</param>
  605. public void SetWorkOrderBaseOverTime(string typeid, Model.T_Wo_WorkOrderBase model_orderbase)
  606. {
  607. BLL.T_Wo_TypeAlarmDate bll_ala = new BLL.T_Wo_TypeAlarmDate();
  608. List<Model.T_Wo_TypeAlarmDate> list_ala = bll_ala.GetModelList(" F_WorkOrderTypeId='" + typeid
  609. + "' and F_DeleteFlag=0 ");
  610. if (list_ala != null && list_ala.Count > 0)
  611. {
  612. Model.T_Wo_TypeAlarmDate model_time = null;
  613. for (int i = 0; i < list_ala.Count; i++)
  614. { //如果有当前类型就取当前
  615. if (list_ala.Count > 1)
  616. {
  617. if (list_ala[i].F_IsMain == 1)
  618. {
  619. continue;
  620. }
  621. }
  622. model_time = list_ala[i];
  623. if (model_time != null)
  624. {
  625. int day = 0;
  626. int hour = 0;
  627. int minute = 0;
  628. switch (model_time.F_Cunit)
  629. {
  630. case 0://分钟
  631. minute = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  632. break;
  633. case 1://小时
  634. hour = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  635. break;
  636. case 2://天
  637. day = model_time.F_Ccount == null ? 0 : int.Parse(model_time.F_Ccount.ToString());
  638. break;
  639. default:
  640. break;
  641. }
  642. if (day == 0 && hour == 0 && minute == 0)
  643. model_orderbase.F_ASKFINISHTIME = null;
  644. else
  645. model_orderbase.F_ASKFINISHTIME = GetNoramlWorkTime(DateTime.Now, day, hour, minute);
  646. day = 0; hour = 0; minute = 0;//清值操作
  647. switch (model_time.F_Gunit)
  648. {
  649. case 0://分钟
  650. minute = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  651. break;
  652. case 1://小时
  653. hour = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  654. break;
  655. case 2://天
  656. day = model_time.F_Gcount == null ? 0 : int.Parse(model_time.F_Gcount.ToString());
  657. break;
  658. default:
  659. break;
  660. }
  661. if (day == 0 && hour == 0 && minute == 0)
  662. model_orderbase.F_REMAINDERTIME = null;
  663. else
  664. model_orderbase.F_REMAINDERTIME = GetNoramlWorkTime(DateTime.Now, day, hour, minute);
  665. }
  666. }
  667. }
  668. }
  669. /// <summary>
  670. /// 当前时间,换算成正常工作时间,并且Add 天时分
  671. /// </summary>
  672. /// <param name="timeStart">初始时间</param>
  673. /// <param name="days">增加的天数</param>
  674. /// <param name="hours">增加的小时</param>
  675. /// <param name="minutes">增加的分钟</param>
  676. /// <returns></returns>
  677. public DateTime GetNoramlWorkTime(DateTime timeStart, int days, int hours, int minutes)
  678. {
  679. timeStart = timeStart.AddDays(days);
  680. timeStart = timeStart.AddHours(hours);
  681. timeStart = timeStart.AddMinutes(minutes);
  682. return timeStart;
  683. }
  684. #endregion
  685. #region 弹出对话框
  686. /// <summary>
  687. /// 弹出对话框
  688. /// </summary>
  689. /// <param name="title"></param>
  690. /// <param name="content"></param>
  691. /// <param name="type"></param>
  692. public void MessageBoxToWindow(string content, string title, string type)
  693. {
  694. string script = "";
  695. switch (type)
  696. {
  697. case "error"://失败
  698. type = "error";
  699. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  700. break;
  701. case "success"://成功
  702. type = "success";
  703. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "',TabCloseById);</script>";
  704. break;
  705. case "catch"://异常
  706. type = "warning";
  707. script = "<script type='text/javascript'> $.ligerDialog.alert('" + title + "','" + content + "','" + type + "');</script>";
  708. break;
  709. default:
  710. type = "question";
  711. break;
  712. }
  713. ClientScript.RegisterClientScriptBlock(this.GetType(), "", script);
  714. }
  715. #endregion
  716. #region 设置黑名单
  717. /// <summary>
  718. /// 设置黑名单
  719. /// </summary>
  720. /// <param name="page"></param>
  721. public void AddBlackPhone(string InPhoneNum, string CallRecId, string txtTime)
  722. {
  723. Model.T_Call_Blacklist model_T_Call_Blacklist = new Model.T_Call_Blacklist();
  724. try
  725. {
  726. LoginUser p_LoginUser = new LoginUser(this.Context);
  727. model_T_Call_Blacklist.F_BlackType = 0;//加入黑名单类型
  728. model_T_Call_Blacklist.F_CallId = CallRecId;//呼叫编号
  729. model_T_Call_Blacklist.F_IsDelete = false;//是否删除
  730. model_T_Call_Blacklist.F_SetTime = DateTime.Now;//设置时间
  731. model_T_Call_Blacklist.F_TelPhone = InPhoneNum;//电话号码
  732. model_T_Call_Blacklist.F_UserId = p_LoginUser.UserID;//添加人id
  733. if (rdTimesType0.Checked)
  734. {
  735. model_T_Call_Blacklist.F_RemoveTime = DateTime.Now.AddMinutes(Convert.ToInt32(txtTime));//超时时间
  736. }
  737. if (rdTimesType1.Checked)
  738. {
  739. model_T_Call_Blacklist.F_RemoveTime = DateTime.Now.AddHours(Convert.ToInt32(txtTime));//超时时间
  740. }
  741. if (rdTimesType2.Checked)
  742. {
  743. model_T_Call_Blacklist.F_RemoveTime = DateTime.Now.AddDays(Convert.ToInt32(txtTime));//超时时间
  744. }
  745. new BLL.T_Call_Blacklist().Add(model_T_Call_Blacklist);
  746. }
  747. catch (Exception ex)
  748. {
  749. //AddOperateLog(1, 15, 0, "设置黑名单:号码:" + InPhoneNum + ",ID:" + CallRecId + ",错误原因:" + ex.ToString() + "!");
  750. }
  751. }
  752. #endregion
  753. #region 客户信息
  754. private Model.T_Cus_CustomerBase GetCustomerModel()
  755. {
  756. Model.T_Cus_CustomerBase _model = new Model.T_Cus_CustomerBase();
  757. try
  758. {
  759. if (hiddCustomerId.Value != "" && hiddCustomerId.Value != "0")
  760. {
  761. _model.F_CustomerId = Convert.ToInt32(hiddCustomerId.Value);
  762. _model = new BLL.T_Cus_CustomerBase().GetModel(Convert.ToInt32(hiddCustomerId.Value));
  763. }
  764. else
  765. {
  766. _model.F_CustomerCode = "KHBH" + DateTime.Now.ToString("yyyyMMddHHmmss");// txtCustomerCode.Text.Trim();
  767. }
  768. _model.F_CustomerName = txtCustomerName.Text.Trim();
  769. if (hiddSeriveDeptId.Value != "")
  770. {
  771. _model.F_ServiceDeptID = Convert.ToInt32(hiddSeriveDeptId.Value);
  772. }
  773. _model.F_ServiceDept = drpServiceDept.Text;
  774. if (hiddProvinceId.Value != "")
  775. {
  776. _model.F_RegionId = Convert.ToInt32(hiddProvinceId.Value);
  777. }
  778. _model.F_Province = drpProvince.Text;
  779. if (hiddCityId.Value != "")
  780. {
  781. _model.F_CityID = Convert.ToInt32(hiddCityId.Value);
  782. }
  783. _model.F_City = drpCity.Text;
  784. _model.F_Telephone = drpTelephone.Text;
  785. _model.F_Mobile = drpMobile.Text;
  786. _model.F_ChargeTelephone = drpChargeTelephone.Text;
  787. return _model;
  788. }
  789. catch
  790. {
  791. return null;
  792. }
  793. }
  794. #endregion
  795. #region 处理来电电话号码 2015-03-27 张高炯
  796. private string DealPhone(string phone)
  797. {
  798. if (phone.Length > 10)
  799. {
  800. if (phone.Length == 12)
  801. {
  802. return phone;
  803. }
  804. else
  805. {
  806. if (phone.Substring(0, 2) == "04")
  807. {
  808. phone = phone.Substring(2, phone.Length - 2);
  809. }
  810. }
  811. }
  812. return phone;
  813. }
  814. #endregion
  815. }
  816. }