Form1.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Quartz;
  10. using Quartz.Impl;
  11. using TimeSchedule;
  12. using WdtUtils;
  13. using Newtonsoft.Json;
  14. using WdtUtils.Proxy;
  15. using WdtUtils.Load;
  16. using Newtonsoft.Json.Linq;
  17. using TempDbToUfida.OpenApi;
  18. using TempDbToUfida;
  19. using WangToTempDb;
  20. using System.Diagnostics;
  21. using cuidian.Common;
  22. using System.Collections;
  23. using System.Collections.Specialized;
  24. using cuidian.OpenApi.Api;
  25. using cuidian.OpenApi.Utils;
  26. using Newtonsoft.Json.Serialization;
  27. using cuidian.OpenApi.Model;
  28. using UfidaToTempDb;
  29. using System.Threading;
  30. using WdtUtils.UpLoad;
  31. using TempDbToWang;
  32. using cuidian.Sql;
  33. namespace WindowsFormsApplication1
  34. {
  35. public partial class Form1 : Form
  36. {
  37. public Form1()
  38. {
  39. InitializeComponent();
  40. __init();
  41. }
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44. ISchedulerFactory schedulerFactory = new StdSchedulerFactory();
  45. IScheduler scheduler = schedulerFactory.GetScheduler();
  46. scheduler.Start();
  47. }
  48. private void aa()
  49. {
  50. ISchedulerFactory sf = new StdSchedulerFactory();
  51. IScheduler scheduler = sf.GetScheduler(); //创建调度实例
  52. //创建任务实例
  53. IJobDetail job = JobBuilder.Create<TimeSchedule.testjob1>().WithIdentity(new JobKey("job1")).Build();
  54. //创建触发器实例
  55. ITrigger trigger = TriggerBuilder.Create().StartAt(DateTime.Now.AddSeconds(0)).WithCronSchedule("0/5 * * * * ? ").Build();
  56. scheduler.ScheduleJob(job, trigger); //绑定触发器和任务
  57. scheduler.Start(); //启动监控
  58. }
  59. private void button2_Click(object sender, EventArgs e)
  60. {
  61. //aa();
  62. }
  63. private void button3_Click(object sender, EventArgs e)
  64. {
  65. InventoryLoad i = new InventoryLoad();
  66. Dictionary<string, string> args = new Dictionary<string, string>();
  67. args.Add("start_time", "2019-4-1");
  68. args.Add("end_time", "2019-4-2");
  69. //InventoryProxy ip = (InventoryProxy)i.Load(args);
  70. InventoryProxy bp = i.Load<InventoryProxy>(args);
  71. int k;
  72. k = 0;
  73. }
  74. private void button1_Click_1(object sender, EventArgs e)
  75. {
  76. VendorApi api = new VendorApi();
  77. cuidian.OpenApi.Model.Vendor v = new cuidian.OpenApi.Model.Vendor();
  78. v.code = "004";
  79. v.sort_code = "01";
  80. v.abbrname = "004";
  81. v.name = "004";
  82. VendorRoot vr = new VendorRoot();
  83. vr.vendor = v;
  84. var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
  85. string s = JsonConvert.SerializeObject(vr, Formatting.Indented, jsonSetting);
  86. //string s = Newtonsoft.Json.JsonConvert.SerializeObject(v);
  87. //s = JsonConvert.SerializeObject(v);
  88. //s = "{\"vendor\":" + s + "}";
  89. //s = "{\"vendor\":{\"code\":\"0971\",\"name\":\"0971名称\",\"sort_code\":\"01\"}}";
  90. BusinessObject bo = api.Add(s);
  91. string a1 = bo.ErrCode;
  92. string a2 = bo.ErrMsg;
  93. int j;
  94. j = 10;
  95. }
  96. private void button2_Click_1(object sender, EventArgs e)
  97. {
  98. }
  99. private void button4_Click(object sender, EventArgs e)
  100. {
  101. }
  102. private void __init()
  103. {
  104. comboBox1.Items.Add("供应商");
  105. comboBox1.Items.Add("仓库");
  106. comboBox1.Items.Add("存货");
  107. comboBox1.Items.Add("其他入库");
  108. comboBox1.Items.Add("其他出库");
  109. comboBox1.Items.Add("采购订单");
  110. comboBox1.Items.Add("采购入库");
  111. comboBox1.Items.Add("采购退货");
  112. comboBox1.Items.Add("销售订单");
  113. comboBox1.Items.Add("销售出库");
  114. }
  115. private void button5_Click(object sender, EventArgs e)
  116. {
  117. if (comboBox1.SelectedItem == null)
  118. {
  119. MessageBox.Show("请选择数据类型");
  120. return;
  121. }
  122. string type = comboBox1.SelectedItem.ToString();
  123. Dictionary<string, string> args = new Dictionary<string, string>();
  124. IUpLoad upload = null;
  125. IUpLoad uploadTwo = null;
  126. switch (type)
  127. {
  128. case "供应商":
  129. upload = new VendorUpLoad();
  130. break;
  131. case "仓库":
  132. upload = new WarehouseUpLoad();
  133. break;
  134. case "存货":
  135. upload = new InventoryUpLoad();
  136. args.Add("start_time", "2020-08-13 13:34:55.000");
  137. args.Add("end_time", "2020-08-13 13:34:55.000");
  138. break;
  139. case "其他入库":
  140. upload = new StockinUpLoad();
  141. args.Add("status", "80");
  142. args.Add("order_type", "2");
  143. args.Add("start_time", "2019-10-1 00:00:00");
  144. args.Add("end_time", "2019-10-30 00:00:00");
  145. break;
  146. case "其他出库":
  147. upload = new StockoutUpLoad();
  148. args.Add("status", "110");
  149. args.Add("order_type", "2");
  150. args.Add("start_time", "2019-10-1 00:00:00");
  151. args.Add("end_time", "2019-10-30 00:00:00");
  152. break;
  153. case "采购订单":
  154. upload = new PO_PomainUpLoad();
  155. args.Add("purchase_no", "CG202006220036");
  156. break;
  157. case "采购入库":
  158. upload = new InvoiceItemaUpLoad();
  159. args.Add("start_time", "2019-10-1 00:00:00");
  160. args.Add("end_time", "2019-10-30 00:00:00.000");
  161. args.Add("status", "60");
  162. break;
  163. case "采购退货":
  164. upload = new PurchaseUpLoad();
  165. args.Add("start_time", "2019-10-17 20:51:28");
  166. args.Add("end_time", "2019-10-17 21:20:00");
  167. break;
  168. case "销售订单":
  169. upload = new TradeUpLoad();
  170. args.Add("start_time", "2019-10-17 20:51:28");
  171. args.Add("end_time", "2019-10-17 21:20:00");
  172. break;
  173. case "销售出库":
  174. upload = new DispatchListSendUpLoad();
  175. args.Add("start_time", "2019-11-30 00:00:00");
  176. args.Add("end_time", "2019-12-17 22:50:00");
  177. break;
  178. default:
  179. break;
  180. }
  181. try
  182. {
  183. upload.UpLoad(args);
  184. MessageBox.Show("ok");
  185. }
  186. catch (Exception ex)
  187. {
  188. MessageBox.Show(ex.Message);
  189. }
  190. }
  191. private void button6_Click(object sender, EventArgs e)
  192. {
  193. if (comboBox1.SelectedItem == null)
  194. {
  195. MessageBox.Show("请选择数据类型");
  196. return;
  197. }
  198. string type = comboBox1.SelectedItem.ToString();
  199. Dictionary<string, string> args = new Dictionary<string, string>();
  200. IDownLoad download = null;
  201. switch (type)
  202. {
  203. case "供应商":
  204. download = new DownLoadVendor();
  205. break;
  206. case "仓库":
  207. download = new DownLoadWarehouse();
  208. break;
  209. case "存货":
  210. download = new DownLoadInventory();
  211. break;
  212. case "其他入库":
  213. download = new DownLoadOtherin();
  214. break;
  215. case "其他出库":
  216. download = new DownLoadOtherout();
  217. break;
  218. case "采购订单":
  219. download = new DownLoadPurchaseorder();
  220. break;
  221. case "采购入库":
  222. download = new DownLoadPurchasein();
  223. break;
  224. case "采购退货":
  225. download = new DownLoadPurchasereturn();
  226. break;
  227. //case "销售订单":
  228. // download = new DownLoadSaleorder();
  229. // //MessageBox.Show("暂不可销售订单导入U8");
  230. // break;
  231. case "销售出库":
  232. download = new DownLoadReturnorder();
  233. //download = new DownLoadSellReturn();//退
  234. break;
  235. default:
  236. break;
  237. }
  238. //try
  239. //{
  240. download.DownLoad();
  241. MessageBox.Show("ok");
  242. //}
  243. //catch (Exception ex)
  244. //{
  245. // MessageBox.Show(ex.Message);
  246. //}
  247. }
  248. /// <summary>
  249. /// u8到中间
  250. /// </summary>
  251. /// <param name="sender"></param>
  252. /// <param name="e"></param>
  253. ///
  254. private void button8_Click(object sender, EventArgs e)
  255. {
  256. //把TR委托给Form2
  257. Form2 f2 = new Form2(SetTR);
  258. f2.Show();
  259. }
  260. private static BaseTrans _TR;
  261. private static TempDbToWang.BaseUpload _UR;
  262. /// <summary>
  263. /// U8到中间
  264. /// </summary>
  265. /// <param name="newTR"></param>
  266. private void SetTR(BaseTrans newTR)
  267. {
  268. try
  269. {
  270. _TR = newTR;
  271. Hashtable args = new Hashtable();
  272. args["Start"] = "2019-10-1 00:00:00";
  273. args["End"] = "2019-10-17 14:00:00";
  274. _TR.TransData(args);
  275. MessageBox.Show("成功");
  276. }
  277. catch
  278. {
  279. MessageBox.Show("请输入正确的格式");
  280. }
  281. }
  282. /// <summary>
  283. /// 中间到旺店通
  284. /// </summary>
  285. /// <param name="newTR"></param>
  286. private void SetUR(TempDbToWang.BaseUpload newUR)
  287. {
  288. try
  289. {
  290. _UR = newUR;
  291. Hashtable args = new Hashtable();
  292. //args["start_time"] = "2019-10-1 00:00:00";
  293. //args["end_time"] = DateTime.Now.AddMinutes(-10).ToString("yyyy-MM-dd HH:mm:ss");
  294. _UR.UploadToWang(args);
  295. #region 中间到旺店通测试专用
  296. //if (_UR is UploadRdrecord08)
  297. //{
  298. // UploadRdrecord08 UR08 = (UploadRdrecord08)_UR;
  299. // foreach (var item in UR08._results)
  300. // {
  301. // MessageBox.Show(item.Message);
  302. // }
  303. //}
  304. //else if (_UR is UploadRdrecord09)
  305. //{
  306. // UploadRdrecord09 UR09 = (UploadRdrecord09)_UR;
  307. // foreach (var item in UR09._results)
  308. // {
  309. // MessageBox.Show(item.Message);
  310. // }
  311. //}
  312. #endregion
  313. MessageBox.Show("成功");
  314. }
  315. catch
  316. {
  317. MessageBox.Show("失败");
  318. }
  319. }
  320. private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  321. {
  322. }
  323. //其他入库单=>到中间=>旺店通
  324. private void button7_Click(object sender, EventArgs e)
  325. {
  326. Form3 f3 = new Form3(SetUR);
  327. f3.Show();
  328. }
  329. private void button9_Click(object sender, EventArgs e)
  330. {
  331. InventoryUpLoad upload = new InventoryUpLoad();
  332. DateTime dt1, dt2, dt3;
  333. dt1 = new DateTime(2017, 5, 1);
  334. dt2 = dt1.AddDays(30);
  335. dt3 = DateTime.Now;
  336. bool flag = true;
  337. try
  338. {
  339. while (dt2 <= dt3 && flag)
  340. {
  341. Dictionary<string, string> args = new Dictionary<string, string>();
  342. args["start_time"] = dt1.ToString("yyyy-MM-dd HH:mm:ss");
  343. args["end_time"] = dt2.ToString("yyyy-MM-dd HH:mm:ss");
  344. upload.UpLoad(args);
  345. dt1 = dt2.AddSeconds(1);
  346. dt2 = dt1.AddDays(30);
  347. if (dt2 > dt3)
  348. {
  349. dt2 = dt3;
  350. flag = false;
  351. }
  352. }
  353. }
  354. catch (Exception ex)
  355. {
  356. MessageBox.Show(ex.Message);
  357. }
  358. MessageBox.Show("ok");
  359. }
  360. private void Form1_Load(object sender, EventArgs e)
  361. {
  362. }
  363. private void button10_Click(object sender, EventArgs e)
  364. {
  365. //string sql = "select cwhcode from warehouse where cwhcode in('WUX208','ZHQ202')";
  366. //string sql = "select cwhcode from warehouse ORDER by cwhcode";
  367. //DataTable dt = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection());
  368. //foreach (DataRow dr in dt.Rows)
  369. //{
  370. // __GetStock(dr["cwhcode"].ToString());
  371. //}
  372. //StockUpLoad up = new StockUpLoad();
  373. //Dictionary<string, string> args = new Dictionary<string, string>();
  374. //args["warehouse_no"] = "2";
  375. ////args["spec_no"] = "01010010";
  376. //args["start_time"] = "2019-8-1";
  377. //args["end_time"] = "2019-8-20";
  378. //up.UpLoad(args);
  379. string sql = "select cinvcode from inventory";
  380. DataTable dt = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection());
  381. StockUpLoad up = new StockUpLoad();
  382. Dictionary<string, string> args = new Dictionary<string, string>();
  383. foreach (DataRow dr in dt.Rows)
  384. {
  385. args["spec_no"] = dr["cinvcode"].ToString();
  386. up.UpLoad(args);
  387. }
  388. MessageBox.Show("aa");
  389. }
  390. private void __GetStock(string whcode)
  391. {
  392. //string sql = "select cinvcode from inventory";
  393. //DataTable dt = DbUtils.Fill(sql, ConnectionUtils.Instance.GetConnection());
  394. //StockUpLoad up = new StockUpLoad();
  395. //Dictionary<string, string> args = new Dictionary<string, string>();
  396. //foreach (DataRow dr in dt.Rows)
  397. //{
  398. // args["warehouse_no"] = whcode;
  399. // args["spec_no"] = dr["cinvcode"].ToString();
  400. // up.UpLoad(args);
  401. //}
  402. StockUpLoad up = new StockUpLoad();
  403. Dictionary<string, string> args = new Dictionary<string, string>();
  404. args["warehouse_no"] = whcode;
  405. args["start_time"] = "2019-8-1";
  406. args["end_time"] = "2019-8-20";
  407. up.UpLoad(args);
  408. }
  409. }
  410. }