Form1.cs 33 KB

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