当前位置: 首页>>代码示例>>C#>>正文


C# SqliteCommand.ExecuteNonQuery方法代码示例

本文整理汇总了C#中Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# SqliteCommand.ExecuteNonQuery方法的具体用法?C# SqliteCommand.ExecuteNonQuery怎么用?C# SqliteCommand.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Community.CsharpSqlite.SQLiteClient.SqliteCommand的用法示例。


在下文中一共展示了SqliteCommand.ExecuteNonQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: createTable

        public static void createTable(Type ja)
        {
            try
            {
                SqliteCommand sql = new SqliteCommand("DROP TABLE " + ja.Name, SqliteManager.connection);
                sql.ExecuteNonQuery();
            }
            catch (Exception e)
            {
            }
            string tmp = "CREATE TABLE " + ja.Name + "(";
            System.Reflection.FieldInfo[] fieldInfo = ja.GetFields();

            bool was = false;
            string primary = "";
            foreach (System.Reflection.FieldInfo info in fieldInfo)
            {
                Type temp = info.FieldType;
                if (was) tmp += ", ";
                tmp += info.Name + " ";
                was = true;
                if (temp == typeof(long))
                {
                    tmp += " INT";
                }
                else
                    if (temp == typeof(string))
                    {
                        tmp += " TEXT";
                    }
                    else
                        if (temp == typeof(double))
                        {
                            tmp += " REAL";
                        }
                        else
                            if (temp == typeof(bool))
                            {
                                tmp += " INT";
                            }
                            else
                            {
                                tmp += " TEXT";
                            }
                if (info.IsDefined(typeof(PrimaryKey), true))
                {
                    if (primary.Length != 0) primary += ", ";
                    primary += info.Name;
                }
            }
            if (primary.Length > 0)
            {
                tmp += ", PRIMARY KEY(" + primary + ") ";
            }
            tmp += ");";
            SqliteCommand sql2 = new SqliteCommand(tmp, SqliteManager.connection);
            sql2.ExecuteNonQuery();
        }
开发者ID:Xplo1T,项目名称:l2tower-database-repository,代码行数:58,代码来源:AbstractTable.cs

