public OasConfig(OasConfigType cfgType, string currentVersion) { OasConfigType = cfgType; CurrentVersion = currentVersion; IsChanged = false; IsAdmin = false; LocalClientMode = false; Data = new OasConfigData(currentVersion); #if DEBUG DataFolderPath = @"..\..\OAS"; #else DataFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\OAS"; #endif Read(); _config = this; }
public static OasConfigData ParseJson(string json, string currentVersion) { OasConfigData ocd = new OasConfigData(currentVersion); JObject o = JObject.Parse(json); JToken caseConfig = o["CaseConfig"]; if (null != caseConfig) { ocd.CaseConfig.ExtractData(caseConfig); } JToken webConfig = o["WebConfig"]; if (null != webConfig) { ocd.WebConfig.ExtractData(webConfig); } JToken webServer = o["WebServer"]; if (null != webServer) { ocd.WebServer.ExtractData(webServer); } JToken UiData = o["UiConfig"]; if (null != UiData) { ocd.UiConfig.ExtractData(UiData); } JToken jt = o["LogPath"]; if (null != jt) { ocd.LogPath = jt.Value <string>(); } jt = o["DataPath"]; if (null != jt) { ocd.DataPath = jt.Value <string>(); } jt = o["ImageExportPath"]; if (null != jt) { ocd.ImageExportPath = jt.Value <string>(); } jt = o["LocalStoragePath"]; if (null != jt) { ocd.LocalStoragePath = jt.Value <string>(); } jt = o["DoNotConnect"]; if (null != jt) { ocd.DoNotConnect = jt.Value <bool>(); } jt = o["AutoLogin"]; if (null != jt) { ocd.AutoLogin = jt.Value <bool>(); } jt = o["AutoExport"]; if (null != jt) { ocd.AutoExport = jt.Value <bool>(); } jt = o["BurnText"]; if (null != jt) { ocd.BurnText = jt.Value <bool>(); } jt = o["MaximizeToKiosk"]; if (null != jt) { ocd.MaximizeToKiosk = jt.Value <bool>(); } jt = o["ShowPreconditions"]; if (null != jt) { ocd.ShowPreconditions = jt.Value <bool>(); } JArray stdDesc = (JArray)o["StandardDescription"]; if (null != stdDesc) { ocd.StandardDescription = new string[stdDesc.Count]; for (int i = 0; i < stdDesc.Count; ++i) { ocd.StandardDescription[i] = stdDesc[i].Value <string>(); } } jt = o["ServerPollTimeout"]; if (null != jt) { ocd.ServerPollTimeout = jt.Value <int>(); } jt = o["WatcherDelay"]; if (null != jt) { ocd.WatcherDelay = jt.Value <int>(); } jt = o["EncodeTraffic"]; if (null != jt) { ocd.EncodeTraffic = jt.Value <bool>(); } jt = o["StartAppAutomatically"]; if (null != jt) { ocd.StartAppAutomatically = jt.Value <bool>(); } jt = o["SqLiteDbPath"]; if (null != jt) { ocd.SqLiteDbPath = jt.Value <string>(); } jt = o["HowManyDaysToShow"]; if (null != jt) { ocd.HowManyDaysToShow = jt.Value <int>(); } jt = o["ShowNotification"]; if (null != jt) { ocd.ShowNotification = jt.Value <bool>(); } jt = o["CloseToTray"]; if (null != jt) { ocd.CloseToTray = jt.Value <bool>(); } jt = o["SortHeader"]; if (null != jt) { ocd.SortHeader = jt.Value <int>(); } jt = o["SortHeaderOrder"]; if (null != jt) { ocd.SortHeaderOrder = jt.Value <bool>(); } jt = o["StampImages"]; if (null != jt) { ocd.StampImages = jt.Value <bool>(); } return(ocd); }