Form1.cs 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  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. //dynamic dynObj = new ExpandoObject();
  151. //dynObj.Name = "名称";
  152. //dynObj.Text = "aaabc";
  153. //List<dynamic> list = new List<dynamic>();
  154. //for(int i = 0; i < 3; i++)
  155. //{
  156. // dynamic d = new ExpandoObject();
  157. // d.Id = i + 1;
  158. // d.Filed1 = $"Field{i}";
  159. // d.Date = DateTime.Now.AddDays(i);
  160. // list.Add(d);
  161. //}
  162. //dynObj.List = list;
  163. //var temTxt = System.Text.Json.JsonSerializer.Serialize(dynObj);
  164. //var dynamic = System.Text.Json.JsonSerializer.Deserialize<ExpandoObject>(temTxt);
  165. //MessageBox.Show(((IDictionary<string, object>)dynamic)["Name"].ToString());
  166. //wispro.sp.utility.MailUtil.SendEmail("测试邮件标题","测试邮件内容","罗才洋","luocaiyang@139.com");
  167. //CreateAppealModel model = new CreateAppealModel();
  168. //HttpClient http = new HttpClient();
  169. //PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"http://localhost:39476/api/PerformanceItem/Get?Id=7341");
  170. //List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
  171. //var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
  172. //await model.Init(item, appealType);
  173. ////await TestQueryFilter();
  174. //List<PerformanceItem> retList = new List<PerformanceItem>();
  175. //var test= retList.Where<PerformanceItem>(p => p.isDanger());
  176. //await InitRules(true);
  177. ////return;
  178. await ImportUsers();
  179. await InputPerformanceItem("ExcelFiles\\21.01-21.06 工程师绩效报表-总表.xlsx", true, false, 0);
  180. ////CalMonth cal = new CalMonth()
  181. ////{
  182. //// Year = 2021,
  183. //// Month = 9,
  184. //// Status = 0
  185. ////};
  186. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--发客户超过一个月未完成案件.xlsx", true,false,1, cal);
  187. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--上个月递交完成案件.xlsx", true, false, 1, cal);
  188. ////await InputPerformanceItem(@"C:\Users\luowen\Downloads\每月绩效统计--中国一次OA授权表.xlsx", true, false, 1, cal,true);
  189. //MessageBox.Show("导入完成!");
  190. }
  191. private PerformanceItem Row2Item_1(DataRow row, List<Staff> Staffs, CalMonth calMonth)
  192. {
  193. PerformanceItem item = new PerformanceItem();
  194. item.ApplicationType = row["申请类型"].ToString().Trim();
  195. if(item.ApplicationType != "发明")
  196. {
  197. return null;
  198. }
  199. item.CaseNo = row["我方文号"].ToString().Trim();
  200. if (calMonth != null)
  201. {
  202. item.CalMonth = calMonth;
  203. }
  204. else
  205. {
  206. if (row.Table.Columns.Contains("绩效核算月份"))
  207. {
  208. string strjxyf = row["绩效核算月份"].ToString().Trim();
  209. string[] temYFs = strjxyf.Split(new char[] { '.' });
  210. item.CalMonth = new CalMonth();
  211. item.CalMonth.Year = int.Parse(temYFs[0]);
  212. item.CalMonth.Month = int.Parse(temYFs[1]);
  213. item.CalMonth.Status = 4;
  214. }
  215. else
  216. {
  217. item.CalMonth = new CalMonth();
  218. item.Status = 0;
  219. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  220. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  221. }
  222. }
  223. item.ApplicationType = row["申请类型"].ToString().Trim();
  224. item.BusinessType = "普通新申请"; // row["业务类型"].ToString().Trim();
  225. item.AgentFeedbackMemo = "发明一次OA授权"; //row["备注(填表注意事项)"].ToString().Trim();
  226. item.DoItem = "发明一次OA授权"; //row["处理事项"].ToString().Trim();
  227. string strHandler = "";
  228. if (row.Table.Columns.Contains("处理人"))
  229. {
  230. strHandler = row["处理人"].ToString().Trim();
  231. }
  232. else
  233. {
  234. if (row.Table.Columns.Contains("案件处理人"))
  235. {
  236. strHandler = row["案件处理人"].ToString().Trim();
  237. }
  238. }
  239. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  240. item.ItemStaffs = new List<ItemStaff>();
  241. foreach (string name in temHandlers)
  242. {
  243. ItemStaff itemStaff = new ItemStaff();
  244. int? iTem = GetStaff(name, Staffs);
  245. if ((iTem != null))
  246. {
  247. //itemStaff.Item = item;
  248. itemStaff.DoPersonId = iTem.Value;
  249. item.ItemStaffs.Add(itemStaff);
  250. }
  251. else
  252. {
  253. itemStaff.DoPerson = new Staff()
  254. {
  255. Name = name,
  256. Account = name,
  257. Password = "12345678",
  258. IsCalPerformsnce = false,
  259. Status = "正式员工",
  260. StaffGradeId = 4
  261. };
  262. item.ItemStaffs.Add(itemStaff);
  263. }
  264. }
  265. if (item.ItemStaffs.Count == 0)
  266. {
  267. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  268. }
  269. if (row.Table.Columns.Contains("核稿人"))
  270. {
  271. item.ReviewerId = GetStaff(row["核稿人"].ToString().Trim(), Staffs);
  272. }
  273. else
  274. {
  275. if (row.Table.Columns.Contains("案件核稿人"))
  276. {
  277. item.ReviewerId = GetStaff(row["案件核稿人"].ToString().Trim(), Staffs);
  278. }
  279. }
  280. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  281. item.ApplicationName = row["申请人"].ToString().Trim();
  282. item.CaseName = row["案件名称"].ToString().Trim();
  283. //案件备注
  284. item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
  285. return item;
  286. }
  287. private PerformanceItem Row2Item(DataRow row, List<Staff> Staffs,CalMonth calMonth)
  288. {
  289. PerformanceItem item = new PerformanceItem();
  290. item.CaseNo = row["我方文号"].ToString().Trim();
  291. if (calMonth != null)
  292. {
  293. item.CalMonth = calMonth;
  294. }
  295. else
  296. {
  297. if (row.Table.Columns.Contains("绩效核算月份"))
  298. {
  299. string strjxyf = row["绩效核算月份"].ToString().Trim();
  300. string[] temYFs = strjxyf.Split(new char[] { '.' });
  301. item.CalMonth = new CalMonth();
  302. item.CalMonth.Year = int.Parse(temYFs[0]);
  303. item.CalMonth.Month = int.Parse(temYFs[1]);
  304. item.CalMonth.Status = 4;
  305. }
  306. else
  307. {
  308. item.CalMonth = new CalMonth();
  309. item.Status = 0;
  310. item.CalMonth.Year = DateTime.Now.AddMonths(-1).Year;
  311. item.CalMonth.Month = DateTime.Now.AddMonths(-1).Month;
  312. }
  313. }
  314. item.ApplicationType = row["申请类型"].ToString().Trim();
  315. item.BusinessType = row["业务类型"].ToString().Trim();
  316. if (row.Table.Columns.Contains("备注(填表注意事项)"))
  317. item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
  318. item.DoItem = row["处理事项"].ToString().Trim();
  319. item.CaseStage = row["案件阶段"].ToString().Trim();
  320. item.CaseCoefficient = row["案件系数"].ToString().Trim();
  321. item.DoItemCoefficient = row["处理事项系数"].ToString().Trim();
  322. item.PreOastaffId = GetStaff(row["前一次OA处理人"].ToString().Trim(), Staffs);
  323. string strHandler = "";
  324. if (row.Table.Columns.Contains("处理人"))
  325. {
  326. strHandler = row["处理人"].ToString().Trim();
  327. }
  328. else
  329. {
  330. if (row.Table.Columns.Contains("案件处理人"))
  331. {
  332. strHandler = row["案件处理人"].ToString().Trim();
  333. }
  334. }
  335. string[] temHandlers = strHandler.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  336. item.ItemStaffs = new List<ItemStaff>();
  337. foreach (string name in temHandlers)
  338. {
  339. ItemStaff itemStaff = new ItemStaff();
  340. string temName = name.Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  341. int? iTem = GetStaff(temName, Staffs);
  342. if ((iTem != null))
  343. {
  344. //itemStaff.Item = item;
  345. itemStaff.DoPersonId = iTem.Value;
  346. item.ItemStaffs.Add(itemStaff);
  347. }
  348. else
  349. {
  350. itemStaff.DoPerson = new Staff()
  351. {
  352. Name = temName,
  353. Account = temName,
  354. Password = "12345678",
  355. IsCalPerformsnce = false,
  356. Status = "已离职",
  357. StaffGradeId = 4
  358. };
  359. item.ItemStaffs.Add(itemStaff);
  360. }
  361. }
  362. if (item.ItemStaffs.Count == 0)
  363. {
  364. System.Diagnostics.Debug.WriteLine($"没有处理人: {item.CaseNo}\t{item.DoItem}");
  365. }
  366. if (row.Table.Columns.Contains("核稿人"))
  367. {
  368. if (!string.IsNullOrEmpty(row["核稿人"].ToString().Trim()))
  369. {
  370. string temName = row["核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  371. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  372. }
  373. }
  374. else
  375. {
  376. if (row.Table.Columns.Contains("案件核稿人"))
  377. {
  378. if (!string.IsNullOrEmpty(row["案件核稿人"].ToString().Trim()))
  379. {
  380. string temName = row["案件核稿人"].ToString().Trim().Split(new char[] { '-' }, StringSplitOptions.RemoveEmptyEntries)[0];
  381. item.ReviewerId = GetStaff(temName.Trim(), Staffs);
  382. }
  383. }
  384. }
  385. item.Customer = new Customer() { Name = row["客户名称"].ToString().Trim() };
  386. item.ApplicationName = row["申请人"].ToString().Trim();
  387. DateTime temDate = new DateTime();
  388. if (DateTime.TryParse(row["处理事项完成日"].ToString().Trim(), out temDate))
  389. {
  390. item.FinishedDate = temDate;
  391. }
  392. //定稿日
  393. if (DateTime.TryParse(row["定稿日"].ToString().Trim(), out temDate))
  394. {
  395. item.FinalizationDate = temDate;
  396. }
  397. //返稿日
  398. if (DateTime.TryParse(row["返稿日"].ToString().Trim(), out temDate))
  399. {
  400. item.ReturnDate = temDate;
  401. }
  402. //案件类型
  403. item.CaseType = row["案件类型"].ToString().Trim();
  404. //案件状态
  405. item.CaseState = row["案件状态"].ToString().Trim();
  406. //处理事项备注
  407. item.DoItemMemo = row["处理事项备注"].ToString().Trim();
  408. //处理状态
  409. item.DoItemState = row["处理状态"].ToString().Trim();
  410. //案件名称
  411. item.CaseName = row["案件名称"].ToString().Trim();
  412. //委案日期
  413. if (DateTime.TryParse(row["委案日期"].ToString().Trim(), out temDate))
  414. {
  415. item.EntrustingDate = temDate;
  416. }
  417. //客户期限
  418. if (DateTime.TryParse(row["客户期限"].ToString().Trim(), out temDate))
  419. {
  420. item.CustomerLimitDate = temDate;
  421. }
  422. //内部期限
  423. if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
  424. {
  425. item.InternalDate = temDate;
  426. }
  427. //初稿日
  428. if (DateTime.TryParse(row["初稿日"].ToString().Trim(), out temDate))
  429. {
  430. item.FirstDraftDate = temDate;
  431. }
  432. //备注(发文严重超期是否属客观原因,若为否,请填写原因)
  433. if (row.Table.Columns.Contains("备注(发文严重超期是否属客观原因,若为否,请填写原因)"))
  434. {
  435. item.OverDueMemo = row["备注(发文严重超期是否属客观原因,若为否,请填写原因)"].ToString().Trim();
  436. }
  437. //案件备注
  438. item.CaseMemo = row["案件备注"].ToString().Trim();
  439. return item;
  440. }
  441. private async Task InputPerformanceItem(string strExcelFile,bool isColumnName,bool ignorHideRows=false,int ColumnNameRow=0,CalMonth calMonth=null,bool isFirstOAFile=false)
  442. {
  443. DataTable dt = NPOIExcel.ExcelToDataTable(strExcelFile, isColumnName,ignorHideRows,ColumnNameRow);
  444. #region 删除重复行
  445. DataTable temdt = new DataTable();
  446. foreach (DataColumn col in dt.Columns)
  447. {
  448. DataColumn temCol = new DataColumn();
  449. temCol.ColumnName = col.ColumnName;
  450. temCol.DataType = col.DataType;
  451. temCol.Caption = col.Caption;
  452. temdt.Columns.Add(temCol);
  453. }
  454. new ExcelHelper().MerageDataTable(temdt, dt);
  455. #endregion
  456. List<Staff> Staffs =await GetStaffsAsync();
  457. foreach(DataRow row in temdt.Rows)
  458. {
  459. PerformanceItem item = null;
  460. if (isFirstOAFile)
  461. {
  462. item = Row2Item_1(row, Staffs, calMonth);
  463. }
  464. else
  465. {
  466. item = Row2Item(row, Staffs, calMonth);
  467. }
  468. if (item != null )
  469. {
  470. if (!InValidDoItem.Contains(item.DoItem))
  471. {
  472. await SavePerformanceItem(item);
  473. }
  474. }
  475. }
  476. }
  477. private int? GetStaff(string v, List<Staff> staffs)
  478. {
  479. if (!string.IsNullOrEmpty(v))
  480. {
  481. string[] temNames = v.Trim().Split(new char[] { '-' },StringSplitOptions.RemoveEmptyEntries);
  482. foreach (Staff sf in staffs)
  483. {
  484. if(sf.Name == temNames[0])
  485. {
  486. return sf.Id;
  487. }
  488. }
  489. }
  490. return null;
  491. }
  492. private async Task ImportUsers()
  493. {
  494. DataTable dt = NPOIExcel.ExcelToDataTable(@"C:\temp\用户列表(2021年10月26日).xlsx", true,false,1);
  495. List<StaffGrade> staffGrades = await GetStaffGrades();
  496. foreach (DataRow row in dt.Rows)
  497. {
  498. Staff staff = new Staff();
  499. staff.Account = row["用户名"].ToString().Trim();
  500. staff.Name = row["姓名"].ToString().Trim();
  501. staff.Tel = row["电话号码"].ToString().Trim();
  502. staff.Mobile = row["手机号码"].ToString().Trim();
  503. staff.Sex = row["性别"].ToString().Trim();
  504. staff.Mail = row["邮箱"].ToString().Trim();
  505. string strGrade = row["工程师等级"].ToString().Trim(); // + "级";
  506. foreach (StaffGrade sg in staffGrades)
  507. {
  508. if (strGrade.Trim() == sg.Grade.Trim())
  509. {
  510. staff.StaffGradeId = sg.Id;
  511. break;
  512. }
  513. }
  514. staff.IsOnJob = (row["是否在职"].ToString().Trim()=="是");
  515. staff.Status = row["岗位状态"].ToString().Trim();
  516. staff.Department = row["部门"].ToString();
  517. staff.WorkPlace = row["工作地"].ToString();
  518. DateTime temDate;
  519. if (DateTime.TryParse(row["入职时间"].ToString(), out temDate))
  520. {
  521. staff.EntyDate = temDate;
  522. }
  523. //staff.IsCalPerformsnce = (row["是否核算绩效"].ToString() == "是");
  524. //staff.Memo = row["备注"].ToString().Trim();
  525. staff.Password = MD5Utility.GetMD5("12345678");
  526. //staff.StaffGradeId = row["姓名"].ToString();
  527. await SaveStaff(staff);
  528. }
  529. }
  530. private string getPinYin(string str)
  531. {
  532. string retStr = "";
  533. for(int i = 0; i < str.Length; i++)
  534. {
  535. ChineseChar cc = new ChineseChar(str[i]);
  536. retStr = retStr + cc.Pinyins[0].ToLower().Replace("1","")
  537. .Replace("2", "").Replace("3", "").Replace("4", "");
  538. }
  539. return retStr;
  540. }
  541. private async Task SaveStaff(Staff obj)
  542. {
  543. HttpClient http = new HttpClient();
  544. var data = await http.PostAsJsonAsync<wispro.sp.entity.Staff>($"http://localhost:39476/api/Staff/Save", obj);
  545. if (data.IsSuccessStatusCode)
  546. {
  547. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  548. //await Task.Delay(1000);
  549. if (result.Success)
  550. {
  551. }
  552. else
  553. {
  554. }
  555. }
  556. else
  557. {
  558. }
  559. }
  560. private async Task SaveBasePointRule(BasePointRule obj)
  561. {
  562. HttpClient http = new HttpClient();
  563. var data = await http.PostAsJsonAsync<BasePointRule>($"http://localhost:39476/api/BasePointRule/New", obj);
  564. if (data.IsSuccessStatusCode)
  565. {
  566. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  567. //await Task.Delay(1000);
  568. if (result.Success)
  569. {
  570. }
  571. else
  572. {
  573. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.Rule}\t{obj.PointExpress}\r\n{result.ErrorMessage}");
  574. }
  575. }
  576. else
  577. {
  578. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.Type}\t{obj.Rule}");
  579. }
  580. }
  581. private async Task SavePerformanceItem(PerformanceItem obj)
  582. {
  583. HttpClient http = new HttpClient();
  584. var data = await http.PostAsJsonAsync<PerformanceItem>($"http://localhost:39476/api/PerformanceItem/New", obj);
  585. if (data.IsSuccessStatusCode)
  586. {
  587. ApiSaveResponse result = await data.Content.ReadFromJsonAsync<ApiSaveResponse>();
  588. //await Task.Delay(1000);
  589. if (result.Success)
  590. {
  591. }
  592. else
  593. {
  594. System.Diagnostics.Debug.WriteLine($"保存错误: {obj.CaseNo}\t{obj.DoItem}\r\n{result.ErrorMessage}");
  595. }
  596. }
  597. else
  598. {
  599. System.Diagnostics.Debug.WriteLine($"调用API错误: {obj.CaseNo}\t{obj.DoItem}");
  600. }
  601. }
  602. private async Task<List<StaffGrade>> GetStaffGrades()
  603. {
  604. HttpClient http = new HttpClient();
  605. var _StaffGrade = await http.GetFromJsonAsync<List<StaffGrade>>($"http://localhost:39476/api/StaffGrade/GetAll");
  606. return _StaffGrade;
  607. }
  608. private async Task<List<Staff>> GetStaffsAsync()
  609. {
  610. HttpClient http = new HttpClient();
  611. ListApiResponse<Staff> data = await http.GetFromJsonAsync<ListApiResponse<Staff>>($"http://localhost:39476/api/Staff/Query?pageIndex=1&pageSize=200");
  612. return data.Results;
  613. }
  614. private void button4_Click(object sender, EventArgs e)
  615. {
  616. Stopwatch watch = new Stopwatch();
  617. watch.Start();
  618. dynamic retObj = wispro.sp.utility.IPEasyUtility.GetPerformanctRecord("S2112392-洗碗机调查分析","提出报告");
  619. PerformanceItem Item = new PerformanceItem();
  620. Item.CaseName = retObj.CaseName;
  621. Item.CaseNo = retObj.CaseNo;
  622. Item.DoItem = retObj.DoItem;
  623. Item.CustomerLimitDate = string.IsNullOrEmpty(retObj.CustomerLimitDate) ? null : DateTime.Parse(retObj.CustomerLimitDate);
  624. Item.Customer = new Customer();
  625. Item.Customer.Name = retObj.CustomerName;
  626. Item.DoItemCoefficient = retObj.DoItemCoefficient;
  627. Item.DoItemMemo = retObj.DoItemMemo;
  628. Item.DoItemState = retObj.DoItemState;
  629. Item.EntrustingDate = string.IsNullOrEmpty(retObj.EntrustingDate) ? null : DateTime.Parse(retObj.EntrustingDate);
  630. Item.FinalizationDate = string.IsNullOrEmpty(retObj.FinalizationDate) ? null : DateTime.Parse(retObj.FinalizationDate);
  631. Item.FinishedDate = string.IsNullOrEmpty(retObj.FinishedDate) ? null : DateTime.Parse(retObj.FinishedDate);
  632. //Item.FirstDraftDate = string.IsNullOrEmpty(retObj.FirstDraftDate) ? null : DateTime.Parse(retObj.FirstDraftDate);
  633. Item.InternalDate = string.IsNullOrEmpty(retObj.InternalDate) ? null : DateTime.Parse(retObj.InternalDate);
  634. if (!string.IsNullOrEmpty(retObj.DoPersons))
  635. {
  636. Item.ItemStaffs = new List<ItemStaff>();
  637. string[] names = retObj.DoPersons.ToString().Split(new char[] { ','},StringSplitOptions.RemoveEmptyEntries);
  638. foreach(var name in names)
  639. {
  640. ItemStaff iStaff = new ItemStaff();
  641. iStaff.DoPerson = new Staff() { Name = name };
  642. Item.ItemStaffs.Add(iStaff);
  643. }
  644. }
  645. Item.ReturnDate = string.IsNullOrEmpty(retObj.ReturnDate) ? null : DateTime.Parse(retObj.ReturnDate);
  646. if (!string.IsNullOrEmpty(retObj.Reviewer))
  647. {
  648. Item.Reviewer = new Staff() { Name = retObj.Reviewer };
  649. }
  650. Item.ApplicationType = retObj.ApplicationType;
  651. Item.BusinessType = retObj.BusinessType;
  652. Item.CaseCoefficient = retObj.CaseCoefficient;
  653. Item.CaseMemo = retObj.CaseMemo;
  654. Item.CaseStage = retObj.CaseStage;
  655. Item.CaseState = retObj.CaseState;
  656. Item.CaseType = retObj.CaseType;
  657. watch.Stop();
  658. System.Diagnostics.Debug.WriteLine("用时{0}毫秒", watch.ElapsedMilliseconds);//获取当前实例测量得出的总运行时间(以毫秒为单位)
  659. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--上个月递交完成案件", true);
  660. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--发客户超过一个月未完成案件", false);
  661. //wispro.sp.utility.IPEasyUtility.DownloadReport("每月绩效统计--中国一次OA授权表", true);
  662. ////每月绩效统计--发客户超过一个月未完成案件
  663. //NewMethod("506aa7ad-c3f4-4ec6-9ec8-ff6b92dcd7c1", "每月绩效统计--发客户超过一个月未完成案件.xlsx", calMonth);
  664. ////每月绩效统计--上个月递交完成案件
  665. //NewMethod("d7308cd2-71e4-4444-9f47-f4d731ddb26a", "每月绩效统计--上个月递交完成案件.xlsx", calMonth);
  666. ////每月绩效统计--中国一次OA授权表
  667. //NewMethod("72454834-afdd-4b98-b42a-0bc912d07610", "每月绩效统计--中国一次OA授权表.xlsx", calMonth, true);
  668. }
  669. }
  670. }