Example #1
0
		private void InitializeCommands()
		{
			m_moveBlockToNewVolumeCommand = m_connection.CreateCommand();
			
			m_moveBlockToNewVolumeCommand.CommandText = @"UPDATE ""Block"" SET ""VolumeID"" = ? WHERE ""Hash"" = ? AND ""Size"" = ?";
			m_moveBlockToNewVolumeCommand.AddParameters(3);
		}
Example #2
0
 public AthleteRepository(System.Data.IDbCommand command)
 {
     if (command == null) {
     throw new System.ArgumentNullException("command", "command cannot be null");
      } else {
     this.command = command;
      }
 }
Example #3
0
 public BlockMarker(System.Data.IDbConnection connection, string blocktablename, string filetablename)
 {
     m_insertblockCommand = connection.CreateCommand();
     m_resetfileCommand  = connection.CreateCommand();
     m_updateAsRestoredCommand = connection.CreateCommand();
     m_statUpdateCommand = connection.CreateCommand();
     
     m_insertblockCommand.Transaction = connection.BeginTransaction();
     m_resetfileCommand.Transaction = m_insertblockCommand.Transaction;
     m_updateAsRestoredCommand.Transaction = m_insertblockCommand.Transaction;
     m_statUpdateCommand.Transaction = m_insertblockCommand.Transaction;
     
     m_blocktablename = blocktablename;
     m_updateTable = "UpdatedBlocks-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
     
     m_insertblockCommand.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""FileID"" INTEGER NOT NULL, ""Index"" INTEGER NOT NULL, ""Hash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL)", m_updateTable));
     m_insertblockCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""FileID"", ""Index"", ""Hash"", ""Size"") VALUES (?, ?, ?, ?) ", m_updateTable);
     m_insertblockCommand.AddParameters(4);
                     
     m_resetfileCommand.CommandText = string.Format(@"DELETE FROM ""{0}"" WHERE ""FileID"" = ?", m_updateTable);
     m_resetfileCommand.AddParameters(1);
     
     m_updateAsRestoredCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""FileID"", ""Index"", ""Hash"", ""Size"") SELECT ""FileID"", ""Index"", ""Hash"", ""Size"" FROM ""{1}"" WHERE ""{1}"".""FileID"" = ?", m_updateTable, m_blocktablename);
     m_updateAsRestoredCommand.AddParameters(1);
     
     m_statUpdateCommand.CommandText = string.Format(@"SELECT COUNT(DISTINCT ""FileID""), SUM(""Size"") FROM ""{0}"" WHERE ""Restored"" = 1 OR ""ID"" IN (SELECT ""{0}"".""ID"" FROM ""{0}"", ""{1}"" WHERE ""{0}"".""FileID"" = ""{1}"".""FileID"" AND ""{0}"".""Index"" = ""{1}"".""Index"" AND ""{0}"".""Hash"" = ""{1}"".""Hash"" AND ""{0}"".""Size"" = ""{1}"".""Size"" )", m_blocktablename, m_updateTable);
 }
Example #4
0
            public void Dispose()
            {
	            if (m_updateTable != null)
	            {
	            	try 
	            	{
	            		m_insertblockCommand.Parameters.Clear();
	            		m_insertblockCommand.ExecuteNonQuery(string.Format(@"DROP TABLE IF EXISTS ""{0}"" ", m_updateTable));
	            	}
	            	catch { }
	            	finally { m_updateTable = null; }
	            }
                            
                if (m_insertblockCommand != null)
                    try { m_insertblockCommand.Dispose(); }
                    catch { }
                    finally { m_insertblockCommand = null; }
                    
                if (m_resetfileCommand != null)
                    try { m_resetfileCommand.Dispose(); }
                    catch { }
                    finally { m_resetfileCommand = null; }
                    
                if (m_updateAsRestoredCommand != null)
                    try { m_updateAsRestoredCommand.Dispose(); }
                    catch { }
                    finally { m_updateAsRestoredCommand = null; }
                    
                if (m_statUpdateCommand != null)
                    try { m_statUpdateCommand.Dispose(); }
                    catch { }
                    finally { m_statUpdateCommand = null; }
                
            }
Example #5
0
 public void ProcessOutputCommand(System.Data.IDbCommand command)
 {
     throw new NotImplementedException();
 }
 public OleDbRowUpdatingEventArgs(System.Data.DataRow dataRow, System.Data.IDbCommand command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping) : base(default(System.Data.DataRow), default(System.Data.IDbCommand), default(System.Data.StatementType), default(System.Data.Common.DataTableMapping))
 {
 }
 public override System.Threading.Tasks.Task <object> ExecuteScalarAsync(System.Data.IDbCommand cmd, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) => throw null;
Example #8
0
 public System.Data.Common.DbDataAdapter CreateDbDataAdapter(System.Data.IDbCommand dbCommand)
 {
     throw new NotImplementedException();
 }
		public CommandEventArgs(System.Data.IDbCommand command)
		{
			Command = command;
		}
            public void Dispose()
            {
                if (m_insertPreviousElementCommand != null)
                {
                    try { m_insertPreviousElementCommand.Dispose(); }
                    catch {}
                    finally { m_insertPreviousElementCommand = null; }
                }

                if (m_insertCurrentElementCommand != null)
                {
                    try { m_insertCurrentElementCommand.Dispose(); }
                    catch {}
                    finally { m_insertCurrentElementCommand = null; }
                }
                
                if (m_transaction != null)
                {
                    try { m_transaction.Rollback(); }
                    catch {}
                    finally
                    {
                        m_previousTable = null;
                        m_currentTable= null;
                        m_transaction = null;
                    }
                }
            }
