123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace AwInitilizer
- {
- public class AppSettingConfig
- {
- public static string FirmwareRoot
- {
- get
- {
- if(Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._FirmwareRoot;
- }
- }
- public static string Language
- {
- get
- {
- if (Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._Language;
- }
- }
- public static string MES
- {
- get
- {
- if (Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._MES;
- }
- }
- public static string MechineCode
- {
- get
- {
- if (Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._MechineCode;
- }
- }
- public static bool IsDisableAuthRequired
- {
- get
- {
- if (Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._IsDisableAuthRequired;
- }
- }
- public static string JohnSenLedComPort
- {
- get
- {
- if (Instance == null)
- {
- Instance = new AppSettingConfig();
- }
- return Instance._JohnSenLedComPort;
- }
- }
- private static AppSettingConfig Instance;
- private string _FirmwareRoot, _Language, _MES , _MechineCode;
- private bool _IsDisableAuthRequired;
- private string _JohnSenLedComPort;
- private static string settingFileName = "config.ini";
- public AppSettingConfig()
- {
- if(!File.Exists(settingFileName))
- {
- LoadDefaultSetting();
- }
- else
- {
- LoadSettingFromDefaultFile();
- }
- }
- private void LoadSettingFromDefaultFile()
- {
- try
- {
- LoadDefaultSetting();
- var configStr = File.ReadAllText(settingFileName);
- var config = Newtonsoft.Json.JsonConvert.DeserializeObject<Model.AppSettingConfig>(configStr);
- _FirmwareRoot = config.FirmwareRoot;
- _Language = config.Language;
- _MES = config.MES;
- _MechineCode = config.MechineCode;
- _IsDisableAuthRequired = config.IsDisableAuthRequired;
- _JohnSenLedComPort = config.JohnSenLedComPort;
- }
- catch
- {
-
- }
- }
- private void LoadDefaultSetting()
- {
- _FirmwareRoot = "./Firmware";
- _Language = "zh-chs";
- _MES = "sajet2";
- _MechineCode = "testMechineCode";
- }
- }
- }
|