Exemplo n.º 1
0
 public static void AddVpn(VpnModel model)
 {
     string sql = "insert into vpn_list (ip,userid,password,type,enabled) values(@1, @2, @3, @4, @5)";
     object[] parampters = new object[]
     {
         model.Ip.Trim(),
         model.UserId,
         model.Password,
         model.Type,
         model.Enabled
     };
     SQLiteHelper.ExecuteNonQuery(connectionString, sql, parampters);
 }
Exemplo n.º 2
0
 public static void MagrationVpnData()
 {
     string xmlFile = @"./VPN.xml";
     DataTable dataTable = null;
     if (File.Exists(xmlFile))
     {
         DataSet xmlDS = new DataSet();
         xmlDS.ReadXml(xmlFile);
         dataTable = (DataTable)xmlDS.Tables[0];
         xmlDS.Dispose();
     }
     for (int j = dataTable.Rows.Count - 1; j >= 0; j--)
     {
         DataRow dr = dataTable.Rows[j];
         VpnModel model = new VpnModel();
         model.Ip = (string)dr[0];
         model.UserId = (string)dr[1];
         model.Password = (string)dr[2];
         model.Type = (string)dr[3];
         model.Enabled = true;
         if (!DAO.HasExistIpAddress(model.Ip))
         {
             DAO.AddVpn(model);
         }
     }
 }
Exemplo n.º 3
0
 public static IList<VpnModel> GetAllVpnAddress()
 {
     string sql = "SELECT id,ip,userid,password,type,enabled FROM vpn_list";
     DataSet ds = SQLiteHelper.ExecuteDataSet(connectionString, sql, null);
     IList<VpnModel> list = new List<VpnModel>();
     if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
     {
         VpnModel model = null;
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             model = new VpnModel();
             model.Id = (Int64)dr[0];
             model.Ip = (string)dr[1];
             model.UserId = (string)dr[2];
             model.Password = (string)dr[3];
             model.Type = (string)dr[4];
             model.Enabled = (bool)dr[5];
             list.Add(model);
         }
     }
     return list;
 }