Example #11
0
        public LocalRecreateDatabase(LocalDatabase parentdb, Options options)
            : base(parentdb)
        {
            m_tempblocklist = "TempBlocklist-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
            m_tempsmalllist = "TempSmalllist-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());

            using (var cmd = m_connection.CreateCommand())
            {
                cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""BlockListHash"" TEXT NOT NULL, ""BlockHash"" TEXT NOT NULL, ""Index"" INTEGER NOT NULL)", m_tempblocklist));
                cmd.ExecuteNonQuery(string.Format(@"CREATE INDEX ""Index_{0}"" ON ""{0}"" (""BlockListHash"");", m_tempblocklist));

                cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""FileHash"" TEXT NOT NULL, ""BlockHash"" TEXT NOT NULL, ""BlockSize"" INTEGER NOT NULL)", m_tempsmalllist));
                cmd.ExecuteNonQuery(string.Format(@"CREATE UNIQUE INDEX ""Index_File_{0}"" ON ""{0}"" (""FileHash"", ""BlockSize"");", m_tempsmalllist));
                cmd.ExecuteNonQuery(string.Format(@"CREATE UNIQUE INDEX ""Index_Block_{0}"" ON ""{0}"" (""BlockHash"", ""BlockSize"");", m_tempsmalllist));
            }

            m_insertFileCommand           = m_connection.CreateCommand();
            m_insertFilesetEntryCommand   = m_connection.CreateCommand();
            m_insertMetadatasetCommand    = m_connection.CreateCommand();
            m_insertBlocksetCommand       = m_connection.CreateCommand();
            m_insertBlocklistHashCommand  = m_connection.CreateCommand();
            m_updateBlockVolumeCommand    = m_connection.CreateCommand();
            m_insertBlockset              = m_connection.CreateCommand();
            m_insertSmallBlockset         = m_connection.CreateCommand();
            m_findBlocksetCommand         = m_connection.CreateCommand();
            m_findMetadatasetCommand      = m_connection.CreateCommand();
            m_findFilesetCommand          = m_connection.CreateCommand();
            m_findblocklisthashCommand    = m_connection.CreateCommand();
            m_findHashBlockCommand        = m_connection.CreateCommand();
            m_insertBlockCommand          = m_connection.CreateCommand();
            m_insertDuplicateBlockCommand = m_connection.CreateCommand();

            m_insertFileCommand.CommandText = @"INSERT INTO ""File"" (""Path"", ""BlocksetID"", ""MetadataID"") VALUES (?,?,?); SELECT last_insert_rowid();";
            m_insertFileCommand.AddParameters(3);

            m_insertFilesetEntryCommand.CommandText = @"INSERT INTO ""FilesetEntry"" (""FilesetID"", ""FileID"", ""Lastmodified"") VALUES (?,?,?)";
            m_insertFilesetEntryCommand.AddParameters(3);

            m_insertMetadatasetCommand.CommandText = @"INSERT INTO ""Metadataset"" (""BlocksetID"") VALUES (?); SELECT last_insert_rowid();";
            m_insertMetadatasetCommand.AddParameters(1);

            m_insertBlocksetCommand.CommandText = @"INSERT INTO ""Blockset"" (""Length"", ""FullHash"") VALUES (?,?); SELECT last_insert_rowid();";
            m_insertBlocksetCommand.AddParameters(2);

            m_insertBlocklistHashCommand.CommandText = @"INSERT INTO ""BlocklistHash"" (""BlocksetID"", ""Index"", ""Hash"") VALUES (?,?,?)";
            m_insertBlocklistHashCommand.AddParameters(3);

            m_updateBlockVolumeCommand.CommandText = @"UPDATE ""Block"" SET ""VolumeID"" = ? WHERE ""Hash"" = ? AND ""Size"" = ?";
            m_updateBlockVolumeCommand.AddParameters(3);

            m_insertBlockset.CommandText = string.Format(@"INSERT INTO ""{0}"" (""BlocklistHash"", ""BlockHash"", ""Index"") VALUES (?,?,?) ", m_tempblocklist);
            m_insertBlockset.AddParameters(3);

            m_insertSmallBlockset.CommandText = string.Format(@"INSERT OR IGNORE INTO ""{0}"" (""FileHash"", ""BlockHash"", ""BlockSize"") VALUES (?,?,?) ", m_tempsmalllist);
            m_insertSmallBlockset.AddParameters(3);

            m_findBlocksetCommand.CommandText = @"SELECT ""ID"" FROM ""Blockset"" WHERE ""Length"" = ? AND ""FullHash"" = ? ";
            m_findBlocksetCommand.AddParameters(2);

            m_findMetadatasetCommand.CommandText = @"SELECT ""Metadataset"".""ID"" FROM ""Metadataset"",""Blockset"" WHERE ""Metadataset"".""BlocksetID"" = ""Blockset"".""ID"" AND ""Blockset"".""FullHash"" = ? AND ""Blockset"".""Length"" = ? ";
            m_findMetadatasetCommand.AddParameters(2);

            m_findFilesetCommand.CommandText = @"SELECT ""ID"" FROM ""File"" WHERE ""Path"" = ? AND ""BlocksetID"" = ? AND ""MetadataID"" = ? ";
            m_findFilesetCommand.AddParameters(3);

            m_findblocklisthashCommand.CommandText = string.Format(@"SELECT DISTINCT ""BlockListHash"" FROM ""{0}"" WHERE ""BlockListHash"" = ? ", m_tempblocklist);
            m_findblocklisthashCommand.AddParameters(1);

            m_findHashBlockCommand.CommandText = @"SELECT ""VolumeID"" FROM ""Block"" WHERE ""Hash"" = ? AND ""Size"" = ? ";
            m_findHashBlockCommand.AddParameters(2);

            m_insertBlockCommand.CommandText = @"INSERT INTO ""Block"" (""Hash"", ""Size"", ""VolumeID"") VALUES (?,?,?)";
            m_insertBlockCommand.AddParameters(3);

            m_insertDuplicateBlockCommand.CommandText = @"INSERT INTO ""DuplicateBlock"" (""BlockID"", ""VolumeID"") VALUES ((SELECT ""ID"" FROM ""Block"" WHERE ""Hash"" = ? AND ""Size"" = ?), ?)";
            m_insertDuplicateBlockCommand.AddParameters(3);

            if (options.UseFilepathCache)
            {
                m_filesetLookup = new PathLookupHelper <PathEntryKeeper>();
            }
        }
