From af54d4cf12953c7b7ca74b178d2c0be5597efd3a Mon Sep 17 00:00:00 2001 From: cyf Date: Tue, 29 Apr 2025 06:15:36 +0000 Subject: [PATCH] SVN r513 SVN-Revision: r513 --- 其他程序/Lskj.TxtFileRead/FrmMain.cs | 74 +++++++++++++++------------ 其他程序/Lskj.TxtFileRead/Program.cs | Bin 478 -> 511 bytes 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/其他程序/Lskj.TxtFileRead/FrmMain.cs b/其他程序/Lskj.TxtFileRead/FrmMain.cs index 4074407..cd4f366 100644 --- a/其他程序/Lskj.TxtFileRead/FrmMain.cs +++ b/其他程序/Lskj.TxtFileRead/FrmMain.cs @@ -12,6 +12,7 @@ using System.Threading; using Microsoft.Win32; using System.Collections; using System.Text.RegularExpressions; +using System.Timers; namespace Lskj.TxtFileRead { @@ -105,6 +106,8 @@ namespace Lskj.TxtFileRead /// private bool activate = false; + public System.Timers.Timer timer2 = new System.Timers.Timer(); + public FrmMain() { InitializeComponent(); @@ -168,7 +171,7 @@ namespace Lskj.TxtFileRead //ftpPrefix = "BOSS2GZSCM_DEVNO_RESTASK_"; //start(); - //InsertData(downloadPath + "\\BOSS2GZSCM_DEVNO_RESTASK_20240302.txt"); + //InsertData(downloadPath + "\\BOSS2GZSCM_DEVNO_RESTASK_20240514.txt"); //InsertData(downloadPath + "\\BOSS2GZSCM_DEVNO_TASKSEND_20230922.txt"); @@ -192,10 +195,29 @@ namespace Lskj.TxtFileRead //if (lines.Count > 30) // lines.RemoveRange(0, prefixAndSql.Count);//删除当前配置的sql条数 //File.WriteAllLines(txtFilePath, lines.ToArray()); - //InitTimer();//2023-10-11改成循环,不使用计时器 + + bool RunAutomatically = IniHelper.Read(iniFile, "RunAutomatically").Equals("1"); + if (RunAutomatically) + { + this.btnSave.Enabled = false; + this.timer2.Elapsed += new System.Timers.ElapsedEventHandler(SelfStarting); + this.timer2.Interval = 2000; + this.timer2.Enabled = true; + this.timer2.Start(); + } } + private void SelfStarting(object sender, ElapsedEventArgs e) + { + this.timer2.Enabled = false; + this.OnSaveClick(null, null); + } + + + + + /// /// 初始化时间设置 @@ -333,6 +355,21 @@ namespace Lskj.TxtFileRead if (dateTime < CurrentTime)//当前时间大于配置时间就执行 { + RefreshLog(DateTime.Now + ":正在连接数据库\r\n"); + if (DBConfig.Instance.CreateConnection()) + { + RefreshLog(DateTime.Now + ":数据库连接成功\r\n"); + } + else + { + RefreshLog(DateTime.Now + ":数据库连接失败\r\n"); + return; + } + + //for (int j = 0; j < ftpPrefixs.Count; j++) + //{ + //} + foreach (string item in ftpPrefixs) { RefreshLog(Time + " : " + item + "\r\n"); @@ -447,7 +484,7 @@ namespace Lskj.TxtFileRead DBConfig.Instance.ServerName = serverName; show_txt.Text = ""; - + RefreshLog(DateTime.Now + ":开始启动\r\n"); if (DBConfig.Instance.CreateConnection()) { if (!activate) @@ -901,33 +938,4 @@ namespace Lskj.TxtFileRead { string field = item.Replace("{", "").Replace("}", ""); string value = row.Table.Columns.Contains(field) ? row[field] + "" : item; - value = value.Replace("'", "''"); - param = param.Replace(item, value); - } - return param; - } - - /// - /// 说明:获取sql语句中替换 - /// 创建人:龚宇超 - /// 创建日期:2017-09-04 - /// 修改人: - /// 修改日期: - /// 修改备注: - /// 版本:1.0 - /// - /// List<System.String>. - public static List GetParamFields(string defaultValue) - { - List list = new List(); - Regex regex = new Regex("{([^{])+}"); - MatchCollection mcs = regex.Matches(defaultValue); - foreach (Match item in mcs) - { - if (list.IndexOf(item.Value) == -1) - list.Add(item.Value); - } - return list; - } - } -} + value = value. \ No newline at end of file diff --git a/其他程序/Lskj.TxtFileRead/Program.cs b/其他程序/Lskj.TxtFileRead/Program.cs index 5f422d28e736cedc11235c0c1816f7035ea40033..effc878632508bdbf651607160b79bb4f33ea151 100644 GIT binary patch literal 511 zcmV2Wx$cNAL5k$!N^4axLQxBI3cm1bP|Av*0_IJD0p zqECb$M0>(7sP$vI#&qgdtJQm^WH^_+)@v9L@khxlQKrID*$f;-sniCvi&saG%=<7b zqx$6A%*+dP%Lh#JkRLu(wV{COVF?5QqjnFismA4V^cJ6bC76=09;=hdg}kkOX2_)k zM)!^Wx&K59gBfe>@v!ApnE7_$o_-1K(~}KDa3q+pd3=B%_?&b3mZG0^Oca%tRM6YG zFj03wXhp{ci?z`GJj0v(b$@AuCW3<>n|9db5iZ{H`Ur-ZmN1$N+?lX>jwwo3mj@~a zg~(f43lj4`ge2u?Vd!T~+LQtpQ#i#NDvi@}<8GQpLayEVU966gG1(w=FaAMS_rV8` zOHJT!?2_`-m!LyLbtm+uDg}P3KmyKNfz_~E4MvWzffF_x=3bq+cVnR0=zmq>b B0OJ4v literal 478 zcmaKou}%U(5Qh7GiY<@k?g1bs1jPmu!(Fs67VF)BtGl!3&YnOFi6L59&`{YL6CXjL z@L}|FrLW)tiinBR&HUd#^JhM0uNg_~@^C;7bd{}le#0mQv6BYL-vtCK;|-!E@nU0i zC^0cT@|(tLsxpQ`1EnGc-lFp}KkB=tRL};Iuq(#PA}5@Td8`Bx-?ye~g7f#Qu1CMnTJUGXQ5e;uQ(I;^ zUZG!cE{#n1o{;EOR?<(P`T2U9DjApA4f;DMP81wS%7hBtKmmD`>dLoChu|7Ur=_(t qMbLL`z@+>xcDJD;GUdFEPz3*MXlLjl^mx