public static bool UpdateSetting(tagSetting setting) { using (var db = new SettingDB(Appinfo.dbPath)) { try { string sql = string.Format("UPDATE tagSetting SET bCheck ='{0}',strUsername = '******', strPwd = '{2}',connectionType = '{3}',connectionInvert = '{4}',nCount = '{5}',IP = '{6}' WHERE nID = '{7}'", TypeUtils.BoolToInt(setting.bCheck), setting.strUsername, setting.strPwd, setting.connectionType, setting.connectionInvert, setting.nCount, setting.IP, setting.nID); int count = db.Execute(sql); Logger.Info($"{DateTime.Now}, 更新设置"); } catch (Exception e) { throw; } } return(true); }
public static string GetIP() { using (var db = new SettingDB(Appinfo.dbPath)) { try { var info = db.Setting.FirstOrDefault(); if (info != null) { return(info.IP); } } catch (Exception e) { throw; } } return(""); }
public static tagSetting QuerySetting() { using (var db = new SettingDB(Appinfo.dbPath)) { try { tagSetting setting = db.Query <tagSetting>("SELECT * FROM tagSetting;").FirstOrDefault(); if (setting == null) { setting = new tagSetting(); db.Insert(setting); } return(setting); } catch (Exception e) { throw; } } return(null); }
public static bool UpdateIP(string strIP) { using (var db = new SettingDB(Appinfo.dbPath)) { try { string sql = string.Format("UPDATE tagSetting SET IP = '{0}' WHERE nID = '0'", strIP); int count = db.Execute(sql); if (count == 0) { count = db.Insert(new tagSetting()); count = db.Execute(sql); } Logger.Info($"{DateTime.Now}, 更新IP,{strIP}"); } catch (Exception e) { throw; } } return(true); }