Example #12
0
 public virtual void Dispose()
 {
     if (m_tablename != null)
         try 
         { 
             using(var cmd = m_connection.CreateCommand())
             {
                 cmd.Transaction = m_transaction;
                 cmd.ExecuteNonQuery(string.Format(@"DROP TABLE IF EXISTS ""{0}""", m_tablename));
             }
         }
         catch {}
         finally { m_tablename = null; }
         
     if (m_insertCommand != null)
         try { m_insertCommand.Dispose(); }
         catch {}
         finally { m_insertCommand = null; }
         
     if (m_transaction != null)
         try { m_transaction.Rollback(); }
         catch {}
         finally { m_transaction = null; }
 }
Example #13
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="connection">Instancia da conexão.</param>
 /// <param name="command"></param>
 public DbCommandWrapper(System.Data.IDbConnection connection, System.Data.IDbCommand command)
 {
     _connection = connection;
     _command    = command;
 }
 public override bool DoesSequenceExist(System.Data.IDbCommand dbCmd, string sequenceName) => throw null;
 public override void AppendFieldCondition(System.Text.StringBuilder sqlFilter, ServiceStack.OrmLite.FieldDefinition fieldDef, System.Data.IDbCommand cmd) => throw null;
 public override void PrepareParameterizedInsertStatement <T>(System.Data.IDbCommand cmd, System.Collections.Generic.ICollection <string> insertFields = default(System.Collections.Generic.ICollection <string>), System.Func <ServiceStack.OrmLite.FieldDefinition, bool> shouldInclude = default(System.Func <ServiceStack.OrmLite.FieldDefinition, bool>)) => throw null;
 public override void PrepareInsertRowStatement <T>(System.Data.IDbCommand dbCmd, System.Collections.Generic.Dictionary <string, object> args) => throw null;
            public void Dispose()
            {
                if (m_insertblockCommand != null)
                    try { m_insertblockCommand.Dispose(); }
                    catch { }
                    finally { m_insertblockCommand = null; }

                if (m_resetfileCommand != null)
                    try { m_resetfileCommand.Dispose(); }
                    catch { }
                    finally { m_resetfileCommand = null; }

                if (m_updateAsRestoredCommand != null)
                    try { m_updateAsRestoredCommand.Dispose(); }
                    catch { }
                    finally { m_updateAsRestoredCommand = null; }

                if (m_updateFileAsDataVerifiedCommand != null)
                    try { m_updateFileAsDataVerifiedCommand.Dispose(); }
                    catch { }
                    finally { m_updateFileAsDataVerifiedCommand = null; }

                if (m_statUpdateCommand != null)
                    try { m_statUpdateCommand.Dispose(); }
                    catch { }
                    finally { m_statUpdateCommand = null; }
            }
