2025-03-28 09:49:56 +08:00

157 lines
6.2 KiB
C#

using GetHttpData.SDK;
using GetHttpData.SDK.ThreadPool;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GetMembership
{
public partial class TestData : Form
{
ConfigThreadTest _ConfigThread = new ConfigThreadTest();
ClientThread _ClientThread = new ClientThread();
public TestData()
{
_ClientThread.setConfiguration("http://192.168.12.110:7000/DataServices/Service.asmx",
"17018EAF3EEBB72A0977D93D5CC642ACC37185B94D849D4E3F7DFF391587B155",
"888888", "042002", "042002", "00:E2:FF:00:63:63", "010");
_ClientThread.IsUpload(true);
_ClientThread.IsDownload(true);
_ClientThread.setConfigThread(_ConfigThread);
_ClientThread.UploadStringEvent += new ClientThread.OutputResultsUploadArg(UploadStringEvent);//监听上传事件
_ClientThread.DownloadStringEvent += new ClientThread.OutputResultsDownArg(DownloadStringEvent);//监听下发事件
InitializeComponent();
timer1.Start();
timer2.Start();
}
private void button1_Click(object sender, EventArgs e)
{
bool falg = _ClientThread.onState();
}
private void timer1_Tick(object sender, EventArgs e)
{
int _MaxID = GetMaxCode("select max(sellmaster_id) from t_sellmaster");
int _MaxID2 = GetMaxCode("select max(endaccount_id) from t_endaccount_new");
int _MaxPid = GetMaxCode("select max(personsell_id) from t_personsell_new");
string sql = @"insert into t_sellmaster(SELLMASTER_ID,SELLMASTER_CODE,SERVERPARTCODE,SERVERPART_NAME,SHOPCODE,SHOPNAME,MACHINECODE,SELLWORKER_CODE,
SELLWORKER_NAME,SELLMASTER_DATE,TICKET_CODE,SELLMASTER_COUNT,SELLMASTER_OFFPRICE,SELLMASTER_AMOUNT,CASHPAY,BANKPAY,MEMBERPAY,COUPONPAY
,MOBILEPAY,INTERNALPAY,OTHERPAY,TRANSFER_STATE) values";
sql += "('" + _MaxID + "','" + _MaxID + "','888888','驿商服务区','042002','驿商门店商品测试','010','0001','驿商收银员1',DateTime('" + DateTime.Now
+ "'),'0001',0,0,0,0,0,0,0,0,0,0,0)";
string _InsertSql = @"insert into t_endaccount_new (endaccount_id,serverpartcode,shopcode,machinecode,startdate,enddate,endaccount_code,
endaccount_type,transfer_state,ticket_count,total_count,total_amount,total_offamount,cashpay,bankpay,memberpay,couponpay,mobilepay,
internalpay,contribution_amount)
values(" + _MaxID2 + ",'888888','042002','010',DateTime('" + DateTime.Now + "'),DateTime('" + DateTime.Now + "'),'" + _MaxID2 + "',1,0,0,0,0,0,0,0,0,0,0,0,0)";
string _InsertSql2 = @"insert into t_personsell_new (personsell_id,serverpartcode,shopcode,machinecode,startdate,enddate,sellworker_code,
endaccount_code,woker_number,transfer_state,ticket_count,total_count,total_amount,total_offamount,cashpay,bankpay,memberpay,couponpay,mobilepay,
internalpay,otherpay,contribution_amount)
values(" + _MaxPid + ",'888888','042002','010',DateTime('" + DateTime.Now + "'),DateTime('" + DateTime.Now + "'),'0001','" + _MaxPid + "',1,0,0,0,0,0,0,0,0,0,0,0,0,0)";
List<string> mList = new List<string>();
mList.Add(sql);
mList.Add(_InsertSql);
mList.Add(_InsertSql2);
DBHelper.ExecuteSqlTran(mList);
}
private void timer2_Tick(object sender, EventArgs e)
{
bool falg = _ClientThread.onState();
}
#region ->
/// <summary>
/// 上传回调结果
/// </summary>
/// <param name="uploadResultInfo"></param>
/// <param name="resultString"></param>
private void UploadStringEvent(UploadResultInfo uploadResultInfo, string resultString)
{
switch (uploadResultInfo.TableName)
{
case "HIGHWAY_EXCHANGE.T_SELLMASTER":
if (uploadResultInfo.StartToEnd)
{
//开始
}
else
{
//结束
}
break;
case "HIGHWAY_EXCHANGE.T_PERSONSELL_NEW":
break;
case "HIGHWAY_EXCHANGE.T_ENDACCOUNT_NEW":
break;
}
System.Diagnostics.Debug.WriteLine(resultString, "OpenTopThreads_" + uploadResultInfo.TableName);
}
/// <summary>
/// 下发回调结果
/// </summary>
/// <param name="downResultInfo"></param>
/// <param name="resultString"></param>
private void DownloadStringEvent(DownResultInfo downResultInfo, string resultString)
{
switch (downResultInfo.TableName)
{
case "HIGHWAY_EXCHANGE.T_USERDEFINEDTYPE":
if (downResultInfo.StartToEnd)
{
//开始
}
else
{
//结束
}
break;
case "HIGHWAY_EXCHANGE.T_COMMODITYEX":
break;
}
System.Diagnostics.Debug.WriteLine(resultString, "OpenDownThreads_" + downResultInfo.TableName);
}
#endregion
#region ->
private int GetMaxCode(string StrSql)
{
//获取最大编号并加1
DataTable _DataTable = DBHelper.QueryOdbc(StrSql).Tables[0];
int MaxCode = 0;
if (_DataTable.Rows.Count > 0)
{
try
{
MaxCode = int.Parse(_DataTable.Rows[0][0].ToString()) + 1;
}
catch
{
MaxCode = 1;
}
}
else
{
MaxCode = 1;
}
return MaxCode;
}
#endregion
}
}