Form1.cs 57 KB

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