public void RemoveReports(params SMSReport[] reports) { if (reports.Length == 0) { return; } List <SMSReport> list = GetReceivedReports(false); lock (lockObj) { try { for (int i = 0; i < reports.Length; i++) { SMSReport r = reports[i]; if (list.Contains(r)) { list.Remove(r); } else { r = list.FirstOrDefault(s => s.snum == r.snum); if (r != null) { list.Remove(r); } } } list.RemoveAll(s => (DateTime.Now - s.time).TotalDays > 100); File.WriteAllText("SMSReport", JsonConvert.SerializeObject(list)); } catch (Exception ex) { LogHelper.Error("移除短信报告文件错误", ex); } } }
public bool?SMS_IS_Receive(string snum) { List <SMSReport> list = GetReceivedReports(); bool? res = null; SMSReport r = list.FirstOrDefault(s => s.snum == snum); if (r != null) { res = r.IsSuccess(); RemoveReports(r); } return(res); }
private List <SMSReport> PullSMSReports() { List <SMSReport> list_tmp = new List <SMSReport> (); SMSReturnCode rcode = SMS_Reports(); if (rcode.IsSuccess) { try { string[] tmps = rcode.ReturnString.Split('|'); if (tmps != null) { for (int i = 0; i < tmps.Length; i++) { string tmp = tmps[i]; if (string.IsNullOrWhiteSpace(tmp)) { continue; } string[] tmparr = tmp.Split('/'); if (tmparr.Length == 5) { SMSReport report = new SMSReport() { snum = tmparr[0].Trim(), uid = tmparr[1], phone = tmparr[2], state = tmparr[3], time = DateTime.ParseExact(tmparr[4], "yyyy-M-d H:mm:ss", CultureInfo.InvariantCulture) }; list_tmp.Add(report); } } } } catch (Exception ex) { LogHelper.Warn(rcode.ReturnString); LogHelper.Error("PullSMSReports", ex); } } return(list_tmp); }