From 6fe02a16e55f17e45a3997171e1b2284d45af25b Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 15 五月 2025 08:32:14 +0800 Subject: [PATCH] 提交 --- CY_ECommercePlatform/CY.WebForm/Global.asax.cs | 209 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 196 insertions(+), 13 deletions(-) diff --git a/CY_ECommercePlatform/CY.WebForm/Global.asax.cs b/CY_ECommercePlatform/CY.WebForm/Global.asax.cs index 943e38a..ffb0dd6 100644 --- a/CY_ECommercePlatform/CY.WebForm/Global.asax.cs +++ b/CY_ECommercePlatform/CY.WebForm/Global.asax.cs @@ -24,7 +24,7 @@ log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo(Server.MapPath("~/config/log4net.config"))); // 鍦ㄥ簲鐢ㄧ▼搴忓惎鍔ㄦ椂杩愯鐨勪唬鐮� TimeTaskHelper.Instance().ExecuteTask += new System.Timers.ElapsedEventHandler(Global_ExecuteTask); - TimeTaskHelper.Instance().Interval = 1000*10;//琛ㄧず闂撮殧 1涓皬鏃� + TimeTaskHelper.Instance().Interval = 1000*3000;//琛ㄧず闂撮殧 1涓皬鏃� TimeTaskHelper.Instance().Start(); } void Global_ExecuteTask(object sender, System.Timers.ElapsedEventArgs e) @@ -33,11 +33,15 @@ //杩欓噷鎵ц瀹氭椂浠诲姟 DateTime time = DateTime.Now; - if (time.ToString("ddd HH") == "鍛ㄤ竴 00") + #region 鏈畬缁撳鎴蜂緥琛岀疆浣� + + + var data = time.ToString("ddd HH"); + if (data == "鍛ㄤ竴 1") { Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [NeedWiHu] = 'true' WHERE[Shifouwanjie] = 2"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [NeedWiHu] = 'true' WHERE[Shifouwanjie] = 2"; try { @@ -67,12 +71,17 @@ } + + #endregion + #region 宸插畬缁撳鎴风淮鎶ょ疆浣� + + string strtime = time.ToString("MM dd HH"); if (strtime == "01 01 01" || strtime == "04 01 01" || strtime == "07 01 01" || strtime == "10 01 01") { //1 銆�4銆�7銆�10鏈� 1鍙�1鐐癸紝鍒锋柊 宸插畬缁撹鍗曠殑缁存姢鎻愰啋 Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [NeedWiHu] = 'true' WHERE[Shifouwanjie] = 1"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [NeedWiHu] = 'true' WHERE[Shifouwanjie] = 1"; try { @@ -94,13 +103,17 @@ DC.Connection.Close(); } } + #endregion + #region 鑺傛棩鎻愰啋缃綅 + + ///浠ヤ笅涓鸿妭鏃ユ彁閱� - time.AddDays(20); + var date20days= time.AddDays(20); ChineseLunisolarCalendar chineseLunisolarCalendar = new ChineseLunisolarCalendar(); - int lyear = chineseLunisolarCalendar.GetYear(time); - int lmonth = chineseLunisolarCalendar.GetMonth(time); - int lday = chineseLunisolarCalendar.GetDayOfMonth(time); + int lyear = chineseLunisolarCalendar.GetYear(date20days); + int lmonth = chineseLunisolarCalendar.GetMonth(date20days); + int lday = chineseLunisolarCalendar.GetDayOfMonth(date20days); //鑾峰彇闂版湀锛屻��0銆�鍒欒〃绀烘病鏈夐棸鏈� int leapMonth = chineseLunisolarCalendar.GetLeapMonth(lyear); @@ -109,7 +122,7 @@ { Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [[JieJiaRiWiHu]] = 'true'"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'true'"; try { @@ -140,7 +153,7 @@ { //涓鑺傛彁閱� Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [[JieJiaRiWiHu]] = 'true'"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'true'"; try { @@ -168,7 +181,7 @@ { //绔崍鑺� Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [[JieJiaRiWiHu]] = 'true'"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'true'"; try { @@ -203,7 +216,7 @@ { //涓鑺傛彁閱� Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [[JieJiaRiWiHu]] = 'true'"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'true'"; try { @@ -234,7 +247,7 @@ { //绔崍鑺� Database DC = new Database(); - string sqlStr = "USE [ECTEST] UPDATE[dbo].[OA_CorporateClients] SET [[JieJiaRiWiHu]] = 'true'"; + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'true'"; try { @@ -258,6 +271,176 @@ } } + #endregion + #region 鑺傛棩鎻愰啋杩囨湡缃綅鍙栨秷 + ///浠ヤ笅涓鸿妭鏃ユ彁閱� + + + ChineseLunisolarCalendar chineseLunisolarCalendar2 = new ChineseLunisolarCalendar(); + lyear = chineseLunisolarCalendar2.GetYear(time); + lmonth = chineseLunisolarCalendar2.GetMonth(time); + lday = chineseLunisolarCalendar2.GetDayOfMonth(time); + //鑾峰彇闂版湀锛屻��0銆�鍒欒〃绀烘病鏈夐棸鏈� + leapMonth = chineseLunisolarCalendar.GetLeapMonth(lyear); + + + if (lmonth == 1 && lday == 1 && time.Hour == 1) + { + + Database DC = new Database(); + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false'"; + + try + { + SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); + //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); + int a = myCmd.ExecuteNonQuery(); + //myDa.Dispose(); + + + } + catch (Exception ee) + { + new Log4NetAdapter().Log("鏄ヨ妭璁剧疆鎻愰啋閿欒 閿欒锛�" + ee.Message); + + } + finally + { + if (DC.Connection.State != System.Data.ConnectionState.Closed) + DC.Connection.Close(); + } + + //鏄ヨ妭鎻愰啋 + } + + if (leapMonth == 0) + { + //娌℃湁闂版湀 + if (lmonth == 8 && lday == 15 && time.Hour == 1) + { + //涓鑺傛彁閱� + Database DC = new Database(); + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false'"; + + try + { + SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); + //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); + int a = myCmd.ExecuteNonQuery(); + //myDa.Dispose(); + + + } + catch (Exception ee) + { + new Log4NetAdapter().Log("涓鑺傛彁閱掗敊璇� 閿欒锛�" + ee.Message); + + } + finally + { + if (DC.Connection.State != System.Data.ConnectionState.Closed) + DC.Connection.Close(); + } + + } + + if (lmonth == 5 && lday == 5 && time.Hour == 1) + { + //绔崍鑺� + Database DC = new Database(); + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false'"; + + try + { + SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); + //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); + int a = myCmd.ExecuteNonQuery(); + //myDa.Dispose(); + + + } + catch (Exception ee) + { + new Log4NetAdapter().Log("绔崍鑺傝缃彁閱掗敊璇� 閿欒锛�" + ee.Message); + + } + finally + { + if (DC.Connection.State != System.Data.ConnectionState.Closed) + DC.Connection.Close(); + } + + } + } + else + { + //鏈夐棸鏈� + + int ms = 8; + if (leapMonth < 8) + ms++; + if (lmonth == ms && lday == 15 && time.Hour == 1) + { + //涓鑺傛彁閱� + Database DC = new Database(); + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false'"; + + try + { + SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); + //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); + int a = myCmd.ExecuteNonQuery(); + //myDa.Dispose(); + + + } + catch (Exception ee) + { + new Log4NetAdapter().Log("涓鑺傝缃彁閱掗敊璇� 閿欒锛�" + ee.Message); + + } + finally + { + if (DC.Connection.State != System.Data.ConnectionState.Closed) + DC.Connection.Close(); + } + + } + + ms = 5; + if (leapMonth < 5) + ms++; + if (lmonth == ms && lday == 5 && time.Hour == 1) + { + //绔崍鑺� + Database DC = new Database(); + string sqlStr = " UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false'"; + + try + { + SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection); + //SqlDataAdapter myDa = new SqlDataAdapter(myCmd); + int a = myCmd.ExecuteNonQuery(); + //myDa.Dispose(); + + + } + catch (Exception ee) + { + new Log4NetAdapter().Log("绔崍鑺傝缃彁閱掗敊璇� 閿欒锛�" + ee.Message); + + } + finally + { + if (DC.Connection.State != System.Data.ConnectionState.Closed) + DC.Connection.Close(); + } + + } + } + + + #endregion } -- Gitblit v1.9.1