Form1.cs 58 KB

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