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 5f422d2..effc878 100644 Binary files a/其他程序/Lskj.TxtFileRead/Program.cs and b/其他程序/Lskj.TxtFileRead/Program.cs differ