parent
e34633edea
commit
3aace68789
|
@ -1,6 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||||
</startup>
|
</startup>
|
||||||
</configuration>
|
</configuration>
|
|
@ -11,12 +11,12 @@ namespace GeneratorCode.Configure
|
||||||
{
|
{
|
||||||
public static class NConfig
|
public static class NConfig
|
||||||
{
|
{
|
||||||
private static string _cfgFileName = @".\config.ini";
|
|
||||||
|
|
||||||
private static IniData _cfgData = null;
|
|
||||||
|
|
||||||
public delegate void ConfigChangedHandle();
|
public delegate void ConfigChangedHandle();
|
||||||
|
|
||||||
|
private static readonly string _cfgFileName = @".\config.ini";
|
||||||
|
|
||||||
|
private static IniData _cfgData;
|
||||||
|
|
||||||
public static event ConfigChangedHandle OnConfigChanged;
|
public static event ConfigChangedHandle OnConfigChanged;
|
||||||
|
|
||||||
private static void ConfigChanged()
|
private static void ConfigChanged()
|
||||||
|
@ -35,7 +35,7 @@ namespace GeneratorCode.Configure
|
||||||
ws.WriteLine("; 应用程序配置文件\n");
|
ws.WriteLine("; 应用程序配置文件\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
FileIniDataParser iniPraser = new FileIniDataParser();
|
var iniPraser = new FileIniDataParser();
|
||||||
iniPraser.Parser.Configuration.CommentString = ";";
|
iniPraser.Parser.Configuration.CommentString = ";";
|
||||||
_cfgData = iniPraser.ReadFile(_cfgFileName);
|
_cfgData = iniPraser.ReadFile(_cfgFileName);
|
||||||
//Trace.WriteLine(_cfgData);
|
//Trace.WriteLine(_cfgData);
|
||||||
|
@ -50,17 +50,17 @@ namespace GeneratorCode.Configure
|
||||||
{
|
{
|
||||||
var cfgTask = new List<string>();
|
var cfgTask = new List<string>();
|
||||||
var appPath = Process.GetCurrentProcess().MainModule.FileName;
|
var appPath = Process.GetCurrentProcess().MainModule.FileName;
|
||||||
|
|
||||||
//Trace.WriteLine("Application: " + appPath);
|
//Trace.WriteLine("Application: " + appPath);
|
||||||
//Trace.WriteLine("Directory: " + Path.GetDirectoryName(appPath));
|
//Trace.WriteLine("Directory: " + Path.GetDirectoryName(appPath));
|
||||||
//Trace.WriteLine("File: " + Path.GetFileName(appPath));
|
//Trace.WriteLine("File: " + Path.GetFileName(appPath));
|
||||||
|
|
||||||
var fw = new FileSystemWatcher()
|
var fw = new FileSystemWatcher
|
||||||
{
|
{
|
||||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite,
|
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite,
|
||||||
Filter = _cfgFileName,
|
Filter = _cfgFileName,
|
||||||
Path = Path.GetDirectoryName(appPath),
|
Path = Path.GetDirectoryName(appPath),
|
||||||
IncludeSubdirectories = false,
|
IncludeSubdirectories = false
|
||||||
};
|
};
|
||||||
|
|
||||||
fw.Changed += (sender, e) =>
|
fw.Changed += (sender, e) =>
|
||||||
|
@ -99,20 +99,17 @@ namespace GeneratorCode.Configure
|
||||||
{
|
{
|
||||||
var ret = defValue;
|
var ret = defValue;
|
||||||
|
|
||||||
if (_cfgData.Equals(null))
|
if (_cfgData.Equals(null)) return ret;
|
||||||
{
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ret = (T) Convert.ChangeType(_cfgData[secName][keyName], typeof(T));
|
ret = (T) Convert.ChangeType(_cfgData[secName][keyName], typeof(T));
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message);
|
Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message);
|
||||||
ret = defValue;
|
ret = defValue;
|
||||||
throw(e);
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Configure\NConfig.cs" />
|
<Compile Include="Configure\NConfig.cs" />
|
||||||
<Compile Include="Logs\NLog.cs" />
|
<Compile Include="Logs\NLog.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="MainCode.cs" />
|
||||||
<Compile Include="Properties\Annotations.cs" />
|
<Compile Include="Properties\Annotations.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="TmatrixSDK\OIDPublishImageGenerator.cs" />
|
<Compile Include="TmatrixSDK\OIDPublishImageGenerator.cs" />
|
||||||
|
|
|
@ -29,10 +29,9 @@ namespace GeneratorCode.Logs
|
||||||
|
|
||||||
public class NLogConfig
|
public class NLogConfig
|
||||||
{
|
{
|
||||||
private object _cfgLock = new object();
|
|
||||||
public delegate void LogCfgChangedHandle();
|
public delegate void LogCfgChangedHandle();
|
||||||
|
|
||||||
public static event LogCfgChangedHandle OnLogCfgChanged;
|
private readonly object _cfgLock = new object();
|
||||||
|
|
||||||
public NLogConfig()
|
public NLogConfig()
|
||||||
{
|
{
|
||||||
|
@ -40,11 +39,6 @@ namespace GeneratorCode.Logs
|
||||||
NConfig.OnConfigChanged += () => { LogCfgChanged(); };
|
NConfig.OnConfigChanged += () => { LogCfgChanged(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void LogCfgChanged()
|
|
||||||
{
|
|
||||||
OnLogCfgChanged?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool LogEnable { get; set; }
|
public bool LogEnable { get; set; }
|
||||||
public NLogLevel LogLevel { get; set; }
|
public NLogLevel LogLevel { get; set; }
|
||||||
public NLogLevel DefaultLevel { get; set; }
|
public NLogLevel DefaultLevel { get; set; }
|
||||||
|
@ -78,13 +72,20 @@ namespace GeneratorCode.Logs
|
||||||
public bool RoolbackFile { get; set; }
|
public bool RoolbackFile { get; set; }
|
||||||
public int MaxFileNum { get; set; }
|
public int MaxFileNum { get; set; }
|
||||||
|
|
||||||
|
public static event LogCfgChangedHandle OnLogCfgChanged;
|
||||||
|
|
||||||
|
protected static void LogCfgChanged()
|
||||||
|
{
|
||||||
|
OnLogCfgChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
public void LogConfig()
|
public void LogConfig()
|
||||||
{
|
{
|
||||||
lock (_cfgLock)
|
lock (_cfgLock)
|
||||||
{
|
{
|
||||||
LogEnable = NConfig.GetCfgValue("LogGlobal", "LogEnable", false);
|
LogEnable = NConfig.GetCfgValue("LogGlobal", "LogEnable", false);
|
||||||
LogLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "LogLevel", (int)NLogLevel.MaxLevel);
|
LogLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "LogLevel", (int) NLogLevel.MaxLevel);
|
||||||
DefaultLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int)NLogLevel.Info);
|
DefaultLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int) NLogLevel.Info);
|
||||||
AsyncMode = NConfig.GetCfgValue("LogGlobal", "AsyncMode", false);
|
AsyncMode = NConfig.GetCfgValue("LogGlobal", "AsyncMode", false);
|
||||||
ForceNewLine = NConfig.GetCfgValue("LogGlobal", "AutoForceNewLine", false);
|
ForceNewLine = NConfig.GetCfgValue("LogGlobal", "AutoForceNewLine", false);
|
||||||
|
|
||||||
|
@ -107,7 +108,8 @@ namespace GeneratorCode.Logs
|
||||||
|
|
||||||
if (MaxItemsCache == 0) MaxItemsCache = int.MaxValue;
|
if (MaxItemsCache == 0) MaxItemsCache = int.MaxValue;
|
||||||
|
|
||||||
CacheMode = (CacheOptMode)NConfig.GetCfgValue("AsyncLogSetting", "CacheFullOpts", (int)CacheOptMode.Drop);
|
CacheMode = (CacheOptMode) NConfig.GetCfgValue("AsyncLogSetting", "CacheFullOpts",
|
||||||
|
(int) CacheOptMode.Drop);
|
||||||
NumOutItems = NConfig.GetCfgValue("AsyncLogSetting", "NumItemsOutEachTime", 10);
|
NumOutItems = NConfig.GetCfgValue("AsyncLogSetting", "NumItemsOutEachTime", 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,14 +120,9 @@ namespace GeneratorCode.Logs
|
||||||
DirPath = NConfig.GetCfgValue("FileLogSetting", "Path", @"");
|
DirPath = NConfig.GetCfgValue("FileLogSetting", "Path", @"");
|
||||||
|
|
||||||
if (DirPath == "" || !Directory.Exists(DirPath) || DirPath == @".\")
|
if (DirPath == "" || !Directory.Exists(DirPath) || DirPath == @".\")
|
||||||
{
|
|
||||||
DirPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\";
|
DirPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\";
|
||||||
}
|
|
||||||
|
|
||||||
if (!Directory.Exists(DirPath))
|
if (!Directory.Exists(DirPath)) Directory.CreateDirectory(DirPath);
|
||||||
{
|
|
||||||
Directory.CreateDirectory(DirPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
FileNamePre = NConfig.GetCfgValue("FileLogSetting", "FileNamePrefix", "");
|
FileNamePre = NConfig.GetCfgValue("FileLogSetting", "FileNamePrefix", "");
|
||||||
EnSplitLog = NConfig.GetCfgValue("FileLogSetting", "AutoSplitFile", true);
|
EnSplitLog = NConfig.GetCfgValue("FileLogSetting", "AutoSplitFile", true);
|
||||||
|
@ -152,13 +149,9 @@ namespace GeneratorCode.Logs
|
||||||
DateTime? dt = null)
|
DateTime? dt = null)
|
||||||
{
|
{
|
||||||
if (dt == null)
|
if (dt == null)
|
||||||
{
|
|
||||||
LogStamp = DateTime.Now;
|
LogStamp = DateTime.Now;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
LogStamp = (DateTime) dt;
|
||||||
LogStamp = (DateTime)dt;
|
|
||||||
}
|
|
||||||
|
|
||||||
LogLevel = level;
|
LogLevel = level;
|
||||||
LogContent = logContent;
|
LogContent = logContent;
|
||||||
|
@ -181,8 +174,8 @@ namespace GeneratorCode.Logs
|
||||||
private static readonly ConcurrentQueue<NLogItem> _logItemCollection = new ConcurrentQueue<NLogItem>();
|
private static readonly ConcurrentQueue<NLogItem> _logItemCollection = new ConcurrentQueue<NLogItem>();
|
||||||
private static readonly object _logOutputLock = new object();
|
private static readonly object _logOutputLock = new object();
|
||||||
private static string _logFileName = "";
|
private static string _logFileName = "";
|
||||||
private static uint _logFileNum = 0;
|
private static uint _logFileNum;
|
||||||
private static StreamWriter _logSw = null;
|
private static StreamWriter _logSw;
|
||||||
|
|
||||||
private static void CreateLogFileHead()
|
private static void CreateLogFileHead()
|
||||||
{
|
{
|
||||||
|
@ -190,7 +183,7 @@ namespace GeneratorCode.Logs
|
||||||
_logSw?.WriteLine("CreateTime: " + string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
_logSw?.WriteLine("CreateTime: " + string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now));
|
||||||
_logSw?.WriteLine("Program: " + Process.GetCurrentProcess().MainModule.FileName);
|
_logSw?.WriteLine("Program: " + Process.GetCurrentProcess().MainModule.FileName);
|
||||||
_logSw?.WriteLine("PID: " + Process.GetCurrentProcess().Id);
|
_logSw?.WriteLine("PID: " + Process.GetCurrentProcess().Id);
|
||||||
_logSw?.WriteLine("Split Count: " + (_logFileNum - 1).ToString());
|
_logSw?.WriteLine("Split Count: " + (_logFileNum - 1));
|
||||||
_logSw?.WriteLine("--------------------------------------------------");
|
_logSw?.WriteLine("--------------------------------------------------");
|
||||||
_logSw?.Flush();
|
_logSw?.Flush();
|
||||||
}
|
}
|
||||||
|
@ -215,12 +208,8 @@ namespace GeneratorCode.Logs
|
||||||
_logFileName += ".log";
|
_logFileName += ".log";
|
||||||
|
|
||||||
if (File.Exists(_logFileName))
|
if (File.Exists(_logFileName))
|
||||||
{
|
|
||||||
if (_logCfg.EnSplitLog)
|
if (_logCfg.EnSplitLog)
|
||||||
{
|
|
||||||
File.Delete(_logFileName);
|
File.Delete(_logFileName);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_logSw = new StreamWriter(_logFileName, true);
|
_logSw = new StreamWriter(_logFileName, true);
|
||||||
CreateLogFileHead();
|
CreateLogFileHead();
|
||||||
|
@ -261,43 +250,33 @@ namespace GeneratorCode.Logs
|
||||||
var tolOut = Math.Min(_logCfg.NumOutItems, _logItemCollection.Count);
|
var tolOut = Math.Min(_logCfg.NumOutItems, _logItemCollection.Count);
|
||||||
|
|
||||||
foreach (var val in Enumerable.Range(1, tolOut))
|
foreach (var val in Enumerable.Range(1, tolOut))
|
||||||
{
|
|
||||||
if (_logItemCollection.TryDequeue(out var logItem))
|
if (_logItemCollection.TryDequeue(out var logItem))
|
||||||
{
|
|
||||||
LogOutput(logItem);
|
LogOutput(logItem);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Thread.Sleep(_logCfg.SleepTime);
|
Thread.Sleep(_logCfg.SleepTime);
|
||||||
|
|
||||||
// 每秒执行一次维护工作
|
// 每秒执行一次维护工作
|
||||||
if ((++cnt % (1000 / _logCfg.SleepTime)) != 0)
|
if (++cnt % (1000 / _logCfg.SleepTime) != 0) continue;
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logSw?.Flush();
|
_logSw?.Flush();
|
||||||
|
|
||||||
if (_logCfg.EnSplitLog)
|
if (_logCfg.EnSplitLog)
|
||||||
{
|
{
|
||||||
bool isNeedSplit = false;
|
var isNeedSplit = false;
|
||||||
|
|
||||||
if (_logCfg.SplitByData && lastDt.Day != DateTime.Now.Day)
|
if (_logCfg.SplitByData && lastDt.Day != DateTime.Now.Day)
|
||||||
{
|
|
||||||
isNeedSplit = true;
|
isNeedSplit = true;
|
||||||
}
|
else if (_logCfg.SplitBySize > 0 &&
|
||||||
else if (_logCfg.SplitBySize > 0 && (new FileInfo(_logFileName)).Length > _logCfg.SplitBySize * (1024 * 1024))
|
new FileInfo(_logFileName).Length > _logCfg.SplitBySize * 1024 * 1024)
|
||||||
{
|
|
||||||
isNeedSplit = true;
|
isNeedSplit = true;
|
||||||
}
|
|
||||||
|
|
||||||
if (isNeedSplit)
|
if (isNeedSplit)
|
||||||
{
|
{
|
||||||
_logSw?.Close();
|
_logSw?.Close();
|
||||||
_logSw?.Dispose();
|
_logSw?.Dispose();
|
||||||
_logSw = null;
|
_logSw = null;
|
||||||
|
|
||||||
string parttn = string.Format("*[{0:d3}]_{1}",
|
var parttn = string.Format("*[{0:d3}]_{1}",
|
||||||
Process.GetCurrentProcess().Id,
|
Process.GetCurrentProcess().Id,
|
||||||
Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName));
|
Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName));
|
||||||
|
|
||||||
|
@ -314,16 +293,17 @@ namespace GeneratorCode.Logs
|
||||||
parttn += $"_{_logFileNum:d3}";
|
parttn += $"_{_logFileNum:d3}";
|
||||||
_logFileNum = Convert.ToUInt32((_logFileNum + 1) % _logCfg.MaxFileNum);
|
_logFileNum = Convert.ToUInt32((_logFileNum + 1) % _logCfg.MaxFileNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logFileName += ".log";
|
_logFileName += ".log";
|
||||||
parttn += ".log";
|
parttn += ".log";
|
||||||
|
|
||||||
foreach (var f in Directory.GetFiles(_logCfg.DirPath, parttn, SearchOption.TopDirectoryOnly))
|
foreach (var f in Directory.GetFiles(_logCfg.DirPath, parttn,
|
||||||
|
SearchOption.TopDirectoryOnly))
|
||||||
{
|
{
|
||||||
File.Delete(f);
|
File.Delete(f);
|
||||||
Trace.WriteLine("Delect Rollback log: " + f);
|
Trace.WriteLine("Delect Rollback log: " + f);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logSw = new StreamWriter(_logFileName, true);
|
_logSw = new StreamWriter(_logFileName, true);
|
||||||
CreateLogFileHead();
|
CreateLogFileHead();
|
||||||
}
|
}
|
||||||
|
@ -352,58 +332,33 @@ namespace GeneratorCode.Logs
|
||||||
{
|
{
|
||||||
var msg = "";
|
var msg = "";
|
||||||
|
|
||||||
if (_logCfg.ShowDate || _logCfg.ShowTime)
|
if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "[";
|
||||||
{
|
|
||||||
msg += "[";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_logCfg.ShowDate)
|
if (_logCfg.ShowDate)
|
||||||
{
|
{
|
||||||
msg += dt.ToString("yyyy-MM-dd");
|
msg += dt.ToString("yyyy-MM-dd");
|
||||||
|
|
||||||
if (_logCfg.ShowTime)
|
if (_logCfg.ShowTime) msg += " ";
|
||||||
{
|
|
||||||
msg += " ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_logCfg.ShowTime)
|
if (_logCfg.ShowTime)
|
||||||
{
|
{
|
||||||
msg += dt.ToString("HH:mm:ss");
|
msg += dt.ToString("HH:mm:ss");
|
||||||
|
|
||||||
if (_logCfg.ShowMSec)
|
if (_logCfg.ShowMSec) msg += "." + dt.ToString("fff");
|
||||||
{
|
|
||||||
msg += "." + dt.ToString("fff");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_logCfg.ShowDate || _logCfg.ShowTime)
|
if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "]";
|
||||||
{
|
|
||||||
msg += "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_logCfg.ShowLevel)
|
if (_logCfg.ShowLevel) msg += " [" + LogLevelToString(logLevel) + "] ";
|
||||||
{
|
|
||||||
msg += " [" + LogLevelToString(logLevel) + "] ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_logCfg.ShowCodeFile)
|
if (_logCfg.ShowCodeFile) msg += "[" + Path.GetFileName(fileName) + "] ";
|
||||||
{
|
|
||||||
msg += "[" + Path.GetFileName(fileName) + "] ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_logCfg.ShowFunction)
|
if (_logCfg.ShowFunction) msg += "- " + funName;
|
||||||
{
|
|
||||||
msg += "- " + funName;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_logCfg.ShowCodeFile || _logCfg.ShowFunction)
|
if (_logCfg.ShowCodeFile || _logCfg.ShowFunction)
|
||||||
{
|
|
||||||
if (_logCfg.ShowCodeLine)
|
if (_logCfg.ShowCodeLine)
|
||||||
{
|
msg += "(" + lineNo + ")";
|
||||||
msg += "(" + lineNo.ToString() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
msg += ": " + logMsg;
|
msg += ": " + logMsg;
|
||||||
|
|
||||||
|
@ -419,11 +374,8 @@ namespace GeneratorCode.Logs
|
||||||
logItem.CodeLine,
|
logItem.CodeLine,
|
||||||
logItem.LogStamp);
|
logItem.LogStamp);
|
||||||
|
|
||||||
if (_logCfg.ForceNewLine)
|
if (_logCfg.ForceNewLine) msg += Environment.NewLine;
|
||||||
{
|
|
||||||
msg += Environment.NewLine;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (_logOutputLock)
|
lock (_logOutputLock)
|
||||||
{
|
{
|
||||||
if (_logCfg.EnConsole) Console.Write(msg);
|
if (_logCfg.EnConsole) Console.Write(msg);
|
||||||
|
@ -436,10 +388,7 @@ namespace GeneratorCode.Logs
|
||||||
System.Diagnostics.Debug.WriteLine(msg);
|
System.Diagnostics.Debug.WriteLine(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_logCfg.EnFile)
|
if (_logCfg.EnFile) _logSw?.Write(msg);
|
||||||
{
|
|
||||||
_logSw?.Write(msg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,10 +406,7 @@ namespace GeneratorCode.Logs
|
||||||
System.Diagnostics.Debug.WriteLine(logMsg);
|
System.Diagnostics.Debug.WriteLine(logMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_logCfg.EnFile)
|
if (_logCfg.EnFile) _logSw?.Write(logMsg);
|
||||||
{
|
|
||||||
_logSw?.Write(logMsg);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,15 +421,10 @@ namespace GeneratorCode.Logs
|
||||||
{
|
{
|
||||||
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
||||||
{
|
{
|
||||||
if (_logCfg.CacheMode == CacheOptMode.Drop)
|
if (_logCfg.CacheMode == CacheOptMode.Drop) return;
|
||||||
{
|
|
||||||
return;
|
NLogItem val;
|
||||||
}
|
_logItemCollection.TryDequeue(out val);
|
||||||
else
|
|
||||||
{
|
|
||||||
NLogItem val;
|
|
||||||
_logItemCollection.TryDequeue(out val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var logItem = new NLogItem(_logCfg.DefaultLevel, logMsg, fileName, funName, lineNo, DateTime.Now);
|
var logItem = new NLogItem(_logCfg.DefaultLevel, logMsg, fileName, funName, lineNo, DateTime.Now);
|
||||||
|
@ -508,17 +449,12 @@ namespace GeneratorCode.Logs
|
||||||
{
|
{
|
||||||
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
||||||
{
|
{
|
||||||
if (_logCfg.CacheMode == CacheOptMode.Drop)
|
if (_logCfg.CacheMode == CacheOptMode.Drop) return;
|
||||||
{
|
|
||||||
return;
|
NLogItem val;
|
||||||
}
|
_logItemCollection.TryDequeue(out val);
|
||||||
else
|
|
||||||
{
|
|
||||||
NLogItem val;
|
|
||||||
_logItemCollection.TryDequeue(out val);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var logItem = new NLogItem(NLogLevel.Debug, logMsg, fileName, funName, lineNo, DateTime.Now);
|
var logItem = new NLogItem(NLogLevel.Debug, logMsg, fileName, funName, lineNo, DateTime.Now);
|
||||||
_logItemCollection.Enqueue(logItem);
|
_logItemCollection.Enqueue(logItem);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,250 +1,303 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.IO;
|
||||||
using System.IO;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Text;
|
||||||
using GeneratorCode.Configure;
|
using GeneratorCode.Configure;
|
||||||
using GeneratorCode.Logs;
|
using GeneratorCode.Logs;
|
||||||
using Newtonsoft.Json;
|
using JetBrains.Annotations;
|
||||||
using TmatrixLibrary;
|
using Newtonsoft.Json;
|
||||||
|
using TmatrixLibrary;
|
||||||
namespace GeneratorCode
|
|
||||||
{
|
namespace GeneratorCode
|
||||||
public class GeneratorParams
|
{
|
||||||
{
|
public class GeneratorParams
|
||||||
public GeneratorParams()
|
{
|
||||||
{
|
public GeneratorParams()
|
||||||
dpi = new[] { 0, 0, 0, 0 };
|
{
|
||||||
point_type = new[] { 0, 0, 0, 0 };
|
dpi = new[] { 0, 0, 0, 0 };
|
||||||
image_type = new[] { false, false, false, true };
|
point_type = new[] { 0, 0, 0, 0 };
|
||||||
StartPageID = 0;
|
image_type = new[] { false, false, false, true };
|
||||||
key = "S0,O000,B0000,P000-255,D2018/12/31;CCAFBQMXYPOAOCIRK52S8QC8SO4A0AGA8Y";
|
StartPageID = 0;
|
||||||
//filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf";
|
key = "S0,O000,B0000,P000-255,D2018/12/31;CCAFBQMXYPOAOCIRK52S8QC8SO4A0AGA8Y";
|
||||||
filePath = "C:\\Works\\pdf\\123.pdf";
|
filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf";
|
||||||
sessionId = "4BD5D923-47EA-4DEF-A1CD-9B85B515B191";
|
//filePath = "C:\\Works\\pdf\\123.pdf";
|
||||||
}
|
sessionId = "4BD5D923-47EA-4DEF-A1CD-9B85B515B191";
|
||||||
|
}
|
||||||
public int[] dpi { get; set; }
|
|
||||||
|
public int[] dpi { get; set; }
|
||||||
public int[] point_type { get; set; }
|
|
||||||
|
public int[] point_type { get; set; }
|
||||||
public bool[] image_type { get; set; }
|
|
||||||
|
public bool[] image_type { get; set; }
|
||||||
public string key { get; set; }
|
|
||||||
|
public string key { get; set; }
|
||||||
public string filePath { get; set; }
|
|
||||||
|
public string filePath { get; set; }
|
||||||
public int StartPageID { get; set; }
|
|
||||||
|
public int StartPageID { get; set; }
|
||||||
public string sessionId { get; set; }
|
|
||||||
}
|
public string sessionId { get; set; }
|
||||||
|
}
|
||||||
public class GenerCodeRet
|
|
||||||
{
|
public class GenerCodeRet
|
||||||
public GenerCodeRet(string sId, int prg)
|
{
|
||||||
{
|
public GenerCodeRet(string sId, int prg)
|
||||||
sessionId = sId;
|
{
|
||||||
progress = prg;
|
sessionId = sId;
|
||||||
}
|
progress = prg;
|
||||||
|
}
|
||||||
public string sessionId { get; set; }
|
|
||||||
|
public string sessionId { get; set; }
|
||||||
public int progress { get; set; }
|
|
||||||
}
|
public int progress { get; set; }
|
||||||
|
}
|
||||||
public class RspMessage
|
|
||||||
{
|
public class MainConfig
|
||||||
public RspMessage(string sId)
|
{
|
||||||
{
|
public delegate void MainCfgChangedHandle();
|
||||||
err = 0;
|
|
||||||
msg = "";
|
private readonly object _cfgLock = new object();
|
||||||
data = new GenerCodeRet(sId, 0);
|
|
||||||
}
|
public MainConfig()
|
||||||
|
{
|
||||||
public RspMessage(string sId, int prg)
|
LoadConfig();
|
||||||
{
|
OnMainCfgChanged += MainCfgChanged;
|
||||||
err = 0;
|
}
|
||||||
msg = "";
|
|
||||||
data = new GenerCodeRet(sId, prg);
|
public bool Base64MsgContent { get; set; }
|
||||||
}
|
public int ServerPort { get; set; }
|
||||||
|
public string ServerAddr { get; set; }
|
||||||
public int err { get; set; }
|
|
||||||
|
public static event MainCfgChangedHandle OnMainCfgChanged;
|
||||||
public string msg { get; set; }
|
|
||||||
|
protected static void MainCfgChanged()
|
||||||
public GenerCodeRet data { get; set; }
|
{
|
||||||
|
OnMainCfgChanged?.Invoke();
|
||||||
public string FormatRspMessage(int errCode, string readme, int prg)
|
}
|
||||||
{
|
|
||||||
var rsp = new RspMessage(data.sessionId, prg);
|
public void LoadConfig()
|
||||||
rsp.err = errCode;
|
{
|
||||||
rsp.msg = (Convert.ToBase64String(Encoding.Default.GetBytes(readme)));
|
lock (_cfgLock)
|
||||||
|
{
|
||||||
return JsonConvert.SerializeObject(rsp);
|
Base64MsgContent = NConfig.GetCfgValue("Main", "ProBase64Msg", true);
|
||||||
}
|
ServerPort = NConfig.GetCfgValue("Main", "ProServerPort", 10088);
|
||||||
|
ServerAddr = NConfig.GetCfgValue("Main", "ProServerAddr", "127.0.0.1");
|
||||||
public static int SendRspMessage(string msg)
|
}
|
||||||
{
|
}
|
||||||
NLog.Debug("Send: " + msg + Environment.NewLine);
|
}
|
||||||
Console.WriteLine(msg);
|
|
||||||
return 0;
|
public class MessageProcess
|
||||||
}
|
{
|
||||||
|
private readonly UdpClient _udp = new UdpClient();
|
||||||
public void ProgressMessage(int step)
|
|
||||||
{
|
public MessageProcess(MainConfig cfg)
|
||||||
var msgContent = FormatRspMessage(0, "Progress", step);
|
{
|
||||||
|
var svrAddr = IPAddress.Parse(cfg.ServerAddr);
|
||||||
msg = JsonConvert.SerializeObject(msgContent);
|
_server = new IPEndPoint(svrAddr, cfg.ServerPort);
|
||||||
|
}
|
||||||
SendRspMessage(msg);
|
|
||||||
}
|
private IPEndPoint _server { get; }
|
||||||
}
|
|
||||||
|
public void SendMessage([NotNull] string msg)
|
||||||
internal class Program
|
{
|
||||||
{
|
if (msg.Length > 0)
|
||||||
private static int Main(string[] args)
|
{
|
||||||
{
|
var sendData = Encoding.Default.GetBytes(msg);
|
||||||
NConfig.InitConfigure();
|
_udp.Send(sendData, sendData.Length, _server);
|
||||||
NLog.NLog_Init();
|
NLog.Debug("Send: " + msg + Environment.NewLine);
|
||||||
GeneratorParams inParams = null;
|
}
|
||||||
RspMessage rspMsg;
|
}
|
||||||
var tmObj = new TmatrixClass();
|
}
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
public class RspMessage
|
||||||
{
|
{
|
||||||
//Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang1\n");
|
public RspMessage(string sId)
|
||||||
};
|
{
|
||||||
|
err = 0;
|
||||||
AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
|
msg = "";
|
||||||
{
|
data = new GenerCodeRet(sId, 0);
|
||||||
//Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang2\n");
|
}
|
||||||
};
|
|
||||||
|
public RspMessage(string sId, int prg)
|
||||||
AppDomain.CurrentDomain.ProcessExit += (sender, ev) =>
|
{
|
||||||
{
|
err = 0;
|
||||||
try
|
msg = "";
|
||||||
{
|
data = new GenerCodeRet(sId, prg);
|
||||||
tmObj.TmatrixUninitialize();
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
public int err { get; set; }
|
||||||
{
|
|
||||||
//var msg = rspMsg.FormatRspMessage(9, e.Message, 0);
|
public string msg { get; set; }
|
||||||
//RspMessage.SendRspMessage(msg);
|
|
||||||
NLog.Crash(e.ToString());
|
public GenerCodeRet data { get; set; }
|
||||||
}
|
|
||||||
|
public string FormatRspMessage(int errCode, string readme, int prg, bool enBase64 = true)
|
||||||
NLog.NLog_Finish();
|
{
|
||||||
};
|
var rsp = new RspMessage(data.sessionId, prg);
|
||||||
|
rsp.err = errCode;
|
||||||
//string inputArg =
|
|
||||||
// "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpbWFnZV90eXBlI" +
|
if (enBase64)
|
||||||
// "jpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6IlMwLE8wMDAsQjAwMDAsUDAwMC0" +
|
rsp.msg = Convert.ToBase64String(Encoding.Default.GetBytes(readme));
|
||||||
// "yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVhZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsIm" +
|
else
|
||||||
// "ZpbGVQYXRoIjoiRTpcXE5ldEVhc2VcXLnsvKOxylxcU2FtcGxlXFwxMjMucGRmIiwiU3Rhcn" +
|
rsp.msg = readme;
|
||||||
// "RQYWdlSUQiOjAsInNlc3Npb25JZCI6IjRCRDVEOTIzLTQ3RUEtNERFRi1BMUNELTlCODVCNT" +
|
|
||||||
// "E1QjE5MSJ9";
|
return JsonConvert.SerializeObject(rsp);
|
||||||
//string inputArg2 = "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpb" +
|
}
|
||||||
// "WFnZV90eXBlIjpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6Il" +
|
}
|
||||||
// "MwLE8wMDAsQjAwMDAsUDAwMC0yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVh" +
|
|
||||||
// "ZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsImZpbGVQYXRoIjoiQzpc" +
|
internal class MainCode
|
||||||
// "XFdvcmtzXFxwZGZcXDEyMy5wZGYiLCJTdGFydFBhZ2VJRCI6MCwic2Vzc" +
|
{
|
||||||
// "2lvbklkIjoiNEJENUQ5MjMtNDdFQS00REVGLUExQ0QtOUI4NUI1MTVCMTkxIn0=";
|
private static int Main(string[] args)
|
||||||
|
{
|
||||||
try
|
NConfig.InitConfigure();
|
||||||
{
|
NLog.NLog_Init();
|
||||||
if (args.Length == 1)
|
GeneratorParams inParams = null;
|
||||||
{
|
RspMessage rspMsg;
|
||||||
var deCode = Convert.FromBase64String(args[0]);
|
var mainCfg = new MainConfig();
|
||||||
var strParams = Encoding.Default.GetString(deCode);
|
var msgProcess = new MessageProcess(mainCfg);
|
||||||
inParams = JsonConvert.DeserializeObject<GeneratorParams>(strParams);
|
var tmObj = new TmatrixClass();
|
||||||
}
|
|
||||||
else if (args.Length == 2)
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
||||||
{
|
{
|
||||||
var deCode = Convert.FromBase64String(args[1]);
|
NLog.Crash("UnHandled Exception: " + e.ToString());
|
||||||
var strParams = Encoding.Default.GetString(deCode);
|
};
|
||||||
inParams = JsonConvert.DeserializeObject<GeneratorParams>(strParams);
|
|
||||||
inParams.sessionId = args[0];
|
AppDomain.CurrentDomain.ProcessExit += (sender, ev) =>
|
||||||
}
|
{
|
||||||
else
|
try
|
||||||
{
|
{
|
||||||
inParams = new GeneratorParams();
|
tmObj.TmatrixUninitialize();
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
catch (Exception e)
|
{
|
||||||
{
|
//var msg = rspMsg.FormatRspMessage(9, e.Message, 0);
|
||||||
rspMsg = new RspMessage("");
|
//RspMessage.SendRspMessage(msg);
|
||||||
var msg = rspMsg.FormatRspMessage(10, e.Message, 0);
|
NLog.Crash(e.ToString());
|
||||||
RspMessage.SendRspMessage(msg);
|
}
|
||||||
NLog.Crash(string.Format("[{0}]: ", (inParams == null) ? inParams.sessionId : "UnInit") + e.Message);
|
|
||||||
return -(int) ErrCode.ERR_JSON_DECODE;
|
NLog.NLog_Finish();
|
||||||
}
|
};
|
||||||
|
|
||||||
rspMsg = new RspMessage(inParams.sessionId);
|
//string inputArg =
|
||||||
|
// "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpbWFnZV90eXBlI" +
|
||||||
tmObj.ProgressChange += rspMsg.ProgressMessage;
|
// "jpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6IlMwLE8wMDAsQjAwMDAsUDAwMC0" +
|
||||||
|
// "yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVhZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsIm" +
|
||||||
var jsInput = JsonConvert.SerializeObject(inParams);
|
// "ZpbGVQYXRoIjoiRTpcXE5ldEVhc2VcXLnsvKOxylxcU2FtcGxlXFwxMjMucGRmIiwiU3Rhcn" +
|
||||||
|
// "RQYWdlSUQiOjAsInNlc3Npb25JZCI6IjRCRDVEOTIzLTQ3RUEtNERFRi1BMUNELTlCODVCNT" +
|
||||||
NLog.Debug("Input:" + jsInput + Environment.NewLine);
|
// "E1QjE5MSJ9";
|
||||||
|
//string inputArg2 = "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpb" +
|
||||||
if (!File.Exists(inParams.filePath))
|
// "WFnZV90eXBlIjpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6Il" +
|
||||||
{
|
// "MwLE8wMDAsQjAwMDAsUDAwMC0yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVh" +
|
||||||
NLog.Error("File Not Exists: " + inParams.filePath + Environment.NewLine);
|
// "ZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsImZpbGVQYXRoIjoiQzpc" +
|
||||||
return -(int) ErrCode.ERR_FILE_NOTEXISTS;
|
// "XFdvcmtzXFxwZGZcXDEyMy5wZGYiLCJTdGFydFBhZ2VJRCI6MCwic2Vzc" +
|
||||||
}
|
// "2lvbklkIjoiNEJENUQ5MjMtNDdFQS00REVGLUExQ0QtOUI4NUI1MTVCMTkxIn0=";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tmObj.TmatrixInitialize();
|
if (args.Length == 1)
|
||||||
}
|
{
|
||||||
catch (Exception e)
|
var deCode = Convert.FromBase64String(args[0]);
|
||||||
{
|
var strParams = Encoding.Default.GetString(deCode);
|
||||||
var msg = rspMsg.FormatRspMessage(7, e.Message, 0);
|
inParams = JsonConvert.DeserializeObject<GeneratorParams>(strParams);
|
||||||
RspMessage.SendRspMessage(msg);
|
}
|
||||||
NLog.Crash(e.ToString());
|
else if (args.Length == 2)
|
||||||
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
{
|
||||||
}
|
var deCode = Convert.FromBase64String(args[1]);
|
||||||
|
var strParams = Encoding.Default.GetString(deCode);
|
||||||
try
|
inParams = JsonConvert.DeserializeObject<GeneratorParams>(strParams);
|
||||||
{
|
inParams.sessionId = args[0];
|
||||||
var ret = tmObj.GenerateTmatrixCode_OID4(inParams.key,
|
}
|
||||||
inParams.filePath, inParams.StartPageID, inParams.point_type,
|
else
|
||||||
inParams.image_type, inParams.dpi);
|
{
|
||||||
|
inParams = new GeneratorParams();
|
||||||
if (ret.Substring(0, 1) != "0")
|
}
|
||||||
{
|
}
|
||||||
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
catch (Exception e)
|
||||||
ret.Substring(1, ret.Length - 1), tmObj.GetProgerss());
|
{
|
||||||
|
rspMsg = new RspMessage("");
|
||||||
NLog.Error(msg + Environment.NewLine);
|
var msg = rspMsg.FormatRspMessage(10, e.Message, 0, mainCfg.Base64MsgContent);
|
||||||
RspMessage.SendRspMessage(msg);
|
msgProcess.SendMessage(msg);
|
||||||
}
|
NLog.Crash(string.Format("[{0}]: ", inParams == null ? inParams.sessionId : "UnInit") + e.Message);
|
||||||
else
|
return -(int) ErrCode.ERR_JSON_DECODE;
|
||||||
{
|
}
|
||||||
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
|
||||||
ret.Substring(1, ret.Length - 1), 100);
|
rspMsg = new RspMessage(inParams.sessionId);
|
||||||
|
|
||||||
NLog.Debug(msg + Environment.NewLine);
|
tmObj.ProgressChange += step =>
|
||||||
RspMessage.SendRspMessage(msg);
|
{
|
||||||
}
|
var msgContent = rspMsg.FormatRspMessage(0, "Progress", step, mainCfg.Base64MsgContent);
|
||||||
}
|
|
||||||
catch (Exception e)
|
var msg = JsonConvert.SerializeObject(msgContent);
|
||||||
{
|
|
||||||
var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss());
|
msgProcess.SendMessage(msg);
|
||||||
RspMessage.SendRspMessage(msg);
|
};
|
||||||
NLog.Crash(e.ToString());
|
|
||||||
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
var jsInput = JsonConvert.SerializeObject(inParams);
|
||||||
}
|
|
||||||
|
NLog.Debug("Input:" + jsInput + Environment.NewLine);
|
||||||
return 0;
|
|
||||||
}
|
if (!File.Exists(inParams.filePath))
|
||||||
|
{
|
||||||
private enum ErrCode
|
NLog.Error("File Not Exists: " + inParams.filePath + Environment.NewLine);
|
||||||
{
|
return -(int) ErrCode.ERR_FILE_NOTEXISTS;
|
||||||
ERR_INPUT_PARAMS = 1,
|
}
|
||||||
ERR_FILE_NOTEXISTS,
|
|
||||||
ERR_EXCEPT_THROW,
|
try
|
||||||
ERR_JSON_DECODE
|
{
|
||||||
}
|
tmObj.TmatrixInitialize();
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = rspMsg.FormatRspMessage(7, e.Message, 0, mainCfg.Base64MsgContent);
|
||||||
|
msgProcess.SendMessage(msg);
|
||||||
|
NLog.Crash(e.ToString());
|
||||||
|
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ret = tmObj.GenerateTmatrixCode_OID4(inParams.key,
|
||||||
|
inParams.filePath, inParams.StartPageID, inParams.point_type,
|
||||||
|
inParams.image_type, inParams.dpi);
|
||||||
|
|
||||||
|
if (ret.Substring(0, 1) != "0")
|
||||||
|
{
|
||||||
|
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
||||||
|
ret.Substring(1, ret.Length - 1),
|
||||||
|
tmObj.GetProgerss(),
|
||||||
|
mainCfg.Base64MsgContent);
|
||||||
|
|
||||||
|
NLog.Error(msg + Environment.NewLine);
|
||||||
|
msgProcess.SendMessage(msg);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
||||||
|
ret.Substring(1, ret.Length - 1), 100,
|
||||||
|
mainCfg.Base64MsgContent);
|
||||||
|
|
||||||
|
NLog.Debug(msg + Environment.NewLine);
|
||||||
|
msgProcess.SendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss(), mainCfg.Base64MsgContent);
|
||||||
|
msgProcess.SendMessage(msg);
|
||||||
|
NLog.Crash(e.ToString());
|
||||||
|
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum ErrCode
|
||||||
|
{
|
||||||
|
ERR_INPUT_PARAMS = 1,
|
||||||
|
ERR_FILE_NOTEXISTS,
|
||||||
|
ERR_EXCEPT_THROW,
|
||||||
|
ERR_JSON_DECODE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,10 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<File Version="1.0">
|
<File Version="1.0">
|
||||||
<ExtensionPoint ID="I_OIDPGHelper" Enable="1">
|
<ExtensionPoint ID="I_OIDPGHelper" Enable="1">
|
||||||
<Plugin ID="OIDPGHelper" Bundle="OIDPGHelper.dll" Enable="1"/>
|
<Plugin ID="OIDPGHelper" Bundle="OIDPGHelper.dll" Enable="1" />
|
||||||
</ExtensionPoint>
|
</ExtensionPoint>
|
||||||
<ExtensionPoint ID="I_OIDTiffConvertor" Enable="1">
|
<ExtensionPoint ID="I_OIDTiffConvertor" Enable="1">
|
||||||
<Plugin ID="OIDTiffConvertor" Bundle="OIDTiffConvertor.dll" Enable="1"/>
|
<Plugin ID="OIDTiffConvertor" Bundle="OIDTiffConvertor.dll" Enable="1" />
|
||||||
</ExtensionPoint>
|
</ExtensionPoint>
|
||||||
</File>
|
</File>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,4 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// 有关程序集的一般信息由以下
|
// 有关程序集的一般信息由以下
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace OIDModule.Generator
|
namespace OIDModule.Generator
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
internal enum OIDBeginBuildState
|
internal enum OIDBeginBuildState
|
||||||
{
|
{
|
||||||
eBBState_OK,
|
eBBState_OK,
|
||||||
|
@ -9,17 +9,20 @@ namespace OIDModule.Generator
|
||||||
eBBState_FailToOpenImageFile,
|
eBBState_FailToOpenImageFile,
|
||||||
eBBState_Unknown
|
eBBState_Unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum OIDPrintPointType
|
internal enum OIDPrintPointType
|
||||||
{
|
{
|
||||||
eOID_PrintPointType_2x2,
|
eOID_PrintPointType_2x2,
|
||||||
eOID_PrintPointType_3x3,
|
eOID_PrintPointType_3x3,
|
||||||
eOID_PrintPointType_4x4
|
eOID_PrintPointType_4x4
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum OIDPublishImageDPIType
|
internal enum OIDPublishImageDPIType
|
||||||
{
|
{
|
||||||
eOID_PublishImageDPI_600,
|
eOID_PublishImageDPI_600,
|
||||||
eOID_PublishImageDPI_1200
|
eOID_PublishImageDPI_1200
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum OIDPublishImageType
|
internal enum OIDPublishImageType
|
||||||
{
|
{
|
||||||
eOID_PIT_Publish_Image,
|
eOID_PIT_Publish_Image,
|
||||||
|
@ -27,6 +30,7 @@ namespace OIDModule.Generator
|
||||||
eOID_PIT_BG_Vertor_Image,
|
eOID_PIT_BG_Vertor_Image,
|
||||||
eOID_PIT_Publish_BG_Image
|
eOID_PIT_Publish_BG_Image
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum OIDPublishObjectType
|
internal enum OIDPublishObjectType
|
||||||
{
|
{
|
||||||
eOID_OT_ElementCode,
|
eOID_OT_ElementCode,
|
||||||
|
@ -35,64 +39,90 @@ namespace OIDModule.Generator
|
||||||
|
|
||||||
internal class OIDPublishImageGenerator
|
internal class OIDPublishImageGenerator
|
||||||
{
|
{
|
||||||
public bool AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType)
|
public bool AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY,
|
||||||
|
int nPointsCount, int nZOrder, int nObjectType)
|
||||||
{
|
{
|
||||||
return OID_PIG_AddObjectInfo(nPageIndex, uiObjectIndex, arPointX, arPointY, nPointsCount, nZOrder, nObjectType);
|
return OID_PIG_AddObjectInfo(nPageIndex, uiObjectIndex, arPointX, arPointY, nPointsCount, nZOrder,
|
||||||
|
nObjectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, int nExportPDFImageDPI)
|
public int BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, int nExportPDFImageDPI)
|
||||||
{
|
{
|
||||||
return OID_PIG_BeginBuildPublishImage(szBGImage, bExportPDFImage, nExportPDFImageDPI);
|
return OID_PIG_BeginBuildPublishImage(szBGImage, bExportPDFImage, nExportPDFImageDPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight)
|
public int BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight)
|
||||||
{
|
{
|
||||||
return OID_PIG_BeginBuildPublishImageByInfo(dbCMWidth, dbCMHeight);
|
return OID_PIG_BeginBuildPublishImageByInfo(dbCMWidth, dbCMHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType)
|
public bool BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage,
|
||||||
|
bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType)
|
||||||
{
|
{
|
||||||
return OID_PIG_BuildPublishImage(szOutputFolderPath, bPrintIdleCode, bSplitBigImage, bMergeSplittedImages, nPublishImageDPIType, nPrintPointType, nPublishImageType);
|
return OID_PIG_BuildPublishImage(szOutputFolderPath, bPrintIdleCode, bSplitBigImage, bMergeSplittedImages,
|
||||||
|
nPublishImageDPIType, nPrintPointType, nPublishImageType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndBuildPublishImage()
|
public void EndBuildPublishImage()
|
||||||
{
|
{
|
||||||
OID_PIG_EndBuildPublishImage();
|
OID_PIG_EndBuildPublishImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Initialize()
|
public bool Initialize()
|
||||||
{
|
{
|
||||||
return OID_PIG_Initialize();
|
return OID_PIG_Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType);
|
CallingConvention.StdCall)]
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
|
private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX,
|
||||||
private static extern int OID_PIG_BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage, int nExportPDFImageDPI);
|
uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType);
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll",
|
||||||
|
CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern int OID_PIG_BeginBuildPublishImage(char[] szBGImage, bool bExportPDFImage,
|
||||||
|
int nExportPDFImageDPI);
|
||||||
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll",
|
||||||
|
CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
|
||||||
private static extern int OID_PIG_BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight);
|
private static extern int OID_PIG_BeginBuildPublishImageByInfo(double dbCMWidth, double dbCMHeight);
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall, CharSet=CharSet.Unicode)]
|
|
||||||
private static extern bool OID_PIG_BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode, bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType, int nPublishImageType);
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll",
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
|
||||||
|
private static extern bool OID_PIG_BuildPublishImage(char[] szOutputFolderPath, bool bPrintIdleCode,
|
||||||
|
bool bSplitBigImage, bool bMergeSplittedImages, int nPublishImageDPIType, int nPrintPointType,
|
||||||
|
int nPublishImageType);
|
||||||
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
|
CallingConvention.StdCall)]
|
||||||
private static extern void OID_PIG_EndBuildPublishImage();
|
private static extern void OID_PIG_EndBuildPublishImage();
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
|
CallingConvention.StdCall)]
|
||||||
private static extern bool OID_PIG_Initialize();
|
private static extern bool OID_PIG_Initialize();
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
|
CallingConvention.StdCall)]
|
||||||
private static extern bool OID_PIG_SetPublishPages(int[] arPageNumbers, int nPageCount);
|
private static extern bool OID_PIG_SetPublishPages(int[] arPageNumbers, int nPageCount);
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
|
CallingConvention.StdCall)]
|
||||||
private static extern bool OID_PIG_SetStartPosition(int nPageIndex, int nXStart, int nYStart);
|
private static extern bool OID_PIG_SetStartPosition(int nPageIndex, int nXStart, int nYStart);
|
||||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
|
||||||
|
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||||
|
CallingConvention.StdCall)]
|
||||||
private static extern void OID_PIG_Uninitialize();
|
private static extern void OID_PIG_Uninitialize();
|
||||||
|
|
||||||
public bool SetPublishPages(int[] arPageNumbers, int nPageCount)
|
public bool SetPublishPages(int[] arPageNumbers, int nPageCount)
|
||||||
{
|
{
|
||||||
return OID_PIG_SetPublishPages(arPageNumbers, nPageCount);
|
return OID_PIG_SetPublishPages(arPageNumbers, nPageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SetStartPosition(int nPageIndex, int nXStart, int nYStart)
|
public bool SetStartPosition(int nPageIndex, int nXStart, int nYStart)
|
||||||
{
|
{
|
||||||
return OID_PIG_SetStartPosition(nPageIndex, nXStart, nYStart);
|
return OID_PIG_SetStartPosition(nPageIndex, nXStart, nYStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Uninitialize()
|
public void Uninitialize()
|
||||||
{
|
{
|
||||||
OID_PIG_Uninitialize();
|
OID_PIG_Uninitialize();
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,16 @@
|
||||||
; 应用程序配置文件
|
; 应用程序配置文件
|
||||||
|
|
||||||
|
;---------------------------------------
|
||||||
|
; 主要配置项
|
||||||
|
;
|
||||||
|
[Main]
|
||||||
|
; 是否对协议中的 msg 字段进行 Base64 编码
|
||||||
|
ProBase64Msg = false
|
||||||
|
; 服务器端口号
|
||||||
|
ProServerPort = 10088
|
||||||
|
; 服务器 IP 地址
|
||||||
|
ProServerAddr = 127.0.0.1
|
||||||
|
|
||||||
;---------------------------------------
|
;---------------------------------------
|
||||||
; Log 相关配置
|
; Log 相关配置
|
||||||
;
|
;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<packages>
|
<packages>
|
||||||
<package id="ini-parser" version="2.5.2" targetFramework="net45" />
|
<package id="ini-parser" version="2.5.2" targetFramework="net45" />
|
||||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
|
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
|
||||||
|
|
Loading…
Reference in New Issue