Form1.cs 57 KB

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