Global.asax 23 KB

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