Commit f63446bb by 陶然

init

parents
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################
/Src/bin/Debug
/Src/obj/Debug
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!--<add name="Database" providerName="Sqlite" connectionString="$ROOT\AppData\primary.sqlite"/>-->
</connectionStrings>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Finances.Icbc
{
internal class Configs
{
public const string TableUiSetting = "ui_settings";
public const string RouteAcceptPayment = "/Restful/Kivii.Icbc.Entities.ICBC/AcceptPayment";
}
}
<?xml version="1.0" encoding = "GBK"?>
<CMS>
<eb>
<pub>
<TransCode>QACCBAL</TransCode>
<CIS></CIS>
<BankCode>102</BankCode>
<ID></ID>
<TranDate></TranDate>
<TranTime></TranTime>
<fSeqno></fSeqno>
</pub>
<in>
<TotalNum>1</TotalNum>
<BLFlag></BLFlag>
<SynFlag></SynFlag>
<rd>
<iSeqno>1</iSeqno>
<AccNo></AccNo>
<CurrType></CurrType>
<ReqReserved3></ReqReserved3>
<AcctSeq></AcctSeq>
</rd>
</in>
</eb>
</CMS>
\ No newline at end of file
<?xml version="1.0" encoding = "GBK"?>
<CMS>
<eb>
<pub>
<TransCode>QHISD</TransCode>
<CIS></CIS>
<BankCode>102</BankCode>
<ID></ID>
<TranDate></TranDate>
<TranTime></TranTime>
<fSeqno></fSeqno>
</pub>
<in>
<AccNo></AccNo>
<BeginDate></BeginDate>
<EndDate></EndDate>
<MinAmt></MinAmt>
<MaxAmt></MaxAmt>
<BankType></BankType>
<NextTag></NextTag>
<CurrType></CurrType>
<DueBillNo></DueBillNo>
<AcctSeq></AcctSeq>
<ComplementFlag></ComplementFlag>
</in>
</eb>
</CMS>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Icbc.Entities
{
public class ICBC
{
/// <summary>
/// 借贷标志
/// </summary>
public string Drcrf { get; set; }
/// <summary>
/// 凭证号
/// </summary>
public string VouhNo { get; set; }
/// <summary>
/// 借方发生额
/// </summary>
public decimal DebitAmount { get; set; }
/// <summary>
/// 贷方发生额
/// </summary>
public decimal CreditAmount { get; set; }
/// <summary>
/// 当前余额
/// </summary>
public string Balance { get; set; }
/// <summary>
/// 对方行号
/// </summary>
public string RecipBkNo { get; set; }
/// <summary>
/// 对方行名
/// </summary>
public string RecipBkName { get; set; }
/// <summary>
/// 对方账号
/// </summary>
public string RecipAccNo { get; set; }
/// <summary>
/// 对方户名
/// </summary>
public string RecipName { get; set; }
/// <summary>
/// 摘要
/// </summary>
public string Summary { get; set; }
/// <summary>
/// 用途
/// </summary>
public string UseCN { get; set; }
/// <summary>
/// 附言
/// </summary>
public string PostScript { get; set; }
/// <summary>
/// 业务代码
/// </summary>
public string BusCode { get; set; }
/// <summary>
/// 交易日期
/// </summary>
public string Date { get; set; }
/// <summary>
/// 时间戳
/// </summary>
public string Time { get; set; }
/// <summary>
/// 业务编号
/// </summary>
public string Ref { get; set; }
/// <summary>
/// 相关业务编号
/// </summary>
public string Oref { get; set; }
/// <summary>
/// 英文备注
/// </summary>
public string EnSummary { get; set; }
/// <summary>
/// 业务种类
/// </summary>
public string BusType { get; set; }
/// <summary>
/// 凭证种类
/// </summary>
public string VouhType { get; set; }
/// <summary>
/// 附加信息
/// </summary>
public string AddInfo { get; set; }
/// <summary>
/// 电子回单唯一标识
/// </summary>
public string Toutfo { get; set; }
/// <summary>
/// 银行交易流水号
/// </summary>
public string OnlySequence { get; set; }
/// <summary>
/// 财务公司二级账户账号
/// </summary>
public string AgentAcctName { get; set; }
/// <summary>
/// 财务公司二级账户账号
/// </summary>
public string AgentAcctNo { get; set; }
/// <summary>
/// 冲正标志,0:正常
/// </summary>
public string UpDtranf { get; set; }
/// <summary>
/// 起息日
/// </summary>
public string ValueDate { get; set; }
/// <summary>
/// 工行交易代码
/// </summary>
public string TrxCode { get; set; }
/// <summary>
/// 业务编号1
/// </summary>
public string Ref1 { get; set; }
/// <summary>
/// 相关业务编号1
/// </summary>
public string Oref1 { get; set; }
/// <summary>
/// 交易类型
/// </summary>
public string CASHF { get; set; }
/// <summary>
/// 入账日期
/// </summary>
public string BusiDate { get; set; }
/// <summary>
/// 入账时间
/// </summary>
public string BusiTime { get; set; }
public string TradeTime { get; set; }
/// <summary>
/// 交易场所
/// </summary>
public string TradeLocation { get; set; }
/// <summary>
/// 账号序号
/// </summary>
public string SubAcctSeq { get; set; }
/// <summary>
/// 币种
/// </summary>
public string THCurrency { get; set; }
/// <summary>
/// 对方行名
/// </summary>
public string RecipBkName1 { get; set; }
/// <summary>
/// 对方行号
/// </summary>
public string RecipBkNo1 { get; set; }
/// <summary>
/// 电子回单唯一标识
/// </summary>
public string TInfoNew { get; set; }
/// <summary>
/// 跨行退回原因
/// </summary>
public string RefundMsg { get; set; }
/// <summary>
/// 回单业务种类
/// </summary>
public string BusTypNo { get; set; }
/// <summary>
/// 回单个性化信息
/// </summary>
public string ReceiptInfo { get; set; }
/// <summary>
/// 柜员号
/// </summary>
public string TelNo { get; set; }
/// <summary>
/// 本方财智账户卡卡号(管家卡卡号)
/// </summary>
public string MDCARDNO { get; set; }
public string TrxAmt { get; set; }
public string TrxCurr { get; set; }
/// <summary>
/// 币种
/// </summary>
public string CurrType { get; set; }
}
public class ICBCConfig
{
public string AccNo { get; set; }
public string AccName { get; set; }
public string currentBalance { get; set; }
public DateTime BeginDate { get; set; }
public DateTime EndDate { get; set; }
public string MinAmt { get; set; }
public string MaxAmt { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
namespace Kivii.Finances.Icbc.Entities
{
internal class NetSafeConfig
{
public string HttpsIp { get; set; }
public int HttpsPort { get; set; }
public string GroupId { get; set; }
public string CertId { get; set; }
public string InterfaceVersion { get; set; }
}
internal class ICBC_NetSafeClient
{
private string httpsIP;
private string signIP;
private int httpPort;
private int signPort;
private int httpTimeOut;
private int signTimeOut;
private StreamWriter logFile;
private bool logSwitch;
private string logDir;
private string xmlVersion;
private string GroupID;
private string CertID;
private string YMDTime;
private string logFN;
private Random RanSeed;
private TimeSpan Local_Bank;
private string LastBankDate;
private string ThirtySix;
private int N36P2;
private int N36P3;
private string HttpHeadString;
private string inputXML;
private string outputXML;
private string BankReturnEncoding;
public string GetHttpHeadString()
{
return HttpHeadString;
}
public ICBC_NetSafeClient()
{
httpsIP = (signIP = "127.0.0.1");
httpPort = 448;
signPort = 449;
httpTimeOut = 30;
signTimeOut = 10;
logSwitch = false;
logFile = null;
xmlVersion = "0.0.0.1";
logDir = "D:\\";
GroupID = null;
CertID = null;
YMDTime = "yyyymmdd";
LastBankDate = null;
Local_Bank = TimeSpan.Zero;
RanSeed = new Random();
ThirtySix = "";
for (int j = 0; j < 10; j++)
{
ThirtySix += Convert.ToChar(48 + j).ToString();
}
for (int i = 0; i < 26; i++)
{
ThirtySix += Convert.ToChar(65 + i).ToString();
}
N36P2 = 1296;
N36P3 = 46656;
}
public string GetHttpsIP()
{
return httpsIP;
}
public void SetHttpsIP(string ip)
{
httpsIP = ip;
}
public string GetSignIP()
{
return signIP;
}
public void SetSignIP(string ip)
{
signIP = ip;
}
public int GetHttpsPort()
{
return httpPort;
}
public void SetHttpsPort(int port)
{
httpPort = port;
}
public int GetSignPort()
{
return signPort;
}
public void SetSignPort(int port)
{
signPort = port;
}
public int GetHttpsTimeOut()
{
return httpTimeOut;
}
public void SetHttpsTimeOut(int time)
{
httpTimeOut = time;
if (httpTimeOut <= 0 || httpTimeOut > 60)
{
httpTimeOut = 30;
}
}
public int GetSignTimeOut()
{
return signTimeOut;
}
public void SetSignTimeOut(int time)
{
signTimeOut = time;
if (signTimeOut <= 0 || signTimeOut > 60)
{
signTimeOut = 10;
}
}
public string GetInterfaceVersion()
{
return xmlVersion;
}
public void SetInterfaceVersion(string ver)
{
xmlVersion = ver.Trim();
}
public void SetLogSwitch(bool log)
{
logSwitch = log;
}
public void SetLogFilePath(string logPath)
{
logDir = logPath;
if (logPath[logPath.Length - 1] != '\\')
{
logDir += "\\";
}
}
public string GetLogFileName()
{
return logFN;
}
public void SetGroupID(string gid)
{
GroupID = gid.Trim();
}
public string GetGroupID()
{
return GroupID;
}
public void SetCertID(string cid)
{
CertID = cid.Trim();
}
public string GetCertID()
{
return CertID;
}
public void SetYMDTime(string ymdt)
{
YMDTime = ymdt;
}
public void Run(string xmlString, out string seqNo, out string result)
{
outputXML = (result = null);
inputXML = xmlString;
XML_EASY reqXML = new XML_EASY(xmlString);
bool needSign = reqXML.GetXMLNode("SignTime") != null;
string sysDateTime = DateTime.Now.ToString("yyyyMMddHHmmssfff");
string TransCode = reqXML.GetXMLNode("TransCode");
if (TransCode == null)
{
TransCode = "";
}
seqNo = reqXML.GetXMLNode("fSeqno");
bool createSeq = false;
if (seqNo == null || seqNo.Trim().Length <= 3)
{
seqNo = GetSeqno(sysDateTime + TransCode);
createSeq = true;
reqXML.SetXMLNode("fSeqno", seqNo);
}
logFN = null;
//if (logSwitch)
//{
// string LFN = createSeq ? seqNo : GetSeqno(sysDateTime + TransCode);
// logFN = logDir + LFN.Substring(0, 6) + "-" + LFN.Substring(6, 4) + "-" + LFN.Substring(10, 4) + "@" + TransCode + ".log";
// if (logFile != null)
// {
// logFile.Close();
// }
// logFile = new StreamWriter(logFN, append: false, Encoding.GetEncoding("GBK"));
// logFile.WriteLine(myInfo);
// logFile.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss fff]"));
// logFile.WriteLine();
//}
if (GetGroupID() != null)
{
reqXML.SetXMLNode("CIS", GetGroupID());
}
if (GetCertID() != null)
{
reqXML.SetXMLNode("ID", GetCertID());
}
string url2;
if (LastBankDate == null && needSign)
{
if (logFile != null)
{
logFile.WriteLine("本交易需签名,未获取过银行服务器时间。检测银行主机时间(Detect Time Info From Bank)。");
}
url2 = "http://" + GetHttpsIP() + ":" + GetHttpsPort().ToString() + "/servlet/ICBCCMPAPIReqServlet?userID=" + GetCertID() + "&PackageID=" + sysDateTime + "&SendTime=" + sysDateTime;
ncPost(url2, sysDateTime, GetHttpsTimeOut(), sign: false);
if (logFile != null)
{
logFile.WriteLine();
}
}
string usingDateTime;
if (YMDTime.ToLower() == "yyyymmdd")
{
if (Local_Bank.TotalMinutes >= 3.0 || Local_Bank.TotalMinutes <= -3.0)
{
usingDateTime = (DateTime.Now - Local_Bank).ToString("yyyyMMddHHmmssfff");
if (logFile != null)
{
logFile.WriteLine("时间误差较大,XML报文日期时间调整到(Follow Bank's DateTime):{0}", usingDateTime);
logFile.WriteLine();
}
}
else
{
usingDateTime = sysDateTime;
}
}
else
{
usingDateTime = YMDTime + sysDateTime.Substring(YMDTime.Length);
}
if (logFile != null)
{
logFile.WriteLine("xml原始报文信息(raw xml):");
logFile.WriteLine(xmlString);
logFile.WriteLine();
logFile.WriteLine();
}
reqXML.SetXMLNode("TranDate", usingDateTime.Substring(0, 8));
reqXML.SetXMLNode("TranTime", usingDateTime.Substring(8));
reqXML.SetXMLNode("SignTime", usingDateTime);
if (reqXML.LocateString("%fSeqno%") > 0)
{
string tmpReq = reqXML.GetXML();
reqXML.SetXML(tmpReq.Replace("%fSeqno%", seqNo));
}
string zipped = reqXML.GetXMLNode("zip");
bool needZip = zipped != null;
if (logFile != null)
{
logFile.WriteLine("补充信息后的xml(decorated xml):");
logFile.WriteLine(reqXML.GetXML());
logFile.WriteLine();
logFile.WriteLine();
}
if (needZip)
{
string afterZip = ZipBase64enc(zipped);
reqXML.SetXMLNode("zip", afterZip);
if (logFile != null)
{
logFile.WriteLine("存在需要压缩的信息(zip string)。");
logFile.WriteLine();
logFile.WriteLine("压缩后的信息(after zipped):");
logFile.WriteLine(afterZip);
logFile.WriteLine();
logFile.WriteLine();
}
}
string reqData2 = "";
string ncReturn2 = "U";
if (needSign)
{
if (logFile != null)
{
logFile.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss fff]"));
logFile.WriteLine("签名-发送地址(sign server address):");
logFile.WriteLine("http://" + GetSignIP() + ":" + GetSignPort().ToString());
logFile.WriteLine();
logFile.WriteLine();
logFile.WriteLine("签名-发送内容(sign server content):");
logFile.WriteLine(reqXML.GetXML());
logFile.WriteLine();
logFile.WriteLine();
}
XML_EASY signStr = new XML_EASY(ncPost("http://" + GetSignIP() + ":" + GetSignPort().ToString(), reqXML.GetXML(), GetSignTimeOut(), sign: true));
if (logFile != null)
{
logFile.WriteLine();
}
reqData2 = signStr.GetXMLNode("sign");
if (reqData2 == null)
{
ncReturn2 = "error<error>签名交易失败!sign server failed!</error>";
if (logFile != null)
{
logFile.WriteLine(ncReturn2);
}
}
else if (logFile != null)
{
logFile.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss fff]"));
logFile.WriteLine("签名-结果(sign server return):");
logFile.WriteLine(signStr.GetXML());
logFile.WriteLine();
logFile.WriteLine();
}
}
else
{
reqData2 = HttpUtility.UrlEncode(reqXML.GetXML(), Encoding.GetEncoding("GBK"));
}
if (reqData2 == null || reqData2.Length == 0)
{
outputXML = (result = ncReturn2);
if (logFile != null)
{
logFile.Close();
logFile = null;
}
return;
}
url2 = "http://" + GetHttpsIP() + ":" + GetHttpsPort().ToString() + "/servlet/ICBCCMPAPIReqServlet?userID=" + GetCertID() + "&PackageID=" + seqNo + "&SendTime=" + usingDateTime;
if (needZip)
{
url2 += "&zipFlag=1";
}
string cont = "Version=" + GetInterfaceVersion() + "&TransCode=" + TransCode + "&BankCode=102&GroupCIS=" + GetGroupID() + "&ID=" + GetCertID() + "&PackageID=" + seqNo + "&Cert=&reqData=" + reqData2;
if (logFile != null)
{
logFile.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss fff]"));
logFile.WriteLine("安全HTTP服务-发送地址(https server address):");
logFile.WriteLine(url2);
logFile.WriteLine();
logFile.WriteLine();
logFile.WriteLine("安全HTTP服务-发送内容(https server content):");
logFile.WriteLine(cont);
logFile.WriteLine();
logFile.WriteLine();
}
ncReturn2 = ncPost(url2, cont, GetHttpsTimeOut(), sign: false);
if (logFile != null)
{
logFile.WriteLine();
}
if (ncReturn2 == null || ncReturn2.Length == 0)
{
outputXML = (result = "error<error>未接受到银行返回信息!https server failed!</error>");
if (logFile != null)
{
logFile.WriteLine(result);
logFile.Close();
logFile = null;
}
return;
}
if (logFile != null)
{
logFile.WriteLine(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss fff]"));
logFile.WriteLine("银行返回结果(bank return mesage):");
logFile.WriteLine(ncReturn2);
logFile.WriteLine();
logFile.WriteLine();
}
BankReturnEncoding = "GBK";
string headInfo = HttpHeadString.ToUpper();
int cs = headInfo.IndexOf("CHARSET");
if (cs > 0)
{
int p3 = headInfo.IndexOf('=', cs);
char[] endCharSet = new char[2]
{
';',
'<'
};
int p2 = headInfo.IndexOfAny(endCharSet, p3);
BankReturnEncoding = headInfo.Substring(p3 + 1, p2 - p3 - 1).Trim();
}
byte[] bytes = Convert.FromBase64String(ncReturn2.Substring(ncReturn2.IndexOf('=') + 1));
if (ncReturn2.IndexOf("errorCode") >= 0)
{
result = "<error>errorCode=" + Encoding.GetEncoding(BankReturnEncoding).GetString(bytes) + "</error>";
}
else
{
result = Encoding.GetEncoding(BankReturnEncoding).GetString(bytes);
}
if (logFile != null)
{
logFile.WriteLine("BASE64解码(base64dec){0}:", BankReturnEncoding);
logFile.WriteLine(result);
logFile.WriteLine();
logFile.WriteLine();
}
XML_EASY resultXML = new XML_EASY(result);
string resultZip = resultXML.GetXMLNode("zip");
if (resultZip != null)
{
resultXML.SetXMLNode("zip", Base64decUnzip(resultZip));
result = resultXML.GetXML();
if (logFile != null)
{
logFile.WriteLine("解压缩(after zipped):");
logFile.WriteLine(result);
logFile.WriteLine();
logFile.WriteLine();
}
}
if (logFile != null)
{
logFile.Close();
logFile = null;
}
outputXML = result;
}
public bool TryNextTag(out string reqID, out string result)
{
reqID = null;
result = null;
XML_EASY xML_EASY = new XML_EASY(outputXML);
string lastNextTag = xML_EASY.GetXMLNode("NextTag");
if (xML_EASY.GetXMLNode("RetCode") != "0" || lastNextTag == null || lastNextTag.Trim().Length == 0)
{
return false;
}
XML_EASY readLastInput = new XML_EASY(inputXML);
readLastInput.SetXMLNode("NextTag", lastNextTag);
Run(readLastInput.GetXML(), out reqID, out result);
return true;
}
private string GetSeqno(string TimeStr)
{
string seq6 = TimeStr.Substring(2, 10);
int ssfff4 = Convert.ToInt32(TimeStr.Substring(12, 5)) * 27 + RanSeed.Next(27);
int x3 = ssfff4 / N36P3;
seq6 += ThirtySix[x3].ToString();
ssfff4 -= x3 * N36P3;
x3 = ssfff4 / N36P2;
seq6 += ThirtySix[x3].ToString();
ssfff4 -= x3 * N36P2;
x3 = ssfff4 / 36;
seq6 += ThirtySix[x3].ToString();
ssfff4 -= x3 * 36;
seq6 += ThirtySix[ssfff4].ToString();
seq6 += "@";
for (int i = 17; i < TimeStr.Length; i += 3)
{
seq6 += TimeStr[i].ToString();
if (seq6.Length >= 20)
{
break;
}
}
return seq6;
}
public string GetSignStr(string str)
{
return ncPost("http://" + GetSignIP() + ":" + GetSignPort().ToString(), str, GetSignTimeOut(), sign: true);
}
private string ncPost(string url, string postCont, int timeOut, bool sign)
{
byte[] bytesToPost = Encoding.GetEncoding("GBK").GetBytes(postCont);
string cookieheader2 = string.Empty;
CookieContainer cookieCon = new CookieContainer();
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(url);
httpRequest.CookieContainer = cookieCon;
httpRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0;)";
httpRequest.Method = "POST";
httpRequest.Timeout = timeOut * 1000;
httpRequest.ServicePoint.Expect100Continue = false;
if (sign)
{
httpRequest.ContentLength = bytesToPost.Length;
httpRequest.ContentType = "INFOSEC_SIGN/1.0";
}
else
{
httpRequest.ContentType = "application/x-www-form-urlencoded;charset=GBK";
}
if (cookieheader2.Equals(string.Empty))
{
cookieheader2 = httpRequest.CookieContainer.GetCookieHeader(new Uri(url));
}
else
{
httpRequest.CookieContainer.SetCookies(new Uri(url), cookieheader2);
}
string stringResponse = "";
try
{
DateTime SendDT = DateTime.Now;
httpRequest.ContentLength = bytesToPost.Length;
Stream requestStream = httpRequest.GetRequestStream();
requestStream.Write(bytesToPost, 0, bytesToPost.Length);
requestStream.Close();
WebResponse wr = httpRequest.GetResponse();
WebHeaderCollection whc = wr.Headers;
string[] allKeys = whc.AllKeys;
string BankDateTime = null;
HttpHeadString = "";
string[] array = allKeys;
foreach (string info in array)
{
if (logFile != null)
{
logFile.WriteLine("{0}:{1}", info, whc.Get(info));
}
if (info == "Date")
{
BankDateTime = (LastBankDate = whc.Get(info));
}
HttpHeadString = HttpHeadString + "<WebHead:" + info + ">" + whc.Get(info) + "</WebHead:" + info + ">";
}
if (BankDateTime != null)
{
string pattern = "";
if (BankDateTime.IndexOf("+0") != -1)
{
BankDateTime = BankDateTime.Replace("GMT", "");
pattern = "ddd, dd MMM yyyy HH':'mm':'ss zzz";
}
if (BankDateTime.ToUpper().IndexOf("GMT") != -1)
{
pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'";
}
if (pattern != "")
{
DateTime bankDT = DateTime.ParseExact(BankDateTime, pattern, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal).ToLocalTime();
Local_Bank = SendDT - bankDT;
HttpHeadString = HttpHeadString + "<WebHead:LocalDate>" + bankDT.ToString("yyyy-MM-dd HH:mm:ss") + "</WebHead:LocalDate>";
if (logFile != null)
{
logFile.WriteLine("Convert Date Info To Local:{0}", bankDT.ToString("yyyy-MM-dd HH:mm:ss"));
}
}
}
Stream responseStream = wr.GetResponseStream();
using (StreamReader responseReader = new StreamReader(responseStream, Encoding.GetEncoding("GBK")))
{
stringResponse = responseReader.ReadToEnd();
}
responseStream.Close();
return stringResponse;
}
catch (Exception)
{
return stringResponse;
}
}
public static string ZipBase64enc(string str)
{
MemoryStream memoryStream = new MemoryStream();
GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress);
byte[] bs = Encoding.GetEncoding("GBK").GetBytes(str);
gZipStream.Write(bs, 0, bs.Length);
gZipStream.Close();
return Convert.ToBase64String(memoryStream.ToArray());
}
public static string Base64decUnzip(string str)
{
GZipStream zips = new GZipStream(new MemoryStream(Convert.FromBase64String(str)), CompressionMode.Decompress);
byte[] block = new byte[1024];
int bytesRead2 = 0;
MemoryStream outBuffer = new MemoryStream();
while (true)
{
bytesRead2 = zips.Read(block, 0, block.Length);
if (bytesRead2 <= 0)
{
break;
}
outBuffer.Write(block, 0, bytesRead2);
}
zips.Close();
return Encoding.GetEncoding("GBK").GetString(outBuffer.ToArray());
}
}
public class XML_EASY
{
private string xmlString;
private int idx;
public XML_EASY(string str)
{
xmlString = str;
idx = 0;
}
public XML_EASY()
{
xmlString = null;
}
public void SetXML(string str)
{
xmlString = str;
idx = 0;
}
public string GetXML()
{
return xmlString;
}
public int Index()
{
return idx;
}
public void ResetIndex()
{
idx = 0;
}
public void LoadXMLFile(string xmlFile)
{
StreamReader sr2 = new StreamReader(xmlFile, Encoding.GetEncoding("GBK"));
xmlString = sr2.ReadToEnd();
sr2.Close();
sr2 = null;
idx = 0;
}
public int LocateString(string str, int fromIdx = 0)
{
int i = xmlString.IndexOf(str, fromIdx);
if (i >= 0)
{
idx = i;
}
return i;
}
public void RepXMLNode(string oldNode, string newNodeContent, int fromIdx = 0)
{
if (oldNode == null || newNodeContent == null)
{
return;
}
string head = "<" + oldNode + ">";
int h = xmlString.IndexOf(head, fromIdx);
if (h >= 0)
{
string tail = "</" + oldNode + ">";
int t = xmlString.IndexOf(tail, h + head.Length);
if (t > h)
{
string strTmp = xmlString = xmlString.Substring(0, h) + newNodeContent + xmlString.Substring(t + tail.Length);
idx = h + newNodeContent.Length;
}
}
}
public string GetXMLNode(string node, int fromIdx = 0)
{
if (xmlString == null || node == null)
{
return null;
}
string head = "<" + node + ">";
int h = xmlString.IndexOf(head, fromIdx);
if (h >= 0)
{
string tail = "</" + node + ">";
int t = xmlString.IndexOf(tail, h + head.Length);
if (t > h)
{
idx = t + tail.Length;
return xmlString.Substring(h + head.Length, t - h - head.Length);
}
}
return null;
}
public void SetXMLNode(string node, string nodeContent, int fromIdx = 0)
{
string head = "<" + node + ">";
int h = xmlString.IndexOf(head, fromIdx);
if (h >= 0)
{
string tail = "</" + node + ">";
int t = xmlString.IndexOf(tail, h + head.Length);
if (t > h)
{
string strTmp = xmlString = xmlString.Substring(0, h + head.Length) + nodeContent + xmlString.Substring(t);
idx = h + head.Length + nodeContent.Length + tail.Length;
}
}
}
public bool NextXMLNode(out string node, out string nodeContent)
{
node = (nodeContent = null);
int h3 = xmlString.IndexOf('<', idx);
if (h3 < 0)
{
return false;
}
int h2 = xmlString.IndexOf('>', h3 + 1);
if (h2 < 0)
{
return false;
}
string node_name = xmlString.Substring(h3 + 1, h2 - h3 - 1);
string tail = "</" + node_name + ">";
int t = xmlString.IndexOf(tail, h2 + 1);
if (t < 0)
{
return false;
}
node = node_name;
nodeContent = xmlString.Substring(h2 + 1, t - h2 - 1);
idx = t + tail.Length;
return true;
}
public bool NextLeafNode(out string node, out string nodeContent)
{
int t;
do
{
t = xmlString.IndexOf("</", idx);
if (t >= idx)
{
int a = xmlString.IndexOf(">", t + 2);
node = xmlString.Substring(t + 2, a - t - 2);
string head = "<" + node + ">";
int b = xmlString.LastIndexOf(head, t, t - idx + 1);
if (b >= idx)
{
nodeContent = xmlString.Substring(b + head.Length, t - b - head.Length);
idx = a + 1;
return true;
}
idx = a + 1;
}
}
while (t >= 0);
node = null;
nodeContent = null;
return false;
}
}
}
using Kivii.Finances.Icbc.Entities;
using Kivii.Icbc.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml;
namespace Kivii.Finances.Icbc
{
internal static class Extension
{
private static List<string> _icbcXML { get; set; }
/// <summary>
/// 获取ICBC流水
/// </summary>
/// <param name="nc1">netSafeClient</param>
/// <param name="icbc">ICBCConfig</param>
/// <param name="nextTag">分页标识,传String.Empty</param>
/// <param name="beginTime">查询开始时间</param>
/// <param name="endTime">结束时间</param>
/// <param name="newGet">查询开始标识,只可传入True</param>
/// <returns></returns>
internal static List<string> GetICBCDetail(this ICBC_NetSafeClient nc1, ICBCConfig icbc, string nextTag, DateTime beginTime, DateTime endTime, bool newGet, out string balance)
{
if (newGet)
{
_icbcXML = new List<string>();
nextTag = string.Empty;
}
XmlDocument QACCBAL = new XmlDocument();
//加载Assembly的资源文件
QACCBAL.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kivii.Finances.Icbc.Content.QACCBAL.txt"));
XML_EASY xML_EASY = new XML_EASY(QACCBAL.InnerXml);
xML_EASY.SetXMLNode("AccNo", icbc.AccNo);
nc1.Run(xML_EASY.GetXML(), out string seqNo, out string result);
xML_EASY.SetXML(result);
if (xML_EASY.LocateString("<error>") >= 0)
{
Console.WriteLine(xML_EASY.GetXMLNode("error"));
balance = "error";
return new List<string>
{
"error"
};
}
string xMLNode = xML_EASY.GetXMLNode("Balance");
if (xMLNode != null && xMLNode.Length > 0)
{
double num = Convert.ToDouble(xMLNode) / 100.0;
string xMLNode2 = xML_EASY.GetXMLNode("QueryTime");
string xMLNode3 = xML_EASY.GetXMLNode("AccName");
Console.WriteLine("账号户名:" + xMLNode3 + "\r\n账号余额:" + num.ToString() + "\r\n银行主机系统时间:" + xMLNode2, "银行返回信息" + seqNo);
balance = num.ToString();
}
else
{
Console.WriteLine("RetMsg:\r\n" + xML_EASY.GetXMLNode("RetMsg"), "银行返回信息" + seqNo);
balance = null;
}
XmlDocument QHISD = new XmlDocument();
QHISD.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kivii.Finances.Icbc.Content.QHISD.txt"));
xML_EASY = new XML_EASY(QHISD.InnerXml);
xML_EASY.SetXMLNode("AccNo", icbc.AccNo);
xML_EASY.SetXMLNode("BeginDate", beginTime.ToString("yyyyMMdd"));
xML_EASY.SetXMLNode("EndDate", endTime.ToString("yyyyMMdd"));
xML_EASY.SetXMLNode("MinAmt", icbc.MinAmt);
xML_EASY.SetXMLNode("MaxAmt", icbc.MaxAmt);
xML_EASY.SetXMLNode("NextTag", nextTag);
nc1.Run(xML_EASY.GetXML(), out string seqNo2, out string rtn);
if (_icbcXML == null) _icbcXML = new List<string>();
_icbcXML.Add(rtn);
XmlDocument doc = new XmlDocument();
doc.LoadXml(rtn);
var tag = doc.GetElementsByTagName("NextTag")[0].InnerXml;
if (!tag.IsNullOrEmpty())
{
nc1.GetICBCDetail(icbc, tag, beginTime, endTime, false, out string currentBalance);
}
return _icbcXML;
}
internal static List<ICBC> GetICBCDetail(this ICBC_NetSafeClient nc1, ICBCConfig icbc, string nextTag, DateTime beginTime, DateTime endTime)
{
//当首次进行查询 把余额也查出来便于和系统余额比对
if (nextTag.IsNullOrEmpty())
{
XmlDocument QACCBAL = new XmlDocument();
QACCBAL.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kivii.Finances.Icbc.Content.QACCBAL.txt"));
XML_EASY xmlEasy = new XML_EASY(QACCBAL.InnerXml);
xmlEasy.SetXMLNode("AccNo", icbc.AccNo);
nc1.Run(xmlEasy.GetXML(), out string seqNo, out string xmlResult);
xmlEasy.SetXML(xmlResult);
if (xmlEasy.LocateString("<error>") >= 0)
{
Console.WriteLine(xmlEasy.GetXMLNode("error"));
icbc.currentBalance = "error";
}
string xMLNode = xmlEasy.GetXMLNode("Balance");
if (xMLNode != null && xMLNode.Length > 0)
{
double num = Convert.ToDouble(xMLNode) / 100.0;
string xMLNode2 = xmlEasy.GetXMLNode("QueryTime");
string xMLNode3 = xmlEasy.GetXMLNode("AccName");
Console.WriteLine("账号户名:" + xMLNode3 + "\r\n账号余额:" + num.ToString() + "\r\n银行主机系统时间:" + xMLNode2, "银行返回信息" + seqNo);
icbc.currentBalance = num.ToString();
}
}
XmlDocument QHISD = new XmlDocument();
QHISD.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kivii.Finances.Icbc.Content.QHISD.txt"));
var xML_EASY = new XML_EASY(QHISD.InnerXml);
xML_EASY.SetXMLNode("AccNo", icbc.AccNo);
xML_EASY.SetXMLNode("BeginDate", beginTime.ToString("yyyyMMdd"));
xML_EASY.SetXMLNode("EndDate", endTime.ToString("yyyyMMdd"));
xML_EASY.SetXMLNode("MinAmt", icbc.MinAmt);
xML_EASY.SetXMLNode("MaxAmt", icbc.MaxAmt);
xML_EASY.SetXMLNode("NextTag", nextTag);
nc1.Run(xML_EASY.GetXML(), out string seqNo2, out string result);
xML_EASY.SetXML(result);
if (xML_EASY.LocateString("<error>") >= 0) throw new Exception("查询失败");
XmlDocument doc = new XmlDocument();
doc.LoadXml(result);
doc.ThrowIfNull("暂未获取到银行流水数据");
XmlNodeList xmlNodeList = doc.GetElementsByTagName("rd");
var rtns = xmlNodeList.XmlToObject();
var accName = doc.GetElementsByTagName("AccName")[0].InnerText;
var accNo = doc.GetElementsByTagName("AccNo")[0].InnerText;
icbc.AccName = accName;
var tag = doc.GetElementsByTagName("NextTag")[0].InnerXml;
if (!tag.IsNullOrEmpty())
{
var more = nc1.GetICBCDetail(icbc, tag, beginTime, endTime);
rtns.AddRange(more);
return rtns;
}
return rtns;
}
internal static string GetICBCBalance(this ICBC_NetSafeClient nc1, ICBCConfig icbc)
{
XmlDocument QACCBAL = new XmlDocument();
//加载Assembly的资源文件
QACCBAL.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream("Kivii.Finances.Icbc.Content.QACCBAL.txt"));
XML_EASY xML_EASY = new XML_EASY(QACCBAL.InnerXml);
xML_EASY.SetXMLNode("AccNo", icbc.AccNo);
nc1.Run(xML_EASY.GetXML(), out string seqNo, out string result);
xML_EASY.SetXML(result);
if (xML_EASY.LocateString("<error>") >= 0)
{
Console.WriteLine(xML_EASY.GetXMLNode("error"));
return "error";
}
string balance;
string xMLNode = xML_EASY.GetXMLNode("Balance");
if (xMLNode != null && xMLNode.Length > 0)
{
double num = Convert.ToDouble(xMLNode) / 100.0;
string xMLNode2 = xML_EASY.GetXMLNode("QueryTime");
string xMLNode3 = xML_EASY.GetXMLNode("AccName");
Console.WriteLine("账号户名:" + xMLNode3 + "\r\n账号余额:" + num.ToString() + "\r\n银行主机系统时间:" + xMLNode2, "银行返回信息" + seqNo);
balance = num.ToString();
}
else
{
Console.WriteLine("RetMsg:\r\n" + xML_EASY.GetXMLNode("RetMsg"), "银行返回信息" + seqNo);
balance = null;
}
return balance;
}
/// <summary>
/// 将xml转成ICBC实体对象
/// </summary>
/// <param name="xmlNodeList"></param>
/// <returns></returns>
internal static List<ICBC> XmlToObject(this XmlNodeList xmlNodeList)
{
List<ICBC> rtns = new List<ICBC>();
var properties = typeof(ICBC).GetProperties();
try
{
foreach (XmlElement item in xmlNodeList)
{
var entity = new ICBC();
foreach (XmlElement node in item)
{
var property = properties.FirstOrDefault(o => o.Name == node.Name);
if (property == null) continue;
if (!property.PropertyType.IsGenericType)
{
//非泛型
property.SetValue(entity, string.IsNullOrEmpty(node.InnerText) ? null : Convert.ChangeType(node.InnerText, property.PropertyType), null);
}
else
{
//泛型Nullable<>
Type genericTypeDefinition = property.PropertyType.GetGenericTypeDefinition();
if (genericTypeDefinition == typeof(Nullable<>))
{
property.SetValue(entity, string.IsNullOrEmpty(node.InnerText) ? null : Convert.ChangeType(node.InnerText, Nullable.GetUnderlyingType(property.PropertyType)), null);
}
}
}
rtns.Add(entity);
}
}
catch (Exception ex)
{
return rtns;
}
return rtns;
}
}
}
namespace Kivii.Client.Finances.Icbc
{
partial class FrmMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.plConfigs = new System.Windows.Forms.Panel();
this.gbIcbc = new System.Windows.Forms.GroupBox();
this.lbNcIntervalUnit = new System.Windows.Forms.Label();
this.lbNcInterval = new System.Windows.Forms.Label();
this.tbxNcAcc = new System.Windows.Forms.TextBox();
this.lbNcAcc = new System.Windows.Forms.Label();
this.tbxNcVersion = new System.Windows.Forms.TextBox();
this.lbNcVersion = new System.Windows.Forms.Label();
this.tbxNcCertId = new System.Windows.Forms.TextBox();
this.lbNcCertId = new System.Windows.Forms.Label();
this.lbNcUrl = new System.Windows.Forms.Label();
this.tbxNcPort = new System.Windows.Forms.TextBox();
this.tbxNcUrl = new System.Windows.Forms.TextBox();
this.tbxNcGroupId = new System.Windows.Forms.TextBox();
this.lbNcGroupId = new System.Windows.Forms.Label();
this.lbNcPort = new System.Windows.Forms.Label();
this.btnNcSync = new System.Windows.Forms.Button();
this.btnNcStart = new System.Windows.Forms.Button();
this.gbk5 = new System.Windows.Forms.GroupBox();
this.lblUrl = new System.Windows.Forms.Label();
this.tbxUserName = new System.Windows.Forms.TextBox();
this.tbxServiceUrl = new System.Windows.Forms.TextBox();
this.btnLogout = new System.Windows.Forms.Button();
this.tbxPassword = new System.Windows.Forms.TextBox();
this.btnLogin = new System.Windows.Forms.Button();
this.lblPassword = new System.Windows.Forms.Label();
this.lblUser = new System.Windows.Forms.Label();
this.rtbMessage = new System.Windows.Forms.RichTextBox();
this.btnNcStop = new System.Windows.Forms.Button();
this.nudxNcInterval = new System.Windows.Forms.NumericUpDown();
this.lbCurrentTime = new System.Windows.Forms.Label();
this.dtpCurrentTime = new System.Windows.Forms.DateTimePicker();
this.plConfigs.SuspendLayout();
this.gbIcbc.SuspendLayout();
this.gbk5.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.nudxNcInterval)).BeginInit();
this.SuspendLayout();
//
// plConfigs
//
this.plConfigs.Controls.Add(this.gbIcbc);
this.plConfigs.Controls.Add(this.gbk5);
this.plConfigs.Dock = System.Windows.Forms.DockStyle.Left;
this.plConfigs.Location = new System.Drawing.Point(0, 0);
this.plConfigs.Name = "plConfigs";
this.plConfigs.Size = new System.Drawing.Size(422, 532);
this.plConfigs.TabIndex = 1;
//
// gbIcbc
//
this.gbIcbc.Controls.Add(this.dtpCurrentTime);
this.gbIcbc.Controls.Add(this.lbCurrentTime);
this.gbIcbc.Controls.Add(this.nudxNcInterval);
this.gbIcbc.Controls.Add(this.btnNcStop);
this.gbIcbc.Controls.Add(this.lbNcIntervalUnit);
this.gbIcbc.Controls.Add(this.lbNcInterval);
this.gbIcbc.Controls.Add(this.tbxNcAcc);
this.gbIcbc.Controls.Add(this.lbNcAcc);
this.gbIcbc.Controls.Add(this.tbxNcVersion);
this.gbIcbc.Controls.Add(this.lbNcVersion);
this.gbIcbc.Controls.Add(this.tbxNcCertId);
this.gbIcbc.Controls.Add(this.lbNcCertId);
this.gbIcbc.Controls.Add(this.lbNcUrl);
this.gbIcbc.Controls.Add(this.tbxNcPort);
this.gbIcbc.Controls.Add(this.tbxNcUrl);
this.gbIcbc.Controls.Add(this.tbxNcGroupId);
this.gbIcbc.Controls.Add(this.lbNcGroupId);
this.gbIcbc.Controls.Add(this.lbNcPort);
this.gbIcbc.Controls.Add(this.btnNcSync);
this.gbIcbc.Controls.Add(this.btnNcStart);
this.gbIcbc.Dock = System.Windows.Forms.DockStyle.Fill;
this.gbIcbc.Location = new System.Drawing.Point(0, 174);
this.gbIcbc.Name = "gbIcbc";
this.gbIcbc.Size = new System.Drawing.Size(422, 358);
this.gbIcbc.TabIndex = 31;
this.gbIcbc.TabStop = false;
this.gbIcbc.Text = "ICBC配置";
//
// lbNcIntervalUnit
//
this.lbNcIntervalUnit.AutoSize = true;
this.lbNcIntervalUnit.Location = new System.Drawing.Point(245, 224);
this.lbNcIntervalUnit.Name = "lbNcIntervalUnit";
this.lbNcIntervalUnit.Size = new System.Drawing.Size(44, 18);
this.lbNcIntervalUnit.TabIndex = 44;
this.lbNcIntervalUnit.Text = "分钟";
//
// lbNcInterval
//
this.lbNcInterval.AutoSize = true;
this.lbNcInterval.Location = new System.Drawing.Point(13, 222);
this.lbNcInterval.Name = "lbNcInterval";
this.lbNcInterval.Size = new System.Drawing.Size(80, 18);
this.lbNcInterval.TabIndex = 42;
this.lbNcInterval.Text = "循 环:";
//
// tbxNcAcc
//
this.tbxNcAcc.Location = new System.Drawing.Point(103, 110);
this.tbxNcAcc.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcAcc.Name = "tbxNcAcc";
this.tbxNcAcc.Size = new System.Drawing.Size(305, 28);
this.tbxNcAcc.TabIndex = 41;
//
// lbNcAcc
//
this.lbNcAcc.AutoSize = true;
this.lbNcAcc.Location = new System.Drawing.Point(13, 113);
this.lbNcAcc.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcAcc.Name = "lbNcAcc";
this.lbNcAcc.Size = new System.Drawing.Size(80, 18);
this.lbNcAcc.TabIndex = 40;
this.lbNcAcc.Text = "账 号:";
//
// tbxNcVersion
//
this.tbxNcVersion.Location = new System.Drawing.Point(286, 73);
this.tbxNcVersion.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcVersion.Name = "tbxNcVersion";
this.tbxNcVersion.Size = new System.Drawing.Size(122, 28);
this.tbxNcVersion.TabIndex = 39;
//
// lbNcVersion
//
this.lbNcVersion.AutoSize = true;
this.lbNcVersion.Location = new System.Drawing.Point(206, 78);
this.lbNcVersion.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcVersion.Name = "lbNcVersion";
this.lbNcVersion.Size = new System.Drawing.Size(80, 18);
this.lbNcVersion.TabIndex = 38;
this.lbNcVersion.Text = "版本号:";
//
// tbxNcCertId
//
this.tbxNcCertId.Location = new System.Drawing.Point(103, 183);
this.tbxNcCertId.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcCertId.Name = "tbxNcCertId";
this.tbxNcCertId.Size = new System.Drawing.Size(305, 28);
this.tbxNcCertId.TabIndex = 37;
//
// lbNcCertId
//
this.lbNcCertId.AutoSize = true;
this.lbNcCertId.Location = new System.Drawing.Point(13, 186);
this.lbNcCertId.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcCertId.Name = "lbNcCertId";
this.lbNcCertId.Size = new System.Drawing.Size(80, 18);
this.lbNcCertId.TabIndex = 36;
this.lbNcCertId.Text = "证书号:";
//
// lbNcUrl
//
this.lbNcUrl.AutoSize = true;
this.lbNcUrl.Location = new System.Drawing.Point(13, 39);
this.lbNcUrl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcUrl.Name = "lbNcUrl";
this.lbNcUrl.Size = new System.Drawing.Size(71, 18);
this.lbNcUrl.TabIndex = 30;
this.lbNcUrl.Text = "NC服务:";
//
// tbxNcPort
//
this.tbxNcPort.Location = new System.Drawing.Point(103, 73);
this.tbxNcPort.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcPort.Name = "tbxNcPort";
this.tbxNcPort.Size = new System.Drawing.Size(95, 28);
this.tbxNcPort.TabIndex = 34;
//
// tbxNcUrl
//
this.tbxNcUrl.BackColor = System.Drawing.SystemColors.Window;
this.tbxNcUrl.Location = new System.Drawing.Point(103, 36);
this.tbxNcUrl.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcUrl.Name = "tbxNcUrl";
this.tbxNcUrl.Size = new System.Drawing.Size(305, 28);
this.tbxNcUrl.TabIndex = 33;
//
// tbxNcGroupId
//
this.tbxNcGroupId.Location = new System.Drawing.Point(103, 147);
this.tbxNcGroupId.Margin = new System.Windows.Forms.Padding(4);
this.tbxNcGroupId.Name = "tbxNcGroupId";
this.tbxNcGroupId.Size = new System.Drawing.Size(305, 28);
this.tbxNcGroupId.TabIndex = 35;
//
// lbNcGroupId
//
this.lbNcGroupId.AutoSize = true;
this.lbNcGroupId.Location = new System.Drawing.Point(13, 150);
this.lbNcGroupId.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcGroupId.Name = "lbNcGroupId";
this.lbNcGroupId.Size = new System.Drawing.Size(80, 18);
this.lbNcGroupId.TabIndex = 32;
this.lbNcGroupId.Text = "组织号:";
//
// lbNcPort
//
this.lbNcPort.AutoSize = true;
this.lbNcPort.Location = new System.Drawing.Point(13, 78);
this.lbNcPort.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lbNcPort.Name = "lbNcPort";
this.lbNcPort.Size = new System.Drawing.Size(80, 18);
this.lbNcPort.TabIndex = 31;
this.lbNcPort.Text = "端口号:";
//
// btnNcSync
//
this.btnNcSync.Location = new System.Drawing.Point(296, 218);
this.btnNcSync.Name = "btnNcSync";
this.btnNcSync.Size = new System.Drawing.Size(112, 30);
this.btnNcSync.TabIndex = 28;
this.btnNcSync.Text = "立即执行";
this.btnNcSync.UseVisualStyleBackColor = true;
this.btnNcSync.Click += new System.EventHandler(this.btnNcSync_Click);
//
// btnNcStart
//
this.btnNcStart.Location = new System.Drawing.Point(16, 292);
this.btnNcStart.Name = "btnNcStart";
this.btnNcStart.Size = new System.Drawing.Size(194, 32);
this.btnNcStart.TabIndex = 29;
this.btnNcStart.Text = "开始同步";
this.btnNcStart.UseVisualStyleBackColor = true;
this.btnNcStart.Click += new System.EventHandler(this.btnNcStart_Click);
//
// gbk5
//
this.gbk5.Controls.Add(this.lblUrl);
this.gbk5.Controls.Add(this.tbxUserName);
this.gbk5.Controls.Add(this.tbxServiceUrl);
this.gbk5.Controls.Add(this.btnLogout);
this.gbk5.Controls.Add(this.tbxPassword);
this.gbk5.Controls.Add(this.btnLogin);
this.gbk5.Controls.Add(this.lblPassword);
this.gbk5.Controls.Add(this.lblUser);
this.gbk5.Dock = System.Windows.Forms.DockStyle.Top;
this.gbk5.Location = new System.Drawing.Point(0, 0);
this.gbk5.Name = "gbk5";
this.gbk5.Size = new System.Drawing.Size(422, 174);
this.gbk5.TabIndex = 30;
this.gbk5.TabStop = false;
this.gbk5.Text = "K5配置";
//
// lblUrl
//
this.lblUrl.AutoSize = true;
this.lblUrl.Location = new System.Drawing.Point(13, 40);
this.lblUrl.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblUrl.Name = "lblUrl";
this.lblUrl.Size = new System.Drawing.Size(80, 18);
this.lblUrl.TabIndex = 13;
this.lblUrl.Text = "服务器:";
//
// tbxUserName
//
this.tbxUserName.Location = new System.Drawing.Point(103, 73);
this.tbxUserName.Margin = new System.Windows.Forms.Padding(4);
this.tbxUserName.Name = "tbxUserName";
this.tbxUserName.Size = new System.Drawing.Size(221, 28);
this.tbxUserName.TabIndex = 17;
//
// tbxServiceUrl
//
this.tbxServiceUrl.BackColor = System.Drawing.SystemColors.Window;
this.tbxServiceUrl.Location = new System.Drawing.Point(103, 37);
this.tbxServiceUrl.Margin = new System.Windows.Forms.Padding(4);
this.tbxServiceUrl.Name = "tbxServiceUrl";
this.tbxServiceUrl.Size = new System.Drawing.Size(221, 28);
this.tbxServiceUrl.TabIndex = 16;
//
// btnLogout
//
this.btnLogout.Enabled = false;
this.btnLogout.Location = new System.Drawing.Point(332, 105);
this.btnLogout.Margin = new System.Windows.Forms.Padding(4);
this.btnLogout.Name = "btnLogout";
this.btnLogout.Size = new System.Drawing.Size(76, 34);
this.btnLogout.TabIndex = 27;
this.btnLogout.Text = "退出";
this.btnLogout.UseVisualStyleBackColor = true;
this.btnLogout.Click += new System.EventHandler(this.btnLogout_Click);
//
// tbxPassword
//
this.tbxPassword.Location = new System.Drawing.Point(103, 110);
this.tbxPassword.Margin = new System.Windows.Forms.Padding(4);
this.tbxPassword.Name = "tbxPassword";
this.tbxPassword.PasswordChar = '*';
this.tbxPassword.Size = new System.Drawing.Size(221, 28);
this.tbxPassword.TabIndex = 18;
//
// btnLogin
//
this.btnLogin.Location = new System.Drawing.Point(332, 37);
this.btnLogin.Margin = new System.Windows.Forms.Padding(4);
this.btnLogin.Name = "btnLogin";
this.btnLogin.Size = new System.Drawing.Size(76, 64);
this.btnLogin.TabIndex = 26;
this.btnLogin.Text = "登录";
this.btnLogin.UseVisualStyleBackColor = true;
this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
//
// lblPassword
//
this.lblPassword.AutoSize = true;
this.lblPassword.Location = new System.Drawing.Point(13, 113);
this.lblPassword.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblPassword.Name = "lblPassword";
this.lblPassword.Size = new System.Drawing.Size(80, 18);
this.lblPassword.TabIndex = 15;
this.lblPassword.Text = "密 码:";
//
// lblUser
//
this.lblUser.AutoSize = true;
this.lblUser.Location = new System.Drawing.Point(13, 79);
this.lblUser.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblUser.Name = "lblUser";
this.lblUser.Size = new System.Drawing.Size(80, 18);
this.lblUser.TabIndex = 14;
this.lblUser.Text = "用户名:";
//
// rtbMessage
//
this.rtbMessage.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbMessage.Location = new System.Drawing.Point(422, 0);
this.rtbMessage.Name = "rtbMessage";
this.rtbMessage.Size = new System.Drawing.Size(683, 532);
this.rtbMessage.TabIndex = 2;
this.rtbMessage.Text = "";
//
// btnNcStop
//
this.btnNcStop.Location = new System.Drawing.Point(214, 292);
this.btnNcStop.Name = "btnNcStop";
this.btnNcStop.Size = new System.Drawing.Size(194, 32);
this.btnNcStop.TabIndex = 45;
this.btnNcStop.Text = "停止同步";
this.btnNcStop.UseVisualStyleBackColor = true;
this.btnNcStop.Click += new System.EventHandler(this.btnNcStop_Click);
//
// nudxNcInterval
//
this.nudxNcInterval.Location = new System.Drawing.Point(103, 219);
this.nudxNcInterval.Name = "nudxNcInterval";
this.nudxNcInterval.Size = new System.Drawing.Size(136, 28);
this.nudxNcInterval.TabIndex = 46;
//
// lbCurrentTime
//
this.lbCurrentTime.AutoSize = true;
this.lbCurrentTime.Location = new System.Drawing.Point(13, 259);
this.lbCurrentTime.Name = "lbCurrentTime";
this.lbCurrentTime.Size = new System.Drawing.Size(134, 18);
this.lbCurrentTime.TabIndex = 47;
this.lbCurrentTime.Text = "到账时间起始:";
//
// dtpCurrentTime
//
this.dtpCurrentTime.Location = new System.Drawing.Point(140, 254);
this.dtpCurrentTime.Name = "dtpCurrentTime";
this.dtpCurrentTime.Size = new System.Drawing.Size(268, 28);
this.dtpCurrentTime.TabIndex = 48;
//
// FrmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1105, 532);
this.Controls.Add(this.rtbMessage);
this.Controls.Add(this.plConfigs);
this.Name = "FrmMain";
this.Text = "工商银行流水同步";
this.Load += new System.EventHandler(this.FrmMain_Load);
this.plConfigs.ResumeLayout(false);
this.gbIcbc.ResumeLayout(false);
this.gbIcbc.PerformLayout();
this.gbk5.ResumeLayout(false);
this.gbk5.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.nudxNcInterval)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel plConfigs;
private System.Windows.Forms.Button btnNcStart;
private System.Windows.Forms.Button btnNcSync;
private System.Windows.Forms.Button btnLogout;
private System.Windows.Forms.Button btnLogin;
private System.Windows.Forms.Label lblUrl;
private System.Windows.Forms.Label lblUser;
private System.Windows.Forms.Label lblPassword;
private System.Windows.Forms.TextBox tbxPassword;
private System.Windows.Forms.TextBox tbxServiceUrl;
private System.Windows.Forms.TextBox tbxUserName;
private System.Windows.Forms.GroupBox gbIcbc;
private System.Windows.Forms.GroupBox gbk5;
private System.Windows.Forms.RichTextBox rtbMessage;
private System.Windows.Forms.Label lbNcUrl;
private System.Windows.Forms.TextBox tbxNcPort;
private System.Windows.Forms.TextBox tbxNcUrl;
private System.Windows.Forms.TextBox tbxNcGroupId;
private System.Windows.Forms.Label lbNcGroupId;
private System.Windows.Forms.Label lbNcPort;
private System.Windows.Forms.TextBox tbxNcCertId;
private System.Windows.Forms.Label lbNcCertId;
private System.Windows.Forms.TextBox tbxNcVersion;
private System.Windows.Forms.Label lbNcVersion;
private System.Windows.Forms.TextBox tbxNcAcc;
private System.Windows.Forms.Label lbNcAcc;
private System.Windows.Forms.Label lbNcInterval;
private System.Windows.Forms.Label lbNcIntervalUnit;
private System.Windows.Forms.Button btnNcStop;
private System.Windows.Forms.NumericUpDown nudxNcInterval;
private System.Windows.Forms.Label lbCurrentTime;
private System.Windows.Forms.DateTimePicker dtpCurrentTime;
}
}
using Kivii.Finances.Icbc;
using Kivii.Finances.Icbc.Entities;
using Kivii.Icbc.Entities;
using Kivii.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Timer = System.Windows.Forms.Timer;
namespace Kivii.Client.Finances.Icbc
{
public partial class FrmMain : Form
{
private JsonServiceClient _client = null;
private Timer _timer = null;
public FrmMain()
{
InitializeComponent();
}
#region 界面控件默认值管理
private void loadDefault(params Control[] ctls)
{
using (var conn = KiviiContext.GetOpenedDbConnection<UiSetting>())
{
foreach (var ctl in ctls)
{
var setting = conn.Select<UiSetting>(o => o.FormName == this.Name && o.ControlName == ctl.Name).FirstOrDefault();
if (setting == null) continue;
ctl.Text = setting.ControlValue;
}
}
}
private void setDefault(params Control[] ctls)
{
using (var conn = KiviiContext.GetOpenedDbConnection<UiSetting>())
{
foreach (var ctl in ctls)
{
var setting = conn.Select<UiSetting>(o => o.FormName == this.Name && o.ControlName == ctl.Name).FirstOrDefault();
if (setting == null)
{
setting = new UiSetting();
setting.FormName = this.Name;
setting.ControlName = ctl.Name;
setting.ControlValue = ctl.Text;
conn.Insert(setting);
}
else
{
setting.ControlValue = ctl.Text;
conn.Update(setting);
}
}
}
}
private void initK5FormCtl(bool notLogin = true)
{
btnLogin.Enabled = notLogin;
tbxServiceUrl.Enabled = notLogin;
tbxUserName.Enabled = notLogin;
tbxPassword.Enabled = notLogin;
tbxNcUrl.Enabled = notLogin;
tbxNcPort.Enabled = notLogin;
nudxNcInterval.Enabled = notLogin;
tbxNcCertId.Enabled = notLogin;
tbxNcGroupId.Enabled = notLogin;
tbxNcVersion.Enabled = notLogin;
tbxNcAcc.Enabled = notLogin;
//dtpCurrentTime.Enabled = notLogin;
btnLogout.Enabled = !notLogin;
btnNcSync.Enabled = !notLogin;
btnNcStart.Enabled = !notLogin;
btnNcStop.Enabled = !notLogin;
}
/// <summary>
/// 输出消息
/// </summary>
/// <param name="message">消息内容</param>
/// <param name="clearMessage">是否清除消息</param>
private void outputMessage(string message, bool clearMessage = false)
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() => outputMessage(message, clearMessage)));
return;
}
if (clearMessage) rtbMessage.Clear();
if (rtbMessage.Lines.Count() > 500) rtbMessage.Clear();
var time = DateTime.Now.ToString("HH:mm:ss");
rtbMessage.AppendText($"[{time}]{message}{Environment.NewLine}");
rtbMessage.ScrollToCaret();
}
#endregion
private void FrmMain_Load(object sender, EventArgs e)
{
initK5FormCtl();
loadDefault(tbxServiceUrl, tbxUserName, tbxPassword, tbxNcAcc, tbxNcCertId, tbxNcGroupId, nudxNcInterval, tbxNcPort, tbxNcUrl, tbxNcVersion, dtpCurrentTime);
}
private void btnLogin_Click(object sender, EventArgs e)
{
if (_client != null)
{
MessageBox.Show("登陆前先退出原连接");
return;
}
btnLogin.Enabled = false;
_client = new JsonServiceClient(tbxServiceUrl.Text);
var auth = new Authenticate { UserName = tbxUserName.Text, Password = tbxPassword.Text, provider = "Kivii" };
var task = _client.PostAsync(auth);
task.Success(resp =>
{
initK5FormCtl(false);
setDefault(tbxServiceUrl, tbxUserName, tbxPassword, tbxNcAcc, tbxNcCertId, tbxNcGroupId, nudxNcInterval, tbxNcPort, tbxNcUrl, tbxNcVersion);
outputMessage($"登录成功:{resp.FullName}");
Thread.Sleep(100);
}, true);
task.Error(err =>
{
initK5FormCtl();
_client.Dispose();
_client = null;
MessageBox.Show(err.Message, "Login Error");
}, true);
}
private void btnLogout_Click(object sender, EventArgs e)
{
if (_client == null)
{
MessageBox.Show("未连接");
return;
}
btnLogout.Enabled = false;
var auth = new Authenticate { provider = "Logout" };
var task = _client.PostAsync(auth);
task.Success(resp =>
{
outputMessage($"退出成功");
_client.Dispose();
_client = null;
Thread.Sleep(100);
timerStop();
initK5FormCtl();
});
task.Error(err =>
{
btnLogout.Enabled = true;
MessageBox.Show(err.Message, "Logout Error");
});
}
private void timerStart()
{
if (_client == null)
{
MessageBox.Show("请先登录!");
return;
}
if (_timer == null)
{
_timer = new Timer();
_timer.Interval = (int)(nudxNcInterval.Value * 60 * 1000);
_timer.Tick += _timer_Tick;
}
_timer.Start();
btnNcStart.Enabled = false;
btnNcStop.Enabled = true;
outputMessage("定时器已启动");
}
private void timerStop()
{
if (_timer != null) _timer.Stop();
_timer = null;
btnNcStart.Enabled = true;
btnNcStop.Enabled = false;
outputMessage("定时器已停止");
}
private void btnNcStart_Click(object sender, EventArgs e)
{
timerStart();
}
private void btnNcStop_Click(object sender, EventArgs e)
{
timerStop();
}
private void btnNcSync_Click(object sender, EventArgs e)
{
SyncPayments();
}
private void _timer_Tick(object sender, EventArgs e)
{
try
{
_timer.Stop();
SyncPayments();
}
catch (Exception ex)
{
outputMessage($"定时器错误:{ex.Message}");
}
finally
{
if (_timer != null) _timer.Start();
}
}
private void SyncPayments()
{
if (InvokeRequired)
{
this.Invoke(new Action(SyncPayments));
return;
}
if (!int.TryParse(tbxNcPort.Text, out int port))
{
outputMessage("NC端口号设置错误");
return;
}
var ncConfig = new NetSafeConfig();
ncConfig.HttpsIp = tbxNcUrl.Text;
ncConfig.HttpsPort = port;
ncConfig.GroupId = tbxNcGroupId.Text;
ncConfig.CertId = tbxNcCertId.Text;
ncConfig.InterfaceVersion = tbxNcVersion.Text;
var icbc = new ICBCConfig();
icbc.AccNo = tbxNcAcc.Text;
icbc.MinAmt = "0";
icbc.MaxAmt = "9999999999";
ICBC_NetSafeClient nc1 = new ICBC_NetSafeClient();
nc1.SetHttpsIP(ncConfig.HttpsIp);
nc1.SetHttpsPort(ncConfig.HttpsPort);
nc1.SetGroupID(ncConfig.GroupId);
nc1.SetCertID(ncConfig.CertId);
nc1.SetInterfaceVersion(ncConfig.InterfaceVersion);
DateTime maxTranslateTime = dtpCurrentTime.Value;
if (maxTranslateTime == DateTime.MinValue) maxTranslateTime = DateTime.Now;
var beginTime = DateTime.Parse(maxTranslateTime.ToString("yyyy-MM-dd 00:00:00"));
var endTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
if (beginTime > endTime)
{
outputMessage($"收款数据中最后一次交易时间{beginTime}大于当前时间{endTime},数据有误!");
return;
}
var items = nc1.GetICBCDetail(icbc, string.Empty, beginTime, endTime);
if (items.IsNullOrEmpty())
{
outputMessage("未找到收款数据");
return;
}
var request = new RequestAccept();
request.Items = items;
request.Icbc = icbc;
try
{
var rtns = _client.Post(request);
outputMessage($"New:{DateTime.Now:yyyy-MM-dd HH:mm:ss}成功查询{rtns.Total}条收款,插入{rtns.Insert}条,跳过重复{rtns.Skip}条!");
DateTime maxTime = DateTime.MinValue;
foreach (var item in items)
{
var time = DateTime.Parse(DateTime.ParseExact(item.Time, "yyyy-MM-dd-HH.mm.ss.ffffff", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd HH:mm:ss"));
if (time >= maxTime)
{
maxTime = time;
}
}
if (maxTime != DateTime.MinValue)
{
dtpCurrentTime.Value = maxTime;
setDefault(dtpCurrentTime);
}
}
catch (Exception ex)
{
outputMessage($"请求同步流水失败,原因:{ex.Message}");
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
<?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>{CB04A619-6FFA-498F-8D74-5EBB43142088}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Kivii.Finances.Icbc</RootNamespace>
<AssemblyName>Kivii.Client.Finances.Icbc.V4.0</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<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="Kivii.Common.V4.0, Version=5.6.2024.1160, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Common.5.6.2024.1160\lib\net40\Kivii.Common.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Core.V4.0, Version=5.6.2023.9000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Core.5.6.2023.9000\lib\net40\Kivii.Core.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.Sqlite.V4.0, Version=5.6.2023.3000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.Sqlite.5.6.2023.3000\lib\net40\Kivii.Linq.Sqlite.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.V4.0, Version=5.6.2024.2000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.5.6.2024.2000\lib\net40\Kivii.Linq.V4.0.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configs.cs" />
<Compile Include="Entities\ICBC.cs" />
<Compile Include="Entities\NetSafeClient.cs" />
<Compile Include="Extension.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Request.cs" />
<Compile Include="UiSetting.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Content\QACCBAL.txt" />
<EmbeddedResource Include="Content\QHISD.txt" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Kivii.Client.Finances.Icbc.V4._0
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Kivii.Client.Finances.Icbc.V4.0")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Kivii.Client.Finances.Icbc.V4.0")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("cb04a619-6ffa-498f-8d74-5ebb43142088")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Finances.Icbc.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kivii.Finances.Icbc.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Finances.Icbc.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
using Kivii.Client.Finances.Icbc;
using Kivii.Icbc.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Finances.Icbc
{
[Route(Configs.RouteAcceptPayment)]
public class RequestAccept:IReturn<InsertTotal>
{
public List<ICBC> Items { get; set; }
public ICBCConfig Icbc { get; set; }
}
public class InsertTotal
{
public int Total { get; set; }
public int Skip { get; set; }
public int Insert { get; set; }
}
}
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.Finances.Icbc
{
[Alias(Configs.TableUiSetting)]
internal class UiSetting: Entity
{
[Required]
[Unique("Form-Control")]
public string FormName { get; set; }
[Required]
[Unique("Form-Control")]
public string ControlName { get; set; }
[Default("")]
public string ControlValue { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Common" version="5.6.2024.1160" targetFramework="net40" />
<package id="Kivii.Core" version="5.6.2023.9000" targetFramework="net40" />
<package id="Kivii.Linq" version="5.6.2024.2000" targetFramework="net40" />
<package id="Kivii.Linq.Sqlite" version="5.6.2023.3000" targetFramework="net40" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment