private byte GetOnlineStyleByPackage(AsyncDataPackageType type) { byte ret = (byte)LinkType.TCP; switch (type) { case AsyncDataPackageType.SAT: ret = (byte)LinkType.SATELLITE; break; case AsyncDataPackageType.SMS: ret = (byte)LinkType.SMS; break; case AsyncDataPackageType.TCP: ret = (byte)LinkType.TCP; break; case AsyncDataPackageType.UDP: ret = (byte)LinkType.UDP; break; } return(ret); }
private string GetOnlineStyle(AsyncDataPackageType type) { string ret = "TCP"; switch (type) { case AsyncDataPackageType.SAT: ret = "SAT"; break; case AsyncDataPackageType.SMS: ret = "SMS"; break; case AsyncDataPackageType.TCP: ret = "TCP"; break; case AsyncDataPackageType.UDP: ret = "UDP"; break; } return(ret); }
/// <summary> /// 保存终端流量 /// </summary> /// <param name="terminal"></param> /// <param name="sim"></param> /// <param name="protocol"></param> /// <param name="len"></param> /// <param name="receive"></param> private void SaveTerminalData(int terminal, string sim, AsyncDataPackageType protocol, int len, bool receive, DateTime time) { var n = (int?)null; var monthly = int.Parse(time.ToString("yyyyMM")); using (var bll = new TerminalFlowBLL()) { var flow = bll.Find(f => f.Sim.Equals(sim) && f.Monthly == monthly); if (null == flow) { flow = bll.GetObject(); flow.Terminal = terminal < 0 ? n : terminal; flow.Monthly = monthly; flow.Sim = sim; if (protocol == AsyncDataPackageType.TCP || protocol == AsyncDataPackageType.UDP) { if (receive) { flow.GPRSReceive = len; } else { flow.GPRSDeliver = len; } } else if (protocol == AsyncDataPackageType.SMS) { if (receive) { flow.SMSReceive = 1; } else { flow.SMSDeliver = 1; } } bll.Add(flow); } else { // 如果终端不存在则更新sim卡号码的流量 if (flow.Terminal == n) { bll.Update(f => f.Sim.Equals(sim) && f.Monthly == monthly, act => { if (n == act.Terminal && 0 < terminal) { act.Terminal = terminal; } if (protocol == AsyncDataPackageType.TCP || protocol == AsyncDataPackageType.UDP) { if (receive) { act.GPRSReceive += len; } else { act.GPRSDeliver += len; } } else if (protocol == AsyncDataPackageType.SMS) { if (receive) { act.SMSReceive += 1; } else { act.SMSDeliver += 1; } } }); } else { bll.Update(f => f.id == flow.id, act => { if (n == act.Terminal && 0 < terminal) { act.Terminal = terminal; } if (protocol == AsyncDataPackageType.TCP || protocol == AsyncDataPackageType.UDP) { if (receive) { act.GPRSReceive += len; } else { act.GPRSDeliver += len; } } else if (protocol == AsyncDataPackageType.SMS) { if (receive) { act.SMSReceive += 1; } else { act.SMSDeliver += 1; } } }); } } } }