parent
e34633edea
commit
3aace68789
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -11,12 +11,12 @@ namespace GeneratorCode.Configure
|
|||
{
|
||||
public static class NConfig
|
||||
{
|
||||
private static string _cfgFileName = @".\config.ini";
|
||||
|
||||
private static IniData _cfgData = null;
|
||||
|
||||
public delegate void ConfigChangedHandle();
|
||||
|
||||
private static readonly string _cfgFileName = @".\config.ini";
|
||||
|
||||
private static IniData _cfgData;
|
||||
|
||||
public static event ConfigChangedHandle OnConfigChanged;
|
||||
|
||||
private static void ConfigChanged()
|
||||
|
@ -35,7 +35,7 @@ namespace GeneratorCode.Configure
|
|||
ws.WriteLine("; 应用程序配置文件\n");
|
||||
}
|
||||
|
||||
FileIniDataParser iniPraser = new FileIniDataParser();
|
||||
var iniPraser = new FileIniDataParser();
|
||||
iniPraser.Parser.Configuration.CommentString = ";";
|
||||
_cfgData = iniPraser.ReadFile(_cfgFileName);
|
||||
//Trace.WriteLine(_cfgData);
|
||||
|
@ -55,12 +55,12 @@ namespace GeneratorCode.Configure
|
|||
//Trace.WriteLine("Directory: " + Path.GetDirectoryName(appPath));
|
||||
//Trace.WriteLine("File: " + Path.GetFileName(appPath));
|
||||
|
||||
var fw = new FileSystemWatcher()
|
||||
var fw = new FileSystemWatcher
|
||||
{
|
||||
NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite,
|
||||
Filter = _cfgFileName,
|
||||
Path = Path.GetDirectoryName(appPath),
|
||||
IncludeSubdirectories = false,
|
||||
IncludeSubdirectories = false
|
||||
};
|
||||
|
||||
fw.Changed += (sender, e) =>
|
||||
|
@ -99,20 +99,17 @@ namespace GeneratorCode.Configure
|
|||
{
|
||||
var ret = defValue;
|
||||
|
||||
if (_cfgData.Equals(null))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
if (_cfgData.Equals(null)) return ret;
|
||||
|
||||
try
|
||||
{
|
||||
ret = (T) Convert.ChangeType(_cfgData[secName][keyName], typeof(T));
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
Trace.WriteLine("[" + _cfgData[secName][keyName] + "] :" + e.Message);
|
||||
ret = defValue;
|
||||
throw(e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Configure\NConfig.cs" />
|
||||
<Compile Include="Logs\NLog.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="MainCode.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TmatrixSDK\OIDPublishImageGenerator.cs" />
|
||||
|
|
|
@ -29,10 +29,9 @@ namespace GeneratorCode.Logs
|
|||
|
||||
public class NLogConfig
|
||||
{
|
||||
private object _cfgLock = new object();
|
||||
public delegate void LogCfgChangedHandle();
|
||||
|
||||
public static event LogCfgChangedHandle OnLogCfgChanged;
|
||||
private readonly object _cfgLock = new object();
|
||||
|
||||
public NLogConfig()
|
||||
{
|
||||
|
@ -40,11 +39,6 @@ namespace GeneratorCode.Logs
|
|||
NConfig.OnConfigChanged += () => { LogCfgChanged(); };
|
||||
}
|
||||
|
||||
protected static void LogCfgChanged()
|
||||
{
|
||||
OnLogCfgChanged?.Invoke();
|
||||
}
|
||||
|
||||
public bool LogEnable { get; set; }
|
||||
public NLogLevel LogLevel { get; set; }
|
||||
public NLogLevel DefaultLevel { get; set; }
|
||||
|
@ -78,13 +72,20 @@ namespace GeneratorCode.Logs
|
|||
public bool RoolbackFile { get; set; }
|
||||
public int MaxFileNum { get; set; }
|
||||
|
||||
public static event LogCfgChangedHandle OnLogCfgChanged;
|
||||
|
||||
protected static void LogCfgChanged()
|
||||
{
|
||||
OnLogCfgChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void LogConfig()
|
||||
{
|
||||
lock (_cfgLock)
|
||||
{
|
||||
LogEnable = NConfig.GetCfgValue("LogGlobal", "LogEnable", false);
|
||||
LogLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "LogLevel", (int)NLogLevel.MaxLevel);
|
||||
DefaultLevel = (NLogLevel)NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int)NLogLevel.Info);
|
||||
LogLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "LogLevel", (int) NLogLevel.MaxLevel);
|
||||
DefaultLevel = (NLogLevel) NConfig.GetCfgValue("LogGlobal", "DefaultLogLevel", (int) NLogLevel.Info);
|
||||
AsyncMode = NConfig.GetCfgValue("LogGlobal", "AsyncMode", false);
|
||||
ForceNewLine = NConfig.GetCfgValue("LogGlobal", "AutoForceNewLine", false);
|
||||
|
||||
|
@ -107,7 +108,8 @@ namespace GeneratorCode.Logs
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -118,14 +120,9 @@ namespace GeneratorCode.Logs
|
|||
DirPath = NConfig.GetCfgValue("FileLogSetting", "Path", @"");
|
||||
|
||||
if (DirPath == "" || !Directory.Exists(DirPath) || DirPath == @".\")
|
||||
{
|
||||
DirPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(DirPath))
|
||||
{
|
||||
Directory.CreateDirectory(DirPath);
|
||||
}
|
||||
if (!Directory.Exists(DirPath)) Directory.CreateDirectory(DirPath);
|
||||
|
||||
FileNamePre = NConfig.GetCfgValue("FileLogSetting", "FileNamePrefix", "");
|
||||
EnSplitLog = NConfig.GetCfgValue("FileLogSetting", "AutoSplitFile", true);
|
||||
|
@ -152,13 +149,9 @@ namespace GeneratorCode.Logs
|
|||
DateTime? dt = null)
|
||||
{
|
||||
if (dt == null)
|
||||
{
|
||||
LogStamp = DateTime.Now;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogStamp = (DateTime)dt;
|
||||
}
|
||||
LogStamp = (DateTime) dt;
|
||||
|
||||
LogLevel = level;
|
||||
LogContent = logContent;
|
||||
|
@ -181,8 +174,8 @@ namespace GeneratorCode.Logs
|
|||
private static readonly ConcurrentQueue<NLogItem> _logItemCollection = new ConcurrentQueue<NLogItem>();
|
||||
private static readonly object _logOutputLock = new object();
|
||||
private static string _logFileName = "";
|
||||
private static uint _logFileNum = 0;
|
||||
private static StreamWriter _logSw = null;
|
||||
private static uint _logFileNum;
|
||||
private static StreamWriter _logSw;
|
||||
|
||||
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("Program: " + Process.GetCurrentProcess().MainModule.FileName);
|
||||
_logSw?.WriteLine("PID: " + Process.GetCurrentProcess().Id);
|
||||
_logSw?.WriteLine("Split Count: " + (_logFileNum - 1).ToString());
|
||||
_logSw?.WriteLine("Split Count: " + (_logFileNum - 1));
|
||||
_logSw?.WriteLine("--------------------------------------------------");
|
||||
_logSw?.Flush();
|
||||
}
|
||||
|
@ -215,12 +208,8 @@ namespace GeneratorCode.Logs
|
|||
_logFileName += ".log";
|
||||
|
||||
if (File.Exists(_logFileName))
|
||||
{
|
||||
if (_logCfg.EnSplitLog)
|
||||
{
|
||||
File.Delete(_logFileName);
|
||||
}
|
||||
}
|
||||
|
||||
_logSw = new StreamWriter(_logFileName, true);
|
||||
CreateLogFileHead();
|
||||
|
@ -261,35 +250,25 @@ namespace GeneratorCode.Logs
|
|||
var tolOut = Math.Min(_logCfg.NumOutItems, _logItemCollection.Count);
|
||||
|
||||
foreach (var val in Enumerable.Range(1, tolOut))
|
||||
{
|
||||
if (_logItemCollection.TryDequeue(out var logItem))
|
||||
{
|
||||
LogOutput(logItem);
|
||||
}
|
||||
}
|
||||
|
||||
Thread.Sleep(_logCfg.SleepTime);
|
||||
|
||||
// 每秒执行一次维护工作
|
||||
if ((++cnt % (1000 / _logCfg.SleepTime)) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (++cnt % (1000 / _logCfg.SleepTime) != 0) continue;
|
||||
|
||||
_logSw?.Flush();
|
||||
|
||||
if (_logCfg.EnSplitLog)
|
||||
{
|
||||
bool isNeedSplit = false;
|
||||
var isNeedSplit = false;
|
||||
|
||||
if (_logCfg.SplitByData && lastDt.Day != DateTime.Now.Day)
|
||||
{
|
||||
isNeedSplit = true;
|
||||
}
|
||||
else if (_logCfg.SplitBySize > 0 && (new FileInfo(_logFileName)).Length > _logCfg.SplitBySize * (1024 * 1024))
|
||||
{
|
||||
else if (_logCfg.SplitBySize > 0 &&
|
||||
new FileInfo(_logFileName).Length > _logCfg.SplitBySize * 1024 * 1024)
|
||||
isNeedSplit = true;
|
||||
}
|
||||
|
||||
if (isNeedSplit)
|
||||
{
|
||||
|
@ -297,7 +276,7 @@ namespace GeneratorCode.Logs
|
|||
_logSw?.Dispose();
|
||||
_logSw = null;
|
||||
|
||||
string parttn = string.Format("*[{0:d3}]_{1}",
|
||||
var parttn = string.Format("*[{0:d3}]_{1}",
|
||||
Process.GetCurrentProcess().Id,
|
||||
Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName));
|
||||
|
||||
|
@ -318,7 +297,8 @@ namespace GeneratorCode.Logs
|
|||
_logFileName += ".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);
|
||||
Trace.WriteLine("Delect Rollback log: " + f);
|
||||
|
@ -352,58 +332,33 @@ namespace GeneratorCode.Logs
|
|||
{
|
||||
var msg = "";
|
||||
|
||||
if (_logCfg.ShowDate || _logCfg.ShowTime)
|
||||
{
|
||||
msg += "[";
|
||||
}
|
||||
if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "[";
|
||||
|
||||
if (_logCfg.ShowDate)
|
||||
{
|
||||
msg += dt.ToString("yyyy-MM-dd");
|
||||
|
||||
if (_logCfg.ShowTime)
|
||||
{
|
||||
msg += " ";
|
||||
}
|
||||
if (_logCfg.ShowTime) msg += " ";
|
||||
}
|
||||
|
||||
if (_logCfg.ShowTime)
|
||||
{
|
||||
msg += dt.ToString("HH:mm:ss");
|
||||
|
||||
if (_logCfg.ShowMSec)
|
||||
{
|
||||
msg += "." + dt.ToString("fff");
|
||||
}
|
||||
if (_logCfg.ShowMSec) msg += "." + dt.ToString("fff");
|
||||
}
|
||||
|
||||
if (_logCfg.ShowDate || _logCfg.ShowTime)
|
||||
{
|
||||
msg += "]";
|
||||
}
|
||||
if (_logCfg.ShowDate || _logCfg.ShowTime) msg += "]";
|
||||
|
||||
if (_logCfg.ShowLevel)
|
||||
{
|
||||
msg += " [" + LogLevelToString(logLevel) + "] ";
|
||||
}
|
||||
if (_logCfg.ShowLevel) msg += " [" + LogLevelToString(logLevel) + "] ";
|
||||
|
||||
if (_logCfg.ShowCodeFile)
|
||||
{
|
||||
msg += "[" + Path.GetFileName(fileName) + "] ";
|
||||
}
|
||||
if (_logCfg.ShowCodeFile) msg += "[" + Path.GetFileName(fileName) + "] ";
|
||||
|
||||
if (_logCfg.ShowFunction)
|
||||
{
|
||||
msg += "- " + funName;
|
||||
}
|
||||
if (_logCfg.ShowFunction) msg += "- " + funName;
|
||||
|
||||
if (_logCfg.ShowCodeFile || _logCfg.ShowFunction)
|
||||
{
|
||||
if (_logCfg.ShowCodeLine)
|
||||
{
|
||||
msg += "(" + lineNo.ToString() + ")";
|
||||
}
|
||||
}
|
||||
msg += "(" + lineNo + ")";
|
||||
|
||||
msg += ": " + logMsg;
|
||||
|
||||
|
@ -419,10 +374,7 @@ namespace GeneratorCode.Logs
|
|||
logItem.CodeLine,
|
||||
logItem.LogStamp);
|
||||
|
||||
if (_logCfg.ForceNewLine)
|
||||
{
|
||||
msg += Environment.NewLine;
|
||||
}
|
||||
if (_logCfg.ForceNewLine) msg += Environment.NewLine;
|
||||
|
||||
lock (_logOutputLock)
|
||||
{
|
||||
|
@ -436,10 +388,7 @@ namespace GeneratorCode.Logs
|
|||
System.Diagnostics.Debug.WriteLine(msg);
|
||||
}
|
||||
|
||||
if (_logCfg.EnFile)
|
||||
{
|
||||
_logSw?.Write(msg);
|
||||
}
|
||||
if (_logCfg.EnFile) _logSw?.Write(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,10 +406,7 @@ namespace GeneratorCode.Logs
|
|||
System.Diagnostics.Debug.WriteLine(logMsg);
|
||||
}
|
||||
|
||||
if (_logCfg.EnFile)
|
||||
{
|
||||
_logSw?.Write(logMsg);
|
||||
}
|
||||
if (_logCfg.EnFile) _logSw?.Write(logMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -475,15 +421,10 @@ namespace GeneratorCode.Logs
|
|||
{
|
||||
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
||||
{
|
||||
if (_logCfg.CacheMode == CacheOptMode.Drop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NLogItem val;
|
||||
_logItemCollection.TryDequeue(out val);
|
||||
}
|
||||
if (_logCfg.CacheMode == CacheOptMode.Drop) return;
|
||||
|
||||
NLogItem val;
|
||||
_logItemCollection.TryDequeue(out val);
|
||||
}
|
||||
|
||||
var logItem = new NLogItem(_logCfg.DefaultLevel, logMsg, fileName, funName, lineNo, DateTime.Now);
|
||||
|
@ -508,15 +449,10 @@ namespace GeneratorCode.Logs
|
|||
{
|
||||
if (_logItemCollection.Count >= _logCfg.MaxItemsCache)
|
||||
{
|
||||
if (_logCfg.CacheMode == CacheOptMode.Drop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
NLogItem val;
|
||||
_logItemCollection.TryDequeue(out val);
|
||||
}
|
||||
if (_logCfg.CacheMode == CacheOptMode.Drop) return;
|
||||
|
||||
NLogItem val;
|
||||
_logItemCollection.TryDequeue(out val);
|
||||
}
|
||||
|
||||
var logItem = new NLogItem(NLogLevel.Debug, logMsg, fileName, funName, lineNo, DateTime.Now);
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using GeneratorCode.Configure;
|
||||
using GeneratorCode.Logs;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
using TmatrixLibrary;
|
||||
|
||||
|
@ -19,8 +20,8 @@ namespace GeneratorCode
|
|||
image_type = new[] { false, false, false, true };
|
||||
StartPageID = 0;
|
||||
key = "S0,O000,B0000,P000-255,D2018/12/31;CCAFBQMXYPOAOCIRK52S8QC8SO4A0AGA8Y";
|
||||
//filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf";
|
||||
filePath = "C:\\Works\\pdf\\123.pdf";
|
||||
filePath = "E:\\NetEase\\轨迹笔\\Sample\\123.pdf"; //"C:\\Works\\pdf\\123.pdf";
|
||||
//filePath = "C:\\Works\\pdf\\123.pdf";
|
||||
sessionId = "4BD5D923-47EA-4DEF-A1CD-9B85B515B191";
|
||||
}
|
||||
|
||||
|
@ -52,6 +53,63 @@ namespace GeneratorCode
|
|||
public int progress { get; set; }
|
||||
}
|
||||
|
||||
public class MainConfig
|
||||
{
|
||||
public delegate void MainCfgChangedHandle();
|
||||
|
||||
private readonly object _cfgLock = new object();
|
||||
|
||||
public MainConfig()
|
||||
{
|
||||
LoadConfig();
|
||||
OnMainCfgChanged += MainCfgChanged;
|
||||
}
|
||||
|
||||
public bool Base64MsgContent { get; set; }
|
||||
public int ServerPort { get; set; }
|
||||
public string ServerAddr { get; set; }
|
||||
|
||||
public static event MainCfgChangedHandle OnMainCfgChanged;
|
||||
|
||||
protected static void MainCfgChanged()
|
||||
{
|
||||
OnMainCfgChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void LoadConfig()
|
||||
{
|
||||
lock (_cfgLock)
|
||||
{
|
||||
Base64MsgContent = NConfig.GetCfgValue("Main", "ProBase64Msg", true);
|
||||
ServerPort = NConfig.GetCfgValue("Main", "ProServerPort", 10088);
|
||||
ServerAddr = NConfig.GetCfgValue("Main", "ProServerAddr", "127.0.0.1");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageProcess
|
||||
{
|
||||
private readonly UdpClient _udp = new UdpClient();
|
||||
|
||||
public MessageProcess(MainConfig cfg)
|
||||
{
|
||||
var svrAddr = IPAddress.Parse(cfg.ServerAddr);
|
||||
_server = new IPEndPoint(svrAddr, cfg.ServerPort);
|
||||
}
|
||||
|
||||
private IPEndPoint _server { get; }
|
||||
|
||||
public void SendMessage([NotNull] string msg)
|
||||
{
|
||||
if (msg.Length > 0)
|
||||
{
|
||||
var sendData = Encoding.Default.GetBytes(msg);
|
||||
_udp.Send(sendData, sendData.Length, _server);
|
||||
NLog.Debug("Send: " + msg + Environment.NewLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class RspMessage
|
||||
{
|
||||
public RspMessage(string sId)
|
||||
|
@ -74,33 +132,21 @@ namespace GeneratorCode
|
|||
|
||||
public GenerCodeRet data { get; set; }
|
||||
|
||||
public string FormatRspMessage(int errCode, string readme, int prg)
|
||||
public string FormatRspMessage(int errCode, string readme, int prg, bool enBase64 = true)
|
||||
{
|
||||
var rsp = new RspMessage(data.sessionId, prg);
|
||||
rsp.err = errCode;
|
||||
rsp.msg = (Convert.ToBase64String(Encoding.Default.GetBytes(readme)));
|
||||
|
||||
if (enBase64)
|
||||
rsp.msg = Convert.ToBase64String(Encoding.Default.GetBytes(readme));
|
||||
else
|
||||
rsp.msg = readme;
|
||||
|
||||
return JsonConvert.SerializeObject(rsp);
|
||||
}
|
||||
|
||||
public static int SendRspMessage(string msg)
|
||||
{
|
||||
NLog.Debug("Send: " + msg + Environment.NewLine);
|
||||
Console.WriteLine(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void ProgressMessage(int step)
|
||||
{
|
||||
var msgContent = FormatRspMessage(0, "Progress", step);
|
||||
|
||||
msg = JsonConvert.SerializeObject(msgContent);
|
||||
|
||||
SendRspMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
internal class Program
|
||||
internal class MainCode
|
||||
{
|
||||
private static int Main(string[] args)
|
||||
{
|
||||
|
@ -108,16 +154,13 @@ namespace GeneratorCode
|
|||
NLog.NLog_Init();
|
||||
GeneratorParams inParams = null;
|
||||
RspMessage rspMsg;
|
||||
var mainCfg = new MainConfig();
|
||||
var msgProcess = new MessageProcess(mainCfg);
|
||||
var tmObj = new TmatrixClass();
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
||||
{
|
||||
//Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang1\n");
|
||||
};
|
||||
|
||||
AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
|
||||
{
|
||||
//Trace.WriteLine("+++++++++++++++++++++++++++++++++++++++++++xajhuang2\n");
|
||||
NLog.Crash("UnHandled Exception: " + e.ToString());
|
||||
};
|
||||
|
||||
AppDomain.CurrentDomain.ProcessExit += (sender, ev) =>
|
||||
|
@ -173,15 +216,22 @@ namespace GeneratorCode
|
|||
catch (Exception e)
|
||||
{
|
||||
rspMsg = new RspMessage("");
|
||||
var msg = rspMsg.FormatRspMessage(10, e.Message, 0);
|
||||
RspMessage.SendRspMessage(msg);
|
||||
NLog.Crash(string.Format("[{0}]: ", (inParams == null) ? inParams.sessionId : "UnInit") + e.Message);
|
||||
var msg = rspMsg.FormatRspMessage(10, e.Message, 0, mainCfg.Base64MsgContent);
|
||||
msgProcess.SendMessage(msg);
|
||||
NLog.Crash(string.Format("[{0}]: ", inParams == null ? inParams.sessionId : "UnInit") + e.Message);
|
||||
return -(int) ErrCode.ERR_JSON_DECODE;
|
||||
}
|
||||
|
||||
rspMsg = new RspMessage(inParams.sessionId);
|
||||
|
||||
tmObj.ProgressChange += rspMsg.ProgressMessage;
|
||||
tmObj.ProgressChange += step =>
|
||||
{
|
||||
var msgContent = rspMsg.FormatRspMessage(0, "Progress", step, mainCfg.Base64MsgContent);
|
||||
|
||||
var msg = JsonConvert.SerializeObject(msgContent);
|
||||
|
||||
msgProcess.SendMessage(msg);
|
||||
};
|
||||
|
||||
var jsInput = JsonConvert.SerializeObject(inParams);
|
||||
|
||||
|
@ -199,8 +249,8 @@ namespace GeneratorCode
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(7, e.Message, 0);
|
||||
RspMessage.SendRspMessage(msg);
|
||||
var msg = rspMsg.FormatRspMessage(7, e.Message, 0, mainCfg.Base64MsgContent);
|
||||
msgProcess.SendMessage(msg);
|
||||
NLog.Crash(e.ToString());
|
||||
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
||||
}
|
||||
|
@ -214,24 +264,27 @@ namespace GeneratorCode
|
|||
if (ret.Substring(0, 1) != "0")
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
||||
ret.Substring(1, ret.Length - 1), tmObj.GetProgerss());
|
||||
ret.Substring(1, ret.Length - 1),
|
||||
tmObj.GetProgerss(),
|
||||
mainCfg.Base64MsgContent);
|
||||
|
||||
NLog.Error(msg + Environment.NewLine);
|
||||
RspMessage.SendRspMessage(msg);
|
||||
msgProcess.SendMessage(msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
||||
ret.Substring(1, ret.Length - 1), 100);
|
||||
ret.Substring(1, ret.Length - 1), 100,
|
||||
mainCfg.Base64MsgContent);
|
||||
|
||||
NLog.Debug(msg + Environment.NewLine);
|
||||
RspMessage.SendRspMessage(msg);
|
||||
msgProcess.SendMessage(msg);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss());
|
||||
RspMessage.SendRspMessage(msg);
|
||||
var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss(), mainCfg.Base64MsgContent);
|
||||
msgProcess.SendMessage(msg);
|
||||
NLog.Crash(e.ToString());
|
||||
return -(int) ErrCode.ERR_EXCEPT_THROW;
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<File Version="1.0">
|
||||
<ExtensionPoint ID="I_OIDPGHelper" Enable="1">
|
||||
<Plugin ID="OIDPGHelper" Bundle="OIDPGHelper.dll" Enable="1"/>
|
||||
</ExtensionPoint>
|
||||
<ExtensionPoint ID="I_OIDTiffConvertor" Enable="1">
|
||||
<Plugin ID="OIDTiffConvertor" Bundle="OIDTiffConvertor.dll" Enable="1"/>
|
||||
</ExtensionPoint>
|
||||
<ExtensionPoint ID="I_OIDPGHelper" Enable="1">
|
||||
<Plugin ID="OIDPGHelper" Bundle="OIDPGHelper.dll" Enable="1" />
|
||||
</ExtensionPoint>
|
||||
<ExtensionPoint ID="I_OIDTiffConvertor" Enable="1">
|
||||
<Plugin ID="OIDTiffConvertor" Bundle="OIDTiffConvertor.dll" Enable="1" />
|
||||
</ExtensionPoint>
|
||||
</File>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,4 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OIDModule.Generator
|
||||
{
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
internal enum OIDBeginBuildState
|
||||
{
|
||||
eBBState_OK,
|
||||
|
@ -9,17 +9,20 @@ namespace OIDModule.Generator
|
|||
eBBState_FailToOpenImageFile,
|
||||
eBBState_Unknown
|
||||
}
|
||||
|
||||
internal enum OIDPrintPointType
|
||||
{
|
||||
eOID_PrintPointType_2x2,
|
||||
eOID_PrintPointType_3x3,
|
||||
eOID_PrintPointType_4x4
|
||||
}
|
||||
|
||||
internal enum OIDPublishImageDPIType
|
||||
{
|
||||
eOID_PublishImageDPI_600,
|
||||
eOID_PublishImageDPI_1200
|
||||
}
|
||||
|
||||
internal enum OIDPublishImageType
|
||||
{
|
||||
eOID_PIT_Publish_Image,
|
||||
|
@ -27,6 +30,7 @@ namespace OIDModule.Generator
|
|||
eOID_PIT_BG_Vertor_Image,
|
||||
eOID_PIT_Publish_BG_Image
|
||||
}
|
||||
|
||||
internal enum OIDPublishObjectType
|
||||
{
|
||||
eOID_OT_ElementCode,
|
||||
|
@ -35,9 +39,11 @@ namespace OIDModule.Generator
|
|||
|
||||
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)
|
||||
|
@ -50,9 +56,11 @@ namespace OIDModule.Generator
|
|||
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()
|
||||
|
@ -65,24 +73,46 @@ namespace OIDModule.Generator
|
|||
return OID_PIG_Initialize();
|
||||
}
|
||||
|
||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
||||
private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX, uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType);
|
||||
[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)]
|
||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||
CallingConvention.StdCall)]
|
||||
private static extern bool OID_PIG_AddObjectInfo(int nPageIndex, ulong uiObjectIndex, uint[] arPointX,
|
||||
uint[] arPointY, int nPointsCount, int nZOrder, int nObjectType);
|
||||
|
||||
[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);
|
||||
[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", CallingConvention=CallingConvention.StdCall)]
|
||||
|
||||
[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", CallingConvention =
|
||||
CallingConvention.StdCall)]
|
||||
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();
|
||||
[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);
|
||||
[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);
|
||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention=CallingConvention.StdCall)]
|
||||
|
||||
[DllImport(@".\OIDPublishImageGenerator\OIDPublishImageGenerator.dll", CallingConvention =
|
||||
CallingConvention.StdCall)]
|
||||
private static extern void OID_PIG_Uninitialize();
|
||||
|
||||
public bool SetPublishPages(int[] arPageNumbers, int nPageCount)
|
||||
{
|
||||
return OID_PIG_SetPublishPages(arPageNumbers, nPageCount);
|
||||
|
|
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 相关配置
|
||||
;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<packages>
|
||||
<package id="ini-parser" version="2.5.2" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
|
||||
|
|
Loading…
Reference in New Issue