Beispiel #1
0
 public string Load()
 {
     try {
         SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase));
         connection.Open();
         string           sql     = @"SELECT rowid, instalDate, application, version, action, ipAddress
                     FROM instals
                     ORDER BY rowid DESC";
         SQLiteCommand    command = new SQLiteCommand(sql, connection);
         List <NewInstal> xx      = new List <NewInstal>();
         SQLiteDataReader reader  = command.ExecuteReader();
         while (reader.Read())
         {
             NewInstal x = new NewInstal();
             x.id          = reader.GetValue(0) == DBNull.Value ? 0 : reader.GetInt32(0);
             x.instalDate  = reader.GetValue(1) == DBNull.Value ? "" : reader.GetString(1);
             x.application = reader.GetValue(2) == DBNull.Value ? "" : reader.GetString(2);
             x.version     = reader.GetValue(3) == DBNull.Value ? "" : reader.GetString(3);
             x.action      = reader.GetValue(4) == DBNull.Value ? "" : reader.GetString(4);
             x.ipAddress   = reader.GetValue(5) == DBNull.Value ? "" : reader.GetString(5);
             xx.Add(x);
         }
         connection.Close();
         string json = JsonConvert.SerializeObject(xx, Formatting.None);
         return(json);
     } catch (Exception e) { return("Error: " + e); }
 }
Beispiel #2
0
    public string Init()
    {
        NewInstal x = new NewInstal();

        x.id          = 0;
        x.instalDate  = DateTime.Now.ToString();
        x.application = "";
        x.version     = "";
        x.action      = "";
        x.ipAddress   = HttpContext.Current.Request.UserHostAddress;
        return(JsonConvert.SerializeObject(x, Formatting.None));
    }
Beispiel #3
0
 public string Save(NewInstal x)
 {
     try {
         string path = HttpContext.Current.Server.MapPath("~/App_Data/" + dataBase);
         db.CreateGlobalDataBase(path, db.instals);
         SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase));
         connection.Open();
         string        sql     = @"INSERT INTO instals VALUES  
                    (@instalDate, @application, @version, @action, @ipAddress)";
         SQLiteCommand command = new SQLiteCommand(sql, connection);
         command.Parameters.Add(new SQLiteParameter("instalDate", x.instalDate));
         command.Parameters.Add(new SQLiteParameter("application", x.application));
         command.Parameters.Add(new SQLiteParameter("version", x.version));
         command.Parameters.Add(new SQLiteParameter("action", x.action));
         command.Parameters.Add(new SQLiteParameter("ipAddress", x.ipAddress));
         command.ExecuteNonQuery();
         connection.Close();
         return("OK");
     } catch (Exception e) { return("Error: " + e); }
 }
Beispiel #4
0
 public string Save(NewInstal x)
 {
     try {
         //string path = HttpContext.Current.Server.MapPath("~/App_Data/" + dataBase);
         //db.CreateGlobalDataBase(path, db.instals);
         using (SQLiteConnection connection = new SQLiteConnection("Data Source=" + Server.MapPath("~/App_Data/" + dataBase))) {
             connection.Open();
             string sql = @"INSERT INTO instals VALUES (@instalDate, @application, @version, @action, @ipAddress)";
             using (SQLiteCommand command = new SQLiteCommand(sql, connection)) {
                 command.Parameters.Add(new SQLiteParameter("instalDate", x.instalDate));
                 command.Parameters.Add(new SQLiteParameter("application", x.application));
                 command.Parameters.Add(new SQLiteParameter("version", x.version));
                 command.Parameters.Add(new SQLiteParameter("action", x.action));
                 command.Parameters.Add(new SQLiteParameter("ipAddress", x.ipAddress));
                 command.ExecuteNonQuery();
             }
         }
         return("OK");
     } catch (Exception e) {
         L.SendErrorLog(e, x.id.ToString(), null, "Instal", "Save");
         return(e.Message);
     }
 }