Form1.cs 61 KB

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