Example #19
0
        public LocalBackupDatabase(LocalDatabase db, Options options)
            : base(db)
        {
            m_findblockCommand             = m_connection.CreateCommand();
            m_insertblockCommand           = m_connection.CreateCommand();
            m_insertfileCommand            = m_connection.CreateCommand();
            m_insertblocksetCommand        = m_connection.CreateCommand();
            m_insertmetadatasetCommand     = m_connection.CreateCommand();
            m_findblocksetCommand          = m_connection.CreateCommand();
            m_findmetadatasetCommand       = m_connection.CreateCommand();
            m_findfilesetCommand           = m_connection.CreateCommand();
            m_insertblocksetentryCommand   = m_connection.CreateCommand();
            m_insertblocklistHashesCommand = m_connection.CreateCommand();
            m_selectblocklistHashesCommand = m_connection.CreateCommand();
            m_insertfileOperationCommand   = m_connection.CreateCommand();
            m_findfileCommand = m_connection.CreateCommand();
            m_selectfilelastmodifiedCommand  = m_connection.CreateCommand();
            m_selectfileHashCommand          = m_connection.CreateCommand();
            m_insertblocksetentryFastCommand = m_connection.CreateCommand();

            m_findblockCommand.CommandText = @"SELECT ""ID"" FROM ""Block"" WHERE ""Hash"" = ? AND ""Size"" = ?";
            m_findblockCommand.AddParameters(2);

            m_findblocksetCommand.CommandText = @"SELECT ""ID"" FROM ""Blockset"" WHERE ""Fullhash"" = ? AND ""Length"" = ?";
            m_findblocksetCommand.AddParameters(2);

            m_findmetadatasetCommand.CommandText = @"SELECT ""A"".""ID"" FROM ""Metadataset"" A, ""BlocksetEntry"" B, ""Block"" C WHERE ""A"".""BlocksetID"" = ""B"".""BlocksetID"" AND ""B"".""BlockID"" = ""C"".""ID"" AND ""C"".""Hash"" = ? AND ""C"".""Size"" = ?";
            m_findmetadatasetCommand.AddParameters(2);

            m_findfilesetCommand.CommandText = @"SELECT ""ID"" FROM ""File"" WHERE ""BlocksetID"" = ? AND ""MetadataID"" = ? AND ""Path"" = ?";
            m_findfilesetCommand.AddParameters(3);

            m_insertblockCommand.CommandText = @"INSERT INTO ""Block"" (""Hash"", ""VolumeID"", ""Size"") VALUES (?, ?, ?); SELECT last_insert_rowid();";
            m_insertblockCommand.AddParameters(3);

            m_insertfileOperationCommand.CommandText = @"INSERT INTO ""FilesetEntry"" (""FilesetID"", ""FileID"", ""Lastmodified"") VALUES (?, ?, ?)";
            m_insertfileOperationCommand.AddParameters(3);

            m_insertfileCommand.CommandText = @"INSERT INTO ""File"" (""Path"",""BlocksetID"", ""MetadataID"") VALUES (?, ? ,?); SELECT last_insert_rowid();";
            m_insertfileCommand.AddParameters(3);

            m_insertblocksetCommand.CommandText = @"INSERT INTO ""Blockset"" (""Length"", ""FullHash"") VALUES (?, ?); SELECT last_insert_rowid();";
            m_insertblocksetCommand.AddParameters(2);

            m_insertblocksetentryFastCommand.CommandText = @"INSERT INTO ""BlocksetEntry"" (""BlocksetID"", ""Index"", ""BlockID"") VALUES (?,?,?)";
            m_insertblocksetentryFastCommand.AddParameters(3);

            m_insertblocksetentryCommand.CommandText = @"INSERT INTO ""BlocksetEntry"" (""BlocksetID"", ""Index"", ""BlockID"") SELECT ? AS A, ? AS B, ""ID"" FROM ""Block"" WHERE ""Hash"" = ? AND ""Size"" = ?";
            m_insertblocksetentryCommand.AddParameters(4);

            m_insertblocklistHashesCommand.CommandText = @"INSERT INTO ""BlocklistHash"" (""BlocksetID"", ""Index"", ""Hash"") VALUES (?, ?, ?)";
            m_insertblocklistHashesCommand.AddParameters(3);

            m_insertmetadatasetCommand.CommandText = @"INSERT INTO ""Metadataset"" (""BlocksetID"") VALUES (?); SELECT last_insert_rowid();";
            m_insertmetadatasetCommand.AddParameter();

            m_selectfilelastmodifiedCommand.CommandText = @"SELECT ""File"".""ID"", ""FilesetEntry"".""LastModified"" FROM ""File"", ""FilesetEntry"" WHERE ""Path"" = ? AND ""File"".""ID"" = ""FilesetEntry"".""FileID"" AND ""FilesetEntry"".""FilesetID"" = ? LIMIT 1";
            m_selectfilelastmodifiedCommand.AddParameters(2);

            //Need a temporary table with path/lastmodified lookups
            m_findfileCommand.CommandText =
                @" SELECT ""File"".""ID"" AS ""FileID"", ""FilesetEntry"".""Lastmodified"", ""FileBlockset"".""Length"", ""MetaBlockset"".""Fullhash"" AS ""Metahash"", ""MetaBlockset"".""Length"" AS ""Metasize"" " +
                @"   FROM ""File"", ""FilesetEntry"", ""Fileset"", ""Blockset"" ""FileBlockset"", ""Metadataset"", ""Blockset"" ""MetaBlockset"" " +
                @"  WHERE ""File"".""Path"" = ? " +
                @"    AND ""FilesetEntry"".""FileID"" = ""File"".""ID"" AND ""Fileset"".""ID"" = ""FilesetEntry"".""FilesetID"" " +
                @"    AND ""FileBlockset"".""ID"" = ""File"".""BlocksetID"" " +
                @"    AND ""Metadataset"".""ID"" = ""File"".""MetadataID"" AND ""MetaBlockset"".""ID"" = ""Metadataset"".""BlocksetID"" " +
                @"  ORDER BY ""Fileset"".""Timestamp"" DESC " +
                @"  LIMIT 1 ";
            m_findfileCommand.AddParameters(1);

            m_selectfileHashCommand.CommandText = @"SELECT ""Blockset"".""Fullhash"" FROM ""Blockset"", ""File"" WHERE ""Blockset"".""ID"" = ""File"".""BlocksetID"" AND ""File"".""ID"" = ?  ";
            m_selectfileHashCommand.AddParameters(1);

            m_selectblocklistHashesCommand.CommandText = @"SELECT ""Hash"" FROM ""BlocklistHash"" WHERE ""BlocksetID"" = ? ORDER BY ""Index"" ASC ";
            m_selectblocklistHashesCommand.AddParameters(1);
        }
            public void Dispose()
            {
                if (m_tablename != null)
                {
                    try
                    {
                        using(var cmd = m_connection.CreateCommand(m_transaction.Parent))
                            cmd.ExecuteNonQuery(string.Format(@"DROP TABLE IF EXISTS ""{0}"" ", m_transaction));
                    }
                    catch { }
                    finally { m_tablename = null; }
                }

                if (m_insertCommand != null)
                    try { m_insertCommand.Dispose(); }
                    catch {}
                    finally { m_insertCommand = null; }
            }
