Form1.cs 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  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. string CaseNo = "PADE1510724";
  1118. DataTable retdt = wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  1119. DataTable retdt1 = wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  1120. DataTable retdt2 = wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  1121. dynamic caseInfo = wispro.sp.utility.IPEasyUtility.GetPerformanceRecord(CaseNo, "处理审查意见");// wispro.sp.utility.IPEasyUtility.GetCaseInfo(CaseNo);
  1122. return caseInfo;
  1123. HttpClient http = new HttpClient();
  1124. var response = http.GetFromJsonAsync<Object>($"http://localhost:22468/api/ipEasy/GetItemFromIPEasyDB?CaseNo={CaseNo}&DoItem=处理审查意见").Result;
  1125. dynamic retItem = new ExpandoObject();
  1126. JsonElement json = ((System.Text.Json.JsonElement)response);
  1127. retItem.CaseNo = json.GetProperty("CaseNo").GetString();
  1128. retItem.ApplicationType = json.GetProperty("ApplicationType").GetString();
  1129. retItem.BusinessType = json.GetProperty("BusinessType").GetString();
  1130. retItem.DoItem = json.GetProperty("DoItem").GetString();
  1131. retItem.CaseStage = json.GetProperty("CaseStage").GetString();
  1132. retItem.CaseCoefficient = json.GetProperty("CaseCoefficient").GetString();
  1133. retItem.DoItemCoefficient = json.GetProperty("DoItemCoefficient").GetString();
  1134. retItem.DoPersons = json.GetProperty("DoPersons").GetString();
  1135. retItem.Reviewer = json.GetProperty("Reviewer").GetString();
  1136. retItem.CustomerName = json.GetProperty("CustomerName").GetString();
  1137. retItem.FinishedDate = json.GetProperty("FinishedDate").GetString();
  1138. retItem.WordCount = json.GetProperty("WordCount").GetString();
  1139. retItem.ReturnDate = json.GetProperty("ReturnDate").GetString();
  1140. retItem.CaseType = json.GetProperty("CaseType").GetString();
  1141. retItem.CaseState = json.GetProperty("CaseState").GetString();
  1142. retItem.DoItemMemo = json.GetProperty("DoItemMemo").GetString();
  1143. retItem.DoItemState = json.GetProperty("DoItemState").GetString();
  1144. retItem.CaseName = json.GetProperty("CaseName").GetString();
  1145. retItem.EntrustingDate = json.GetProperty("EntrustingDate").GetString();
  1146. retItem.CustomerLimitDate = json.GetProperty("CustomerLimitDate").GetString();
  1147. retItem.InternalDate = json.GetProperty("InternalDate").GetString();
  1148. retItem.FirstDraftDate = json.GetProperty("FirstDraftDate").GetString();
  1149. retItem.CaseMemo = json.GetProperty("CaseMemo").GetString();
  1150. retItem.FinalizationDate = json.GetProperty("FinalizationDate").GetString();
  1151. var bytRespon =http.GetAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true").Result;
  1152. //byte[] data = await http.GetByteArrayAsync($"http://localhost:22468/api/ipEasy/GetDataFromIPEasy?ReportName=每月绩效统计--发客户超过一个月未完成案件&isModifyDate=true");
  1153. if (bytRespon.IsSuccessStatusCode)
  1154. {
  1155. string result = bytRespon.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty);
  1156. byte[] data = Convert.FromBase64String(result);
  1157. //byte[] data = bytRespon.Content.ReadAsByteArrayAsync().Result;//Here is the problem
  1158. XmlSerializer serializer = new XmlSerializer(typeof(System.Data.DataTable));
  1159. MemoryStream memory = new MemoryStream(data);
  1160. DataTable dt = (DataTable)serializer.Deserialize(memory);
  1161. }
  1162. return response;
  1163. }
  1164. private async void button4_Click_1(object sender, EventArgs e)
  1165. {
  1166. dynamic ret = await GetPerformanceItemFromIPEasy();
  1167. //if (ret != null)
  1168. {
  1169. //System.Diagnostics.Debug.WriteLine(ret.ToString());
  1170. }
  1171. return;
  1172. if (Token == null)
  1173. {
  1174. await Login();
  1175. }
  1176. //await StatisticsLevelCount(2022,2);
  1177. //await StatisticsLevelCount(2022, 3);
  1178. await StatisticsLevelCount(2022, 4);
  1179. await StatisticsLevelCount(2022, 5);
  1180. await StatisticsLevelCount(2022, 6);
  1181. }
  1182. }
  1183. }