public ManageTags(Sqlite db) { InitializeComponent(); this.db = db; FillList(); }
public void Dispose() { insert?.Dispose(); @select?.Dispose(); if (connection != null) { vacuumer.Remove(connection); Sqlite.ClearPool(connection); connection.Dispose(); } }
// When a word list is deleted, remove it from the results view. void OnWordListDeleted(object sender, Sqlite.WordListEventArgs e) { for (int i = 0; i < results.Items.Count; ) { var tag = results.Items[i].Tag; if (tag is ListInfo && ((ListInfo)tag).ID == e.SetID) results.Items.RemoveAt(i); else if (tag is WordSearchResult && ((WordSearchResult)tag).SetID == e.SetID) results.Items.RemoveAt(i); else i++; } }
public static void Update(int runID, int personID, string description) { Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.RunIntervalTable + " SET personID = " + personID + ", description = \"" + description + "\" WHERE uniqueID == " + runID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); Sqlite.Close(); }
public static void Update(int eventID, int personID, string vars, string description) { Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.MultiChronopicTable + " SET personID = " + personID + ", vars = \"" + vars + //vars is distance on runAnalysis "\", description = \"" + description + "\" WHERE uniqueID == " + eventID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); Sqlite.Close(); }
public string Query(string tableName, string test, string variable, int sex, string ageInterval, int countryID, int sportID, int speciallityID, int levelID, int evaluatorID) { string str = Sqlite.SQLBuildQueryString(tableName, test, variable, sex, ageInterval, countryID, sportID, speciallityID, levelID, evaluatorID ); return(SqliteServer.Query(str)); }
/// <summary>Returns the enumerator to iterator through all table rows</summary> IEnumerator <Type> IEnumerable <Type> .GetEnumerator() { if (DB == null) { return(Enumerable.Empty <Type>().GetEnumerator()); } Debug.Assert(DB.AssertCorrectThread()); var sql = Sqlite.Sql("select ", BaseTableName, ".* from ", TableName, " join ", BaseTableName, " on [Key]=[Id]"); return(DB.EnumRows <Type>(sql).GetEnumerator()); }
public int UploadSport(Sport mySport) { int id = -1; //upload if doesn't exists (uploaded before by this or other evaluator) if (!Sqlite.Exists(false, Constants.SportTable, mySport.Name)) { id = mySport.InsertAtDB(false); } return(id); //uniqueID of sport at server }
private void Form1_Load(object sender, EventArgs e) { Sqlite.Sqlinit(); timer1.Start(); metroLabel1.Text = "版本:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); Sqlite.CreateTable("OutTable", new string[] { "ID", "Email", "Name", "Password", "CreatTime" }, new string[] { "integer", "text", "text", "text", "text" }); Untils.Filldgv("OutTable", dgv_OL); Sqlite.CreateTable("EATable", new string[] { "ID", "Email", "Name", "Password", "CreatTime" }, new string[] { "integer", "text", "text", "text", "text" }); Untils.Filldgv("EATable", dgv_EA); Sqlite.CreateTable("ProtonTable", new string[] { "ID", "Email", "Name", "Password", "CreatTime" }, new string[] { "integer", "text", "text", "text", "text" }); Untils.Filldgv("ProtonTable", dgv_pro); }
//private void StartCoroutine(IEnumerator enumerator) //{ // throw new NotImplementedException(); //} /// <summary> /// 存储选择的角色及名字 /// </summary> void CharacterSave() { //存储选择的角色 PlayerPrefs.SetInt("SelectCharacterIndex", selectedIndex); string loginAccount = PlayerPrefs.GetString("loginAccount"); Sqlite.Instance().Open(Application.dataPath + "/data.db"); Sqlite.Instance().ExecuteNonQuery(string.Format ("update user set username='******',character = '{1}' where account='{2}'", userName, selectedIndex.ToString(), loginAccount)); Sqlite.Instance().Close(); }
public static void Update(int jumpID, int personID, string fall, double weight, string description) { Sqlite.Open(); dbcmd.CommandText = "UPDATE jumpRj SET personID = " + personID + ", fall = " + Util.ConvertToPoint(Convert.ToDouble(fall)) + ", weight = " + Util.ConvertToPoint(weight) + ", description = \"" + description + "\" WHERE uniqueID == " + jumpID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); Sqlite.Close(); }
//double public static void UpdateAttribute(int personID, int sessionID, string attribute, double attrValue) { Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.PersonSessionTable + " SET " + attribute + " = " + Util.ConvertToPoint(attrValue) + " WHERE personID = " + personID + " AND sessionID = " + sessionID ; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); Sqlite.Close(); }
public static void Update(int eventID, string type, string time, int personID, string description) { Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.ReactionTimeTable + " SET personID = " + personID + ", type = \"" + type + "\", time = " + Util.ConvertToPoint(time) + ", description = \"" + description + "\" WHERE uniqueID == " + eventID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); Sqlite.Close(); }
private void on_delete_selected_row_clicked(object o, EventArgs args) { int uniqueID = UtilGtk.GetSelectedRowUniqueID( treeview_load, store_load, store_load_uniqueID_col); if (uniqueID > 0) { Sqlite.Delete(false, Constants.ExecuteAutoTable, uniqueID); store_load = UtilGtk.RemoveRow(treeview_load, store_load); button_next.Sensitive = false; } }
public static PersonSession Select(bool dbconOpened, int personID, int sessionID) { if (!dbconOpened) { Sqlite.Open(); } string tps = Constants.PersonSessionTable; string sessionIDString = " AND sessionID == " + sessionID; if (sessionID == -1) { sessionIDString = " ORDER BY sessionID DESC limit 1"; } dbcmd.CommandText = "SELECT * FROM " + tps + " WHERE personID == " + personID + sessionIDString; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); PersonSession ps = new PersonSession(); ps.UniqueID = -1; while (reader.Read()) { ps = new PersonSession( Convert.ToInt32(reader[0].ToString()), //uniqueID personID, //personID sessionID, //sessionID Convert.ToDouble(Util.ChangeDecimalSeparator(reader[3].ToString())), //height Convert.ToDouble(Util.ChangeDecimalSeparator(reader[4].ToString())), //weight Convert.ToInt32(reader[5].ToString()), //sportID Convert.ToInt32(reader[6].ToString()), //speciallityID Convert.ToInt32(reader[7].ToString()), //practice reader[8].ToString() //comments ); } reader.Close(); if (!dbconOpened) { Sqlite.Close(); } return(ps); }
//use SelectRunTypes object. Since 1.6.3 public static List <object> SelectRunTypesNew(string allRunsName, bool onlyName) { //allRunsName: add and "allRunsName" value //onlyName: return only type name string whereString = ""; Sqlite.Open(); dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunTypeTable + whereString + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); List <object> types = new List <object>(); SelectRunTypes type; if (allRunsName != "") { type = new SelectRunTypes(allRunsName); types.Add(type); } while (reader.Read()) { if (onlyName) { type = new SelectRunTypes(reader[1].ToString()); } else { type = new SelectRunTypes( Convert.ToInt32(reader[0]), //uniqueID reader[1].ToString(), //nameEnglish Convert.ToDouble(Util.ChangeDecimalSeparator(reader[2].ToString())), //distance reader[3].ToString() //description ); } types.Add(type); } reader.Close(); Sqlite.Close(); return(types); }
public static Sport Select(bool dbconOpened, int uniqueID) { if (!dbconOpened) { Sqlite.Open(); } dbcmd.CommandText = "SELECT * FROM " + Constants.SportTable + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); Sport mySport = null; while (reader.Read()) { mySport = new Sport( uniqueID, reader[1].ToString(), //name Util.IntToBool(Convert.ToInt32(reader[2])), //userDefined Util.IntToBool(Convert.ToInt32(reader[3])), //hasSpeciallities reader[4].ToString() //graphLink ); } reader.Close(); //manage problem if sport was deleted, return 1st sport: "undefined" if (mySport == null) { //sportsChronojump[0] is "undefined" string [] sportsFull = sportsChronojump[0].Split(new char[] { ':' }); mySport = new Sport( 1, //uniqueID sportsFull[0], //name false, //userDefined Util.StringToBool(sportsFull[2]), //hasSpeciallities sportsFull[3] //graphLink ); } if (!dbconOpened) { Sqlite.Close(); } return(mySport); }
private static List <Cookie> GetCookies(string basePath) { if (!File.Exists(basePath)) { return(null); } List <Cookie> result; try { string text = $"{Path.GetTempPath()}/{Helper.GetRandomString()}.fv"; if (File.Exists(text)) { File.Delete(text); } File.Copy(basePath, text, true); Sqlite sqlite = new Sqlite(text); sqlite.ReadTable("cookies"); List <Cookie> list = new List <Cookie>(); for (var i = 0; i < sqlite.GetRowCount(); i++) { try { string value = string.Empty; try { value = Encoding.UTF8.GetString(Chromium.DecryptChromium(Encoding.Default.GetBytes(sqlite.GetValue(i, 12)), null)); } catch (Exception) { } bool.TryParse(sqlite.GetValue(i, 6), out var flag); list.Add(new Cookie { Domain = sqlite.GetValue(i, 1), Name = sqlite.GetValue(i, 2), Path = sqlite.GetValue(i, 4), ExpirationDate = sqlite.GetValue(i, 5), Secure = flag.ToString().ToUpper(), Value = value, HostOnly = "TRUE" }); } catch (Exception) { } } result = list; } catch { result = new List <Cookie>(); } return(result); }
private void OpenConnection(FileInfo storeFile, out IDbConnection newConnection) { lock (globalLock) { newConnection = Sqlite.GetDatabaseConnection(storeFile); try { using (var ver = newConnection.CreateCommand()) { ver.CommandText = "PRAGMA user_version"; var currentVersion = (uint)(long)ver.ExecuteScalar(); if (!currentVersion.Equals(SCHEMA)) { throw new IndexOutOfRangeException("SCHEMA"); } } } catch (Exception ex) { NoticeFormat( "Recreating database, schema update. ({0})", ex.Message ); Sqlite.ClearPool(newConnection); newConnection.Close(); newConnection.Dispose(); newConnection = null; for (var i = 0; i < 10; ++i) { try { GC.Collect(); storeFile.Delete(); break; } catch (IOException) { Thread.Sleep(100); } } newConnection = Sqlite.GetDatabaseConnection(storeFile); } using (var pragma = connection.CreateCommand()) { pragma.CommandText = "PRAGMA journal_size_limt = 33554432"; pragma.ExecuteNonQuery(); } } }
// This is the usual chronojump's call (default database) public static string[] SelectAllSessions(string filterName) { Sqlite.Open(); // SelectAllSessions is used here and by the Chronojump importer to allow to pass an arbitrary // dbcon. string [] mySessions = selectAllSessionsDo(filterName, dbcon); //close database connection Sqlite.Close(); return(mySessions); }
public string UploadRunIntervalType(RunType type, int evalSID) { string typeServer = type.Name + "-" + evalSID.ToString(); Console.WriteLine("RUN_I" + typeServer + ":" + type.Distance + ":" + type.Description); if (!Sqlite.Exists(false, Constants.RunIntervalTypeTable, typeServer)) { type.Name = typeServer; SqliteRunIntervalType.Insert(type, Constants.RunIntervalTypeTable, false); return(typeServer); } return("-1"); }
//updating local session when it gets uploaded public static void UpdateUploadingState(int uniqueID, int state) { //if(!dbconOpened) Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.SessionTable + " SET uploadingState = " + state + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); //if(!dbconOpened) Sqlite.Close(); }
/* * IfNameExistsAddSuffix starts ---------------------> */ /* * this method check if a name exists. * if exists, add a suffix, like _copy * but if the string already ends with _copy add a number: _copy2 * but if the number already exists, like _copy21, convert into _copy22 * always check that the new string exists. * * The main reason of this method is not to have a: * unnamed_copy_copy_copy_copy (that's very ugly and breaks the interface), and have instead: * unnamed_copy4 */ public static string IfNameExistsAddSuffix(string name, string suffix) { Sqlite.Open(); if (Sqlite.Exists(true, Constants.EncoderConfigurationTable, name)) { do { name = ifNameExistsAddSuffixDo(name, suffix); } while (Sqlite.Exists(true, Constants.EncoderConfigurationTable, name)); } Sqlite.Close(); return(name); }
//updating local session when it gets uploaded public static void UpdateServerUniqueID(int uniqueID, int serverID) { //if(!dbconOpened) Sqlite.Open(); dbcmd.CommandText = "UPDATE " + Constants.SessionTable + " SET serverUniqueID = " + serverID + " WHERE uniqueID == " + uniqueID; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); //if(!dbconOpened) Sqlite.Close(); }
/* * multiChronopic class methods */ public static int Insert(bool dbconOpened, string tableName, string uniqueID, int personID, int sessionID, string type, int cp1StartedIn, int cp2StartedIn, int cp3StartedIn, int cp4StartedIn, string cp1InStr, string cp1OutStr, string cp2InStr, string cp2OutStr, string cp3InStr, string cp3OutStr, string cp4InStr, string cp4OutStr, string vars, string description, int simulated) { if (!dbconOpened) { Sqlite.Open(); } if (uniqueID == "-1") { uniqueID = "NULL"; } dbcmd.CommandText = "INSERT INTO " + tableName + " (uniqueID, personID, sessionID, type, " + " cp1StartedIn, cp2StartedIn, cp3StartedIn, cp4StartedIn, " + " cp1InStr, cp1OutStr, cp2InStr, cp2OutStr, cp3InStr, cp3OutStr, cp4InStr, cp4OutStr, " + " vars, description, simulated)" + " VALUES (" + uniqueID + ", " + personID + ", " + sessionID + ", \"" + type + "\", " + cp1StartedIn + ", " + cp2StartedIn + ", " + cp3StartedIn + ", " + cp4StartedIn + ", \"" + cp1InStr + "\", \"" + cp1OutStr + "\", \"" + cp2InStr + "\", \"" + cp2OutStr + "\", \"" + cp3InStr + "\", \"" + cp3OutStr + "\", \"" + cp4InStr + "\", \"" + cp4OutStr + "\", \"" + vars + "\", \"" + description + "\", " + simulated + ")"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); //int myLast = dbcon.LastInsertRowId; //http://stackoverflow.com/questions/4341178/getting-the-last-insert-id-with-sqlite-net-in-c string myString = @"select last_insert_rowid()"; dbcmd.CommandText = myString; int myLast = Convert.ToInt32(dbcmd.ExecuteScalar()); // Need to type-cast since `ExecuteScalar` returns an object. if (!dbconOpened) { Sqlite.Close(); } return(myLast); }
protected bool PulseGTK() { if (quitNow) { return(false); } //if( ( needEndSplashWin && pingEnd ) // || ! thread.IsAlive) { if (needEndSplashWin || !thread.IsAlive) { LogB.ThreadEnding(); fakeSplashButton.Click(); LogB.Information("splash window ending here"); LogB.ThreadEnded(); return(false); } //need to do this, if not it crashes because chronopicWin gets died by thread ending splashWin = SplashWindow.Show(); //Log.WriteLine("splash"); if (updatingDB) { splashWin.ShowProgressbar("updating"); splashWin.UpdateLabel(splashMessage + " " + Sqlite.PrintConversionText()); splashWin.UpdateProgressbar("version", Sqlite.PrintConversionVersion()); splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate()); splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate()); } else if (creatingDB) { splashWin.ShowProgressbar("creating"); splashWin.UpdateProgressbar("version", Sqlite.PrintCreation()); //splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate()); splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate()); } if (needUpdateSplashMessage) { splashWin.UpdateLabel(splashMessage); needUpdateSplashMessage = false; } Thread.Sleep(50); //Log.Write(" (PulseGTK:" + thread.ThreadState.ToString() + ") "); return(true); }
public override void update(ActionTimer timer) { using (SQLiteCommand command = new SQLiteCommand(Sqlite.getSqlite().connection)) { command.CommandText = "SELECT name FROM `account` WHERE `id`=@id"; command.Parameters.AddWithValue("@id", this.accID); using (SQLiteDataReader sdrITM = command.ExecuteReader()) { if (sdrITM.HasRows) { sdrITM.Read(); this.name = Convert.ToString(sdrITM["name"]); accExists = true; } } } if (accExists) { using (SQLiteCommand command = new SQLiteCommand(Accounts.Logs.SQLiteLogger.connection)) { command.CommandText = "SELECT * FROM `logStats` WHERE `accountID`=@id"; command.Parameters.AddWithValue("@id", this.accID); using (SQLiteDataReader sdrITM = command.ExecuteReader()) { if (sdrITM.HasRows) { List <AccountLogChar> alcList = new List <AccountLogChar>(); while (sdrITM.Read()) { AccountLogChar alc = new AccountLogChar(); alc.type = Convert.ToInt32(sdrITM["type"]); alc.value = Convert.ToInt32(sdrITM["value"]); alc.time = Convert.ToInt64(sdrITM["time"]); alcList.Add(alc); } charStatList = alcList.ToArray(); } } } } isFinished = true; timer.removeAction(this); }
//use SelectRunITypes object. Since 1.6.3 public static List <object> SelectRunIntervalTypesNew(string allRunsName, bool onlyName) { Sqlite.Open(); dbcmd.CommandText = "SELECT * " + " FROM " + Constants.RunIntervalTypeTable + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); List <object> types = new List <object>(); SelectRunITypes type; if (allRunsName != "") { type = new SelectRunITypes(allRunsName); types.Add(type); } while (reader.Read()) { if (onlyName) { type = new SelectRunITypes(reader[1].ToString()); } else { type = new SelectRunITypes( Convert.ToInt32(reader[0]), //uniqueID reader[1].ToString(), //nameEnglish Convert.ToDouble(Util.ChangeDecimalSeparator(reader[2].ToString())), //distance Util.IntToBool(Convert.ToInt32(reader[3].ToString())), //tracksLimited Convert.ToInt32(reader[4].ToString()), //fixedValue Util.IntToBool(Convert.ToInt32(reader[5].ToString())), //unlimited reader[6].ToString(), //description Util.ChangeDecimalSeparator(reader[7].ToString()) //distancesString ); } types.Add(type); } reader.Close(); Sqlite.Close(); return(types); }
public static User Load(Sqlite lit, int id) { User rst = new Entity.User(); DataTable dt = lit.GetDataTable(string.Format("select fid,fnumber,fname,fpsw from t_user where fid={0}", id)); if (dt.Rows.Count > 0) { rst.id = (int)dt.Rows[0]["fid"]; rst.number = dt.Rows[0]["fnumber"].ToString(); rst.name = dt.Rows[0]["fname"].ToString(); rst.password = dt.Rows[0]["fpsw"].ToString(); } return(rst); }
public frmApiEdit(int id = 0) { InitializeComponent(); _lit = new xl_rp.Sqlite(); listDb.DisplayMember = "name"; listUser.DisplayMember = "name"; listRight.DisplayMember = "name"; dgParam.ColumnCount = 4; dgParam.ColumnHeadersVisible = true; dgParam.Columns[0].DataPropertyName = "name"; dgParam.Columns[0].HeaderText = "名称"; dgParam.Columns[1].DataPropertyName = "key"; dgParam.Columns[1].HeaderText = "sql标记"; dgParam.Columns[2].DataPropertyName = "defValue"; dgParam.Columns[2].HeaderText = "默认值"; dgParam.Columns[3].DataPropertyName = "note"; dgParam.Columns[3].HeaderText = "备注"; if (id == 0) { _apiObj = new Entity.ApiObj(); this.Text = "新增"; } else { _apiObj = ApiObj.Load(_lit, id); this.Text = _apiObj.name; } txtName.DataBindings.Add("Text", _apiObj, "name"); txtNumber.DataBindings.Add("Text", _apiObj, "number"); txtNote.DataBindings.Add("Text", _apiObj, "note"); dgParam.DataSource = _apiObj.param; listRight.DataSource = _apiObj.right; listDb.DataSource = Db.Load(_lit); List <User> users = User.Load(_lit); for (int i = users.Count - 1; i >= 0; --i) { for (int j = 0; j < _apiObj.right.Count; j++) { if (_apiObj.right[j].id == users[i].id) { users.RemoveAt(i); } } } listUser.DataSource = users; }
//if by any bug there's no active, then create default public static EncoderConfigurationSQLObject SelectActive(Constants.EncoderGI encoderGI) { Sqlite.Open(); dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderConfigurationTable + " WHERE encoderGI = \"" + encoderGI.ToString() + "\" AND active = \"True\""; LogB.SQL(dbcmd.CommandText.ToString()); dbcmd.ExecuteNonQuery(); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); EncoderConfigurationSQLObject econfSO = new EncoderConfigurationSQLObject(); bool success = false; if (reader.Read()) { string [] strFull = reader[4].ToString().Split(new char[] { ':' }); EncoderConfiguration econf = new EncoderConfiguration( (Constants.EncoderConfigurationNames) Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0])); econf.ReadParamsFromSQL(strFull); econfSO = new EncoderConfigurationSQLObject( Convert.ToInt32(reader[0].ToString()), //uniqueID encoderGI, //encoderGI true, //active reader[3].ToString(), //name econf, //encoderConfiguration reader[5].ToString() //description ); success = true; } reader.Close(); //if by any bug there's no active, then create default and call himself again to select if (!success) { insertDefault(encoderGI); Sqlite.Close(); return(SelectActive(encoderGI)); } Sqlite.Close(); return(econfSO); }
// Token: 0x0600018A RID: 394 RVA: 0x0000B1A4 File Offset: 0x000093A4 public static void Cookie_Grab(string profilePath, string browser_name, string profile) { try { Sqlite sqlite = new Sqlite(GetCookies.CreateTempCopy(Path.Combine(profilePath, "Cookies"))); sqlite.ReadTable("cookies"); for (int i = 0; i < sqlite.GetRowCount(); i++) { GetCookies.CCookies++; try { GetCookies.Cookies.Add(string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}{7}", new object[] { sqlite.GetValue(i, "host_key").Trim(), sqlite.GetValue(i, "httponly") == "1", sqlite.GetValue(i, "path").Trim(), sqlite.GetValue(i, "secure") == "1", sqlite.GetValue(i, "expires_utc").Trim(), sqlite.GetValue(i, "name").Trim(), GetCookies.DecryptBlob(sqlite.GetValue(i, "encrypted_value"), DataProtectionScope.CurrentUser, null).Trim(), Environment.NewLine })); GetCookies.domains.Add(sqlite.GetValue(i, "host_key").Trim()); } catch (Exception) { } } using (StreamWriter streamWriter = new StreamWriter(string.Concat(new string[] { Program.dir, "\\Browsers\\", profile, "_", browser_name, "_Cookies.txt" }))) { for (int j = 0; j < GetCookies.Cookies.Count <string>(); j++) { streamWriter.Write(GetCookies.Cookies[j]); } } GetCookies.Cookies.Clear(); } catch { } }
public EditQuote(Sqlite db, string quoteString) { InitializeComponent(); this.db = db; changed = false; tChanged = false; string[] arg = parseString(quoteString); quoteText.Text = arg[0].Trim(); authorText.Text = arg[1].Trim(); locationText.Text = arg[2].Trim(); string sql = "SELECT id FROM quotes WHERE quotes='" + ReplaceQuoteChar(quoteText.Text) + "';"; id = db.GetID<long>(sql); // Get tags from database and update tag textbox. string[] tagList = GetTags(); origTags = new string[tagList.Length]; for (int i = 0; i < tagList.Length; i++) { origTags[i] = tagList[i]; // Keep a copy if (i + 1 == tagList.Length) { tagText.Text += tagList[i]; } else { tagText.Text += tagList[i] + ", "; } } authorText.TextChanged += new EventHandler(authorText_TextChanged); quoteText.TextChanged += new EventHandler(quoteText_TextChanged); locationText.TextChanged += new EventHandler(locationText_TextChanged); tagText.TextChanged += new EventHandler(tagText_TextChanged); }
/* * useful to do a conversion from an int to a double * used on jump.angle * we done on sqlite/jump.cs: * on createTable change "angle INT" to "angle FLOAT" * then call this alterTableColumn * * but CAUTION: doing this, all the float data is converted to .0 * eg: 27.35 will be 27.0 * -1 will be -1.0 * * if we don't use this, and we have created a column as int, and introduce floats or doubles, * we can insert ok the float or doubles, but on select we will have ints */ protected internal static void alterTableColumn(Sqlite sqliteObject, string tableName, int columns) { conversionSubRate = 1; conversionSubRateTotal = -1; //unknown yet //2st create convert temp table sqliteObject.createTable(Constants.ConvertTempTable); //2nd copy all data from desired table to temp table adding the simulated column ArrayList myArray = new ArrayList(2); dbcmd.CommandText = "SELECT * " + "FROM " + tableName + " ORDER BY uniqueID"; SqliteDataReader reader; reader = dbcmd.ExecuteReader(); LogB.SQL(dbcmd.CommandText.ToString()); while(reader.Read()) { string [] myReaderStr = new String[columns]; for (int i=0; i < columns; i ++) myReaderStr[i] = reader[i].ToString(); Event myEvent = new Event(); switch (tableName) { case Constants.JumpTable: myEvent = new Jump(myReaderStr); break; case Constants.JumpRjTable: myEvent = new JumpRj(myReaderStr); break; case Constants.RunTable: myEvent = new Run(myReaderStr); break; case Constants.RunIntervalTable: myEvent = new RunInterval(myReaderStr); break; case Constants.ReactionTimeTable: myEvent = new ReactionTime(myReaderStr); break; case Constants.PulseTable: myEvent = new Pulse(myReaderStr); break; } myArray.Add(myEvent); } reader.Close(); conversionSubRateTotal = myArray.Count * 2; foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } //3rd drop desired table Sqlite.dropTable(tableName); //4d create desired table (now with new columns) sqliteObject.createTable(tableName); //5th insert data in desired table foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, tableName); conversionSubRate ++; } //6th drop temp table Sqlite.dropTable(Constants.ConvertTempTable); }
/* * The problem of this method is that uses class constructors: person, jump, ... * and if the sqlite version is updated from a really old version * maybe the object has to be converted from really older class to old, and then to new class (two conversions) * and this can have problems in the class construction * The best seem to have a boolean that indicates if certain conversion has done before * (see bool runAndRunIntervalInitialSpeedAdded) */ protected internal static void convertTables(Sqlite sqliteObject, string tableName, int columnsBefore, ArrayList columnsToAdd, bool putDescriptionInMiddle) { conversionSubRate = 1; conversionSubRateTotal = -1; //unknown yet //2st create convert temp table sqliteObject.createTable(Constants.ConvertTempTable); //2nd copy all data from desired table to temp table (in event tables, adding the simulated column) ArrayList myArray = new ArrayList(2); dbcmd.CommandText = "SELECT * " + "FROM " + tableName + " ORDER BY uniqueID"; LogB.SQL(dbcmd.CommandText.ToString()); SqliteDataReader reader; reader = dbcmd.ExecuteReader(); while(reader.Read()) { string [] myReaderStr = new String[columnsBefore + columnsToAdd.Count]; int i; for (i=0; i < columnsBefore; i ++) myReaderStr[i] = reader[i].ToString(); foreach (string myStr in columnsToAdd) myReaderStr[i++] = myStr; if (putDescriptionInMiddle) { //string [] strFull = changePos.Split(new char[] {':'}); //int row1 = Convert.ToInt32(strFull[0]); //int row2 = Convert.ToInt32(strFull[1]); string desc = myReaderStr[6]; myReaderStr[6] = myReaderStr[7]; myReaderStr[7] = myReaderStr[8]; myReaderStr[8] = myReaderStr[9]; myReaderStr[9] = desc; } if(tableName == Constants.PersonOldTable) { PersonOld myPerson = new PersonOld(myReaderStr); myArray.Add(myPerson); } else if(tableName == Constants.SessionTable) { Session mySession = new Session(myReaderStr); myArray.Add(mySession); } else if(tableName == Constants.RunIntervalTypeTable) { RunType myType = new RunType(myReaderStr, true); //interval myArray.Add(myType); } else if(tableName == Constants.PersonSessionOldWeightTable) { PersonSessionOld myPS = new PersonSessionOld(myReaderStr); myArray.Add(myPS); } else { Event myEvent = new Event(); switch (tableName) { case Constants.JumpTable: myEvent = new Jump(myReaderStr); break; case Constants.JumpRjTable: myEvent = new JumpRj(myReaderStr); break; case Constants.RunTable: myEvent = new Run(myReaderStr); break; case Constants.RunIntervalTable: myEvent = new RunInterval(myReaderStr); break; case Constants.ReactionTimeTable: myEvent = new ReactionTime(myReaderStr); break; case Constants.PulseTable: myEvent = new Pulse(myReaderStr); break; } myArray.Add(myEvent); } } reader.Close(); LogB.SQL("1" + tableName); conversionSubRateTotal = myArray.Count * 2; if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, Constants.ConvertTempTable, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, Constants.ConvertTempTable); conversionSubRate ++; } } LogB.SQL("2" + tableName); //3rd drop desired table Sqlite.dropTable(tableName); LogB.SQL("3" + tableName); //4d create desired table (now with new columns) sqliteObject.createTable(tableName); LogB.SQL("4" + tableName); //5th insert data in desired table if(tableName == Constants.PersonOldTable) { foreach (PersonOld myPerson in myArray) { myPerson.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.SessionTable) { foreach (Session mySession in myArray) { mySession.InsertAtDB(true, tableName); conversionSubRate ++; } } else if(tableName == Constants.RunIntervalTypeTable) { foreach (RunType type in myArray) { type.InsertAtDB(true, tableName, true); //last true is for interval conversionSubRate ++; } } else if(tableName == Constants.PersonSessionOldWeightTable) { foreach (PersonSessionOld ps in myArray) { ps.InsertAtDB(true, tableName); conversionSubRate ++; } } else { foreach (Event myEvent in myArray) { myEvent.InsertAtDB(true, tableName); conversionSubRate ++; } } LogB.SQL("5" + tableName); //6th drop temp table Sqlite.dropTable(Constants.ConvertTempTable); }
// When a list is opened, move it to the front of the recent lists section. void OnWordListAccessed(object sender, Sqlite.WordListEventArgs e) { UpdateResults(); }
public static void Create() { Sqlite sqlite = new Sqlite (); sqlite.AutoDDL (dbName, true); Debug.Log ("StreamingAssets Create Sqlite DB : " + dbName); }