示例2: CreateHistoryTable

 private void CreateHistoryTable()
 {
     string sql = @"
     CREATE TABLE history (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     client_id varchar(32) NOT NULL,
     from_jid varchar(3071),
     to_jid varchar(3071),
     timestamp INTEGER NOT NULL,
     message TEXT
     )";
     var command = new SqliteCommand(sql, _connection);
     command.ExecuteNonQuery();
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:14,代码来源:InitialMS.cs

示例3: CreateVcard

 private void CreateVcard()
 {
     string sql = @"
     CREATE TABLE contact_details (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     jid varchar(2048) NOT NULL,
     hash varchar(2048) NOT NULL,
     fullname varchar(2048) NULL,
     url varchar(2048) NULL,
     birthday INTEGER NULL,
     details TEXT NULL,
     photoType varchar(2048) NULL,
     photoBin BLOB NULL
     );
     CREATE INDEX IX_contact_details ON contact_details(jid, hash)
     ";
     var command = new SqliteCommand(sql, _connection);
     command.ExecuteNonQuery();
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:19,代码来源:Migration2.cs

示例4: CreateDiscoCache

 private void CreateDiscoCache()
 {
     string sql = @"
     CREATE TABLE caps_info (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     node varchar(2048) NULL,
     version varchar(2048) NULL,
     hash varchar(2048) NULL
     );
     CREATE TABLE feature (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     uri varchar(2048) UNIQUE NOT NULL
     );
     CREATE TABLE caps_to_feature (
     id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
     caps_info_id int NOT NULL,
     feature_id int NOT NULL,
     FOREIGN KEY (caps_info_id) REFERENCES caps_info(id),
     FOREIGN KEY (feature_id) REFERENCES feature(id)
     )";
     var command = new SqliteCommand(sql, _connection);
     command.ExecuteNonQuery();
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:23,代码来源:Migration1.cs

示例5: ExportToFile

        public static void ExportToFile(string filename, List<Core.Data.Geocache> gcList)
        {
            try
            {
                DateTime nextUpdate = DateTime.Now.AddSeconds(1);
                using (Utils.ProgressBlock fixscr = new Utils.ProgressBlock("ExportingiGeoKnife", "CreatingFile", 1, 0, true))
                {
                    System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
                    logTypes.Add(2, "Found it");
                    logTypes.Add(3, "Didn't find it");
                    logTypes.Add(4, "Write note");
                    logTypes.Add(5, "Archive");
                    logTypes.Add(7, "Needs Archived");
                    logTypes.Add(9, "Will Attend");
                    logTypes.Add(10, "Attended");
                    logTypes.Add(11, "Webcam Photo Taken");
                    logTypes.Add(12, "Unarchive");
                    logTypes.Add(22, "Temporarily Disable Listing");
                    logTypes.Add(23, "Enable Listing");
                    logTypes.Add(24, "Publish Listing");
                    logTypes.Add(25, "Retract Listing");
                    logTypes.Add(45, "Needs Maintenance");
                    logTypes.Add(46, "Owner Maintenance");
                    logTypes.Add(47, "Update Coordinates");
                    logTypes.Add(68, "Post Reviewer Note");
                    logTypes.Add(74, "Announcement");

                    if (System.IO.File.Exists(filename))
                    {
                        System.IO.File.Delete(filename);
                    }

                    Utils.ResourceHelper.SaveToFile("/iGeoKnife/sqlite.db3", filename, true);

                    using (SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", filename)))
                    {
                        dbcon.Open();

                        DbParameter par;
                        using (Utils.ProgressBlock progress = new Utils.ProgressBlock("ExportingiGeoKnife", "SavingGeocaches", gcList.Count, 0, true))
                        {
                            using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd2 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd3 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd4 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd5 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd6 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd7 = new SqliteCommand("", dbcon))
                            using (SqliteCommand cmd8 = new SqliteCommand("", dbcon))
                            {
                                cmd.CommandText = "drop index CachesSmart";
                                cmd.ExecuteNonQuery();

                                cmd.CommandText = "insert into Caches (Code, Name, PlacedBy, Archived, CacheId, CacheType, Container, Country, Difficulty, Found, HasCorrected, HasUserNote, Latitude, LongHtm, Longitude, OwnerName, PlacedDate, ShortHtm, State, Terrain, UserFlag, IsOwner, LatOriginal, LonOriginal, Status, GcNote, IsPremium, FavPoints) values (@Code, @Name, @PlacedBy, @Archived, @CacheId, @CacheType, @Container, @Country, @Difficulty, @Found, @HasCorrected, @HasUserNote, @Latitude, @LongHtm, @Longitude, @OwnerName, @PlacedDate, @ShortHtm, @State, @Terrain, @UserFlag, @IsOwner, @LatOriginal, @LonOriginal, @Status, @GcNote, @IsPremium, @FavPoints)";
                                cmd2.CommandText = "insert into CacheMemo (Code, LongDescription, ShortDescription, Url, Hints, UserNote) values (@Code, @LongDescription, @ShortDescription, @Url, @Hints, @UserNote)";
                                cmd3.CommandText = "insert into Attributes (aCode, aId, aInc) values (@aCode, @aId, @aInc)";
                                cmd4.CommandText = "insert into LogMemo (lParent, lLogId, lText) values (@lParent, @lLogId, @lText)";
                                cmd5.CommandText = "insert into Logs (lParent, lLogId, lType, lBy, lDate, lLat, lLon, lEncoded, lownerid, lHasHtml, lIsowner, lTime) values (@lParent, @lLogId, @lType, @lBy, @lDate, @lLat, @lLon, @lEncoded, @lownerid, @lHasHtml, @lIsowner, @lTime)";
                                cmd6.CommandText = "insert into WayMemo (cParent, cCode, cComment, cUrl) values (@cParent, @cCode, @cComment, @cUrl)";
                                cmd7.CommandText = "insert into Waypoints (cParent, cCode, cPrefix, cName, cType, cLat, cLon, cByuser, cDate, cFlag, sB1) values (@cParent, @cCode, @cPrefix, @cName, @cType, @cLat, @cLon, @cByuser, @cDate, @cFlag, @sB1)";
                                cmd8.CommandText = "insert into Corrected (kCode, kBeforeLat, kBeforeLon, kAfterLat, kAfterLon) values (@kCode, @kBeforeLat, @kBeforeLon, @kAfterLat, @kAfterLon)";

                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kCode";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kBeforeLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLat";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);
                                par = cmd8.CreateParameter();
                                par.ParameterName = "@kAfterLon";
                                par.DbType = DbType.String;
                                cmd8.Parameters.Add(par);

                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cParent";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cCode";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cPrefix";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
                                par.ParameterName = "@cName";
                                par.DbType = DbType.String;
                                cmd7.Parameters.Add(par);
                                par = cmd7.CreateParameter();
//.........这里部分代码省略.........
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:101,代码来源:Export.cs

示例6: save

        public void save(SqliteConnection conn)
        {
            string command;
            if (id == -1)
                command = "insert into mediaitem (name, type, checked_to_patron_id, " +
                          " checkout_date, due_date) values (@name, @type, @patron_id, @co_date, @due_date);";
            else
                command = "update mediaitem set [email protected], [email protected], [email protected]_id, " +
                          " [email protected]_date, [email protected]_date where [email protected]";
            SqliteCommand cmd = new SqliteCommand(command, conn);
            cmd.Parameters.Add("@id", id);
            cmd.Parameters.Add("@name", name);
            cmd.Parameters.Add("@type", type);
            if (checked_to_patron_id > -1)
                cmd.Parameters.Add("@patron_id", checked_to_patron_id);
            else
                cmd.Parameters.Add("@patron_id", null);
            if (checkout_date != null)
                cmd.Parameters.Add("@co_date", checkout_date.Value.ToString());
            else
                cmd.Parameters.Add("@co_date", null);
            if (due_date != null)
                cmd.Parameters.Add("@due_date", due_date);
            else
                cmd.Parameters.Add("@due_date", null);

            cmd.ExecuteNonQuery();
            //id = cmd.LastInsertRowID();
        }
开发者ID:taxilian,项目名称:some_library,代码行数:29,代码来源:OurMediaItem.cs

示例7: SetupVersion

 private void SetupVersion()
 {
     string sql = "update version set num = 3";
     var command = new SqliteCommand(sql, _connection);
     command.ExecuteNonQuery();
 }
开发者ID:Irdis,项目名称:VSTalk,代码行数:6,代码来源:Migration2.cs

示例8: Add

 /// <summary>
 /// Add a list of file metadata into database
 /// Combinational transaction feature is supported
 /// </summary>
 /// <param name="mData"></param>
 /// <param name="con"></param>
 /// <returns></returns>
 public bool Add(IList<FileMetaDataItem> mData, SqliteConnection con)
 {
     const string cmdText = "INSERT INTO " + Configuration.TBL_METADATA +
                            "( " + Configuration.COL_SOURCE_ID + "," + Configuration.COL_RELATIVE_PATH + "," +
                            Configuration.COL_HASH_CODE + "," +
                            Configuration.COL_LAST_MODIFIED_TIME + "," +
                            Configuration.COL_NTFS_ID1 + "," +
                            Configuration.COL_NTFS_ID2 + ")" +
                            "VALUES (@source_id , @relative_path, @hash_code, @last_modified_time, @ntfs_id1, @ntfs_id2) ";
     try
     {
         foreach (FileMetaDataItem item in mData)
         {
             using (var cmd = new SqliteCommand(cmdText, con))
             {
                 cmd.Parameters.Add(new SqliteParameter("@source_id", DbType.String) { Value = item.SourceId });
                 cmd.Parameters.Add(new SqliteParameter("@relative_path", DbType.String) { Value = item.RelativePath });
                 cmd.Parameters.Add(new SqliteParameter("@hash_code", DbType.String) { Value = item.HashCode });
                 cmd.Parameters.Add(new SqliteParameter("@last_modified_time", DbType.DateTime) { Value = item.LastModifiedTime });
                 cmd.Parameters.Add(new SqliteParameter("@ntfs_id1", DbType.Int32) { Value = item.NTFS_ID1 });
                 cmd.Parameters.Add(new SqliteParameter("@ntfs_id2", DbType.Int32) { Value = item.NTFS_ID2 });
                 cmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
开发者ID:nydehi,项目名称:onesync,代码行数:38,代码来源:SQLiteMetaDataProvider.cs

示例9: ExecuteNonQuery

 // TODO: As all exceptions apper to be caught here the ExecuteNonQuery() calls probably 
 // do not need to be in try/catch 's
 protected int ExecuteNonQuery(SqliteCommand cmd)
 {
     int retries = 0;
     restart:
     try
     {
         lock (GetLock())
         {
             PrepReader(ref cmd);
             UnescapeSql(cmd);
             var value = cmd.ExecuteNonQuery();
             cmd.Connection.Close();
             return value;
         }
     }
     catch (SqliteBusyException ex)
     {
         if (retries++ > 5)
             MainConsole.Instance.WarnFormat("[Sqlite]: Exception processing command: {0}, Exception: {1}",
                                     cmd.CommandText, ex);
         else
             goto restart;
         return 0;
     }
     catch (SqliteException ex)
     {
         MainConsole.Instance.WarnFormat("[Sqlite]: Exception processing command: {0}, Exception: {1}",
                                 cmd.CommandText, ex);
     }
     catch (Exception ex)
     {
         MainConsole.Instance.WarnFormat("[Sqlite]: Exception processing command: {0}, Exception: {1}",
                                 cmd.CommandText, ex); 
     }
     return 0;
 }
开发者ID:EnricoNirvana,项目名称:WhiteCore-Dev,代码行数:38,代码来源:SQLiteDataManager.cs

示例10: InitDatabase

        private bool InitDatabase(SqliteConnection dbcon)
        {
            bool result = false;
            try
            {
                if (dbcon.State == ConnectionState.Closed)
                {
                    dbcon.Open();
                }
                using (SqliteCommand cmd = new SqliteCommand("",dbcon))
                {
                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='project_info'";
                    object o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'project_info' (item_name text, item_value text)";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='geocache_cfields'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'geocache_cfields' (field_name text)";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='geocache'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'geocache' (id text, code text, name text, datafromdate text, lat real, lon real, disttocent integer, angletocent integer, available integer, archived integer, country text, state text, cachetype integer, placedby text, owner text, ownerid text, container integer, terrain real, difficulty real, shortdescr text, shortdescrhtml integer, longdescr text, longdescrhtml integer, encodedhints text, url text, memberonly integer, customcoords integer, attrids text, favorites integer, selected integer, municipality text, city text, customlat real, customlon real, notes text, publiceddate text, personalnote text, flagged integer, found integer, locked integer)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "create unique index idx_geocache on geocache (code)";
                        cmd.ExecuteNonQuery();
                    }
                    else if (!ColumnExists(dbcon,"geocache","locked"))
                    {
                        cmd.CommandText = "alter table geocache add locked integer";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "update geocache set locked=0";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='log'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'log' (id text, gccode text, tbcode text, date text, finder text, finderid text, logtext text, encoded integer, datafromdate text, logtype integer)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "create unique index idx_log on log (id)";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='logimage'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'logimage' (id text, logid text, url text, name text, datafromdate text)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "create unique index idx_logimage on logimage (id)";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='waypoint'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'waypoint' (id text, code text, geocachecode text, name text, datafromdate text, comment text, description text, url text, urlname text, wptype integer, lat real, lon real, time text)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "create unique index idx_waypoint on waypoint (code)";
                        cmd.ExecuteNonQuery();
                    }

                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='userwaypoint'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'userwaypoint' (id integer, geocachecode text, description text, lat real, lon real, time text)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "create unique index idx_userwaypoint on userwaypoint (id)";
                        cmd.ExecuteNonQuery();
                    }


                    cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='counter'";
                    o = cmd.ExecuteScalar();
                    if (o == null || o.GetType() == typeof(DBNull))
                    {
                        cmd.CommandText = "create table 'counter' (geocache integer, log integer, waypoint integer, logimage integer)";
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = "insert into counter (geocache, log, waypoint, logimage) values (0, 0, 0, 0)";
                        cmd.ExecuteNonQuery();
                    }
                }
                result = true;
            }
            catch
            {
            }
//.........这里部分代码省略.........
开发者ID:RH-Code,项目名称:GAPP,代码行数:101,代码来源:InternalStorage.cs

示例11: SetBlockState

			void SetBlockState(byte[] blockId, bool[] status) {
				UInt64 statusValue = 0;
				UInt64 statusId = 0;

				// Build 64bit value.
				for (byte valuePos = 0; valuePos < 64; valuePos++) {
					statusValue += (status[valuePos] ? 1ul : 0ul) << valuePos;
				}

				// Try and get a valid status id.
				try {
					parent.DatabaseMutex.WaitOne();
					var selectStatusCmd = new SqliteCommand(String.Format(@STATUSSELECT,
					                                                      ECCCracker.TABLESTATUSNAME,
					                                                      statusValue), parent.Database);
					var selectStatusReader = selectStatusCmd.ExecuteReader();
					if (selectStatusReader.HasRows) {
						selectStatusReader.NextResult();
						statusId = (UInt64)selectStatusReader.GetInt64(0);
					} else {
						var insertStatusCmd = new SqliteCommand(String.Format(@STATUSINSERT,
						                                                      ECCCracker.TABLESTATUSNAME,
						                                                      statusValue), parent.Database);
						insertStatusCmd.ExecuteNonQuery();
						var lastInsertIdCmd = new SqliteCommand("SELECT last_insert_rowid();", parent.Database);
						var lastInsertIdReader = lastInsertIdCmd.ExecuteReader();
						lastInsertIdReader.NextResult();
						statusId = (UInt64)lastInsertIdReader.GetInt64(0);
						lastInsertIdReader.Close();
					}
					selectStatusReader.Close();
				} catch (Exception e) {
					Console.WriteLine("Thread {0}: Encountered Exception while marking block as complete:", threadId);
					Console.WriteLine(e);
					Console.ReadKey();
				} finally {
					parent.DatabaseMutex.ReleaseMutex();
				}

				// Try and mark block as complete.
				try {
					parent.DatabaseMutex.WaitOne();
					var insertBlockCmd = new SqliteCommand(String.Format(@BLOCKINSERT,
					                                                     ECCCracker.TABLEBLOCKSNAME,
					                                                     BitConverter.ToUInt64(blockId, 0),
					                                                     BitConverter.ToUInt64(blockId, 8),
					                                                     BitConverter.ToUInt64(blockId, 16),
					                                                     BitConverter.ToUInt64(blockId, 24),
					                                                     BitConverter.ToUInt64(blockId, 32),
					                                                     BitConverter.ToUInt64(blockId, 40),
					                                                     statusId), parent.Database);
					insertBlockCmd.ExecuteNonQuery();
					var lastInsertIdCmd = new SqliteCommand("SELECT last_insert_rowid();", parent.Database);
					var lastInsertIdReader = lastInsertIdCmd.ExecuteReader();
					lastInsertIdReader.NextResult();
					UInt64 blockRowId = (UInt64)lastInsertIdReader.GetInt64(0);
					lastInsertIdReader.Close();
					if (blockRowId == 0)
						Console.WriteLine("Thread {0}: Failed to mark block as complete.", threadId);
				} catch (Exception e) {
					Console.WriteLine("Thread {0}: Encountered Exception while marking block as complete:", threadId);
					Console.WriteLine(e);
					Console.ReadKey();
				} finally {
					parent.DatabaseMutex.ReleaseMutex();
				}
			}
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:67,代码来源:ECCCracker.cs

示例12: GetNextBlockId

			/// <summary>
			/// Gets the next block identifier.
			/// </summary>
			/// <returns>The next block identifier.</returns>
			BigInteger GetNextBlockId() {
				BigInteger newBlockId = -1;
				Byte[] newBlockData = new Byte[48 + 1];

				parent.DatabaseMutex.WaitOne();
				bool isValid0 = false, isValid1 = false;
				while ((isValid0 == false || isValid1 == false) && BigInteger.Compare(newBlockId, parent.BlockMaximum) <= 0) {
					isValid0 = isValid1 = false;

					// Generate random number.
					randomizer.NextBytes(newBlockData);
					newBlockData[47] = (byte)(newBlockData[47] & 0x03); // Using 6 bits less than maximum.
					newBlockData[48] = 0x00;
					newBlockId = new BigInteger(newBlockData);

					// Check if the block id is already being used.
					try { //Trycrash-Construct
						var checkThreadUsageCmd = new SqliteCommand(String.Format(@THREADSELECT,
						                                                          @ECCCracker.TABLETHREADSNAME,
						                                                          BitConverter.ToUInt64(newBlockData, 0),
						                                                          BitConverter.ToUInt64(newBlockData, 8),
						                                                          BitConverter.ToUInt64(newBlockData, 16),
						                                                          BitConverter.ToUInt64(newBlockData, 24),
						                                                          BitConverter.ToUInt64(newBlockData, 32),
						                                                          BitConverter.ToUInt64(newBlockData, 40)), parent.Database);
						var checkThreadUsageReader = checkThreadUsageCmd.ExecuteReader();
						if (checkThreadUsageReader.HasRows) {// If there are rows containing this item, continue with generating the next number
							checkThreadUsageReader.Close();
							continue;
						}
						checkThreadUsageReader.Close();
						isValid0 = true;
					} catch (Exception e) {
						Console.WriteLine("Thread {0}: Encountered Exception while trying to get next block Id:", threadId);
						Console.WriteLine(e);
						Console.ReadKey();
					}

					// Check if the block id has already been used.
					try {
						var checkBlockDoneCmd = new SqliteCommand(String.Format(@BLOCKSELECT,
						                                                        @ECCCracker.TABLEBLOCKSNAME,
						                                                        BitConverter.ToUInt64(newBlockData, 0),
						                                                        BitConverter.ToUInt64(newBlockData, 8),
						                                                        BitConverter.ToUInt64(newBlockData, 16),
						                                                        BitConverter.ToUInt64(newBlockData, 24),
						                                                        BitConverter.ToUInt64(newBlockData, 32),
						                                                        BitConverter.ToUInt64(newBlockData, 40)), parent.Database);
						var checkThreadUsageReader = checkBlockDoneCmd.ExecuteReader();
						if (checkThreadUsageReader.HasRows) {// If there are rows containing this item, continue with generating the next number
							checkThreadUsageReader.Close();
							continue;
						}
						checkThreadUsageReader.Close();
						isValid1 = true;
					} catch (Exception e) {
						Console.WriteLine("Thread {0}: Encountered Exception while trying to get next block Id:", threadId);
						Console.WriteLine(e);
						Console.ReadKey();
					}
				}

				// Now set the block id as being used.
				try {
					var setBlockUsedCmd = new SqliteCommand(String.Format(@THREADINSERT,
					                                                      @ECCCracker.TABLETHREADSNAME,
					                                                      threadId,
					                                                      BitConverter.ToUInt64(newBlockData, 0),
					                                                      BitConverter.ToUInt64(newBlockData, 8),
					                                                      BitConverter.ToUInt64(newBlockData, 16),
					                                                      BitConverter.ToUInt64(newBlockData, 24),
					                                                      BitConverter.ToUInt64(newBlockData, 32),
					                                                      BitConverter.ToUInt64(newBlockData, 40)), parent.Database);
					setBlockUsedCmd.ExecuteNonQuery();
				} catch (Exception e) {
					Console.WriteLine("Thread {0}: Encountered Exception while trying to get next block Id:", threadId);
					Console.WriteLine(e);
					Console.ReadKey();
				}
				parent.DatabaseMutex.ReleaseMutex();

				return newBlockId;
			}
开发者ID:R4P3-NET,项目名称:AccountingServerEmulatorSource,代码行数:87,代码来源:ECCCracker.cs

示例13: Update

 public bool Update(IList<FileMetaDataItem> items, SqliteConnection con)
 {
     string cmdText = string.Format("UPDATE {0} SET {1} = @hash, {2} = @lmf WHERE {3} = @rel AND {4} = @sourceId",
                                    Configuration.TBL_METADATA, Configuration.COL_HASH_CODE,
                                    Configuration.COL_LAST_MODIFIED_TIME, Configuration.COL_RELATIVE_PATH, Configuration.COL_SOURCE_ID);
     try
     {
         foreach (FileMetaDataItem item in items)
         {
             using (var cmd = new SqliteCommand(cmdText, con))
             {
                 cmd.Parameters.Add(new SqliteParameter("@hash", DbType.String) { Value = item.HashCode });
                 cmd.Parameters.Add(new SqliteParameter("@lmf", DbType.DateTime) { Value = item.LastModifiedTime });
                 cmd.Parameters.Add(new SqliteParameter("@rel", DbType.String) { Value = item.RelativePath });
                 cmd.Parameters.Add(new SqliteParameter("@sourceId", DbType.String) { Value = item.SourceId });
                 cmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception)
     {
         return false;
     }
     return true;
 }
开发者ID:nydehi,项目名称:onesync,代码行数:25,代码来源:SQLiteMetaDataProvider.cs

示例14: Delete

 public bool Delete(IList<FolderMetadataItem> items, SqliteConnection con)
 {
     const string cmdText = "DELETE FROM " + Configuration.TLB_FOLDERMETADATA +
                            " WHERE " + Configuration.COL_SOURCE_ID + " = @sourceId AND " +
                            Configuration.COL_RELATIVE_PATH + " = @path";
     try
     {
         foreach (FolderMetadataItem item in items)
         {
             using (var cmd = new SqliteCommand(cmdText, con))
             {
                 cmd.Parameters.Add(new SqliteParameter("@sourceId", DbType.String) { Value = item.SourceId });
                 cmd.Parameters.Add(new SqliteParameter("@path", DbType.String) { Value = item.RelativePath });
                 cmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception)
     { return false; }
     return true;
 }
开发者ID:nydehi,项目名称:onesync,代码行数:21,代码来源:SQLiteMetaDataProvider.cs

示例15: ExportToGDAK

        public async Task ExportToGDAK(List<Core.Data.Geocache> gcList, string targetFolder, int maxLogCount, bool offlineImages, int maxInImgFolder)
        {
            string filename = Path.Combine(targetFolder, "sqlite.db3");
            await Task.Run(() =>
            {
                try
                {
                    DateTime nextUpdate = DateTime.Now.AddSeconds(1);
                    using (Utils.ProgressBlock fixscr = new Utils.ProgressBlock("ExportingGDAK", "CreatingFile", 1, 0, true))
                    {
                        System.Collections.Hashtable logTypes = new System.Collections.Hashtable();
                        logTypes.Add(2, "Found it");
                        logTypes.Add(3, "Didn't find it");
                        logTypes.Add(4, "Write note");
                        logTypes.Add(5, "Archive");
                        logTypes.Add(7, "Needs Archived");
                        logTypes.Add(9, "Will Attend");
                        logTypes.Add(10, "Attended");
                        logTypes.Add(11, "Webcam Photo Taken");
                        logTypes.Add(12, "Unarchive");
                        logTypes.Add(22, "Temporarily Disable Listing");
                        logTypes.Add(23, "Enable Listing");
                        logTypes.Add(24, "Publish Listing");
                        logTypes.Add(25, "Retract Listing");
                        logTypes.Add(45, "Needs Maintenance");
                        logTypes.Add(46, "Owner Maintenance");
                        logTypes.Add(47, "Update Coordinates");
                        logTypes.Add(68, "Post Reviewer Note");
                        logTypes.Add(74, "Announcement");

                        if (System.IO.File.Exists(filename))
                        {
                            System.IO.File.Delete(filename);
                        }
                        SqliteConnection dbconFiles = null;
                        string basePath = null;
                        int imgFolderIndex = 0;
                        int imgInFolderCount = 0;
                        if (Core.Settings.Default.GDAKExportOfflineImages)
                        {
                            basePath = System.IO.Path.Combine(targetFolder, "GrabbedImages");
                            if (!System.IO.Directory.Exists(basePath))
                            {
                                System.IO.Directory.CreateDirectory(basePath);
                            }
                            if (Core.Settings.Default.GDAKMaxImagesInFolder > 0)
                            {
                                string imgSubFolder = System.IO.Path.Combine(basePath, string.Format("batch{0}", imgFolderIndex));
                                while (System.IO.Directory.Exists(imgSubFolder))
                                {
                                    imgFolderIndex++;
                                    imgSubFolder = System.IO.Path.Combine(basePath, string.Format("batch{0}", imgFolderIndex));
                                }
                            }
                            dbconFiles = new SqliteConnection(string.Format("data source=file:{0}", System.IO.Path.Combine(basePath, "files.db3")));
                            dbconFiles.Open();
                            using (SqliteCommand cmd = new SqliteCommand("", dbconFiles))
                            {
                                cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='fdone'";
                                object o = cmd.ExecuteScalar();
                                if (o == null || o.GetType() == typeof(DBNull))
                                {
                                    cmd.CommandText = "CREATE TABLE fdone (dlink text)";
                                    cmd.ExecuteNonQuery();
                                    cmd.CommandText = "CREATE INDEX ifdone on fdone (dlink)";
                                    cmd.ExecuteNonQuery();
                                }

                                cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='files'";
                                o = cmd.ExecuteScalar();
                                if (o == null || o.GetType() == typeof(DBNull))
                                {
                                    cmd.CommandText = "CREATE TABLE files (Link text collate nocase, Fname text collate nocase, Found integer)";
                                    cmd.ExecuteNonQuery();
                                    cmd.CommandText = "CREATE INDEX ilink on files (Link)";
                                    cmd.ExecuteNonQuery();
                                    cmd.CommandText = "CREATE INDEX ifname on files (Fname)";
                                    cmd.ExecuteNonQuery();
                                }

                                cmd.CommandText = "SELECT name FROM sqlite_master WHERE type='table' AND name='purge'";
                                o = cmd.ExecuteScalar();
                                if (o == null || o.GetType() == typeof(DBNull))
                                {
                                    cmd.CommandText = "CREATE TABLE purge (pfile text)";
                                    cmd.ExecuteNonQuery();
                                }
                            }
                        }
                        using (SqliteConnection dbcon = new SqliteConnection(string.Format("data source=file:{0}", filename)))
                        {
                            dbcon.Open();
                            using (SqliteCommand cmd = new SqliteCommand("", dbcon))
                            {
                                foreach (string s in SQLCREATEDBTABLES)
                                {
                                    cmd.CommandText = s;
                                    cmd.ExecuteNonQuery();
                                }
                                foreach (string s in SQLCREATEDBINDEXES)
//.........这里部分代码省略.........
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:101,代码来源:Export.cs


注:本文中的Community.CsharpSqlite.SQLiteClient.SqliteCommand.ExecuteNonQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。