Form1.cs 31 KB

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