private List <OldReport> parseEntities(MySqlDataReader dr) { List <OldReport> results = new List <OldReport>(); while (dr.Read()) { OldReport entity = new OldReport(); entity.ID = dr.GetInt64("Id"); entity.VendorId = dr.GetInt64("VendorId"); entity.OldReportInfo = dr.GetString("OldReport"); entity.Status = dr.GetString("Status"); entity.Message = dr.GetString("Message") ?? ""; entity.CreateTime = dr.GetDateTime("CreateTime"); entity.ChangeTime = dr.GetDateTime("ChangeTime"); entity.CreateUser = dr.GetString("CreateUser"); entity.ChangeUser = dr.GetString("ChangeUser"); results.Add(entity); } dr.Close(); dr.Dispose(); return(results); }
private List <NewReport> parseNewReport(OldReport info) { List <NewReport> results = new List <NewReport>(); //get all old report urls JArray reports = JArray.Parse(info.OldReportInfo); foreach (var report in reports) { string noticeMessage = report.SelectToken("noticeMessage").ToString(); string reportUrl = report.SelectToken("reportUrl").ToString(); string time = report.SelectToken("time").ToString(); //call and get old report content WebHeaderCollection header = new WebHeaderCollection(); header.Add("Authorization", "Basic 5d076e5c3d34cb8bb08e54a4bb7e223e"); string body = HttpHelper.WebRequestToServer(reportUrl, "", null, 60000, "GET", "utf-8", "json", header, null, false, false); Console.Write(body); if (string.IsNullOrWhiteSpace(body)) { continue; } NewReport newReport = new NewReport() { VendorId = info.VendorId }; List <string> result1 = RegexUtil.getMatchedStrings(body, RegexUtil.GetReportTimePattern); DateTime tempDateTime; decimal tempDecimal; newReport.CreateTime = result1.Count > 1 && DateTime.TryParse(result1[1], out tempDateTime) ? tempDateTime : DateTime.MinValue; List <InterfaceInfoNode> interfaceList = new List <InterfaceInfoNode>(); List <string> result2 = RegexUtil.getMatchedStrings(body, RegexUtil.GetInterfaceProcessInfoPattern); for (int i = 0; i < result2.Count; i += 3) { InterfaceInfoNode interfaceInfoNode = new InterfaceInfoNode(); interfaceInfoNode.caseTypeName = (result2.Count > i + 1) ? result2[i + 1] : ""; interfaceInfoNode.progress = (result2.Count > i + 2) && decimal.TryParse(result2[i + 2], out tempDecimal) ? tempDecimal : 0m; interfaceInfoNode.caseType = getCaseType(interfaceInfoNode.caseTypeName); interfaceList.Add(interfaceInfoNode); } newReport.InterfaceProcessInfo = JsonConvert.SerializeObject(interfaceList); List <CaseInfoNode> caseList = new List <CaseInfoNode>(); List <string> result3 = RegexUtil.getMatchedStrings(body, RegexUtil.GetCaseInfoPattern); for (int i = 0; i < result3.Count; i += 5) { CaseInfoNode caseInfo = new CaseInfoNode(); caseInfo.caseId = (result3.Count > i + 1) ? result3[i + 1] : ""; caseInfo.caseName = (result3.Count > i + 2) ? result3[i + 2] : ""; caseInfo.caseTypeName = (result3.Count > i + 3) ? result3[i + 3] : ""; caseInfo.caseStateDesc = (result3.Count > i + 4) ? result3[i + 4] : ""; caseList.Add(caseInfo); } newReport.CaseInfo = JsonConvert.SerializeObject(caseList); results.Add(newReport); } return(results); }