Example #21
0
 private long GetPreviousFilesetID(System.Data.IDbCommand cmd)
 {
     return(GetPreviousFilesetID(cmd, OperationTimestamp, m_filesetId));
 }
Example #22
0
			public void Dispose()
			{
        		m_lookup = null;
				if (m_command != null)
					try { m_command.Dispose(); }
					finally { m_command = null; }
			}
Example #23
0
        private long GetPreviousFilesetID(System.Data.IDbCommand cmd, DateTime timestamp, long filesetid)
        {
            var lastFilesetId = cmd.ExecuteScalarInt64(@"SELECT ""ID"" FROM ""Fileset"" WHERE ""Timestamp"" < ? AND ""ID"" != ? ORDER BY ""Timestamp"" DESC ", -1, NormalizeDateTimeToEpochSeconds(timestamp), filesetid);

            return(lastFilesetId);
        }
Example #24
0
 public void Notify(System.Data.IDbCommand cmd)
 {
     this.Observers.ForEach(o => {
         o.Log(cmd);
     });
 }
Example #25
0
        protected override void CreateUpdateParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            NotaFiscal nota = (NotaFiscal)businessObject;

            CreateKeyParameters(businessObject, cmd);
            DALObject.CreateParameter(cmd, "@CodigoSituacao", System.Data.DbType.Int32, nota.codigoSituacao);
            DALObject.CreateParameter(cmd, "@DescricaoSituacao", System.Data.DbType.String, nota.descricaoSituacao);
            DALObject.CreateParameter(cmd, "@DataSituacao", System.Data.DbType.DateTime, nota.dataSituacao);
            DALObject.CreateParameter(cmd, "@XMLNotaFiscal", System.Data.DbType.String, nota.xmlNota);
            DALObject.CreateParameter(cmd, "@XMLProcesso", System.Data.DbType.String, nota.xmlProcesso);
            DALObject.CreateParameter(cmd, "@cStat", System.Data.DbType.String, nota.cStat);
            DALObject.CreateParameter(cmd, "@xMotivo", System.Data.DbType.String, nota.xMotivo);
            DALObject.CreateParameter(cmd, "@nProt", System.Data.DbType.String, nota.nProt);
            DALObject.CreateParameter(cmd, "@xmlPedidoCancelamento", System.Data.DbType.String, nota.xmlPedidoCancelamento);
            DALObject.CreateParameter(cmd, "@xmlProcessoCancelamento", System.Data.DbType.String, nota.xmlProcessoCancelamento);
            DALObject.CreateParameter(cmd, "@nProtCancelamento", System.Data.DbType.String, nota.nProtCancelamento);
            DALObject.CreateParameter(cmd, "@versao", System.Data.DbType.Int32, nota.versao);
        }
Example #26
0
 public void DeriveParameters(System.Data.IDbCommand spCommand)
 {
     throw new NotImplementedException();
 }
Example #27
0
        protected override void CreateKeyParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            Log oLog = (Log)businessObject;

            DALObject.CreateParameter(cmd, "@NumeroLog", System.Data.DbType.Int32, oLog.numero);
        }
 public override object ExecuteInsert(Database db, System.Data.IDbCommand cmd, string primaryKeyName)
 {
     db.ExecuteNonQueryHelper(cmd);
     return(db.ExecuteScalar <object>("SELECT @@@IDENTITY AS NewID;"));
 }
