标准化错误代码
This commit is contained in:
parent
1ce879d762
commit
8f2c87b3b7
|
@ -64,7 +64,14 @@ namespace GeneratorCode.Configure
|
|||
|
||||
try
|
||||
{
|
||||
ret = (T) Convert.ChangeType(_cfgData[segName][keyName], typeof(T));
|
||||
string val;
|
||||
|
||||
|
||||
if (_cfgData.TryGetKey(segName + _cfgData.SectionKeySeparator + keyName, out val))
|
||||
{
|
||||
ret = (T)Convert.ChangeType(val, typeof(T));
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// Created : 02-14-2019
|
||||
//
|
||||
// Last Modified By : 黄昕 <hzhuangxin01@corp.netease.com>
|
||||
// Last Modified On : 02-26-2019
|
||||
// Last Modified On : 03-04-2019
|
||||
// ***********************************************************************
|
||||
// <copyright file="MainCode.cs" company="NetEase">
|
||||
// Copyright © 2019
|
||||
|
@ -41,8 +41,8 @@ namespace GeneratorCode
|
|||
imageType = 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";
|
||||
}
|
||||
|
||||
|
@ -289,9 +289,13 @@ namespace GeneratorCode
|
|||
rsp.err = errCode;
|
||||
|
||||
if (enBase64)
|
||||
{
|
||||
rsp.msg = Convert.ToBase64String(Encoding.Default.GetBytes(readme));
|
||||
}
|
||||
else
|
||||
{
|
||||
rsp.msg = readme;
|
||||
}
|
||||
|
||||
return JsonConvert.SerializeObject(rsp);
|
||||
}
|
||||
|
@ -302,6 +306,46 @@ namespace GeneratorCode
|
|||
/// </summary>
|
||||
internal class MainCode
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the offical error code.
|
||||
/// </summary>
|
||||
/// <param name="err">The error.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private static int GetOfficalErrCode([NotNull] string err = "0")
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case "0":
|
||||
return (int) ErrCode.ErrSuccesed;
|
||||
|
||||
case "1":
|
||||
return (int) ErrCode.ErrKeyTampered;
|
||||
|
||||
case "2":
|
||||
return (int) ErrCode.ErrKeyOldStyle;
|
||||
|
||||
case "3":
|
||||
return (int) ErrCode.ErrKeyExpired;
|
||||
|
||||
case "4":
|
||||
return (int) ErrCode.ErrFileNotExists;
|
||||
|
||||
case "5":
|
||||
return (int) ErrCode.ErrStartPage;
|
||||
|
||||
case "6":
|
||||
return (int) ErrCode.ErrPageNotEnough;
|
||||
|
||||
case "7":
|
||||
return (int) ErrCode.ErrSizeMoreThan780;
|
||||
|
||||
case "8":
|
||||
return (int) ErrCode.ErrSizeMoreThan6242;
|
||||
}
|
||||
|
||||
return (int) ErrCode.ErrUnknownCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the entry point of the application.
|
||||
/// </summary>
|
||||
|
@ -338,20 +382,6 @@ namespace GeneratorCode
|
|||
NLog.NLog_Finish();
|
||||
};
|
||||
|
||||
//string inputArg =
|
||||
// "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpbWFnZV90eXBlI" +
|
||||
// "jpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6IlMwLE8wMDAsQjAwMDAsUDAwMC0" +
|
||||
// "yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVhZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsIm" +
|
||||
// "ZpbGVQYXRoIjoiRTpcXE5ldEVhc2VcXLnsvKOxylxcU2FtcGxlXFwxMjMucGRmIiwiU3Rhcn" +
|
||||
// "RQYWdlSUQiOjAsInNlc3Npb25JZCI6IjRCRDVEOTIzLTQ3RUEtNERFRi1BMUNELTlCODVCNT" +
|
||||
// "E1QjE5MSJ9";
|
||||
//string inputArg2 = "eyJkcGkiOlswLDAsMCwwXSwicG9pbnRfdHlwZSI6WzAsMCwwLDBdLCJpb" +
|
||||
// "WFnZV90eXBlIjpbZmFsc2UsZmFsc2UsZmFsc2UsdHJ1ZV0sImtleSI6Il" +
|
||||
// "MwLE8wMDAsQjAwMDAsUDAwMC0yNTUsRDIwMTgvMTIvMzE7Q0NBRkJRTVh" +
|
||||
// "ZUE9BT0NJUks1MlM4UUM4U080QTBBR0E4WSIsImZpbGVQYXRoIjoiQzpc" +
|
||||
// "XFdvcmtzXFxwZGZcXDEyMy5wZGYiLCJTdGFydFBhZ2VJRCI6MCwic2Vzc" +
|
||||
// "2lvbklkIjoiNEJENUQ5MjMtNDdFQS00REVGLUExQ0QtOUI4NUI1MTVCMTkxIn0=";
|
||||
|
||||
try
|
||||
{
|
||||
if (args.Length == 1)
|
||||
|
@ -380,7 +410,7 @@ namespace GeneratorCode
|
|||
|
||||
if (inParams != null) NLog.Crash(string.Format("[{0}]: ", inParams.sessionId) + e.Message);
|
||||
|
||||
return -(int) ErrCode.ErrJsonDecode;
|
||||
return (int) ErrCode.ErrJsonDecode;
|
||||
}
|
||||
|
||||
rspMsg = new RspMessage(inParams.sessionId);
|
||||
|
@ -401,7 +431,7 @@ namespace GeneratorCode
|
|||
if (!File.Exists(inParams.filePath))
|
||||
{
|
||||
NLog.Error("File Not Exists: " + inParams.filePath + Environment.NewLine);
|
||||
return -(int) ErrCode.ErrFileNotexists;
|
||||
return (int) ErrCode.ErrFileNotExists;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -413,7 +443,7 @@ namespace GeneratorCode
|
|||
var msg = rspMsg.FormatRspMessage(7, e.Message, 0, mainCfg.Base64MsgContent);
|
||||
msgProcess.SendMessage(msg);
|
||||
NLog.Crash(e.ToString());
|
||||
return -(int) ErrCode.ErrExceptThrow;
|
||||
return (int) ErrCode.ErrExceptThrow;
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -422,7 +452,9 @@ namespace GeneratorCode
|
|||
inParams.filePath, inParams.startPageId, inParams.pointType,
|
||||
inParams.imageType, inParams.dpi);
|
||||
|
||||
if (ret.Substring(0, 1) != "0")
|
||||
var errCode = GetOfficalErrCode(ret.Substring(0, 1));
|
||||
|
||||
if (errCode != 0)
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(int.Parse(ret.Substring(0, 1)),
|
||||
ret.Substring(1, ret.Length - 1),
|
||||
|
@ -441,16 +473,16 @@ namespace GeneratorCode
|
|||
NLog.Debug(msg + Environment.NewLine);
|
||||
msgProcess.SendMessage(msg);
|
||||
}
|
||||
|
||||
return errCode;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var msg = rspMsg.FormatRspMessage(8, e.Message, tmObj.GetProgerss(), mainCfg.Base64MsgContent);
|
||||
msgProcess.SendMessage(msg);
|
||||
NLog.Crash(e.ToString());
|
||||
return -(int) ErrCode.ErrExceptThrow;
|
||||
return (int) ErrCode.ErrExceptThrow;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -458,25 +490,70 @@ namespace GeneratorCode
|
|||
/// </summary>
|
||||
private enum ErrCode
|
||||
{
|
||||
/// <summary>
|
||||
/// The error succesed
|
||||
/// </summary>
|
||||
ErrSuccesed = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The error size more than780
|
||||
/// </summary>
|
||||
ErrSizeMoreThan780 = 105,
|
||||
|
||||
/// <summary>
|
||||
/// The error size more than6242
|
||||
/// </summary>
|
||||
ErrSizeMoreThan6242 = 106,
|
||||
|
||||
/// <summary>
|
||||
/// The error start page
|
||||
/// </summary>
|
||||
ErrStartPage = 110,
|
||||
|
||||
/// <summary>
|
||||
/// The error input parameters
|
||||
/// </summary>
|
||||
ErrInputParams = 1,
|
||||
ErrInputParams = 122,
|
||||
|
||||
/// <summary>
|
||||
/// The error key tampered
|
||||
/// </summary>
|
||||
ErrKeyTampered = 123,
|
||||
|
||||
/// <summary>
|
||||
/// The error key old style
|
||||
/// </summary>
|
||||
ErrKeyOldStyle = 124,
|
||||
|
||||
/// <summary>
|
||||
/// The error key expired
|
||||
/// </summary>
|
||||
ErrKeyExpired = 125,
|
||||
|
||||
/// <summary>
|
||||
/// The error page not enough
|
||||
/// </summary>
|
||||
ErrPageNotEnough = 126,
|
||||
|
||||
/// <summary>
|
||||
/// The error file not exists
|
||||
/// </summary>
|
||||
ErrFileNotexists,
|
||||
ErrFileNotExists = 127,
|
||||
|
||||
/// <summary>
|
||||
/// The error except throw
|
||||
/// </summary>
|
||||
ErrExceptThrow,
|
||||
ErrExceptThrow = 128,
|
||||
|
||||
/// <summary>
|
||||
/// The error json decode
|
||||
/// </summary>
|
||||
ErrJsonDecode
|
||||
ErrJsonDecode = 129,
|
||||
|
||||
/// <summary>
|
||||
/// The error unknown code
|
||||
/// </summary>
|
||||
ErrUnknownCode = 130
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1058,13 +1058,13 @@ namespace TmatrixLibrary
|
|||
str = TmatrixKeyCheck_OID4(KeyStr);
|
||||
if (str.Substring(0, 1) != "0") return str;
|
||||
|
||||
if (PDFFileName == "") return "1Please select PDF file first !";
|
||||
if (PDFFileName == "") return "4Please select PDF file first !";
|
||||
|
||||
if (StartPageID < int.Parse(gsPID1) || StartPageID > int.Parse(gsPID2))
|
||||
return "2Start page ID must be located between " + gsPID1 + " ~ " + gsPID2;
|
||||
return "5Start page ID must be located between " + gsPID1 + " ~ " + gsPID2;
|
||||
gPageNum = GetPDFPageNumber(PDFFileName);
|
||||
if (gPageNum + StartPageID - 1 > int.Parse(gsPID2))
|
||||
return "3Not enough code page for this PDF to generate !";
|
||||
return "6Not enough code page for this PDF to generate !";
|
||||
|
||||
SetProgress(1);
|
||||
|
||||
|
@ -1207,11 +1207,11 @@ namespace TmatrixLibrary
|
|||
case 1:
|
||||
case 2:
|
||||
if (num16 <= 780 && num17 <= 780) break;
|
||||
return "4PDF page size's width or height > 780mm !";
|
||||
return "7PDF page size's width or height > 780mm !";
|
||||
|
||||
case 3:
|
||||
if (num16 <= 0x1862 && num17 <= 0x1862) break;
|
||||
return "5PDF page size's width or height > 6242mm !";
|
||||
return "8PDF page size's width or height > 6242mm !";
|
||||
}
|
||||
|
||||
var numArray3 = new uint[5];
|
||||
|
|
Loading…
Reference in New Issue