Form1.cs 61 KB

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