Form1.cs 58 KB

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