Form1.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. using DynamicExpresso;
  2. using Microsoft.International.Converters.PinYinConverter;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Configuration;
  7. using System.Data;
  8. using System.Diagnostics;
  9. using System.Drawing;
  10. using System.Dynamic;
  11. using System.Linq;
  12. using System.Net.Http;
  13. using System.Net.Http.Json;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows.Forms;
  17. using wispro.sp.entity;
  18. using wispro.sp.share;
  19. using wispro.sp.utility;
  20. namespace wispro.sp.winClient
  21. {
  22. public partial class Form1 : Form
  23. {
  24. public Form1()
  25. {
  26. InitializeComponent();
  27. }
  28. private void button1_Click(object sender, EventArgs e)
  29. {
  30. DateTime startTime = DateTime.Now;
  31. frmMerageExcel frm = new frmMerageExcel();
  32. if (frm.ShowDialog() == DialogResult.OK)
  33. {
  34. MessageBox.Show($"合并完成,合并后文件保存在:\r\n{frm.SaveFilePath}\r\n用时:{DateTime.Now - startTime }");
  35. }
  36. }
  37. private void button2_Click(object sender, EventArgs e)
  38. {
  39. OpenFileDialog ofd = new OpenFileDialog()
  40. {
  41. Multiselect = false,
  42. Filter = "*.xls|*.xlsx"
  43. };
  44. string strDinashuRegularFile = ConfigurationSettings.AppSettings["DinashuRegularFile"];
  45. if (ofd.ShowDialog() == DialogResult.OK)
  46. {
  47. new ExcelHelper().FillDianShu(ofd.FileName, strDinashuRegularFile);
  48. }
  49. MessageBox.Show("完成点数输入!");
  50. }
  51. private string[] InValidDoItem = new string[]
  52. {
  53. "案件异常-催缴年费",
  54. "案件异常-视为放弃取得专利权",
  55. "办理登记手续",
  56. "办理登记手续-确认客户是否委托",
  57. "代理所变更",
  58. "绘图",
  59. "技术确认",
  60. "缴年费",
  61. "请求保密审查",
  62. "请求费减",
  63. "请求实审",
  64. "取得申请号",
  65. "取得证书",
  66. "取得专利权评价报告",
  67. "确认官方审查状况",
  68. "询问放弃或复审",
  69. "知识点总结",
  70. "专利权人发明人申请人信息变更",
  71. "专利挖掘与布局",
  72. "我方文号前缀带J",
  73. "开卷",
  74. "请求提前公开",
  75. "取得国际检索报告",
  76. "委外检索",
  77. "中止程序",
  78. "终止",
  79. "案件异常-视为撤回",
  80. "进入国家阶段提醒",
  81. "请求恢复权利",
  82. "请求优先权",
  83. "取得【无效宣告请求审查决定】",
  84. "撤回",
  85. "请求退款",
  86. "确认是否委托申请与类型",
  87. "专利交易",
  88. "专利权评价报告",
  89. "专利权人发明人申请人信息变更+代理所变更"
  90. };
  91. private async Task InitRules(bool isSave)
  92. {
  93. List<BasePointRule> rules = new List<BasePointRule>();
  94. DataTable dt = wispro.sp.utility.NPOIExcel.ExcelToDataTable("ExcelFiles\\20211109-绩效点数规则-lcy-v1.xlsx", true);
  95. PerformanceItem item = new PerformanceItem() { CaseNo = "PAEPO2016277", DoItem= "提交检索主题声明", };
  96. foreach(DataRow row in dt.Rows)
  97. {
  98. BasePointRule rule = new BasePointRule()
  99. {
  100. Rule = row["规则"].ToString(),
  101. PointExpress = row["点数计算"].ToString(),
  102. Priority = int.Parse(row["优先级修订"].ToString()),
  103. Type = row["类型"].ToString()
  104. };
  105. try
  106. {
  107. var interpreter = new Interpreter();
  108. //item.ApplicationType
  109. Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(rule.Rule, "p");
  110. bool result = func.Invoke(item);
  111. if (result)
  112. {
  113. item.BasePoint = (double?)interpreter.Eval(rule.PointExpress);
  114. item.Type = rule.Type;
  115. System.Diagnostics.Debug.WriteLine("");
  116. }
  117. rules.Add(rule);
  118. }
  119. catch(Exception ex)
  120. {
  121. System.Diagnostics.Debug.WriteLine(rule.Rule + "\r\n" + ex.ToString());
  122. }
  123. }
  124. if (isSave)
  125. {
  126. foreach (BasePointRule rule in rules)
  127. {
  128. double d;
  129. if(double.TryParse(rule.PointExpress,out d))
  130. {
  131. rule.PointExpress = d.ToString("0.00");
  132. }
  133. await SaveBasePointRule(rule);
  134. }
  135. }
  136. }
  137. public async Task TestQueryFilter()
  138. {
  139. //QueryFilter filter = new QueryFilter();
  140. //filter.ConditionTree = new ExpressTree();
  141. //string ValueType = typeof(PerformanceItem).GetProperty("CaseNo").PropertyType.ToString();
  142. //FieldCondition condition1 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PACN", ValueType = ValueType };
  143. //FieldCondition condition2 = new FieldCondition() { FieldName = "CaseNo", Operator = OperatorEnum.Contains, Value = "PAUS", ValueType = ValueType };
  144. //filter.ConditionTree.AddCondition(LogicEnum.And,condition1);
  145. //filter.ConditionTree.AddCondition(LogicEnum.Or, condition2);
  146. //System.Diagnostics.Debug.WriteLine(filter.ConditionTree.ToExpressString("s")); ;
  147. }
  148. private async void button3_Click(object sender, EventArgs e)
  149. {
  150. wispro.sp.utility.MailUtil.SendEmail("测试邮件标题","测试邮件内容","罗才洋","luocaiyang@139.com");
  151. //CreateAppealModel model = new CreateAppealModel();
  152. //HttpClient http = new HttpClient();
  153. //PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"http://localhost:39476/api/PerformanceItem/Get?Id=7341");
  154. //List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
  155. //var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
  156. //await model.Init(item, appealType);
  157. ////await TestQueryFilter();
  158. //List<PerformanceItem> retList = new List<PerformanceItem>();
  159. //var test= retList.Where<PerformanceItem>(p => p.isDanger());
  160. //await InitRules(true);
  161. ////return;
  162. //await ImportUsers();
  163. //await InputPerformanceItem("ExcelFiles\\21.01-21.06 工程师绩效报表-总表.xlsx", true, false, 0);
  164. ////CalMonth cal = new CalMonth()
  165. ////{
  166. //// Year = 2021,
  167. //// Month = 9,
  168. //// Status = 0
  169. ////};
  170. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--发客户超过一个月未完成案件.xlsx", true,false,1, cal);
  171. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--上个月递交完成案件.xlsx", true, false, 1, cal);
  172. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--中国一次OA授权表.xlsx", true, false, 1, cal,true);
  173. //MessageBox.Show("导入完成!");
  174. }
  175. private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
  176. {
  177. PerformanceItem item = new PerformanceItem();
  178. item.ApplicationType = row["申请类型"].ToString().Trim();
  179. if(item.ApplicationType != "发明")
  180. {
  181. return null;
  182. }
  183. item.CaseNo = row["我方文号"].ToString().Trim();
  184. if (calMonth != null)
  185. {
  186. item.CalMonth = calMonth;
  187. }
  188. else
  189. {
  190. if (row.Table.Columns.Contains("绩效核算月份"))
  191. {
  192. string strjxyf = row["绩效核算月份"].ToString().Trim();
  193. string[] temYFs = strjxyf.Split(new char[] { '.' });
  194. item.CalMonth = new CalMonth();
  195. item.CalMonth.Year = int.Parse(temYFs[0]);
  196. item.CalMonth.Month = int.Parse(temYFs[1]);
  197. item.CalMonth.Status = 4;
  198. }
  199. else
  200. {
  201. item.CalMonth = new CalMonth();
  202. item.Status = 0;
  203. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  204. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  205. }
  206. }
  207. item.ApplicationType = row["申请类型"].ToString().Trim();
  208. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  209. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  210. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  211. string strHandler = "";
  212. if (row.Table.Columns.Contains("处理人"))
  213. {
  214. strHandler = row["处理人"].ToString().Trim();
  215. }
  216. else
  217. {
  218. if (row.Table.Columns.Contains("案件处理人"))
  219. {
  220. strHandler = row["案件处理人"].ToString().Trim();
  221. }
  222. }
  223. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  224. item.ItemStaffs = new List<ItemStaff>();
  225. foreach (string name in temHandlers)
  226. {
  227. ItemStaff itemStaff = new ItemStaff();
  228. int? iTem = GetStaff(name, Staffs);
  229. if ((iTem != null))
  230. {
  231. //itemStaff.Item = item;
  232. itemStaff.DoPersonId = iTem.Value;
  233. item.ItemStaffs.Add(itemStaff);
  234. }
  235. else
  236. {
  237. itemStaff.DoPerson = new Staff()
  238. {
  239. Name = name,
  240. Account = name,
  241. Password = "12345678",
  242. IsCalPerformsnce = false,
  243. Status = "正式员工",
  244. StaffGradeId = 4
  245. };
  246. item.ItemStaffs.Add(itemStaff);
  247. }
  248. }
  249. if (item.ItemStaffs.Count == 0)
  250. {
  251. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  252. }
  253. if (row.Table.Columns.Contains("核稿人"))
  254. {
  255. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim(), Staffs);
  256. }
  257. else
  258. {
  259. if (row.Table.Columns.Contains("案件核稿人"))
  260. {
  261. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim(), Staffs);
  262. }
  263. }
  264. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  265. item.ApplicationName = row["申请人"].ToString().Trim();
  266. item.CaseName = row["案件名称"].ToString().Trim();
  267. //案件备注
  268. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  269. return item;
  270. }
  271. private PerformanceItem Row2Item(DataRow row, List<Staff> Staffs,CalMonth calMonth)
  272. {
  273. PerformanceItem item = new PerformanceItem();
  274. item.CaseNo = row["我方文号"].ToString().Trim();
  275. if (calMonth != null)
  276. {
  277. item.CalMonth = calMonth;
  278. }
  279. else
  280. {
  281. if (row.Table.Columns.Contains("绩效核算月份"))
  282. {
  283. string strjxyf = row["绩效核算月份"].ToString().Trim();
  284. string[] temYFs = strjxyf.Split(new char[] { '.' });
  285. item.CalMonth = new CalMonth();
  286. item.CalMonth.Year = int.Parse(temYFs[0]);
  287. item.CalMonth.Month = int.Parse(temYFs[1]);
  288. item.CalMonth.Status = 4;
  289. }
  290. else
  291. {
  292. item.CalMonth = new CalMonth();
  293. item.Status = 0;
  294. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  295. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  296. }
  297. }
  298. item.ApplicationType = row["申请类型"].ToString().Trim();
  299. item.BusinessType = row["业务类型"].ToString().Trim();
  300. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  301. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  302. item.DoItem = row["处理事项"].ToString().Trim();
  303. item.CaseStage = row["案件阶段"].ToString().Trim();
  304. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  305. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  306. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim(), Staffs);
  307. string strHandler = "";
  308. if (row.Table.Columns.Contains("处理人"))
  309. {
  310. strHandler = row["处理人"].ToString().Trim();
  311. }
  312. else
  313. {
  314. if (row.Table.Columns.Contains("案件处理人"))
  315. {
  316. strHandler = row["案件处理人"].ToString().Trim();
  317. }
  318. }
  319. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  320. item.ItemStaffs = new List<ItemStaff>();
  321. foreach (string name in temHandlers)
  322. {
  323. ItemStaff itemStaff = new ItemStaff();
  324. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  325. int? iTem = GetStaff(temName, Staffs);
  326. if ((iTem != null))
  327. {
  328. //itemStaff.Item = item;
  329. itemStaff.DoPersonId = iTem.Value;
  330. item.ItemStaffs.Add(itemStaff);
  331. }
  332. else
  333. {
  334. itemStaff.DoPerson = new Staff()
  335. {
  336. Name = temName,
  337. Account = temName,
  338. Password = "12345678",
  339. IsCalPerformsnce = false,
  340. Status = "已离职",
  341. StaffGradeId = 4
  342. };
  343. item.ItemStaffs.Add(itemStaff);
  344. }
  345. }
  346. if (item.ItemStaffs.Count == 0)
  347. {
  348. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  349. }
  350. if (row.Table.Columns.Contains("核稿人"))
  351. {
  352. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  353. {
  354. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  355. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  356. }
  357. }
  358. else
  359. {
  360. if (row.Table.Columns.Contains("案件核稿人"))
  361. {
  362. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  363. {
  364. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  365. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  366. }
  367. }
  368. }
  369. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  370. item.ApplicationName = row["申请人"].ToString().Trim();
  371. DateTime temDate = new DateTime();
  372. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  373. {
  374. item.FinishedDate = temDate;
  375. }
  376. //定稿日
  377. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  378. {
  379. item.FinalizationDate = temDate;
  380. }
  381. //返稿日
  382. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  383. {
  384. item.ReturnDate = temDate;
  385. }
  386. //案件类型
  387. item.CaseType = row["案件类型"].ToString().Trim();
  388. //案件状态
  389. item.CaseState = row["案件状态"].ToString().Trim();
  390. //处理事项备注
  391. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  392. //处理状态
  393. item.DoItemState = row["处理状态"].ToString().Trim();
  394. //案件名称
  395. item.CaseName = row["案件名称"].ToString().Trim();
  396. //委案日期
  397. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  398. {
  399. item.EntrustingDate = temDate;
  400. }
  401. //客户期限
  402. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  403. {
  404. item.CustomerLimitDate = temDate;
  405. }
  406. //内部期限
  407. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  408. {
  409. item.InternalDate = temDate;
  410. }
  411. //初稿日
  412. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  413. {
  414. item.FirstDraftDate = temDate;
  415. }
  416. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  417. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  418. {
  419. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  420. }
  421. //案件备注
  422. item.CaseMemo = row["案件备注"].ToString().Trim();
  423. return item;
  424. }
  425. private async Task InputPerformanceItem(string strExcelFile,bool isColumnName,bool ignorHideRows=false,int ColumnNameRow=0,CalMonth calMonth=null,bool isFirstOAFile=false)
  426. {
  427. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName,ignorHideRows,ColumnNameRow);
  428. #region 删除重复行
  429. DataTable temdt = new DataTable();
  430. foreach (DataColumn col in dt.Columns)
  431. {
  432. DataColumn temCol = new DataColumn();
  433. temCol.ColumnName = col.ColumnName;
  434. temCol.DataType = col.DataType;
  435. temCol.Caption = col.Caption;
  436. temdt.Columns.Add(temCol);
  437. }
  438. new ExcelHelper().MerageDataTable(temdt, dt);
  439. #endregion
  440. List<Staff> Staffs =await GetStaffsAsync();
  441. foreach(DataRow row in temdt.Rows)
  442. {
  443. PerformanceItem item = null;
  444. if (isFirstOAFile)
  445. {
  446. item = Row2Item_1(row, Staffs, calMonth);
  447. }
  448. else
  449. {
  450. item = Row2Item(row, Staffs, calMonth);
  451. }
  452. if (item != null )
  453. {
  454. if (!InValidDoItem.Contains(item.DoItem))
  455. {
  456. await SavePerformanceItem(item);
  457. }
  458. }
  459. }
  460. }
  461. private int? GetStaff(string v, List<Staff> staffs)
  462. {
  463. if (!string.IsNullOrEmpty(v))
  464. {
  465. string[] temNames = v.Trim().Split(new char[] { '-' },StringSplitOptions.RemoveEmptyEntries);
  466. foreach (Staff sf in staffs)
  467. {
  468. if(sf.Name == temNames[0])
  469. {
  470. return sf.Id;
  471. }
  472. }
  473. }
  474. return null;
  475. }
  476. private async Task ImportUsers()
  477. {
  478. DataTable dt = NPOIExcel.ExcelToDataTable(@"C:\temp\用户列表(2021年10月26日).xlsx", true,false,1);
  479. List<StaffGrade> staffGrades = await GetStaffGrades();
  480. foreach (DataRow row in dt.Rows)
  481. {
  482. Staff staff = new Staff();
  483. staff.Account = row["用户名"].ToString().Trim();
  484. staff.Name = row["姓名"].ToString().Trim();
  485. staff.Tel = row["电话号码"].ToString().Trim();
  486. staff.Mobile = row["手机号码"].ToString().Trim();
  487. staff.Sex = row["性别"].ToString().Trim();
  488. staff.Mail = row["邮箱"].ToString().Trim();
  489. string strGrade = row["工程师等级"].ToString().Trim(); // + "级";
  490. foreach (StaffGrade sg in staffGrades)
  491. {
  492. if (strGrade.Trim() == sg.Grade.Trim())
  493. {
  494. staff.StaffGradeId = sg.Id;
  495. break;
  496. }
  497. }
  498. staff.IsOnJob = (row["是否在职"].ToString().Trim()=="是");
  499. staff.Status = row["岗位状态"].ToString().Trim();
  500. staff.Department = row["部门"].ToString();
  501. staff.WorkPlace = row["工作地"].ToString();
  502. DateTime temDate;
  503. if (DateTime.TryParse(row["入职时间"].ToString(), out temDate))
  504. {
  505. staff.EntyDate = temDate;
  506. }
  507. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  508. //staff.Memo = row["备注"].ToString().Trim();
  509. staff.Password = MD5Utility.GetMD5("12345678");
  510. //staff.StaffGradeId = row["姓名"].ToString();
  511. await SaveStaff(staff);
  512. }
  513. }
  514. private string getPinYin(string str)
  515. {
  516. string retStr = "";
  517. for(int i = 0; i < str.Length; i++)
  518. {
  519. ChineseChar cc = new ChineseChar(str[i]);
  520. retStr = retStr + cc.Pinyins[0].ToLower().Replace("1","")
  521. .Replace("2", "").Replace("3", "").Replace("4", "");
  522. }
  523. return retStr;
  524. }
  525. private async Task SaveStaff(Staff obj)
  526. {
  527. HttpClient http = new HttpClient();
  528. var data = await http.PostAsJsonAsync<wispro.sp.entity.Staff>($"http://localhost:39476/api/Staff/Save", obj);
  529. if (data.IsSuccessStatusCode)
  530. {
  531. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  532. //await Task.Delay(1000);
  533. if (result.Success)
  534. {
  535. }
  536. else
  537. {
  538. }
  539. }
  540. else
  541. {
  542. }
  543. }
  544. private async Task SaveBasePointRule(BasePointRule obj)
  545. {
  546. HttpClient http = new HttpClient();
  547. var data = await http.PostAsJsonAsync<BasePointRule>($"http://localhost:39476/api/BasePointRule/New", obj);
  548. if (data.IsSuccessStatusCode)
  549. {
  550. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  551. //await Task.Delay(1000);
  552. if (result.Success)
  553. {
  554. }
  555. else
  556. {
  557. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.Rule}\t{obj.PointExpress}\r\n{result.ErrorMessage}");
  558. }
  559. }
  560. else
  561. {
  562. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.Type}\t{obj.Rule}");
  563. }
  564. }
  565. private async Task SavePerformanceItem(PerformanceItem obj)
  566. {
  567. HttpClient http = new HttpClient();
  568. var data = await http.PostAsJsonAsync<PerformanceItem>($"http://localhost:39476/api/PerformanceItem/New", obj);
  569. if (data.IsSuccessStatusCode)
  570. {
  571. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  572. //await Task.Delay(1000);
  573. if (result.Success)
  574. {
  575. }
  576. else
  577. {
  578. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.CaseNo}\t{obj.DoItem}\r\n{result.ErrorMessage}");
  579. }
  580. }
  581. else
  582. {
  583. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.CaseNo}\t{obj.DoItem}");
  584. }
  585. }
  586. private async Task<List<StaffGrade>> GetStaffGrades()
  587. {
  588. HttpClient http = new HttpClient();
  589. var _StaffGrade = await http.GetFromJsonAsync<List<StaffGrade>>($"http://localhost:39476/api/StaffGrade/GetAll");
  590. return _StaffGrade;
  591. }
  592. private async Task<List<Staff>> GetStaffsAsync()
  593. {
  594. HttpClient http = new HttpClient();
  595. ListApiResponse<Staff> data = await http.GetFromJsonAsync<ListApiResponse<Staff>>($"http://localhost:39476/api/Staff/Query?pageIndex=1&pageSize=200");
  596. return data.Results;
  597. }
  598. private void button4_Click(object sender, EventArgs e)
  599. {
  600. Stopwatch watch = new Stopwatch();
  601. watch.Start();
  602. dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanctRecord("S2112392-洗碗机调查分析","提出报告");
  603. PerformanceItem Item = new PerformanceItem();
  604. Item.CaseName = retObj.CaseName;
  605. Item.CaseNo = retObj.CaseNo;
  606. Item.DoItem = retObj.DoItem;
  607. Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
  608. Item.Customer = new Customer();
  609. Item.Customer.Name = retObj.CustomerName;
  610. Item.DoItemCoefficient = retObj.DoItemCoefficient;
  611. Item.DoItemMemo = retObj.DoItemMemo;
  612. Item.DoItemState = retObj.DoItemState;
  613. Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
  614. Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
  615. Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
  616. //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
  617. Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
  618. if (!string.IsNullOrEmpty(retObj.DoPersons))
  619. {
  620. Item.ItemStaffs = new List<ItemStaff>();
  621. string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
  622. foreach(var name in names)
  623. {
  624. ItemStaff iStaff = new ItemStaff();
  625. iStaff.DoPerson = new Staff() { Name = name };
  626. Item.ItemStaffs.Add(iStaff);
  627. }
  628. }
  629. Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
  630. if (!string.IsNullOrEmpty(retObj.Reviewer))
  631. {
  632. Item.Reviewer = new Staff() { Name = retObj.Reviewer };
  633. }
  634. Item.ApplicationType = retObj.ApplicationType;
  635. Item.BusinessType = retObj.BusinessType;
  636. Item.CaseCoefficient = retObj.CaseCoefficient;
  637. Item.CaseMemo = retObj.CaseMemo;
  638. Item.CaseStage = retObj.CaseStage;
  639. Item.CaseState = retObj.CaseState;
  640. Item.CaseType = retObj.CaseType;
  641. watch.Stop();
  642. System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
  643. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  644. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  645. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  646. ////每月绩效统计--发客户超过一个月未完成案件
  647. //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);
  648. ////每月绩效统计--上个月递交完成案件
  649. //NewMethod("d7308cd2-71e4-4444-9f47-f4d731ddb26a", "每月绩效统计--上个月递交完成案件.xlsx", calMonth);
  650. ////每月绩效统计--中国一次OA授权表
  651. //NewMethod("72454834-afdd-4b98-b42a-0bc912d07610", "每月绩效统计--中国一次OA授权表.xlsx", calMonth, true);
  652. }
  653. }
  654. }