Global.asax 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <%@ Application Language="C#" %>
  2. <%@ Import Namespace="Castle.ActiveRecord" %>
  3. <%@ Import Namespace="Castle.ActiveRecord.Framework.Config" %>
  4. <%@ Import Namespace="BizCom" %>
  5. <%@ Import Namespace="SiteCore" %>
  6. <%@ Import Namespace="Utils" %>
  7. <%@ Import Namespace="System.Threading" %>
  8. <%@ Import Namespace="System.IO" %>
  9. <%@ Import Namespace="System.Data" %>
  10. <%@ Import Namespace="System.Data.SqlClient" %>
  11. <%@ Import Namespace="System.Web" %>
  12. <%@ Import Namespace="System.Security.Cryptography" %>
  13. <%@ Import Namespace="Newtonsoft.Json" %>
  14. <script RunAt="server">
  15. static HttpHelper tb_http = new HttpHelper();
  16. static string api_url = "http://xy.ifireant.com/taobaoapi";
  17. string conn = "";
  18. System.Threading.Timer gtimer;
  19. int BeginInterval = 100;
  20. System.Timers.Timer timerGetRefundsData;
  21. System.Timers.Timer timerCheckUnusualOrder;
  22. System.Timers.Timer timerAutoDispatch;
  23. System.Timers.Timer timerDayClear;
  24. void Application_Start(object sender, EventArgs e)
  25. {
  26. log4net.Config.XmlConfigurator.Configure();
  27. // Code that runs on application startup
  28. InPlaceConfigurationSource source = new InPlaceConfigurationSource();
  29. System.Collections.Generic.IDictionary<string, string> properties = new System.Collections.Generic.Dictionary<string, string>();
  30. properties.Add("connection.driver_class", "NHibernate.Driver.SqlClientDriver");
  31. properties.Add("proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory,NHibernate.ByteCode.Castle");
  32. properties.Add("dialect", "NHibernate.Dialect.MsSql2005Dialect");
  33. properties.Add("connection.provider", "NHibernate.Connection.DriverConnectionProvider");
  34. properties.Add("show_sql", "true");
  35. conn = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
  36. properties.Add("connection.connection_string", conn);
  37. source.Add(typeof(ActiveRecordBase), properties);
  38. source.IsRunningInWebApp = true;
  39. //IConfigurationSource source =ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
  40. Type[] acTypes = new[]
  41. {
  42. typeof(XUser),
  43. typeof(XModular),
  44. typeof(CeErpModular),
  45. typeof(CeErpUser),
  46. typeof(CeErpPost),
  47. //typeof(CeErpPersonPost),
  48. typeof(CeErpUserInfo),
  49. typeof(CeErpOrderFormData),
  50. typeof(CeErpOrganization),
  51. typeof(CeErpShop),
  52. typeof(CeErpSupplier),
  53. typeof(CeErpProduct),
  54. typeof(CeErpProductHour),
  55. typeof(CeErpSupplierProduct),
  56. typeof(CeErpTrade),
  57. typeof(CeErpTradeOrder),
  58. typeof(CeErpTradeCell),
  59. typeof(CeErpTradeLog),
  60. typeof(CeErpTradeResponsible),
  61. typeof(CeErpTradeAfterSaleLog),
  62. typeof(CeErpTradeAfterSaleExtend),
  63. typeof(CeErpTradeCellExtend),
  64. typeof(CeErpTradeRefund),
  65. typeof(CeErpTradeSample),
  66. typeof(CeErpBill),
  67. typeof(CeErpReturnCash),
  68. typeof(CeErpExpressInfo),
  69. typeof(CeErpUserPost),
  70. typeof(CeErpZhangDan),
  71. typeof(CeErpInvoicingInfo),
  72. typeof(CeErpCustomer),
  73. typeof(CeErpTmcLog),
  74. typeof(XPermission),
  75. typeof(XLog),
  76. typeof(Log_Login),
  77. typeof(LogOperate),
  78. typeof(SiteInfo),
  79. typeof(CEErpPrintModel),
  80. typeof(CeErpNotice),
  81. typeof(CeErpNoticeCell),
  82. typeof(CeErpDesignerFinishRate),
  83. typeof(CeErpPlaceRegister),
  84. typeof(CeErpPersuade),
  85. typeof(CeErpProcessList),
  86. typeof(CeErpMethod),
  87. typeof(CeErpStayGoods),
  88. typeof(CeErpProfession),
  89. typeof(CeErpDesignerBill),
  90. typeof(CeErpDesignerBillLog),
  91. typeof(CeErpProductPrice),
  92. typeof(CeErpMailInfo),
  93. typeof(SupplierLog),
  94. typeof(CeErpMessageTip),
  95. typeof(CeErpToManagement),
  96. typeof(CeErpSpecialRefund),
  97. typeof(CeErpMessageAPI),
  98. typeof(CeErpDesignerFinishRateNew),
  99. typeof(CeWithdraw),
  100. typeof(CeErpDesignInfo),
  101. typeof(CeErpSampleCustomer),
  102. typeof(CeErpTradeSpu),
  103. typeof(CeErpSukuraData),
  104. typeof(CeErpDeliverMark),
  105. typeof(CeErpPackData),
  106. typeof(CeErpPackDataItem),
  107. typeof(CeErpSupplierProductTime),
  108. typeof(CeErpTradeCellFile),
  109. typeof(CeErpDataSendOrderInfo)
  110. };
  111. ActiveRecordStarter.Initialize(source, acTypes);
  112. //gtimer = new System.Threading.Timer(new TimerCallback(global_elapsed), null, 5000, 5000);//每5秒钟运行一次
  113. ////初始化获取退款数据定时任务定时器
  114. //InitGetRefundsDataTimer();
  115. ////初始化更新异常订单状态定时器
  116. //InitCheckUnusualOrderTimer();
  117. //初始化自动派单定时器
  118. //InitAutoDispatchTimer();
  119. //初始化每日清除数据定时器
  120. //InitDayClearTimer();
  121. }
  122. #region 获取退款数据定时任务
  123. //初始化获取退款数据定时器
  124. private void InitGetRefundsDataTimer()
  125. {
  126. timerGetRefundsData = new System.Timers.Timer();
  127. timerGetRefundsData.Interval = BeginInterval;
  128. timerGetRefundsData.Elapsed += new System.Timers.ElapsedEventHandler(GetRefundsData);
  129. timerGetRefundsData.Enabled = true;
  130. }
  131. //退款任务改为定时查看是否有责任人为确认 认可责任,大于48小时自动确认
  132. private void GetRefundsData(object sender, System.Timers.ElapsedEventArgs e)
  133. {
  134. timerGetRefundsData.Enabled = false;
  135. if (webConfig.Refund_Switch == "1")
  136. {
  137. timerGetRefundsData.Interval = int.Parse(webConfig.Refund_Interval);
  138. //每天获取退款信息的时间
  139. if (webConfig.Refund_Time.Contains(DateTime.Now.ToString("HH")))
  140. {
  141. commonHelper.autoRefreshRefundState();
  142. }
  143. }
  144. //if (webConfig.Refund_Switch == "1")
  145. //{
  146. // timerGetRefundsData.Interval = int.Parse(webConfig.Refund_Interval);
  147. // //每天获取退款信息的时间
  148. // if (DateTime.Now.ToString("HH:mm") == webConfig.Refund_Time)
  149. // {
  150. // WriteLog(string.Format("退款 | {0} | {1}", DateTime.Now.ToString(), "开始获取退款数据!"));
  151. // SqlConnection sqlCnt = new SqlConnection(conn);
  152. // sqlCnt.Open();
  153. // //按店铺获取退款信息
  154. // string sql = "select * from CE_ErpShop";
  155. // SqlDataAdapter myDataAdapter = new SqlDataAdapter(sql, sqlCnt);
  156. // DataSet myDataSet = new DataSet();
  157. // myDataAdapter.Fill(myDataSet, "Shop");
  158. // DataTable myTable = myDataSet.Tables[0];
  159. // foreach (DataRow Dr in myTable.Rows)
  160. // {
  161. // string shopname = Dr["ShopName"].ToString();
  162. // string sessionKey = Dr["AppSecret"].ToString();
  163. // if (sessionKey == null || sessionKey == "")
  164. // {
  165. // continue;
  166. // }
  167. // DateTime stime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 00:00:00"));
  168. // DateTime etime = DateTime.Parse(DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd 23:59:59"));
  169. // string res = RefundsReceiveGet(sessionKey, stime, etime);
  170. // //判断是否获取有效的退款信息
  171. // if (res == "") return;
  172. // if (res.Contains("error_response"))
  173. // {
  174. // WriteLog(string.Format("退款 | {0} | {1}" , DateTime.Now.ToString(), res));
  175. // continue;
  176. // }
  177. // try
  178. // {
  179. // SiteCore.taoObj.Refunds_receive_get_response_Obj reObj = null;
  180. // res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  181. // reObj = JsonConvert.DeserializeObject<SiteCore.taoObj.Refunds_receive_get_response_Obj>(res);
  182. // List<SiteCore.taoObj.Refunds_receive_get_response_Obj.Refund> reItemList = reObj.refunds_receive_get_response.refunds.refund;
  183. // foreach (SiteCore.taoObj.Refunds_receive_get_response_Obj.Refund item in reItemList)
  184. // {
  185. // //若退款信息已存在则遍历下一条数据
  186. // string RefundExistSQL = string.Format("SELECT * FROM CE_ErpTradeRefund WHERE refund_id = '{0}'", item.refund_id);
  187. // SqlDataAdapter adRefundExist = new SqlDataAdapter(RefundExistSQL, sqlCnt);
  188. // DataSet dsRefundExist = new DataSet();
  189. // adRefundExist.Fill(dsRefundExist, "Refund");
  190. // if (dsRefundExist.Tables[0].Rows.Count > 0)
  191. // continue;
  192. // //插入退款数据
  193. // string RefundInsertSQL = string.Format("INSERT INTO CE_ErpTradeRefund " +
  194. // "(refund_id,tid,oid,created,modified,status,order_status,good_status,payment,refund_fee,refund_phase,reason,describe,buyer_nick,seller_nick,total_fee,has_good_return,RefundState) " +
  195. // "VALUES ('{0}','{1}','{2}','{3}','{4}','{5}'," +
  196. // "'{6}','{7}','{8}','{9}','{10}','{11}'," +
  197. // "'{12}','{13}','{14}','{15}',{16},{17})",
  198. // item.refund_id, item.tid, item.oid, item.created.ToString(), item.modified.ToString(), item.status,
  199. // item.order_status, item.good_status, item.payment, item.refund_fee, item.refund_phase, item.reason,
  200. // item.desc, item.buyer_nick, item.seller_nick, item.total_fee, item.has_good_return ? "1" : "0", 1);
  201. // SqlCommand insertCMD = sqlCnt.CreateCommand(); //创建SqlCommand对象
  202. // insertCMD.CommandType = CommandType.Text;
  203. // insertCMD.CommandText = RefundInsertSQL;
  204. // insertCMD.ExecuteNonQuery();
  205. // insertCMD.CommandText = "insert into CE_ErpTradeLog(tid,OrderState,UserId,OperateTime,Con,AfterSaleState)"
  206. // + string.Format(" Values('{0}',9, 0 ,getdate(),'{1}',0);", item.tid, "退款完成"); ;
  207. // insertCMD.ExecuteNonQuery();
  208. // }
  209. // WriteLog(string.Format("退款 | {0} | {1}", DateTime.Now.ToString(), "结束获取退款数据!"));
  210. // }
  211. // catch (Exception ex)
  212. // {
  213. // WriteLog(string.Format("退款 | {0} | {1}", DateTime.Now.ToString(), ex.Message));
  214. // }
  215. // finally
  216. // {
  217. // if (sqlCnt.State == ConnectionState.Open)
  218. // sqlCnt.Close();
  219. // }
  220. // }
  221. // }
  222. //}
  223. timerGetRefundsData.Enabled = true;
  224. }
  225. /// <summary>
  226. /// 查询退款列表(根据开始结束时间)
  227. /// </summary>
  228. /// <param name="sessionKey"></param>
  229. /// <param name="orderid"></param>
  230. /// <returns></returns>
  231. public static string RefundsReceiveGet(string sessionKey, DateTime stime, DateTime etime)
  232. {
  233. //json参数
  234. var res_obj = new
  235. {
  236. fields = "refund_id,tid,title,buyer_nick,seller_nick,total_fee,status,created,refund_fee,oid,good_status,company_name,sid,payment,reason,desc,has_good_return,modified,order_status,refund_phase",
  237. start_modified = stime,
  238. end_modified = etime
  239. };
  240. string ro_json = JsonConvert.SerializeObject(res_obj);
  241. //post参数
  242. List<string> postLst = new List<string>();
  243. setParmsHead(sessionKey, ref postLst);
  244. postLst.Add("methodName=taobao.refunds.receive.get");
  245. postLst.Add("requestObjectJson=" + HttpUtility.UrlEncode(ro_json));
  246. HttpItem item = new HttpItem()
  247. {
  248. URL = api_url,
  249. Method = "POST",
  250. ContentType = "application/x-www-form-urlencoded",
  251. Postdata = string.Join("&", postLst.ToArray())
  252. };
  253. HttpResult hResult = tb_http.GetHtml(item);
  254. return hResult.Html;
  255. //return html;
  256. }
  257. private static void setParmsHead(string session, ref List<string> lst)
  258. {
  259. lst.Add("action=executeTopApi");
  260. lst.Add("format=1");
  261. lst.Add("SessionKey=" + session);
  262. lst.Add("sign=" + GetSign());
  263. lst.Add("isItemApi=3");
  264. }
  265. public static string GetSign()
  266. {
  267. string code = "";
  268. int sc = DateTimeToUnixTime(DateTime.Now) / 60;
  269. code = Md5(Md5(sc + "1b46af52a8dcaa822b98b1be9d447bb2").ToLower()).ToLower();
  270. code = System.Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(code));
  271. return code;
  272. }
  273. /// <summary>
  274. /// MD5加密
  275. /// </summary>
  276. /// <param name="s"></param>
  277. /// <returns></returns>
  278. private static string Md5(string s)
  279. {
  280. using (var md5 = MD5.Create())
  281. {
  282. var result = md5.ComputeHash(Encoding.Default.GetBytes(s));
  283. var strResult = BitConverter.ToString(result);
  284. return strResult.Replace("-", "").ToUpper();
  285. }
  286. }
  287. public static int DateTimeToUnixTime(DateTime dateTime)
  288. {
  289. return (int)(dateTime - TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1))).TotalSeconds;
  290. }
  291. public static string GetUTF8String2(byte[] buffer)
  292. {
  293. if (buffer == null)
  294. return null;
  295. if (buffer.Length <= 3)
  296. {
  297. return Encoding.UTF8.GetString(buffer);
  298. }
  299. byte[] bomBuffer = new byte[] { 0xef, 0xbb, 0xbf };
  300. if (buffer[0] == bomBuffer[0] && buffer[1] == bomBuffer[1] && buffer[2] == bomBuffer[2])
  301. {
  302. return new UTF8Encoding(false).GetString(buffer, 3, buffer.Length - 3);
  303. }
  304. return Encoding.UTF8.GetString(buffer);
  305. }
  306. #endregion
  307. #region 更新异常订单状态
  308. //初始化更新异常订单状态定时器
  309. private void InitCheckUnusualOrderTimer()
  310. {
  311. timerCheckUnusualOrder = new System.Timers.Timer();
  312. timerCheckUnusualOrder.Interval = BeginInterval;
  313. timerCheckUnusualOrder.Elapsed += new System.Timers.ElapsedEventHandler(CheckUnusualOrder);
  314. timerCheckUnusualOrder.Enabled = true;
  315. }
  316. private void CheckUnusualOrder(object sender, System.Timers.ElapsedEventArgs e)
  317. {
  318. timerCheckUnusualOrder.Enabled = false;
  319. if (webConfig.UnusualOrder_Switch == "1")
  320. {
  321. WriteLog(string.Format("异常 | {0} | {1}", DateTime.Now.ToString(), "开始更新异常订单状态!"));
  322. //定时器轮询间隔(毫秒)
  323. timerCheckUnusualOrder.Interval = int.Parse(webConfig.UnusualOrder_Interval);
  324. SqlConnection sqlCnt = new SqlConnection(conn);
  325. try
  326. {
  327. sqlCnt.Open();
  328. SqlCommand updCMD = sqlCnt.CreateCommand();
  329. //更新设计异常订单状态
  330. string UnusualSQL = webConfig.UnusualOrder_CheckDesignSQL;
  331. if (UnusualSQL != "")
  332. {
  333. updCMD.CommandType = CommandType.Text;
  334. updCMD.CommandText = UnusualSQL;
  335. updCMD.ExecuteNonQuery();
  336. }
  337. //更新下单异常订单状态
  338. UnusualSQL = webConfig.UnusualOrder_CheckPlaceSQL;
  339. if (UnusualSQL != "")
  340. {
  341. updCMD = sqlCnt.CreateCommand();
  342. updCMD.CommandType = CommandType.Text;
  343. updCMD.CommandText = UnusualSQL;
  344. updCMD.ExecuteNonQuery();
  345. }
  346. //更新发货异常订单状态
  347. UnusualSQL = webConfig.UnusualOrder_CheckDeliverySQL;
  348. if (UnusualSQL != "")
  349. {
  350. updCMD = sqlCnt.CreateCommand();
  351. updCMD.CommandType = CommandType.Text;
  352. updCMD.CommandText = UnusualSQL;
  353. updCMD.ExecuteNonQuery();
  354. }
  355. WriteLog(string.Format("异常 | {0} | {1}", DateTime.Now.ToString(), "结束更新异常订单状态!"));
  356. }
  357. catch (Exception ed)
  358. {
  359. WriteLog(string.Format("异常 | {0} | {1}", DateTime.Now.ToString(), ed.Message));
  360. }
  361. finally
  362. {
  363. if (sqlCnt.State == ConnectionState.Open)
  364. sqlCnt.Close();
  365. }
  366. }
  367. timerCheckUnusualOrder.Enabled = true;
  368. }
  369. #endregion
  370. #region 自动派单
  371. private void InitAutoDispatchTimer()
  372. {
  373. timerAutoDispatch = new System.Timers.Timer();
  374. timerAutoDispatch.Interval = BeginInterval;
  375. timerAutoDispatch.Elapsed += new System.Timers.ElapsedEventHandler(AutoDispatch);
  376. timerAutoDispatch.Enabled = true;
  377. }
  378. private void AutoDispatch(object sender, System.Timers.ElapsedEventArgs e)
  379. {
  380. timerAutoDispatch.Enabled = false;
  381. if (webConfig.Dispatch_Switch == "1")
  382. {
  383. //定时器轮询间隔(毫秒)
  384. timerAutoDispatch.Interval = int.Parse(webConfig.Dispatch_Interval);
  385. commonHelper.DoAutoDispatch2(conn);
  386. }
  387. timerAutoDispatch.Enabled = true;
  388. }
  389. #endregion
  390. #region 每日清除数据
  391. private void InitDayClearTimer()
  392. {
  393. timerDayClear = new System.Timers.Timer();
  394. timerDayClear.Interval = BeginInterval;
  395. timerDayClear.Elapsed += new System.Timers.ElapsedEventHandler(DayClear);
  396. timerDayClear.Enabled = true;
  397. }
  398. private void DayClear(object sender, System.Timers.ElapsedEventArgs e)
  399. {
  400. timerDayClear.Enabled = false;
  401. if (webConfig.DayClear_Switch == "1")
  402. {
  403. //定时器轮询间隔(毫秒)
  404. timerDayClear.Interval = int.Parse(webConfig.DayClear_Interval);
  405. //当前时间在自动派单时间列表内
  406. if (webConfig.DayClear_Time.Contains(DateTime.Now.ToString("HH:mm")))
  407. {
  408. WriteLog(string.Format("清除 | {0} | {1}", DateTime.Now.ToString(), "开始自动清除数据!"));
  409. SqlConnection sqlCnt = new SqlConnection(conn);
  410. try
  411. {
  412. sqlCnt.Open();
  413. SqlCommand updCMD = sqlCnt.CreateCommand();
  414. updCMD.CommandType = CommandType.Text;
  415. updCMD.CommandText = webConfig.DayClear_ClearSQL;
  416. updCMD.ExecuteNonQuery();
  417. WriteLog(string.Format("清除 | {0} | {1}", DateTime.Now.ToString(), "结束自动清除数据!"));
  418. }
  419. catch (Exception ed)
  420. {
  421. WriteLog(string.Format("清除 | {0} | {1}", DateTime.Now.ToString(), ed.Message));
  422. }
  423. finally
  424. {
  425. if (sqlCnt.State == ConnectionState.Open)
  426. sqlCnt.Close();
  427. }
  428. }
  429. }
  430. timerDayClear.Enabled = true;
  431. }
  432. #endregion
  433. void global_elapsed(object state)
  434. {
  435. try
  436. {
  437. DateTime curTime = DateTime.Now;
  438. int day = curTime.Day;
  439. int hour = curTime.Hour;
  440. int minute = curTime.Minute;
  441. if (webConfig.GetTmc == "1")
  442. {
  443. taobaoTmcTest.getInfo();
  444. }
  445. }
  446. catch (Exception ex)
  447. {
  448. XLog.SaveLog(0, ex.Message);
  449. }
  450. }
  451. void Application_End(object sender, EventArgs e)
  452. {
  453. // 在应用程序关闭时运行的代码
  454. // 解决应用池回收问题
  455. //System.Threading.Thread.Sleep(5000);
  456. ////http://localhost:911/login.aspx
  457. //string strUrl = CommonHelper.GetPrePath() + "login.aspx";
  458. //System.Net.HttpWebRequest _HttpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strUrl);
  459. //System.Net.HttpWebResponse _HttpWebResponse = (System.Net.HttpWebResponse)_HttpWebRequest.GetResponse();
  460. //System.IO.Stream _Stream = _HttpWebResponse.GetResponseStream();//得到回写的字节流
  461. }
  462. void Application_BeginRequest(Object sender, EventArgs e)
  463. {
  464. //if (CommonHelper.CheckUrlQuerySqlStr())
  465. //{
  466. // Response.Redirect(CommonHelper.GetPrePath() + "ErrorPage.htm");
  467. // Response.End();
  468. //}
  469. }
  470. void Application_Error(object sender, EventArgs e)
  471. {
  472. // Code that runs when an unhandled error occurs
  473. //if (config.Instance.Site.SpiderIp.Contains(CommonHelper.ClientIP))return;
  474. //SyLog.WriteLog(Server.GetLastError());
  475. }
  476. void Session_Start(object sender, EventArgs e)
  477. {
  478. // Code that runs when a new session is started
  479. }
  480. void Session_End(object sender, EventArgs e)
  481. {
  482. // Code that runs when a session ends.
  483. // Note: The Session_End event is raised only when the sessionstate mode
  484. // is set to InProc in the Web.config file. If session mode is set to StateServer
  485. // or SQLServer, the event is not raised.
  486. }
  487. //写入日志
  488. private void WriteLog(string LogText)
  489. {
  490. string sDir = System.IO.Path.GetTempPath() + @"Log\" + DateTime.Now.ToString("yyyyMM");
  491. if (!Directory.Exists(sDir))
  492. Directory.CreateDirectory(sDir);
  493. using (StreamWriter sw = new StreamWriter(sDir + @"\Log_" + DateTime.Now.ToString("dd") + ".txt", true, Encoding.UTF8))
  494. {
  495. sw.Write(LogText + System.Environment.NewLine);
  496. }
  497. }
  498. </script>