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 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); }