Example #29
0
        protected override void CreateInsertParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            Log oLog = (Log)businessObject;

            CreateKeyParameters(businessObject, cmd);
            DALObject.CreateParameter(cmd, "@CodigoSituacao", System.Data.DbType.Int32, oLog.codigoSituacao);
            DALObject.CreateParameter(cmd, "@DataLog", System.Data.DbType.DateTime, oLog.data);
            DALObject.CreateParameter(cmd, "@DescricaoSituacao", System.Data.DbType.String, oLog.descricaoSituacao);
            DALObject.CreateParameter(cmd, "@CNPJ", System.Data.DbType.String, oLog.empresa);
            DALObject.CreateParameter(cmd, "@ChaveNota", System.Data.DbType.String, oLog.chaveNota);
        }
 protected override System.Data.Common.RowUpdatedEventArgs CreateRowUpdatedEvent(System.Data.DataRow dataRow, System.Data.IDbCommand command, System.Data.StatementType statementType, System.Data.Common.DataTableMapping tableMapping)
 {
     throw null;
 }
        protected override void CreateKeyParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            Parametro param = (Parametro)businessObject;

            DALObject.CreateParameter(cmd, "@CNPJ", System.Data.DbType.String, param.empresa);
        }
Example #32
0
            public void Commit(ILogWriter log)
            {
                m_insertblockCommand.Parameters.Clear();
                var rc = m_insertblockCommand.ExecuteNonQuery(string.Format(@"UPDATE ""{0}"" SET ""Restored"" = 1 WHERE ""ID"" IN (SELECT ""{0}"".""ID"" FROM ""{0}"", ""{1}"" WHERE ""{0}"".""FileID"" = ""{1}"".""FileID"" AND ""{0}"".""Index"" = ""{1}"".""Index"" AND ""{0}"".""Hash"" = ""{1}"".""Hash"" AND ""{0}"".""Size"" = ""{1}"".""Size"" )", m_blocktablename, m_updateTable));
                var nc = Convert.ToInt64(m_insertblockCommand.ExecuteScalar(string.Format(@"SELECT COUNT(*) FROM ""{0}"" ", m_updateTable)));
                    		
                if (rc != nc)
                    log.AddWarning(string.Format("Inconsistency while marking blocks as updated. Updated blocks: {0}, Registered blocks: {1}", rc, nc), null);
                
                m_insertblockCommand.ExecuteNonQuery(string.Format(@"DROP TABLE IF EXISTS ""{0}"" ", m_updateTable));
                m_updateTable = null;

                var tr = m_insertblockCommand.Transaction;
                m_insertblockCommand.Dispose();
                m_insertblockCommand = null;
                using(new Logging.Timer("CommitBlockMarker"))
                    tr.Commit();
                tr.Dispose();
            }
        protected override void CreateUpdateParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            Parametro param = (Parametro)businessObject;

            CreateKeyParameters(businessObject, cmd);
            DALObject.CreateParameter(cmd, "@TipoOperacao", System.Data.DbType.Int32, param.tipoAmbiente);
            DALObject.CreateParameter(cmd, "@ModoOperacao", System.Data.DbType.Int32, param.tipoEmissao);
            DALObject.CreateParameter(cmd, "@UnidadeFederativa", System.Data.DbType.Int32, param.UF);

            DALObject.CreateParameter(cmd, "@QtdeNFLote", System.Data.DbType.Int32, param.qtdeNotasPorLotes);
            DALObject.CreateParameter(cmd, "@TempoFechaLote", System.Data.DbType.Int32, param.tempoParaLote);
            DALObject.CreateParameter(cmd, "@TamanhoLote", System.Data.DbType.Int32, param.tamMaximoLoteKB);
            DALObject.CreateParameter(cmd, "@TempoEspera", System.Data.DbType.Int32, param.tempoEspera);

            DALObject.CreateParameter(cmd, "@DiretorioRecibo", System.Data.DbType.String, param.pastaRecibo);
            DALObject.CreateParameter(cmd, "@DiretorioEntrada", System.Data.DbType.String, param.pastaEntrada);
            DALObject.CreateParameter(cmd, "@DiretorioSaida", System.Data.DbType.String, param.pastaSaida);
            DALObject.CreateParameter(cmd, "@DiretorioImpressao", System.Data.DbType.String, param.pastaImpressao);
            DALObject.CreateParameter(cmd, "@DiretorioXSD", System.Data.DbType.String, param.pastaXSD);

            DALObject.CreateParameter(cmd, "@UsaProxy", System.Data.DbType.Boolean, param.prx);
            DALObject.CreateParameter(cmd, "@DominioProxy", System.Data.DbType.String, param.prxDmn);
            DALObject.CreateParameter(cmd, "@SenhaProxy", System.Data.DbType.String, param.prxPsw);
            DALObject.CreateParameter(cmd, "@UrlProxy", System.Data.DbType.String, param.prxUrl);
            DALObject.CreateParameter(cmd, "@UsuarioProxy", System.Data.DbType.String, param.prxUsr);

            DALObject.CreateParameter(cmd, "@TimeOut", System.Data.DbType.Int32, param.timeout);
            DALObject.CreateParameter(cmd, "@NomeCertificado", System.Data.DbType.String, param.certificado);
            DALObject.CreateParameter(cmd, "@WService", System.Data.DbType.Boolean, param.usaWService);
            DALObject.CreateParameter(cmd, "@versao", System.Data.DbType.Int32, param.versao);
        }
