FuelGradeConvertor.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace SinochemInternetPlusApp
  8. {
  9. static class FuelGradeConvertor
  10. {
  11. private static Dictionary<string, string> gradeMapping;
  12. static FuelGradeConvertor()
  13. {
  14. gradeMapping = new Dictionary<string, string>();
  15. string mapConfig = GenericSinochemEpsApp.AppSettings["GradeNameToGradeNo"];
  16. if(!string.IsNullOrEmpty(mapConfig))
  17. {
  18. string[] grades = mapConfig.Split(';');
  19. foreach (string gd in grades)
  20. {
  21. string[] pair = gd.Split(':');
  22. gradeMapping.Add(pair[0], pair[1]);
  23. }
  24. }
  25. else
  26. {
  27. Console.WriteLine("GradeNameToGradeNo config not found!!!");
  28. }
  29. }
  30. public static string GetGradeNo(string gradeName)
  31. {
  32. string gradeId = "";
  33. try
  34. {
  35. gradeId = gradeMapping[gradeName];
  36. }
  37. catch(Exception)
  38. {
  39. }
  40. return gradeId;
  41. }
  42. }
  43. }