FuelGradeConvertor.cs 1.2 KB

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