Example #34
0
              public Basiclist(System.Data.IDbConnection connection, string volumename)
              {
                m_connection = connection;
                m_volumename = volumename;
                m_transaction = m_connection.BeginTransaction();
                var tablename = TABLE_PREFIX + "-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());

                using(var cmd = m_connection.CreateCommand())
                {
                    cmd.Transaction = m_transaction;
                    cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" {1}", tablename, TABLEFORMAT));
                    m_tablename = tablename;
                }
                
                m_insertCommand = m_connection.CreateCommand();
                m_insertCommand.Transaction = m_transaction;
                m_insertCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" {1}", m_tablename, INSERTCOMMAND);
                m_insertCommand.AddParameters(INSERTARGUMENTS);
            }
Example #35
0
 public override void Write(object @object, int i, System.Data.IDbCommand preparedStatement) /* throws System.Exception */
 {
 }
 public void Commit(ILogWriter log)
 {
     var tr = m_insertblockCommand.Transaction;
     m_insertblockCommand.Dispose();
     m_insertblockCommand = null;
     using (new Logging.Timer("CommitBlockMarker"))
         tr.Commit();
     tr.Dispose();
 }
Example #37
0
 public void SetLastCommand(System.Data.IDbCommand command)
 {
     LastCommand = command;
 }
            public DirectBlockMarker(System.Data.IDbConnection connection, string blocktablename, string filetablename, string statstablename)
            {
                m_insertblockCommand = connection.CreateCommand();
                m_resetfileCommand = connection.CreateCommand();
                m_updateAsRestoredCommand = connection.CreateCommand();
                m_updateFileAsDataVerifiedCommand = connection.CreateCommand();
                m_statUpdateCommand = connection.CreateCommand();

                m_insertblockCommand.Transaction = connection.BeginTransaction();
                m_resetfileCommand.Transaction = m_insertblockCommand.Transaction;
                m_updateAsRestoredCommand.Transaction = m_insertblockCommand.Transaction;
                m_updateFileAsDataVerifiedCommand.Transaction = m_insertblockCommand.Transaction;
                m_statUpdateCommand.Transaction = m_insertblockCommand.Transaction;

                m_blocktablename = blocktablename;
                m_filetablename = filetablename;

                m_insertblockCommand.CommandText = string.Format(
                      @"UPDATE ""{0}"" SET ""Restored"" = 1 "
                    + @" WHERE ""FileID"" = ? AND ""Index"" = ? AND ""Hash"" = ? AND ""Size"" = ? AND ""Metadata"" = ? AND ""Restored"" = 0 "
                    , m_blocktablename);
                m_insertblockCommand.AddParameters(5);

                m_resetfileCommand.CommandText = string.Format(
                      @"UPDATE ""{0}"" SET ""Restored"" = 0 WHERE ""FileID"" = ? "
                    , m_blocktablename);
                m_resetfileCommand.AddParameters(1);

                m_updateAsRestoredCommand.CommandText = string.Format(
                      @"UPDATE ""{0}"" SET ""Restored"" = 1 WHERE ""FileID"" = ? AND ""Metadata"" <= ? "
                    , m_blocktablename);
                m_updateAsRestoredCommand.AddParameters(2);

                m_updateFileAsDataVerifiedCommand.CommandText = string.Format(
                      @"UPDATE ""{0}"" SET ""DataVerified"" = 1 WHERE ""ID"" = ?"
                    , m_filetablename);
                m_updateFileAsDataVerifiedCommand.AddParameters(1); 

                if (statstablename != null)
                {
                    // Fields in Stats: TotalFiles, TotalBlocks, TotalSize
                    //                  FilesFullyRestored, FilesPartiallyRestored, BlocksRestored, SizeRestored
                    m_statUpdateCommand.CommandText = string.Format(@"SELECT SUM(""FilesFullyRestored""), SUM(""SizeRestored"") FROM ""{0}"" ", statstablename);
                }
                else // very slow fallback if stats tables were not created
                    m_statUpdateCommand.CommandText = string.Format(@"SELECT COUNT(DISTINCT ""FileID""), SUM(""Size"") FROM ""{0}"" WHERE ""Restored"" = 1 ", m_blocktablename);

            }
 public global::UseCase1.SubmissionList ExecuteOne(IDatabaseQuery query, System.Data.IDbCommand command)
 {
     this.cms.Position = 0;
     query.Execute(command, CollectOne);
     return(one);
 }
            public MissingBlockList(string volumename, System.Data.IDbConnection connection, System.Data.IDbTransaction transaction)
            {
                m_connection = connection;
                m_transaction = new TemporaryTransactionWrapper(m_connection, transaction);
                m_volumename = volumename;
                var tablename = "MissingBlocks-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
                using(var cmd = m_connection.CreateCommand())
                {
                    cmd.Transaction = m_transaction.Parent;
                    cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""Hash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL, ""Restored"" INTEGER NOT NULL) ", tablename));
                    m_tablename = tablename;

                    var blockCount = cmd.ExecuteNonQuery(string.Format(@"INSERT INTO ""{0}"" (""Hash"", ""Size"", ""Restored"") SELECT DISTINCT ""Block"".""Hash"", ""Block"".""Size"", 0 AS ""Restored"" FROM ""Block"",""Remotevolume"" WHERE ""Block"".""VolumeID"" = ""Remotevolume"".""ID"" AND ""Remotevolume"".""Name"" = ? ", m_tablename), volumename);
                    if (blockCount == 0)
                        throw new Exception(string.Format("Unexpected empty block volume: {0}", volumename));

                    cmd.ExecuteNonQuery(string.Format(@"CREATE UNIQUE INDEX ""{0}-Ix"" ON ""{0}"" (""Hash"", ""Size"", ""Restored"")", tablename));
                }

                m_insertCommand = m_connection.CreateCommand();
                m_insertCommand.Transaction = m_transaction.Parent;
                m_insertCommand.CommandText = string.Format(@"UPDATE ""{0}"" SET ""Restored"" = ? WHERE ""Hash"" = ? AND ""Size"" = ? AND ""Restored"" = ? ", tablename);
                m_insertCommand.AddParameters(4);
            }
 public List <global::UseCase1.SubmissionList> ExecuteAll(IDatabaseQuery query, System.Data.IDbCommand command)
 {
     this.cms.Position = 0;
     query.Execute(command, CollectAll);
     return(list);
 }
 public StorageHelper(System.Data.IDbConnection con)
 {
     m_connection = con;
     m_previousTable = "Previous-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
     m_currentTable = "Current-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
     
     m_transaction = m_connection.BeginTransaction();
     
     using(var cmd = m_connection.CreateCommand())
     {
         cmd.Transaction = m_transaction;
         
         cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""Path"" TEXT NOT NULL, ""FileHash"" TEXT NULL, ""MetaHash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL, ""Type"" INTEGER NOT NULL) ", m_previousTable));
         cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""Path"" TEXT NOT NULL, ""FileHash"" TEXT NULL, ""MetaHash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL, ""Type"" INTEGER NOT NULL) ", m_currentTable));
     }
     
     m_insertPreviousElementCommand = m_connection.CreateCommand();
     m_insertPreviousElementCommand.Transaction = m_transaction;
     m_insertPreviousElementCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""Path"", ""FileHash"", ""MetaHash"", ""Size"", ""Type"") VALUES (?,?,?,?,?)", m_previousTable);
     m_insertPreviousElementCommand.AddParameters(5);
     
     m_insertCurrentElementCommand = m_connection.CreateCommand();
     m_insertCurrentElementCommand.Transaction = m_transaction;
     m_insertCurrentElementCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""Path"", ""FileHash"", ""MetaHash"", ""Size"", ""Type"") VALUES (?,?,?,?,?)", m_currentTable);
     m_insertCurrentElementCommand.AddParameters(5);
 }
        protected override void CreateInsertParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            NotaInutilizada nota = (NotaInutilizada)businessObject;

            CreateKeyParameters(businessObject, cmd);
            DALObject.CreateParameter(cmd, "@Data", System.Data.DbType.DateTime, nota.data);
            DALObject.CreateParameter(cmd, "@XMLResposta", System.Data.DbType.String, nota.XMLResposta);
            DALObject.CreateParameter(cmd, "@XMLPedido", System.Data.DbType.String, nota.XMLPedido);
        }
