DataDownloadLocalExtension.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using Newtonsoft.Json.Linq;
  2. using PTMedicalInsurance.Business;
  3. using PTMedicalInsurance.Forms.BasicDatas.services;
  4. using PTMedicalInsurance.Helper;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace GuiYangBaseMI.Forms.BasicDatas
  15. {
  16. public partial class DataDownloadLocalExtension : Form
  17. {
  18. private Form mainForm;
  19. private DirectoryDownloadLocalExtService service = new DirectoryDownloadLocalExtService();
  20. private DownloadType downloadType;
  21. private string errMsg;
  22. CenterBusiness cBus = new CenterBusiness();
  23. HisMainBusiness hBus = new HisMainBusiness();
  24. HisIrisServices hIS = new HisIrisServices();
  25. MIIrisServices mIS = new MIIrisServices();
  26. InvokeHelper invoker = new InvokeHelper();
  27. public DataDownloadLocalExtension()
  28. {
  29. InitializeComponent();
  30. }
  31. public DataDownloadLocalExtension(Form frm)
  32. {
  33. InitializeComponent();
  34. InitForm(frm);
  35. }
  36. /// <summary>
  37. /// 初始化界面
  38. /// </summary>
  39. /// <param name="frm"></param>
  40. private void InitForm(Form frm)
  41. {
  42. mainForm = frm;
  43. CheckForIllegalCrossThreadCalls = false;
  44. // 禁用关闭按钮
  45. this.FormBorderStyle = FormBorderStyle.None;
  46. // 隐藏标题栏
  47. this.ControlBox = false;
  48. // 其他可能需要的配置
  49. this.TopLevel = false;
  50. this.Dock = DockStyle.Fill; // 根据需要设置 Dock 属性
  51. //默认药品,手工输入
  52. rbDirectory.Checked = rbSpecialVer.Checked = true;
  53. }
  54. /// <summary>
  55. /// 设置枚举值
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. private void DownloadTypeCheckedChanged(object sender, EventArgs e)
  60. {
  61. if (rbDirectory.Checked) downloadType = DownloadType.Directory;
  62. else if (rbLimitPrice.Checked) downloadType = DownloadType.LimitPrice;
  63. else if (rbSelfRaito.Checked) downloadType = DownloadType.SelfRatio;
  64. else downloadType = DownloadType.None;
  65. }
  66. /// <summary>
  67. /// 获取最大版本号
  68. /// </summary>
  69. /// <returns></returns>
  70. private string GetMaxVer()
  71. {
  72. JObject joMaxVerNO = mIS.getDirectoryMaxVersionNO(-1);
  73. string ver = joMaxVerNO["result"]["MaxVersionNO"].ToString();
  74. tbVersionNO.Text = ver;
  75. return ver;
  76. }
  77. /// <summary>
  78. /// 下载封装
  79. /// </summary>
  80. /// <param name="err"></param>
  81. private void Download(out string err)
  82. {
  83. err = "";
  84. if (rbSpecialVer.Checked)
  85. {
  86. service.SignleDownload(tbVersionNO.Text, downloadType, this);
  87. }
  88. if (rbFromSpecialVer.Checked)
  89. {
  90. service.LoopDownload(tbVersionNO.Text, downloadType, this);
  91. }
  92. if (rbAutoQueryMaxVer.Checked)
  93. {
  94. service.LoopDownload(GetMaxVer(), downloadType, this);
  95. }
  96. }
  97. private void btExit_Click(object sender, EventArgs e)
  98. {
  99. mainForm.Close();
  100. }
  101. private void btDownload_Click(object sender, EventArgs e)
  102. {
  103. Download(out errMsg);
  104. }
  105. }
  106. }