| | |
| | | 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 |
| | | { |
| | | string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SETTINGFILE); |
| | | if (File.Exists(configPath)) |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | return data; |
| | | } |
| | | } |
| | |
| | | |
| | | public static List<string> AddNewProductionCode(string code) |
| | | { |
| | | List<string> codes = GetProcessCodes(); |
| | | List<string> codes = GetProductionCodes(); |
| | | if (!codes.Contains(code)) |
| | | { |
| | | codes.Add(code); |
| | | } |
| | | if (Data != null && Data.ContainsKey(PROPERTY_PRODUCTIONCODES)) |
| | | var dataTemp = Data; |
| | | if (dataTemp != null && dataTemp.ContainsKey(PROPERTY_PRODUCTIONCODES)) |
| | | { |
| | | Data[PROPERTY_PRODUCTIONCODES] = new JArray(codes); |
| | | string newDataStr = JsonConvert.SerializeObject(Data, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.Auto }); |
| | | using (StreamWriter writer = new StreamWriter(GetSettingFilePath(), false, System.Text.Encoding.UTF8)) |
| | | 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 GetProcessCodes(); |
| | | return GetProductionCodes(); |
| | | } |
| | | |
| | | public static string GetConfigFilePath() |
| | |
| | | if (Data != null && Data.ContainsKey(PROPERTY_CONFIGPATH)) |
| | | { |
| | | path = Data.Value<string>(PROPERTY_CONFIGPATH); |
| | | } |
| | | |
| | | return path; |
| | | } |
| | | |
| | | public static string GetSettingFilePath() |
| | | { |
| | | string path = ""; |
| | | |
| | | if (Data != null && Data.ContainsKey(SETTINGFILE)) |
| | | { |
| | | path = Data.Value<string>(SETTINGFILE); |
| | | } |
| | | |
| | | return path; |