Example #44
0
			public BlockQuery(System.Data.IDbConnection con, Options options, System.Data.IDbTransaction transaction)
			{
				m_command = con.CreateCommand();
				m_command.Transaction = transaction;
				
				if (options.BlockHashLookupMemory > 0)
				{
					m_lookup = new HashLookupHelper<long>((ulong)options.BlockHashLookupMemory);
					using(var reader = m_command.ExecuteReader(@"SELECT ""Hash"", ""Size"" FROM ""Block"" "))
					while (reader.Read())
					{
						var hash = reader.GetValue(0).ToString();
						var size = Convert.ToInt64(reader.GetValue(1));
						m_lookup.Add(hash, size, size);
					}
				}
				
				m_command.Parameters.Clear();
				m_command.CommandText = @"SELECT ""VolumeID"" FROM ""Block"" WHERE ""Hash"" = ? AND ""Size"" = ? ";
				m_command.AddParameters(2);
			}
        protected override void CreateUpdateParameters(BusinessObject businessObject, System.Data.IDbCommand cmd)
        {
            Evento oEvento = (Evento)businessObject;

            CreateKeyParameters(businessObject, cmd);
            DALObject.CreateParameter(cmd, "@situacao", System.Data.DbType.Int32, oEvento.codigoSituacao);
            DALObject.CreateParameter(cmd, "@tpEvento", System.Data.DbType.Int32, oEvento.tpEvento);
            DALObject.CreateParameter(cmd, "@xmlProcesso", System.Data.DbType.String, oEvento.XMLResposta);
            DALObject.CreateParameter(cmd, "@XMLPedido", System.Data.DbType.String, oEvento.XMLPedido);
        }
 public override object ExecuteInsert(Database db, System.Data.IDbCommand cmd, string primaryKeyName)
 {
     return(db.ExecuteScalarHelper(cmd));
 }
 public override System.Threading.Tasks.Task <int> ExecuteNonQueryAsync(System.Data.IDbCommand cmd, System.Threading.CancellationToken token = default(System.Threading.CancellationToken)) => throw null;