| | |
| | | const string PROPERTY_DESCRIPTION = "Description"; |
| | | const string PROPERTY_ICONPATH = "IconPath"; |
| | | |
| | | static string ConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SETTINGFILE); |
| | | static JObject data = null; |
| | | static JObject Data |
| | | { |
| | | get |
| | | { |
| | | if (data == null) |
| | | if (File.Exists(ConfigPath)) |
| | | { |
| | | string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SETTINGFILE); |
| | | if (File.Exists(configPath)) |
| | | using (StreamReader reader = new StreamReader(ConfigPath, System.Text.Encoding.UTF8)) |
| | | { |
| | | using (StreamReader reader = new StreamReader(configPath, System.Text.Encoding.UTF8)) |
| | | { |
| | | string dataStr = reader.ReadToEnd(); |
| | | data = JsonConvert.DeserializeObject<JObject>(dataStr); |
| | | } |
| | | string dataStr = reader.ReadToEnd(); |
| | | data = JsonConvert.DeserializeObject<JObject>(dataStr); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | } |
| | |
| | | return codes; |
| | | } |
| | | |
| | | public static List<string> AddNewProductionCode(string code) |
| | | { |
| | | List<string> codes = GetProductionCodes(); |
| | | if (!codes.Contains(code)) |
| | | { |
| | | codes.Add(code); |
| | | } |
| | | var dataTemp = Data; |
| | | if (dataTemp != null && dataTemp.ContainsKey(PROPERTY_PRODUCTIONCODES)) |
| | | { |
| | | dataTemp[PROPERTY_PRODUCTIONCODES] = new JArray(codes); |
| | | |
| | | string newDataStr = JsonConvert.SerializeObject(dataTemp, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); |
| | | using (StreamWriter writer = new StreamWriter(ConfigPath, false, System.Text.Encoding.UTF8)) |
| | | { |
| | | writer.Write(newDataStr); |
| | | writer.Flush(); |
| | | writer.Close(); |
| | | } |
| | | } |
| | | return GetProductionCodes(); |
| | | } |
| | | |
| | | public static string GetConfigFilePath() |
| | | { |
| | | string path = ""; |