7 changed files with 372 additions and 0 deletions
@ -0,0 +1,25 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 17 |
|||
VisualStudioVersion = 17.14.36202.13 d17.14 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProcessManage", "ProcessManage\ProcessManage.csproj", "{C23B5C86-638A-431E-939B-591CDF8CF6D3}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{C23B5C86-638A-431E-939B-591CDF8CF6D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{C23B5C86-638A-431E-939B-591CDF8CF6D3}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{C23B5C86-638A-431E-939B-591CDF8CF6D3}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{C23B5C86-638A-431E-939B-591CDF8CF6D3}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {27BEF72D-8965-44C7-A72E-C25F919388E2} |
|||
EndGlobalSection |
|||
EndGlobal |
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8" ?> |
|||
<configuration> |
|||
<startup> |
|||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> |
|||
</startup> |
|||
</configuration> |
@ -0,0 +1,52 @@ |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
|
|||
namespace ProcessManage |
|||
{ |
|||
internal class IniFile |
|||
{ |
|||
public class IniFiles |
|||
{ |
|||
public string path; |
|||
[DllImport("kernel32")] //返回0表示失败,非0为成功
|
|||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); |
|||
[DllImport("kernel32")] //返回取得字符串缓冲区的长度
|
|||
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); |
|||
/// <summary>
|
|||
/// 保存ini文件的路径
|
|||
/// 调用示例:var ini = IniFiles("C:\file.ini");
|
|||
/// </summary>
|
|||
/// <param name="INIPath"></param>
|
|||
public IniFiles(string iniPath) |
|||
{ |
|||
this.path = iniPath; |
|||
} |
|||
/// <summary>
|
|||
/// 写Ini文件
|
|||
/// 调用示例:ini.IniWritevalue("Server","name","localhost");
|
|||
/// </summary>
|
|||
/// <param name="Section">[缓冲区]</param>
|
|||
/// <param name="Key">键</param>
|
|||
/// <param name="value">值</param>
|
|||
public void IniWritevalue(string Section, string Key, string value) |
|||
{ |
|||
WritePrivateProfileString(Section, Key, value, this.path); |
|||
} |
|||
/// <summary>
|
|||
/// 读Ini文件
|
|||
/// 调用示例:ini.IniWritevalue("Server","name");
|
|||
/// </summary>
|
|||
/// <param name="Section">[缓冲区]</param>
|
|||
/// <param name="Key">键</param>
|
|||
/// <returns>值</returns>
|
|||
public string IniReadvalue(string Section, string Key) |
|||
{ |
|||
StringBuilder temp = new StringBuilder(255); |
|||
|
|||
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path); |
|||
return temp.ToString(); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,118 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data; |
|||
using System.IO; |
|||
|
|||
namespace ProcessManage |
|||
{ |
|||
public class LogGing |
|||
{ |
|||
public static void LogGingDATA(string dat) |
|||
{ |
|||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
|||
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";//日志文件
|
|||
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:"; |
|||
|
|||
if (Directory.Exists(logpath))//检查日志路径
|
|||
{ |
|||
if (!File.Exists(logPath))//检查日志文件并写入启动日志
|
|||
{ |
|||
FileStream fs = new FileStream(logPath, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
|||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
wr.WriteLine(Log_time + dat); |
|||
wr.Close(); |
|||
} |
|||
else |
|||
{ |
|||
try |
|||
{ |
|||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); |
|||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
wr.WriteLine(Log_time + dat); |
|||
wr.Close(); |
|||
} |
|||
catch { } |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(logpath); |
|||
directoryInfo.Create();//创建日志路径
|
|||
} |
|||
} |
|||
public static void ERRDATA(System.Exception dat) |
|||
{ |
|||
string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); |
|||
string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录
|
|||
// string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
|||
// System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录
|
|||
string log_path = logpath + "\\ERR" + Log_time + ".txt"; |
|||
string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
|||
if (Directory.Exists(logpath))//检查日志路径
|
|||
{ |
|||
if (!File.Exists(log_path))//检查文件并写入
|
|||
{ |
|||
// FileStream fs = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建文件
|
|||
// StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
// wr.Close();
|
|||
FileStream fil = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
|||
StreamWriter wfil = new StreamWriter(fil);//创建文件
|
|||
wfil.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString()); |
|||
wfil.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.Source.ToString() + Environment.NewLine.ToString()); |
|||
wfil.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString()); |
|||
wfil.WriteLine("[" + Log_timehms + "];[Error area] ||" + dat.StackTrace.ToString()); |
|||
wfil.Close(); |
|||
} |
|||
else |
|||
{ |
|||
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
|
|||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
wr.WriteLine("[" + Log_timehms + "];[Error] ||" + Environment.NewLine.ToString()); |
|||
wr.WriteLine("[" + Log_timehms + "];[Error source] ||" + dat.ToString() + Environment.NewLine.ToString()); |
|||
wr.WriteLine("[" + Log_timehms + "];[Error message] ||" + dat.Message.ToString() + Environment.NewLine.ToString()); |
|||
wr.WriteLine("[" + Log_timehms + "];[Error area] ||" + dat.ToString()); |
|||
wr.Close(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(logpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
} |
|||
public static void ExchangeDATA(string dat) |
|||
{ |
|||
string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); |
|||
string logpath = System.Environment.CurrentDirectory + "\\Exchange";//日志文件目录
|
|||
// string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
|
|||
// System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录
|
|||
string log_path = logpath + "\\Exchange" + Log_time + ".txt"; |
|||
string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
|||
if (Directory.Exists(logpath))//检查日志路径
|
|||
{ |
|||
if (!File.Exists(log_path))//检查文件并写入
|
|||
{ |
|||
// FileStream fs = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建文件
|
|||
// StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
// wr.Close();
|
|||
FileStream fil = new FileStream(log_path, FileMode.CreateNew, FileAccess.Write);//创建写入文件
|
|||
StreamWriter wfil = new StreamWriter(fil);//创建文件
|
|||
wfil.WriteLine("[" + Log_timehms + "];[Exchange] ||" + dat); |
|||
wfil.Close(); |
|||
} |
|||
else |
|||
{ |
|||
FileStream fs = new FileStream(log_path, FileMode.Append, FileAccess.Write);//创建写入文件
|
|||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|||
wr.WriteLine("[" + Log_timehms + "];[Exchange] ||" + dat); |
|||
wr.Close(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(logpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,55 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{C23B5C86-638A-431E-939B-591CDF8CF6D3}</ProjectGuid> |
|||
<OutputType>Exe</OutputType> |
|||
<RootNamespace>ProcessManage</RootNamespace> |
|||
<AssemblyName>ProcessManage</AssemblyName> |
|||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> |
|||
<Deterministic>true</Deterministic> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Net.Http" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="IniFile.cs" /> |
|||
<Compile Include="LogGing.cs" /> |
|||
<Compile Include="Program.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="App.config" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
</Project> |
@ -0,0 +1,83 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data; |
|||
using System.Data.SqlClient; |
|||
using System.Linq; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace ProcessManage |
|||
{ |
|||
internal class Program |
|||
{ |
|||
private static IniFile.IniFiles Configini = new IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "ProcessManageConfigini.ini"); |
|||
private static string SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
|||
private static string SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2"); |
|||
private static string SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3"); |
|||
private static string SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4"); |
|||
private static string SQLPASWORD = Configini.IniReadvalue("SQL_SERVER", "SQL5"); |
|||
private static DataTable DyelotsBulkedRecipe = new DataTable(); |
|||
private static Timer _timer; |
|||
private static int Count = 0; |
|||
private static readonly int _intervalMs = int.Parse( Configini.IniReadvalue("SQL_SERVER", "SQL6")); |
|||
static void Main(string[] args) |
|||
{ |
|||
Console.WriteLine("Process选择功能启动"); |
|||
_timer = new Timer( |
|||
callback: EXTask, |
|||
state: null, |
|||
dueTime: 100, |
|||
period: Timeout.Infinite); |
|||
|
|||
Console.ReadKey();//等待退出
|
|||
|
|||
_timer?.Dispose();//清理
|
|||
Console.WriteLine("程序退出"); |
|||
} |
|||
|
|||
private static void EXTask(object state) |
|||
{ |
|||
string Connstr_SC; |
|||
string DyelotsBulkedRecipe_sql = "SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Created > '" |
|||
+ DateTime.Now.AddDays(-1).ToString("yyyy/MM/dd") + "' AND Process IS NULL"; |
|||
try |
|||
{ |
|||
DyelotsBulkedRecipe.Clear(); |
|||
|
|||
if (SQMOD == "Windows Authentication") |
|||
{ |
|||
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI"; |
|||
} |
|||
else |
|||
{ |
|||
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";User ID=" + SQLUSER + ";Password=" + SQLPASWORD; |
|||
} |
|||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); |
|||
conn_SC.OpenAsync(); //连接数据库
|
|||
SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC); |
|||
conn_SC.Close(); |
|||
DyelotsBulkedRecipe_.Fill(DyelotsBulkedRecipe); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Console.Write("\n"+DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss")+$"转换{Count}条"); |
|||
Count = 0; |
|||
} |
|||
catch (Exception ex) |
|||
{//错误处理
|
|||
LogGing.ERRDATA(ex); |
|||
Console.Write(ex.ToString()); |
|||
} |
|||
finally |
|||
{ |
|||
_timer.Change( |
|||
dueTime: _intervalMs, |
|||
period: Timeout.Infinite);//设定下次触发
|
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,33 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// 有关程序集的一般信息由以下
|
|||
// 控制。更改这些特性值可修改
|
|||
// 与程序集关联的信息。
|
|||
[assembly: AssemblyTitle("ProcessManage")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("ProcessManage")] |
|||
[assembly: AssemblyCopyright("Copyright © 2025")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
|||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
|||
//请将此类型的 ComVisible 特性设置为 true。
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
|||
[assembly: Guid("c23b5c86-638a-431e-939b-591cdf8cf6d3")] |
|||
|
|||
// 程序集的版本信息由下列四个值组成:
|
|||
//
|
|||
// 主版本
|
|||
// 次版本
|
|||
// 生成号
|
|||
// 修订号
|
|||
//
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Reference in new issue