Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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("");
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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);
 }