Form1.cs 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  1. using AntDesign;
  2. using DynamicExpresso;
  3. using Microsoft.International.Converters.PinYinConverter;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.ComponentModel;
  7. using System.Configuration;
  8. using System.Data;
  9. using System.Diagnostics;
  10. using System.Drawing;
  11. using System.Drawing.Imaging;
  12. using System.Dynamic;
  13. using System.IO;
  14. using System.Linq;
  15. using System.Net.Http;
  16. using System.Net.Http.Json;
  17. using System.Runtime.Serialization.Formatters.Binary;
  18. using System.Text;
  19. using System.Text.Json;
  20. using System.Threading.Tasks;
  21. using System.Windows.Forms;
  22. using System.Xml.Serialization;
  23. using wispro.sp.entity;
  24. using wispro.sp.entity.workflowDefine;
  25. using wispro.sp.share;
  26. using wispro.sp.share.Utility;
  27. using wispro.sp.share.webViewObject;
  28. using wispro.sp.utility;
  29. namespace wispro.sp.winClient
  30. {
  31. public partial class Form1 : Form
  32. {
  33. public Form1()
  34. {
  35. InitializeComponent();
  36. }
  37. private void button1_Click(object sender, EventArgs e)
  38. {
  39. DateTime startTime = DateTime.Now;
  40. frmMerageExcel frm = new frmMerageExcel();
  41. if (frm.ShowDialog() == DialogResult.OK)
  42. {
  43. MessageBox.Show($"合并完成,合并后文件保存在:\r\n{frm.SaveFilePath}\r\n用时:{DateTime.Now - startTime }");
  44. }
  45. }
  46. private void button2_Click(object sender, EventArgs e)
  47. {
  48. OpenFileDialog ofd = new OpenFileDialog()
  49. {
  50. Multiselect = false,
  51. Filter = "*.xls|*.xlsx"
  52. };
  53. string strDinashuRegularFile = ConfigurationSettings.AppSettings["DinashuRegularFile"];
  54. if (ofd.ShowDialog() == DialogResult.OK)
  55. {
  56. new ExcelHelper().FillDianShu(ofd.FileName, strDinashuRegularFile);
  57. }
  58. MessageBox.Show("完成点数输入!");
  59. }
  60. private string[] InValidDoItem = new string[]
  61. {
  62. "案件异常-催缴年费",
  63. "案件异常-视为放弃取得专利权",
  64. "办理登记手续",
  65. "办理登记手续-确认客户是否委托",
  66. "代理所变更",
  67. "绘图",
  68. "技术确认",
  69. "缴年费",
  70. "请求保密审查",
  71. "请求费减",
  72. "请求实审",
  73. "取得申请号",
  74. "取得证书",
  75. "取得专利权评价报告",
  76. "确认官方审查状况",
  77. "询问放弃或复审",
  78. "知识点总结",
  79. "专利权人发明人申请人信息变更",
  80. "专利挖掘与布局",
  81. "我方文号前缀带J",
  82. "开卷",
  83. "请求提前公开",
  84. "取得国际检索报告",
  85. "委外检索",
  86. "中止程序",
  87. "终止",
  88. "案件异常-视为撤回",
  89. "进入国家阶段提醒",
  90. "请求恢复权利",
  91. "请求优先权",
  92. "取得【无效宣告请求审查决定】",
  93. "撤回",
  94. "请求退款",
  95. "确认是否委托申请与类型",
  96. "专利交易",
  97. "专利权评价报告",
  98. "专利权人发明人申请人信息变更+代理所变更"
  99. };
  100. private async Task InitRules(bool isSave)
  101. {
  102. List<BasePointRule> rules = new List<BasePointRule>();
  103. DataTable dt = wispro.sp.utility.NPOIExcel.ExcelToDataTable("ExcelFiles\\20211109-绩效点数规则-lcy-v1.xlsx", true);
  104. PerformanceItem item = new PerformanceItem() { CaseNo = "PAEPO2016277", DoItem= "提交检索主题声明", };
  105. foreach(DataRow row in dt.Rows)
  106. {
  107. BasePointRule rule = new BasePointRule()
  108. {
  109. Rule = row["规则"].ToString(),
  110. PointExpress = row["点数计算"].ToString(),
  111. Priority = int.Parse(row["优先级修订"].ToString()),
  112. Type = row["类型"].ToString()
  113. };
  114. try
  115. {
  116. var interpreter = new Interpreter();
  117. //item.ApplicationType
  118. Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(rule.Rule, "p");
  119. bool result = func.Invoke(item);
  120. if (result)
  121. {
  122. item.BasePoint = (double?)interpreter.Eval(rule.PointExpress);
  123. item.Type = rule.Type;
  124. System.Diagnostics.Debug.WriteLine("");
  125. }
  126. rules.Add(rule);
  127. }
  128. catch(Exception ex)
  129. {
  130. System.Diagnostics.Debug.WriteLine(rule.Rule + "\r\n" + ex.ToString());
  131. }
  132. }
  133. if (isSave)
  134. {
  135. foreach (BasePointRule rule in rules)
  136. {
  137. double d;
  138. if(double.TryParse(rule.PointExpress,out d))
  139. {
  140. rule.PointExpress = d.ToString("0.00");
  141. }
  142. await SaveBasePointRule(rule);
  143. }
  144. }
  145. }
  146. public async Task TestQueryFilter()
  147. {
  148. //QueryFilter filter = new QueryFilter();
  149. //filter.ConditionTree = new ExpressTree();
  150. //string ValueType = typeof(PerformanceItem).GetProperty("CaseNo").PropertyType.ToString();
  151. //FieldCondition condition1 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PACN", ValueType = ValueType };
  152. //FieldCondition condition2 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PAUS", ValueType = ValueType };
  153. //filter.ConditionTree.AddCondition(LogicEnum.And,condition1);
  154. //filter.ConditionTree.AddCondition(LogicEnum.Or, condition2);
  155. //System.Diagnostics.Debug.WriteLine(filter.ConditionTree.ToExpressString("s")); ;
  156. }
  157. enum enumTest
  158. {
  159. [Description("男")]
  160. man,
  161. [Description("女")]
  162. woman
  163. }
  164. private async void button3_Click(object sender, EventArgs e)
  165. {
  166. //await StartImport();
  167. //await RemoveDBNotFinishedDate();
  168. await CalJXPoint();
  169. //await RefreshPerformanceItem(3);
  170. //await UpdateStaff();
  171. //await InitDepartment();
  172. //await GetTest();
  173. //await Compare2DB();
  174. //await RefreshPerformanceItem(1);
  175. //await RefreshPerformanceItem(2);
  176. //await RefreshPerformanceItem(3);
  177. //await UserField2String(lstAJQL);
  178. //await UserField2String(lstAJXS);
  179. //await UserField2String(lstDoItemXS);
  180. //await UserField2String(lstJXBL);
  181. //await UserField2String(lstRXSX);
  182. //await UserField2String(lstYZCQ);
  183. //await ImportUsers();
  184. //await InputPerformanceItem("c:\\temp\\21.01-21.11 工程师绩效报表-总表.xlsx", true, false, 0);
  185. }
  186. private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
  187. {
  188. PerformanceItem item = new PerformanceItem();
  189. item.ApplicationType = row["申请类型"].ToString().Trim();
  190. if(item.ApplicationType != "发明")
  191. {
  192. return null;
  193. }
  194. item.CaseNo = row["我方文号"].ToString().Trim();
  195. if (calMonth != null)
  196. {
  197. item.CalMonth = calMonth;
  198. }
  199. else
  200. {
  201. if (row.Table.Columns.Contains("绩效核算月份"))
  202. {
  203. string strjxyf = row["绩效核算月份"].ToString().Trim();
  204. string[] temYFs = strjxyf.Split(new char[] { '.' });
  205. item.CalMonth = new CalMonth();
  206. item.CalMonth.Year = int.Parse(temYFs[0]);
  207. item.CalMonth.Month = int.Parse(temYFs[1]);
  208. item.CalMonth.Status = 4;
  209. }
  210. else
  211. {
  212. item.CalMonth = new CalMonth();
  213. item.Status = 0;
  214. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  215. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  216. }
  217. }
  218. item.ApplicationType = row["申请类型"].ToString().Trim();
  219. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  220. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  221. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  222. string strHandler = "";
  223. if (row.Table.Columns.Contains("处理人"))
  224. {
  225. strHandler = row["处理人"].ToString().Trim();
  226. }
  227. else
  228. {
  229. if (row.Table.Columns.Contains("案件处理人"))
  230. {
  231. strHandler = row["案件处理人"].ToString().Trim();
  232. }
  233. }
  234. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  235. item.ItemStaffs = new List<ItemStaff>();
  236. foreach (string name in temHandlers)
  237. {
  238. ItemStaff itemStaff = new ItemStaff();
  239. int? iTem = GetStaff(name, Staffs);
  240. if ((iTem != null))
  241. {
  242. //itemStaff.Item = item;
  243. itemStaff.DoPersonId = iTem.Value;
  244. item.ItemStaffs.Add(itemStaff);
  245. }
  246. else
  247. {
  248. itemStaff.DoPerson = new Staff()
  249. {
  250. Name = name,
  251. Account = name,
  252. Password = "12345678",
  253. IsCalPerformsnce = false,
  254. Status = "正式员工",
  255. StaffGradeId = 4
  256. };
  257. item.ItemStaffs.Add(itemStaff);
  258. }
  259. }
  260. if (item.ItemStaffs.Count == 0)
  261. {
  262. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  263. }
  264. if (row.Table.Columns.Contains("核稿人"))
  265. {
  266. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim(), Staffs);
  267. }
  268. else
  269. {
  270. if (row.Table.Columns.Contains("案件核稿人"))
  271. {
  272. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim(), Staffs);
  273. }
  274. }
  275. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  276. item.ApplicationName = row["申请人"].ToString().Trim();
  277. item.CaseName = row["案件名称"].ToString().Trim();
  278. //案件备注
  279. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  280. return item;
  281. }
  282. private PerformanceItem Row2Item(DataRow row, List<Staff> Staffs,CalMonth calMonth)
  283. {
  284. PerformanceItem item = new PerformanceItem();
  285. item.CaseNo = row["我方文号"].ToString().Trim();
  286. if (calMonth != null)
  287. {
  288. item.CalMonth = calMonth;
  289. }
  290. else
  291. {
  292. if (row.Table.Columns.Contains("绩效核算月份"))
  293. {
  294. string strjxyf = row["绩效核算月份"].ToString().Trim();
  295. string[] temYFs = strjxyf.Split(new char[] { '.' });
  296. item.CalMonth = new CalMonth();
  297. item.CalMonth.Year = int.Parse(temYFs[0]);
  298. if (temYFs[1] == "1")
  299. {
  300. temYFs[1] = "10";
  301. }
  302. item.CalMonth.Month = int.Parse(temYFs[1]);
  303. item.CalMonth.Status = 4;
  304. }
  305. else
  306. {
  307. item.CalMonth = new CalMonth();
  308. item.Status = 0;
  309. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  310. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  311. }
  312. }
  313. item.ApplicationType = row["申请类型"].ToString().Trim();
  314. item.BusinessType = row["业务类型"].ToString().Trim();
  315. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  316. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  317. item.DoItem = row["处理事项"].ToString().Trim();
  318. item.CaseStage = row["案件阶段"].ToString().Trim();
  319. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  320. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  321. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim(), Staffs);
  322. string strHandler = "";
  323. if (row.Table.Columns.Contains("处理人"))
  324. {
  325. strHandler = row["处理人"].ToString().Trim();
  326. }
  327. else
  328. {
  329. if (row.Table.Columns.Contains("案件处理人"))
  330. {
  331. strHandler = row["案件处理人"].ToString().Trim();
  332. }
  333. }
  334. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  335. item.ItemStaffs = new List<ItemStaff>();
  336. foreach (string name in temHandlers)
  337. {
  338. ItemStaff itemStaff = new ItemStaff();
  339. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  340. int? iTem = GetStaff(temName, Staffs);
  341. if ((iTem != null))
  342. {
  343. //itemStaff.Item = item;
  344. itemStaff.DoPersonId = iTem.Value;
  345. item.ItemStaffs.Add(itemStaff);
  346. }
  347. else
  348. {
  349. itemStaff.DoPerson = new Staff()
  350. {
  351. Name = temName,
  352. Account = temName,
  353. Password = "12345678",
  354. IsCalPerformsnce = false,
  355. Status = "已离职",
  356. StaffGradeId = 4
  357. };
  358. item.ItemStaffs.Add(itemStaff);
  359. }
  360. }
  361. if (item.ItemStaffs.Count == 0)
  362. {
  363. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  364. }
  365. if (row.Table.Columns.Contains("核稿人"))
  366. {
  367. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  368. {
  369. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  370. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  371. }
  372. }
  373. else
  374. {
  375. if (row.Table.Columns.Contains("案件核稿人"))
  376. {
  377. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  378. {
  379. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  380. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  381. }
  382. }
  383. }
  384. if (!string.IsNullOrEmpty(row["点数"].ToString().Trim())) {
  385. item.BasePoint = double.Parse(row["点数"].ToString().Trim());
  386. }
  387. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  388. item.ApplicationName = row["申请人"].ToString().Trim();
  389. DateTime temDate = new DateTime();
  390. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  391. {
  392. item.FinishedDate = temDate;
  393. }
  394. //定稿日
  395. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  396. {
  397. item.FinalizationDate = temDate;
  398. }
  399. //返稿日
  400. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  401. {
  402. item.ReturnDate = temDate;
  403. }
  404. //案件类型
  405. item.CaseType = row["案件类型"].ToString().Trim();
  406. //案件状态
  407. item.CaseState = row["案件状态"].ToString().Trim();
  408. //处理事项备注
  409. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  410. //处理状态
  411. item.DoItemState = row["处理状态"].ToString().Trim();
  412. //案件名称
  413. item.CaseName = row["案件名称"].ToString().Trim();
  414. //委案日期
  415. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  416. {
  417. item.EntrustingDate = temDate;
  418. }
  419. //客户期限
  420. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  421. {
  422. item.CustomerLimitDate = temDate;
  423. }
  424. //内部期限
  425. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  426. {
  427. item.InternalDate = temDate;
  428. }
  429. //初稿日
  430. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  431. {
  432. item.FirstDraftDate = temDate;
  433. }
  434. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  435. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  436. {
  437. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  438. }
  439. //案件备注
  440. item.CaseMemo = row["案件备注"].ToString().Trim();
  441. return item;
  442. }
  443. private async Task InputPerformanceItem(string strExcelFile,bool isColumnName,bool ignorHideRows=false,int ColumnNameRow=0,CalMonth calMonth=null,bool isFirstOAFile=false)
  444. {
  445. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName,ignorHideRows,ColumnNameRow);
  446. #region 删除重复行
  447. DataTable temdt = new DataTable();
  448. foreach (DataColumn col in dt.Columns)
  449. {
  450. DataColumn temCol = new DataColumn();
  451. temCol.ColumnName = col.ColumnName;
  452. temCol.DataType = col.DataType;
  453. temCol.Caption = col.Caption;
  454. temdt.Columns.Add(temCol);
  455. }
  456. new ExcelHelper().MerageDataTable(temdt, dt);
  457. #endregion
  458. List<Staff> Staffs =await GetStaffsAsync();
  459. foreach(DataRow row in temdt.Rows)
  460. {
  461. PerformanceItem item = null;
  462. if (isFirstOAFile)
  463. {
  464. item = Row2Item_1(row, Staffs, calMonth);
  465. }
  466. else
  467. {
  468. item = Row2Item(row, Staffs, calMonth);
  469. }
  470. if (item != null )
  471. {
  472. System.Diagnostics.Debug.WriteLine($"{DateTime.Now}\t{item.CaseNo}\t{item.CaseName}");
  473. if (!InValidDoItem.Contains(item.DoItem))
  474. {
  475. await SavePerformanceItem(item);
  476. }
  477. }
  478. }
  479. }
  480. private async Task Compare2DB()
  481. {
  482. if (Token == null)
  483. {
  484. await Login();
  485. }
  486. HttpClient http = CreateHttp();
  487. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  488. var data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/CompareExcel2DB");
  489. //await GetDoItemInfo("PACN2027395", "处理审查意见", "一通");
  490. }
  491. private async Task RefreshPerformanceItem(int Type)
  492. {
  493. if (Token == null)
  494. {
  495. await Login();
  496. }
  497. await RefreshItemAsync(Type);
  498. //await GetDoItemInfo("PACN2027395", "处理审查意见", "一通");
  499. }
  500. private async Task StartImport()
  501. {
  502. if (Token == null)
  503. {
  504. await Login();
  505. }
  506. HttpClient http = CreateHttp();//
  507. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  508. var data = await http.GetFromJsonAsync<ApiSaveResponse>($"{strAPIBaseUri}/api/SystemData/StartImportData");
  509. }
  510. private async Task CalJXPoint()
  511. {
  512. if (Token == null)
  513. {
  514. await Login();
  515. }
  516. //await CalJXPointAsync(2022,2);
  517. await CalJXPointAsync(2022, 6);
  518. }
  519. private async Task RemoveDBNotFinishedDate()
  520. {
  521. if (Token == null)
  522. {
  523. await Login();
  524. }
  525. await DeleteDBNotFinishedTimeAsync(2022, 2);
  526. //await CalJXPointAsync(2022, 1);
  527. }
  528. List<string> lstJXBL = new List<string>() {
  529. "柳芳","杨超","何倚雯","李姣","张庆玲","李建民","李申","李莉","刘桂兰"
  530. ,"唐双","瞿璨","张鹏","钟锦光","翁旋艺","钟子敏"
  531. };
  532. List<string> lstAJXS = new List<string>() {
  533. "柳芳","杨超","何倚雯","李姣","张庆玲","李建民","李申","李莉","刘桂兰"
  534. ,"唐双","瞿璨","张鹏","钟锦光","翁旋艺","钟子敏","邢丽霞",
  535. "李庆波","黄瑜","程利","黎坚怡","舒丽亚","管自英","张晓薇","刘希"
  536. };
  537. List<string> lstDoItemXS = new List<string>() {
  538. "吴继红","赖玲玲","郭竟微","陈鹤","王本鼎","高凌云","周煜祥","何丹风",
  539. "田婵玉","孙心洁","陈舒敏","邢丽霞"
  540. };
  541. List<string> lstAJQL = new List<string>() {
  542. "柳芳","杨超","何倚雯","李姣","张庆玲","李建民","李申","李莉","刘桂兰"
  543. ,"唐双","瞿璨","张鹏","钟锦光","翁旋艺","吴继红","赖玲玲","郭竟微","陈鹤",
  544. "王本鼎","高凌云","周煜祥","何丹风","田婵玉","孙心洁","陈舒敏","钟子敏",
  545. "李庆波","黄瑜","程利","黎坚怡","舒丽亚","管自英","张晓薇","刘希"
  546. };
  547. List<string> lstYZCQ = new List<string>() {
  548. "吴继红","赖玲玲","郭竟微","陈鹤","王本鼎","高凌云","周煜祥","何丹风",
  549. "田婵玉","孙心洁","陈舒敏"
  550. };
  551. List<string> lstRXSX = new List<string>() {
  552. "夏敏","柳芳","杨超","何倚雯","李姣","张庆玲","李建民","李申","李莉","刘桂兰"
  553. ,"唐双","瞿璨","张鹏","钟锦光","翁旋艺","钟子敏","李庆波","黄瑜","程利",
  554. "黎坚怡","舒丽亚","管自英","张晓薇","刘希"
  555. };
  556. private async Task UserField2String(List<string> lstList)
  557. {
  558. if (Token == null)
  559. {
  560. await Login();
  561. }
  562. //List<Staff> Reviewers = await getReviewers(14232, 1);
  563. //Reviewers = await getReviewers(14232, 5);
  564. List<Staff> Staffs = await GetStaffsAsync();
  565. List<UserField> lstUsers = new List<UserField>();
  566. foreach(var name in lstList)
  567. {
  568. lstUsers.Add(new UserField()
  569. {
  570. UserConditionType = UserConditionType.Staff,
  571. UserType = UserType.Staff,
  572. UserValue = GetStaff(name, Staffs).ToString()
  573. });
  574. }
  575. JsonSerializerOptions options = new() { IgnoreNullValues = true };
  576. var strJson = System.Text.Json.JsonSerializer.Serialize(lstUsers, lstUsers.GetType(), options);
  577. System.Diagnostics.Debug.WriteLine(strJson);
  578. }
  579. private int? GetStaff(string v, List<Staff> staffs)
  580. {
  581. if (!string.IsNullOrEmpty(v))
  582. {
  583. string[] temNames = v.Trim().Split(new char[] { '-' },StringSplitOptions.RemoveEmptyEntries);
  584. foreach (Staff sf in staffs)
  585. {
  586. if(sf.Name == temNames[0])
  587. {
  588. return sf.Id;
  589. }
  590. }
  591. }
  592. return null;
  593. }
  594. private async Task InitDepartment()
  595. {
  596. if (Token == null)
  597. {
  598. await Login();
  599. }
  600. string strUrl = $"{strAPIBaseUri}/api/Organization/InitUserDepartment";
  601. HttpClient http = CreateHttp();
  602. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  603. var response = await http.GetAsync(strUrl);
  604. }
  605. private async Task UpdateStaff()
  606. {
  607. OpenFileDialog ofd = new OpenFileDialog();
  608. if (ofd.ShowDialog() == DialogResult.OK)
  609. {
  610. string fileName = ofd.FileName;
  611. DataTable dt = NPOIExcel.ExcelToDataTable(fileName, true, false,0);
  612. if (Token == null)
  613. {
  614. await Login();
  615. }
  616. foreach(DataRow row in dt.Rows)
  617. {
  618. Staff staff = new Staff();
  619. staff.Account = row["Account"].ToString();
  620. staff.Name = row["Name"].ToString().Trim();
  621. staff.Sex = row["Sex"].ToString().Trim();
  622. staff.Status = row["Status"].ToString().Trim();
  623. staff.Tel = row["Tel"].ToString();
  624. if (staff.Tel == "NULL")
  625. {
  626. staff.Tel = null;
  627. }
  628. staff.Mobile = row["Mobile"].ToString().Trim();
  629. if (staff.Mobile == "NULL")
  630. {
  631. staff.Mobile = null;
  632. }
  633. string temStatus = row["xm备注1"].ToString();
  634. if(!string.IsNullOrEmpty(temStatus) && temStatus != staff.Status)
  635. {
  636. staff.Status = temStatus;
  637. }
  638. if (staff.Status == "NULL")
  639. {
  640. staff.Status = null;
  641. }
  642. staff.IsOnJob = (row["IsOnJob"].ToString() == "1");
  643. staff.IsCalPerformsnce = (row["IsCalPerformsnce"].ToString() == "1");
  644. staff.IsCalPerformsnce = (row["是否计算绩效"].ToString() == "是");
  645. staff.Department = row["Department"].ToString().Trim();
  646. if (staff.Department == "NULL")
  647. {
  648. staff.Department = null;
  649. }
  650. staff.WorkPlace = row["WorkPlace"].ToString().Trim();
  651. if (staff.WorkPlace == "NULL")
  652. {
  653. staff.WorkPlace = null;
  654. }
  655. staff.Mail = row["Mail"].ToString().Trim();
  656. if (staff.Mail == "NULL")
  657. {
  658. staff.Mail = null;
  659. }
  660. staff.Memo = row["Memo"].ToString().Trim();
  661. if (staff.Memo == "NULL")
  662. {
  663. staff.Memo = null;
  664. }
  665. int temSGID;
  666. if (int.TryParse(row["StaffGradeId"].ToString().Trim(), out temSGID)){
  667. staff.StaffGradeId = temSGID;
  668. }
  669. DateTime temDate;
  670. if(DateTime.TryParse(row["EntyDate"].ToString(),out temDate))
  671. {
  672. staff.EntyDate = temDate;
  673. }
  674. // xm备注2 StaffGradeId EntyDate
  675. var temStaff = await GetStaff(staff.Name);
  676. bool isSaved = false;
  677. if (temStaff == null)
  678. {
  679. isSaved = true;
  680. //staff.Password = MD5Utility.GetMD5("12345678");
  681. }
  682. else
  683. {
  684. staff.Id = temStaff.Id;
  685. //staff.Password = temStaff.Password;
  686. isSaved =
  687. (staff.Name != temStaff.Name) ||
  688. (staff.Account != temStaff.Account) ||
  689. (staff.Department != temStaff.Department) ||
  690. (staff.EntyDate != temStaff.EntyDate) ||
  691. (staff.IsOnJob != temStaff.IsOnJob) ||
  692. (staff.Mail != temStaff.Mail) ||
  693. (staff.Mobile != temStaff.Mobile) ||
  694. (staff.Sex != temStaff.Sex) ||
  695. (staff.Status != temStaff.Status) ||
  696. (staff.Tel != temStaff.Tel) ||
  697. (staff.WorkPlace != temStaff.WorkPlace) ||
  698. (staff.StaffGradeId != temStaff.StaffGradeId) ||
  699. (staff.IsCalPerformsnce != temStaff.IsCalPerformsnce );
  700. }
  701. if (isSaved)
  702. {
  703. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  704. //staff.Memo = row["备注"].ToString().Trim();
  705. //staff.StaffGradeId = row["姓名"].ToString();
  706. await SaveStaff(staff);
  707. }
  708. System.Diagnostics.Debug.WriteLine($"{staff.Account}\t{staff.Name}");
  709. }
  710. }
  711. }
  712. private async Task ImportUsers()
  713. {
  714. OpenFileDialog ofd = new OpenFileDialog();
  715. if (ofd.ShowDialog() == DialogResult.OK)
  716. {
  717. string fileName = ofd.FileName;
  718. DataTable dt = NPOIExcel.ExcelToDataTable(fileName, true, false, 1);
  719. if(Token == null)
  720. {
  721. await Login();
  722. }
  723. List<StaffGrade> staffGrades = await GetStaffGrades();
  724. foreach (DataRow row in dt.Rows)
  725. {
  726. Staff staff = new Staff();
  727. staff.Account = row["用户名"].ToString().Trim();
  728. staff.Name = row["姓名"].ToString().Trim();
  729. staff.Tel = row["电话号码"].ToString().Trim();
  730. staff.Mobile = row["手机号码"].ToString().Trim();
  731. staff.Sex = row["性别"].ToString().Trim();
  732. staff.Mail = row["邮箱"].ToString().Trim();
  733. string strGrade = row["工程师等级"].ToString().Trim(); // + "级";
  734. foreach (StaffGrade sg in staffGrades)
  735. {
  736. if (strGrade.Trim() == sg.Grade.Trim())
  737. {
  738. staff.StaffGradeId = sg.Id;
  739. break;
  740. }
  741. }
  742. staff.IsOnJob = (row["是否在职"].ToString().Trim() == "是");
  743. staff.Status = row["岗位状态"].ToString().Trim();
  744. staff.Department = row["部门"].ToString();
  745. staff.WorkPlace = row["工作地"].ToString();
  746. DateTime temDate;
  747. if (DateTime.TryParse(row["入职时间"].ToString(), out temDate))
  748. {
  749. staff.EntyDate = temDate;
  750. }
  751. var temStaff = await GetStaff(staff.Name);
  752. bool isSaved = false;
  753. if (temStaff == null)
  754. {
  755. isSaved = true;
  756. staff.Password = MD5Utility.GetMD5("12345678");
  757. }
  758. else
  759. {
  760. staff.Id = temStaff.Id;
  761. staff.Password = temStaff.Password;
  762. isSaved =
  763. (staff.Name != temStaff.Name) ||
  764. (staff.Account != temStaff.Account) ||
  765. (staff.Department != temStaff.Department) ||
  766. (staff.EntyDate != temStaff.EntyDate) ||
  767. (staff.IsOnJob != temStaff.IsOnJob) ||
  768. (staff.Mail != temStaff.Mail) ||
  769. (staff.Mobile != temStaff.Mobile) ||
  770. (staff.Sex != temStaff.Sex) ||
  771. (staff.Status != temStaff.Status) ||
  772. (staff.Tel != temStaff.Tel) ||
  773. (staff.WorkPlace != temStaff.WorkPlace) ||
  774. (staff.StaffGradeId != temStaff.StaffGradeId);
  775. }
  776. if (isSaved)
  777. {
  778. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  779. //staff.Memo = row["备注"].ToString().Trim();
  780. //staff.StaffGradeId = row["姓名"].ToString();
  781. await SaveStaff(staff);
  782. }
  783. }
  784. }
  785. }
  786. private string getPinYin(string str)
  787. {
  788. string retStr = "";
  789. for(int i = 0; i < str.Length; i++)
  790. {
  791. ChineseChar cc = new ChineseChar(str[i]);
  792. retStr = retStr + cc.Pinyins[0].ToLower().Replace("1","")
  793. .Replace("2", "").Replace("3", "").Replace("4", "");
  794. }
  795. return retStr;
  796. }
  797. string strAPIBaseUri = "http://1.116.113.26:81";// "http://47.106.221.167:8081"; // "http://localhost:39476";//
  798. userToken Token;
  799. public async Task GetTest()
  800. {
  801. await Login();
  802. string strUrl = $"{strAPIBaseUri}/api/PerformanceItem/CurrentData2Excel";
  803. HttpClient http = CreateHttp();
  804. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  805. var response = await http.GetFromJsonAsync<FileProcessTask>(strUrl);
  806. while (!response.Finished)
  807. {
  808. response = await http.GetFromJsonAsync<FileProcessTask>($"{strAPIBaseUri}/api/FileProcesTask/Get?Id={response.Id}");
  809. System.Diagnostics.Debug.WriteLine($"{response.Processed}/{response.Size}");
  810. System.Threading.Thread.Sleep(2000);
  811. }
  812. byte[] data = await http.GetByteArrayAsync($"{strAPIBaseUri}/api/FileProcesTask/Download?Id={response.Id}");
  813. using (var file = System.IO.File.Create(response.FilePath))
  814. {
  815. file.Write(data, 0, data.Length);
  816. }
  817. #region aaa
  818. //DataTable dt = utility.NPOIExcel.ExcelToDataTable("C:\\temp\\userList.xlsx", true, false, 0);
  819. //foreach (DataRow row in dt.Rows)
  820. //{
  821. // string strAccount = row["Account"].ToString();
  822. // System.Diagnostics.Debug.WriteLine(strAccount);
  823. // string strStatus = row["Status"].ToString();
  824. // if (string.IsNullOrEmpty(strStatus))
  825. // {
  826. // strStatus = "未知";
  827. // }
  828. // string strMail = row["Mail"].ToString();
  829. // if (strAccount != "陈金勇" && strAccount!="南通流程邮箱")
  830. // {
  831. // string strUrl = $"{strAPIBaseUri}/api/Account/Modify?accountName={strAccount}&status={strStatus}&mail={strMail}";
  832. // var response = await CreateHttp().GetFromJsonAsync<ApiSaveResponse>(strUrl);
  833. // }
  834. // else
  835. // {
  836. // Console.WriteLine("");
  837. // }
  838. //}
  839. #endregion
  840. //var strUrl = "https://47.106.221.167/api/PerformanceItem/CalMyStatistics?userid=98&year=2021&month=12";
  841. //var response =await CreateHttp().GetFromJsonAsync<List<StaffStatistics>>(strUrl);
  842. }
  843. public async Task Login()
  844. {
  845. share.webViewObject.loginDto dto = new share.webViewObject.loginDto();
  846. dto.Name = "caiyangl";
  847. dto.Password = "Lqftiu807005";
  848. var response =await CreateHttp().PostAsJsonAsync<loginDto>($"{strAPIBaseUri}/api/account/Login", dto);
  849. if (response.IsSuccessStatusCode)
  850. {
  851. Token = await response.Content.ReadFromJsonAsync<userToken>();
  852. }
  853. }
  854. private async Task StatisticsLevelCount(int year, int month)
  855. {
  856. HttpClient http = CreateHttp();
  857. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  858. await http.GetAsync($"{strAPIBaseUri}/api/PerformanceItem/StatisticsLevelCount?year={year}&month={month}");
  859. }
  860. public async Task<entity.workflowDefine.Workflow> GetWorkflow(int Id, HttpClient _httpClient)
  861. {
  862. var ret = await _httpClient.GetFromJsonAsync<entity.workflowDefine.Workflow>($"{strAPIBaseUri}/api/WorkflowEngine/GetWorkflow?workflowId={Id}");
  863. return ret;
  864. }
  865. public async Task<List<entity.workflowDefine.Step>> GetSteps(int Id, HttpClient _httpClient)
  866. {
  867. var ret = await _httpClient.GetFromJsonAsync<List<entity.workflowDefine.Step>>($"{strAPIBaseUri}/api/WorkflowEngine/GetSteps?workflowId={Id}");
  868. return ret;
  869. }
  870. public async Task<List<entity.workflowDefine.Action>> GetActions(int workflowId, HttpClient _httpClient)
  871. {
  872. var ret = await _httpClient.GetFromJsonAsync<List<entity.workflowDefine.Action>>($"{strAPIBaseUri}/api/WorkflowEngine/GetActions?workflowId={workflowId}");
  873. return ret;
  874. }
  875. public async Task<List<entity.workflowDefine.TrasferCondition>> GetTransfers(int workflowId, HttpClient _httpClient)
  876. {
  877. var ret = await _httpClient.GetFromJsonAsync<List<entity.workflowDefine.TrasferCondition>>($"{strAPIBaseUri}/api/WorkflowEngine/GetTrasfers?workflowId={workflowId}");
  878. return ret;
  879. }
  880. private async Task SaveStaff(Staff obj)
  881. {
  882. HttpClient http = CreateHttp();
  883. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  884. var data = await http.PostAsJsonAsync<wispro.sp.entity.Staff>($"{strAPIBaseUri}/api/Staff/Save", obj);
  885. if (data.IsSuccessStatusCode)
  886. {
  887. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  888. //await Task.Delay(1000);
  889. if (result.Success)
  890. {
  891. }
  892. else
  893. {
  894. }
  895. }
  896. else
  897. {
  898. }
  899. }
  900. private async Task<Staff> GetStaff(string strName)
  901. {
  902. HttpClient http = CreateHttp();
  903. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  904. try
  905. {
  906. var data = await http.GetFromJsonAsync<wispro.sp.entity.Staff>($"{strAPIBaseUri}/api/Staff/GetByName?Name={strName}");
  907. return data;
  908. }
  909. catch
  910. {
  911. return null;
  912. }
  913. }
  914. private async Task SaveBasePointRule(BasePointRule obj)
  915. {
  916. HttpClient http = CreateHttp();
  917. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  918. var data = await http.PostAsJsonAsync<BasePointRule>($"{strAPIBaseUri}/api/BasePointRule/New", obj);
  919. if (data.IsSuccessStatusCode)
  920. {
  921. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  922. //await Task.Delay(1000);
  923. if (result.Success)
  924. {
  925. }
  926. else
  927. {
  928. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.Rule}\t{obj.PointExpress}\r\n{result.ErrorMessage}");
  929. }
  930. }
  931. else
  932. {
  933. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.Type}\t{obj.Rule}");
  934. }
  935. }
  936. private async Task SavePerformanceItem(PerformanceItem obj)
  937. {
  938. HttpClient http = CreateHttp();
  939. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  940. if (obj.CalMonth.Month == 10)
  941. {
  942. System.Diagnostics.Debug.WriteLine($"{obj.CalMonth.Year}-{obj.CalMonth.Month}\t{obj.CaseNo}");
  943. }
  944. var isExist = await http.PostAsJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/IsExist", obj);
  945. if (isExist.IsSuccessStatusCode && await isExist.Content.ReadFromJsonAsync<bool>()==false)
  946. {
  947. var data = await http.PostAsJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/New", obj);
  948. if (data.IsSuccessStatusCode)
  949. {
  950. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  951. //await Task.Delay(1000);
  952. if (result.Success)
  953. {
  954. }
  955. else
  956. {
  957. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.CaseNo}\t{obj.DoItem}\r\n{result.ErrorMessage}");
  958. }
  959. }
  960. else
  961. {
  962. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.CaseNo}\t{obj.DoItem}");
  963. }
  964. }
  965. }
  966. private HttpClient CreateHttp()
  967. {
  968. HttpClientHandler clientHandler = new HttpClientHandler();
  969. clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
  970. return new HttpClient(clientHandler);
  971. }
  972. private async Task<List<StaffGrade>> GetStaffGrades()
  973. {
  974. HttpClient http = CreateHttp();
  975. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  976. var _StaffGrade = await http.GetFromJsonAsync<List<StaffGrade>>($"{strAPIBaseUri}/api/StaffGrade/GetAll");
  977. return _StaffGrade;
  978. }
  979. private async Task<List<Staff>> GetStaffsAsync()
  980. {
  981. HttpClient http = CreateHttp();
  982. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  983. ListApiResponse<Staff> data = await http.GetFromJsonAsync<ListApiResponse<Staff>>($"{strAPIBaseUri}/api/Staff/Query?pageIndex=1&pageSize=1000");
  984. return data.Results;
  985. }
  986. private async Task<PerformanceItem> CalJXPointAsync(int year,int month)
  987. {
  988. HttpClient http = CreateHttp();//
  989. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  990. var data = await http.GetFromJsonAsync<ApiSaveResponse>($"{strAPIBaseUri}/api/PerformanceItem/RefreshBasePoint");
  991. //var data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/CalJXPoint?year={year}&month={month}");
  992. return null;//data;
  993. }
  994. private async Task<PerformanceItem> DeleteDBNotFinishedTimeAsync(int year, int month)
  995. {
  996. HttpClient http = CreateHttp();
  997. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  998. var data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/RemoveDBNotFinishDate?year={year}&month={month}");
  999. return data;
  1000. }
  1001. private async Task<PerformanceItem> RefreshItemAsync(int type)
  1002. {
  1003. HttpClient http = CreateHttp();
  1004. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  1005. var data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/PerformanceItem/RefreshFromIPEasy_Batch?type={type}");
  1006. return data;
  1007. }
  1008. private async Task<List<Staff>> getReviewers(int itemId,int appealTypeId)
  1009. {
  1010. HttpClient http = CreateHttp();
  1011. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  1012. List<Staff> data = await http.GetFromJsonAsync<List<Staff>>($"{strAPIBaseUri}/api/Staff/GetReviewers?itemId={itemId}&appealTypeId={appealTypeId}");
  1013. return data;
  1014. }
  1015. private async Task<PerformanceItem> GetDoItemInfo(string CaseNo, string DoItem, string caseStage)
  1016. {
  1017. HttpClient http = CreateHttp();
  1018. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  1019. PerformanceItem data = await http.GetFromJsonAsync<PerformanceItem>($"{strAPIBaseUri}/api/IPEasy/GetDoItemInfo?CaseNo={CaseNo}&DoItem={DoItem}&caseStage={caseStage}");
  1020. return data;
  1021. }
  1022. private void button4_Click(object sender, EventArgs e)
  1023. {
  1024. Stopwatch watch = new Stopwatch();
  1025. watch.Start();
  1026. //每月绩效统计--发客户超过一个月未完成案件
  1027. //DownloadReport("每月绩效统计--发客户超过一个月未完成案件", calMonth, false);
  1028. //每月绩效统计--上个月递交完成案件
  1029. //DownloadReport("每月绩效统计--上个月递交完成案件", calMonth, true);
  1030. //每月绩效统计--中国一次OA授权表
  1031. //DownloadReport("每月绩效统计--中国一次OA授权表", calMonth, true, true);
  1032. //"每月绩效统计--专案进度跟踪~S卷", "每月绩效统计--专案开卷报表~S卷"
  1033. wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  1034. wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  1035. wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  1036. wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--专案进度跟踪~S卷", false);
  1037. wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--专案开卷报表~S卷", false);
  1038. #region aaa
  1039. //dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanceRecord("S2112392-洗碗机调查分析","提出报告");
  1040. //PerformanceItem Item = new PerformanceItem();
  1041. //Item.CaseName = retObj.CaseName;
  1042. //Item.CaseNo = retObj.CaseNo;
  1043. //Item.DoItem = retObj.DoItem;
  1044. //Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
  1045. //Item.Customer = new Customer();
  1046. //Item.Customer.Name = retObj.CustomerName;
  1047. //Item.DoItemCoefficient = retObj.DoItemCoefficient;
  1048. //Item.DoItemMemo = retObj.DoItemMemo;
  1049. //Item.DoItemState = retObj.DoItemState;
  1050. //Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
  1051. //Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
  1052. //Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
  1053. ////Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
  1054. //Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
  1055. //if (!string.IsNullOrEmpty(retObj.DoPersons))
  1056. //{
  1057. // Item.ItemStaffs = new List<ItemStaff>();
  1058. // string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
  1059. // foreach(var name in names)
  1060. // {
  1061. // ItemStaff iStaff = new ItemStaff();
  1062. // iStaff.DoPerson = new Staff() { Name = name };
  1063. // Item.ItemStaffs.Add(iStaff);
  1064. // }
  1065. //}
  1066. //Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
  1067. //if (!string.IsNullOrEmpty(retObj.Reviewer))
  1068. //{
  1069. // Item.Reviewer = new Staff() { Name = retObj.Reviewer };
  1070. //}
  1071. //Item.ApplicationType = retObj.ApplicationType;
  1072. //Item.BusinessType = retObj.BusinessType;
  1073. //Item.CaseCoefficient = retObj.CaseCoefficient;
  1074. //Item.CaseMemo = retObj.CaseMemo;
  1075. //Item.CaseStage = retObj.CaseStage;
  1076. //Item.CaseState = retObj.CaseState;
  1077. //Item.CaseType = retObj.CaseType;
  1078. #endregion
  1079. watch.Stop();
  1080. System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
  1081. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  1082. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  1083. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  1084. ////每月绩效统计--发客户超过一个月未完成案件
  1085. //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);
  1086. ////每月绩效统计--上个月递交完成案件
  1087. //NewMethod("d7308cd2-71e4-4444-9f47-f4d731ddb26a", "每月绩效统计--上个月递交完成案件.xlsx", calMonth);
  1088. ////每月绩效统计--中国一次OA授权表
  1089. //NewMethod("72454834-afdd-4b98-b42a-0bc912d07610", "每月绩效统计--中国一次OA授权表.xlsx", calMonth, true);
  1090. }
  1091. private async void button5_Click(object sender, EventArgs e)
  1092. {
  1093. await StartImport();
  1094. }
  1095. private async void button6_Click(object sender, EventArgs e)
  1096. {
  1097. if (Token == null)
  1098. {
  1099. await Login();
  1100. }
  1101. HttpClient http = CreateHttp();//
  1102. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  1103. var data = await http.GetFromJsonAsync<ApiSaveResponse>($"{strAPIBaseUri}/api/SystemData/UpdateJXData");
  1104. }
  1105. private async void button7_Click(object sender, EventArgs e)
  1106. {
  1107. if (Token == null)
  1108. {
  1109. await Login();
  1110. }
  1111. HttpClient http = CreateHttp();//
  1112. http.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("bearer", Token.Token);
  1113. var data = await http.GetFromJsonAsync<ApiSaveResponse>($"{strAPIBaseUri}/api/SystemData/SendInvaldDataMessage");
  1114. }
  1115. private async Task<dynamic> GetPerformanceItemFromIPEasy()
  1116. {
  1117. HttpClient http = new HttpClient();
  1118. var response = http.GetFromJsonAsync<Object>($"http://localhost:22468/api/ipEasy/GetItemFromIPEasyDB?CaseNo=PADE1510724&DoItem=处理审查意见").Result;
  1119. dynamic retItem = new ExpandoObject();
  1120. JsonElement json = ((System.Text.Json.JsonElement)response);
  1121. retItem.CaseNo = json.GetProperty("CaseNo").GetString();
  1122. retItem.ApplicationType = json.GetProperty("ApplicationType").GetString();
  1123. retItem.BusinessType = json.GetProperty("BusinessType").GetString();
  1124. retItem.DoItem = json.GetProperty("DoItem").GetString();
  1125. retItem.CaseStage = json.GetProperty("CaseStage").GetString();
  1126. retItem.CaseCoefficient = json.GetProperty("CaseCoefficient").GetString();
  1127. retItem.DoItemCoefficient = json.GetProperty("DoItemCoefficient").GetString();
  1128. retItem.DoPersons = json.GetProperty("DoPersons").GetString();
  1129. retItem.Reviewer = json.GetProperty("Reviewer").GetString();
  1130. retItem.CustomerName = json.GetProperty("CustomerName").GetString();
  1131. retItem.FinishedDate = json.GetProperty("FinishedDate").GetString();
  1132. retItem.WordCount = json.GetProperty("WordCount").GetString();
  1133. retItem.ReturnDate = json.GetProperty("ReturnDate").GetString();
  1134. retItem.CaseType = json.GetProperty("CaseType").GetString();
  1135. retItem.CaseState = json.GetProperty("CaseState").GetString();
  1136. retItem.DoItemMemo = json.GetProperty("DoItemMemo").GetString();
  1137. retItem.DoItemState = json.GetProperty("DoItemState").GetString();
  1138. retItem.CaseName = json.GetProperty("CaseName").GetString();
  1139. retItem.EntrustingDate = json.GetProperty("EntrustingDate").GetString();
  1140. retItem.CustomerLimitDate = json.GetProperty("CustomerLimitDate").GetString();
  1141. retItem.InternalDate = json.GetProperty("InternalDate").GetString();
  1142. retItem.FirstDraftDate = json.GetProperty("FirstDraftDate").GetString();
  1143. retItem.CaseMemo = json.GetProperty("CaseMemo").GetString();
  1144. retItem.FinalizationDate = json.GetProperty("FinalizationDate").GetString();
  1145. var bytRespon =http.GetAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true").Result;
  1146. //byte[] data = await http.GetByteArrayAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true");
  1147. if (bytRespon.IsSuccessStatusCode)
  1148. {
  1149. string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
  1150. byte[] data = Convert.FromBase64String(result);
  1151. //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
  1152. XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
  1153. MemoryStream memory = new MemoryStream(data);
  1154. DataTable dt = (DataTable)serializer.Deserialize(memory);
  1155. }
  1156. return response;
  1157. }
  1158. private async void button4_Click_1(object sender, EventArgs e)
  1159. {
  1160. dynamic ret = await GetPerformanceItemFromIPEasy();
  1161. //if (ret != null)
  1162. {
  1163. //System.Diagnostics.Debug.WriteLine(ret.ToString());
  1164. }
  1165. return;
  1166. if (Token == null)
  1167. {
  1168. await Login();
  1169. }
  1170. //await StatisticsLevelCount(2022,2);
  1171. //await StatisticsLevelCount(2022, 3);
  1172. await StatisticsLevelCount(2022, 4);
  1173. await StatisticsLevelCount(2022, 5);
  1174. await StatisticsLevelCount(2022, 6);
  1175. }
  1176. }
  1177. }