Form1.cs 58 KB

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