12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SinochemInternetPlusApp
- {
- static class FuelGradeConvertor
- {
- private static Dictionary<string, string> gradeMapping;
- static FuelGradeConvertor()
- {
- gradeMapping = new Dictionary<string, string>();
- string mapConfig = App.AppSettings["GradeNameToGradeNo"];
- if(!string.IsNullOrEmpty(mapConfig))
- {
- string[] grades = mapConfig.Split(';');
- foreach (string gd in grades)
- {
- string[] pair = gd.Split(':');
- gradeMapping.Add(pair[0], pair[1]);
- }
- }
- else
- {
- Console.WriteLine("GradeNameToGradeNo config not found!!!");
- }
- }
- public static string GetGradeNo(string gradeName)
- {
- string gradeId = "";
- try
- {
- gradeId = gradeMapping[gradeName];
- }
- catch(Exception)
- {
- }
- return gradeId;
- }
- }
- }
|