PhoneISPTool.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using CallCenter.Calls;
  2. using CallCenter.Share.Enums;
  3. namespace CallCenter.Tools
  4. {
  5. /// <summary>
  6. /// 电话号码获取运营商工具类
  7. /// </summary>
  8. public static class PhoneIspTool
  9. {
  10. public static EPhoneISP GetPhoneIsp(string phoneNum)
  11. {
  12. if (!string.IsNullOrEmpty(phoneNum))
  13. {
  14. //移动号码段
  15. string cm = "134,135,136,137,138,139,150,151,152,157,158,159,182,183,187,188,147,";
  16. //联通号码段
  17. string cu = "130,131,132,155,156,185,186,145,";
  18. //电信 号码段
  19. string ct = "133,153,189,";
  20. if (phoneNum.Substring(0,1)=="0")
  21. {
  22. phoneNum = phoneNum.Remove(0,1);
  23. }
  24. string noSegment = phoneNum.Substring(0, 3) + ",";
  25. if (cm.IndexOf(noSegment, StringComparison.Ordinal)>=0)
  26. {
  27. return EPhoneISP.CM;
  28. }
  29. else if (cu.IndexOf(noSegment, StringComparison.Ordinal) >= 0)
  30. {
  31. return EPhoneISP.CU;
  32. }else if (ct.IndexOf(noSegment, StringComparison.Ordinal) >= 0)
  33. {
  34. return EPhoneISP.CT;
  35. }
  36. else
  37. {
  38. return EPhoneISP.NULL;
  39. }
  40. }
  41. return EPhoneISP.NULL;
  42. }
  43. }
  44. }