SVN-Revision: r513
This commit is contained in:
cyf
2025-04-29 06:15:36 +00:00
parent f5140c98f2
commit af54d4cf12
2 changed files with 41 additions and 33 deletions
+41 -33
View File
@@ -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
/// </summary>
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);
}
/// <summary>
/// 初始化时间设置
@@ -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;
}
/// <summary>
/// <para>说明:获取sql语句中替换</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2017-09-04 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <returns>List&lt;System.String&gt;.</returns>
public static List<string> GetParamFields(string defaultValue)
{
List<string> list = new List<string>();
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.
Binary file not shown.