private List <KuaidiListItem> GetKuaidiList() { List <KuaidiListItem> kuaidiList = new List <KuaidiListItem>(); string kuaidiPath = Path.Combine(appPath, "kuaidi.txt"); if (File.Exists(kuaidiPath)) { string[] lines = File.ReadAllLines(kuaidiPath); foreach (string line in lines) { if (!string.IsNullOrWhiteSpace(line) && !line.StartsWith("#")) { string[] fields = line.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (fields.Length == 4) { KuaidiListItem item = new KuaidiListItem(); item.DisplayName = fields[0]; item.ComPyName = fields[1]; item.ComCnName = fields[2]; item.KdNumber = fields[3]; kuaidiList.Add(item); } } } } return(kuaidiList); }
private void ShowInfoWindow(KuaidiListItem selectedItem) { currentWindow = kuaidiInfoWindow; LogData(selectedItem.ToString()); try { string url = string.Format(urlFormat, selectedItem.ComPyName, selectedItem.KdNumber); string responseStr = XingKongUtils.HttpUtils.Get(url); LogData(responseStr); //Regex reg = new Regex(@"(?i)\\[uU]([0-9a-f]{4})"); //responseStr = reg.Replace(responseStr, delegate (Match m) { return ((char)Convert.ToInt32(m.Groups[1].Value, 16)).ToString(); }); EntityHelper.ResponseEntity response = JsonConvert.DeserializeObject <EntityHelper.ResponseEntity>(responseStr); lbInfoTitle.Text = selectedItem.ComCnName + " " + selectedItem.KdNumber; if (response.data != null && response.data.Count > 0) { ShowDashedLineByCount(response.data.Count); for (int i = 0; i < 4; i++) { if (i + 1 <= response.data.Count) { LogData(string.Format("i={0}, desc={1}, time={2}", i, response.data[i].context, response.data[i].time)); infoGroup[i].Msg = response.data[i].context; infoGroup[i].Time = response.data[i].time; infoGroup[i].Visibility = true; } else { infoGroup[i].Visibility = false; } } } else { g1.Visibility = true; g2.Visibility = false; g3.Visibility = false; g4.Visibility = false; g1.Msg = response.message + ""; g1.Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } } catch (Exception ex) { lbInfoTitle.Text = "错误"; g1.Visibility = false; g2.Visibility = false; g3.Visibility = false; g4.Visibility = false; LogData(ex.Message); } XingKongScreen.ClearScreen(); currentWindow.HardworkDraw(); XingKongScreen.FreshScreen(); }