public static void WriteQueueToXml(IDataQueue queue, Stream fw, string dbName, string tableName) { DataTable table = ConnTools.DataTableFromStructure(queue.GetRowFormat); table.TableName = tableName; List <string> fldnames = new List <string>(); foreach (IColumnStructure col in queue.GetRowFormat.Columns) { fldnames.Add(col.ColumnName); } XmlWriter xw = XmlTextWriter.Create(fw, new XmlWriterSettings { Encoding = Encoding.UTF8, CheckCharacters = false }); //XmlTextWriter xw = new XmlTextWriter(fw, Encoding.UTF8); //xw.Settings = new XmlWriterSettings { CheckCharacters = false }; xw.WriteStartDocument(); xw.WriteStartElement(dbName); // mono has bug in writing schema if (!Core.IsMono) { table.WriteXmlSchema(xw); } List <string> ids = new List <string>(); foreach (IColumnStructure col in queue.GetRowFormat.Columns) { ids.Add(XmlTool.NormalizeIdentifier(col.ColumnName)); } try { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); xw.WriteStartElement(tableName); for (int i = 0; i < row.FieldCount; i++) { row.ReadValue(i); var type = row.GetFieldType(); if (type == TypeStorage.Null) { continue; } xw.WriteElementString(ids[i], XmlTool.ObjectToString(row.GetValue(i))); } xw.WriteEndElement(); } } finally { queue.CloseReading(); } xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); }
public virtual void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var colnames = from c in queue.GetRowFormat.Columns select c.ColumnName; bool autoinc = queue.GetRowFormat.FindAutoIncrementColumn() != null; if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, true); } try { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); m_dmp.PutCmd("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); } } finally { queue.CloseReading(); } if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, false); } }
private void DoRead(IDataQueue queue) { try { int page = 0; do { while (page < m_directory.Count) { lock (m_directory) { BinaryReader br = new BinaryReader(m_cache); m_cache.Seek(m_directory[page], SeekOrigin.Begin); ChunkInfo info = ChunkInfo.LoadInfo(br); for (int i = 0; i < info.Count; i++) { queue.PutRecord(BedTool.LoadRecord(br, m_table)); } } page++; } if (State == TabularDataViewState.Loading) { System.Threading.Thread.Sleep(100); } } while (State == TabularDataViewState.Loading); queue.PutEof(); } finally { queue.CloseWriting(); } }
void DoWrite(IDataQueue queue) { TableStructure ts; if (m_create_table) { ts = new TableStructure(queue.GetRowFormat); ts.FullName = new NameWithSchema(m_schema, m_tblname); m_conn.SystemConnection.SafeChangeDatabase(m_dbname); m_conn.RunScript(dmp => { dmp.CreateTable(ts); }); } else { ts = new TableStructure(DoGetRowFormat()); } IBulkInserter inserter = m_conn.Dialect.CreateBulkInserter(); inserter.Connection = m_conn; inserter.CopyOptions = CopyOptions.Clone(); inserter.DatabaseName = m_dbname; inserter.DestinationTable = ts; inserter.ProgressInfo = ProgressInfo; inserter.Run(queue); }
/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="prepareToSendQueue">The service bus queue for preparing to send notifications.</param> /// <param name="dataQueue">The service bus queue for the data queue.</param> /// <param name="dataQueueMessageOptions">The options for the data queue messages.</param> /// <param name="groupsService">The groups service.</param> /// <param name="exportDataRepository">The Export data repository instance.</param> /// <param name="appCatalogService">App catalog service.</param> /// <param name="appSettingsService">App settings service.</param> /// <param name="userAppOptions">User app options.</param> /// <param name="loggerFactory">The logger factory.</param> public SentNotificationsController( INotificationDataRepository notificationDataRepository, ISentNotificationDataRepository sentNotificationDataRepository, ITeamDataRepository teamDataRepository, IPrepareToSendQueue prepareToSendQueue, IDataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions, IGroupsService groupsService, IExportDataRepository exportDataRepository, IAppCatalogService appCatalogService, IAppSettingsService appSettingsService, IOptions <UserAppOptions> userAppOptions, ILoggerFactory loggerFactory) { if (dataQueueMessageOptions is null) { throw new ArgumentNullException(nameof(dataQueueMessageOptions)); } this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.sentNotificationDataRepository = sentNotificationDataRepository ?? throw new ArgumentNullException(nameof(sentNotificationDataRepository)); this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.prepareToSendQueue = prepareToSendQueue ?? throw new ArgumentNullException(nameof(prepareToSendQueue)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; this.groupsService = groupsService ?? throw new ArgumentNullException(nameof(groupsService)); this.exportDataRepository = exportDataRepository ?? throw new ArgumentNullException(nameof(exportDataRepository)); this.appCatalogService = appCatalogService ?? throw new ArgumentNullException(nameof(appCatalogService)); this.appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); this.userAppOptions = userAppOptions?.Value ?? throw new ArgumentNullException(nameof(userAppOptions)); this.logger = loggerFactory?.CreateLogger <SentNotificationsController>() ?? throw new ArgumentNullException(nameof(loggerFactory)); }
protected override void DoRead(IDataQueue queue) { try { using (CsvReader cr = CreateReader()) { ITableStructure format = GetStructure(cr); IEnumerable <string[]> reader = cr; foreach (string[] row in reader) { queue.PutRecord(new ArrayDataRecord(format, row)); } queue.PutEof(); } } catch (Exception e) { ProgressInfo.LogError(e); queue.PutError(e); } finally { queue.CloseWriting(); } FinalizeBulkCopy(); }
public IAsyncResult BeginRead(AsyncCallback callback, IDataQueue queue) { Action <IDataQueue> readproc = DoRead; IAsyncResult res = readproc.BeginInvoke(queue, callback, null); lock (m_readProcs) { m_readProcs[res] = readproc; } return(res); }
protected override void DoWrite(IDataQueue queue) { using (FileStream fw = new FileStream(GetWorkingFileName(), FileMode.Create)) { XmlDataTool.WriteQueueToXml(queue, fw, "DataSet", "DataRow"); } FinalizeBulkCopy(); }
/// <summary> /// Initializes a new instance of the <see cref="DataAggregationTriggerActivity"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository.</param> /// <param name="dataQueue">The data queue.</param> /// <param name="options">The data queue message options.</param> public DataAggregationTriggerActivity( INotificationDataRepository notificationDataRepository, IDataQueue dataQueue, IOptions <DataQueueMessageOptions> options) { this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.messageDelayInSeconds = options?.Value?.MessageDelayInSeconds ?? throw new ArgumentNullException(nameof(options)); }
/// <summary> /// Initializes a new instance of the <see cref="SendMessageScheduler"/> class. /// </summary> /// <param name="logger">system logger.</param> /// <param name="factory">factory.</param> public SendMessageScheduler(ILogger <SendMessageScheduler> logger, IServiceScopeFactory factory) { this.smslogger = logger; this.notificationDataRepository = factory.CreateScope().ServiceProvider.GetRequiredService <INotificationDataRepository>(); this.sentNotificationDataRepository = factory.CreateScope().ServiceProvider.GetRequiredService <ISentNotificationDataRepository>(); this.prepareToSendQueue = factory.CreateScope().ServiceProvider.GetRequiredService <IPrepareToSendQueue>(); this.dataQueue = factory.CreateScope().ServiceProvider.GetRequiredService <IDataQueue>(); this.forceCompleteMessageDelayInSeconds = 86400; }
private void DoRead(IDataQueue queue) { WantTable(); foreach (var row in m_table.Rows) { queue.PutRecord(row); } queue.PutEof(); }
protected override void RunBulkCopy(IDataQueue queue) { int okRowCount = 0, failRowCount = 0; List <string> insertErrors = new List <string>(); ITableStructure dst = queue.GetRowFormat; var conn = (NpgsqlConnection)Connection.SystemConnection; NpgsqlCommand command = new NpgsqlCommand(Connection.Dialect.GenerateScript(d => d.Put("^copy %f (%,i) ^from ^stdin", DestinationTable.FullName, from c in dst.Columns select c.ColumnName)), conn); NpgsqlCopyIn cin = new NpgsqlCopyIn(command, conn); try { cin.Start(); var fw = new BinaryWriter(cin.CopyStream); while (!queue.IsEof) { IBedRecord rec = queue.GetRecord(); for (int i = 0; i < rec.FieldCount; i++) { if (i > 0) { fw.Write((byte)'\t'); } rec.ReadValue(i); WriteField(rec, fw); } fw.Write((byte)'\r'); fw.Write((byte)'\n'); okRowCount++; } fw.Flush(); cin.End(); } catch (Exception err) { cin.Cancel("canceled"); ProgressInfo.LogMessageDetail( "INSERT", DatAdmin.LogLevel.Error, String.Format("{0}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName)), err.ToString()); throw; } if (failRowCount > 0) { ProgressInfo.LogMessageDetail( "INSERT", DatAdmin.LogLevel.Error, String.Format("{0}, OK:{1}, FAIL:{2}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName), okRowCount, failRowCount), insertErrors.CreateDelimitedText("\r\n") ); } else { ProgressInfo.LogMessage("INSERT", DatAdmin.LogLevel.Info, Texts.Get("s_inserted_into_table$table$rows", "table", DestinationTable.FullName, "rows", okRowCount)); } }
public void SaveFixedData(IDataQueue queue) { InMemoryTable tbl = InMemoryTable.FromEnumerable(queue.GetRowFormat, queue.EnumRows()); if (tbl.Rows.Count == 0) { tbl = null; } SaveFixedData(tbl); }
protected override void DoRead(IDataQueue queue) { using (XmlReader xr = XmlReader.Create(GetWorkingFileName(), new XmlReaderSettings { CheckCharacters = false })) { m_loadedData = XmlDataTool.ReadXmlToQueue(xr, queue, "DataRow"); } FinalizeBulkCopy(); }
public FileConsumer(IDataQueue dataQueue, FileInfo outputFile) { if (!outputFile.Exists) { StreamWriter sw = File.CreateText(outputFile.FullName); sw.Close(); } _dataQueue = dataQueue; _outputFile = outputFile; }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var tdst = m_db.GetTable(table.FullName); ITabularDataStore dstds = tdst.GetDataStoreAndReuse(); dstds.CopyOptions = opts; dstds.ProgressInfo = ProgressInfo; IAsyncResult async = dstds.BeginWrite(null, queue); dstds.EndWrite(async); }
protected override void DoRead(IDataQueue queue) { if (m_table.m_table.FixedData != null) { foreach (var row in m_table.m_table.FixedData.Rows) { queue.PutRecord(row); } } queue.PutEof(); }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var colnames = from c in queue.GetRowFormat.Columns select c.ColumnName; bool autoinc = queue.GetRowFormat.FindAutoIncrementColumn() != null; if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, true); } try { if (Cfg != null && Cfg.JoinInserts) { int rowsInBatch = 0; while (!queue.IsEof) { if (Cfg.BatchLimit > 0 && rowsInBatch >= Cfg.BatchLimit) { m_dmp.EndCommand(); rowsInBatch = 0; } if (rowsInBatch > 0) { m_dmp.Put(";\n"); } IBedRecord row = queue.GetRecord(); m_dmp.Put("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); rowsInBatch++; } if (rowsInBatch > 0) { m_dmp.EndCommand(); } } else { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); m_dmp.PutCmd("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); } } } finally { queue.CloseReading(); } if (autoinc) { m_dmp.AllowIdentityInsert(table.FullName, false); } }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var name = new NameWithSchema(table.FullName.Schema, table.FullName.Name, false); var entry = m_zip.PutNextEntry(XmlTool.NormalizeIdentifier(name.ToString()) + ".drs"); BedDataStats stats = new BedDataStats(); BedTool.WriteQueueToStream(queue, m_zip, stats); ProgressInfo.LogMessage("s_export", LogLevel.Info, Texts.Get("s_exported$table$rows$bytes", "rows", stats.Rows, "bytes", stats.Bytes, "table", table.FullName)); //ZipEntry entry = new ZipEntry(XmlTool.NormalizeIdentifier(table.FullName.ToString()) + ".xml"); //m_zip.PutNextEntry(entry); //XmlTool.WriteQueueToXml(queue, m_zip, "DataSet", "DataRow"); }
/// <summary> /// Initializes a new instance of the <see cref="SentNotificationsController"/> class. /// </summary> /// <param name="channelDataRepository">Channel data repository service that deals with the table storage in azure.</param> /// <param name="notificationDataRepository">Notification data repository service that deals with the table storage in azure.</param> /// <param name="sentNotificationDataRepository">Sent notification data repository.</param> /// <param name="sentNotificationUpdateDataRepository">Sent update notification data repository.</param> /// <param name="sentNotificationDataRepstry">Sent notification data repository to Get Likes.</param> /// <param name="teamDataRepository">Team data repository instance.</param> /// <param name="distributionListDataRepository">DistributionList data repository instance.</param> /// <param name="prepareToSendQueue">The service bus queue for preparing to send notifications.</param> /// <param name="sendQueue">The service bus queue for the send queue.</param> /// <param name="dataQueue">The service bus queue for the data queue.</param> /// <param name="dataQueueMessageOptions">The options for the data queue messages.</param> /// <param name="groupsService">The groups service.</param> /// <param name="memberService">The meber info service.</param> /// <param name="reactionService">The reaction of message service.</param> /// <param name="exportDataRepository">The Export data repository instance.</param> /// <param name="appCatalogService">App catalog service.</param> /// <param name="appSettingsService">App settings service.</param> /// <param name="userAppOptions">User app options.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="configuration">The Configuration.</param> /// <param name="botOptions">bot options.</param> public SentNotificationsController( IChannelDataRepository channelDataRepository, INotificationDataRepository notificationDataRepository, ISentUpdateandDeleteNotificationDataRepository sentNotificationDataRepository, ISentUpdateDataRepository sentNotificationUpdateDataRepository, ISentNotificationDataRepository sentNotificationDataRepstry, ITeamDataRepository teamDataRepository, IDistributionListDataRepository distributionListDataRepository, IPrepareToSendQueue prepareToSendQueue, ISendQueue sendQueue, IDataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions, IGroupsService groupsService, IMessageReactionService reactionService, ITeamMembersService memberService, IExportDataRepository exportDataRepository, IAppCatalogService appCatalogService, IAppSettingsService appSettingsService, IOptions <UserAppOptions> userAppOptions, ILoggerFactory loggerFactory, IConfiguration configuration, IOptions <BotOptions> botOptions) { if (dataQueueMessageOptions is null) { throw new ArgumentNullException(nameof(dataQueueMessageOptions)); } var options = botOptions ?? throw new ArgumentNullException(nameof(botOptions)); this.channelDataRepository = channelDataRepository ?? throw new ArgumentNullException(nameof(channelDataRepository)); this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.sentNotificationDataRepository = sentNotificationDataRepository ?? throw new ArgumentNullException(nameof(sentNotificationDataRepository)); this.sentNotificationUpdateDataRepository = sentNotificationUpdateDataRepository ?? throw new ArgumentException(nameof(sentNotificationUpdateDataRepository)); this.sentNotificationDataRepstry = sentNotificationDataRepstry ?? throw new ArgumentNullException(nameof(sentNotificationDataRepstry)); this.teamDataRepository = teamDataRepository ?? throw new ArgumentNullException(nameof(teamDataRepository)); this.distributionListDataRepository = distributionListDataRepository ?? throw new ArgumentNullException(nameof(distributionListDataRepository)); this.prepareToSendQueue = prepareToSendQueue ?? throw new ArgumentNullException(nameof(prepareToSendQueue)); this.sendQueue = sendQueue ?? throw new ArgumentNullException(nameof(sendQueue)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; this.groupsService = groupsService ?? throw new ArgumentNullException(nameof(groupsService)); this.reactionService = reactionService ?? throw new ArgumentNullException(nameof(reactionService)); this.memberService = memberService ?? throw new ArgumentNullException(nameof(memberService)); this.exportDataRepository = exportDataRepository ?? throw new ArgumentNullException(nameof(exportDataRepository)); this.appCatalogService = appCatalogService ?? throw new ArgumentNullException(nameof(appCatalogService)); this.appSettingsService = appSettingsService ?? throw new ArgumentNullException(nameof(appSettingsService)); this.userAppOptions = userAppOptions?.Value ?? throw new ArgumentNullException(nameof(userAppOptions)); this.logger = loggerFactory?.CreateLogger <SentNotificationsController>() ?? throw new ArgumentNullException(nameof(loggerFactory)); this.account = string.Empty; this.configuration = configuration; }
public static void WriteQueueToStream(IDataQueue queue, Stream fw, BedDataStats stats) { BinaryWriter bw = new BinaryWriter(fw); bw.Write(SIGNATURE); bw.Write((int)2); // version var ts = queue.GetRowFormat; bw.Write7BitEncodedInt(ts.Columns.Count); var pk = ts.FindConstraint <IPrimaryKey>(); foreach (IColumnStructure col in ts.Columns) { bw.Write(col.ColumnName); bw.Write((byte)col.DataType.DefaultStorage); ColFlags flags = 0; if (pk != null && pk.Columns.IndexOfIf(c => c.ColumnName == col.ColumnName) >= 0) { flags |= ColFlags.ISPK; } bw.Write((byte)flags); } MemoryStream rowdata = new MemoryStream(); BinaryWriter bwrow = new BinaryWriter(rowdata); try { while (!queue.IsEof) { rowdata.Position = 0; rowdata.SetLength(0); IBedRecord row = queue.GetRecord(); BedTool.SaveRecord(ts.Columns.Count, row, bwrow); bw.Write7BitEncodedInt((int)rowdata.Length); rowdata.WriteTo(bw.BaseStream); if (stats != null) { stats.Rows++; stats.Bytes += (int)rowdata.Length; stats.Bytes += 4; } } } finally { queue.CloseReading(); } // write EOF mark bw.Write7BitEncodedInt(-1); }
/// <summary> /// Initializes a new instance of the <see cref="QueueScheduledMessage"/> class. /// </summary> /// <param name="notificationDataRepository">Notification data repository.</param> /// <param name="prepareToSendQueue">Prepare to send queue service.</param> /// <param name="dataQueue">data queue service.</param> /// <param name="dataQueueMessageOptions">data que message option service.</param> public QueueScheduledMessage( INotificationDataRepository notificationDataRepository, IPrepareToSendQueue prepareToSendQueue, IDataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions) { if (dataQueueMessageOptions is null) { throw new ArgumentNullException(nameof(dataQueueMessageOptions)); } this.notificationDataRepository = notificationDataRepository ?? throw new ArgumentNullException(nameof(notificationDataRepository)); this.prepareToSendQueue = prepareToSendQueue ?? throw new ArgumentNullException(nameof(prepareToSendQueue)); this.dataQueue = dataQueue ?? throw new ArgumentNullException(nameof(dataQueue)); this.forceCompleteMessageDelayInSeconds = dataQueueMessageOptions.Value.ForceCompleteMessageDelayInSeconds; }
public FileProducer(IDataQueue dataQueue, FileInfo inputFileInfo) { // Check the input file exists if (!inputFileInfo.Exists) { throw new Exception($"File {inputFileInfo.FullName} passed to producer doesn't exist!"); } _dataQueue = dataQueue; _inputFileInfo = inputFileInfo; _producerThread = new Thread(RunProducer); }
private void DoFillOnBackground(IDataQueue queue) { try { m_state = TabularDataViewState.Loading; //DataTable curbuf = null; Chunk curchunk = null; try { while (!queue.IsEof) { if (curchunk == null) { curchunk = new Chunk(); } IBedRecord rec = queue.GetRecord(); curchunk.SaveRecord(rec); if (curchunk.Count >= BUFFER_SIZE) { FlushChunk(curchunk); curchunk = null; } } } finally { queue.CloseReading(); } if (curchunk != null) { FlushChunk(curchunk); } m_state = TabularDataViewState.Prepared; } catch (Exception e) { Errors.Report(e); m_state = TabularDataViewState.Error; queue.PutError(e); } finally { queue.CloseWriting(); } if (LoadedNextData != null) { LoadedNextData(this, new LoadedNextDataArgs(m_serializedRows)); } }
public static IEnumerable <IBedRecord> EnumRows(this IDataQueue queue) { try { while (!queue.IsEof) { yield return(queue.GetRecord()); } } finally { queue.CloseReading(); } }
public override void Run(IDataQueue queue) { string oldmode = Connection.SystemConnection.ExecuteScalar("SELECT @@SQL_MODE").ToString(); try { Connection.SystemConnection.ExecuteNonQuery("SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'"); base.Run(queue); } finally { Connection.SystemConnection.ExecuteNonQuery("SET SQL_MODE='" + oldmode + "'"); } }
private void DoRead(IDataQueue queue) { try { foreach (var row in m_table.Rows) { queue.PutRecord(row); } queue.PutEof(); } finally { queue.CloseWriting(); } }
protected override void RunBulkCopy(IDataQueue queue) { ITableStructure ts = queue.GetRowFormat; if (ts.Columns.Count == 1) { // SqlBulkCopy has problems when running on tables with one column RunInserts(queue); return; } using (SqlBulkCopy bcp = new SqlBulkCopy((SqlConnection)Connection.SystemConnection, SqlBulkCopyOptions.KeepIdentity | SqlBulkCopyOptions.KeepNulls, null)) { bcp.DestinationTableName = Connection.Dialect.QuoteFullName(DestinationTable.FullName); ITableStructure dst_ts = DestinationTable; if (ts.Columns.Count < dst_ts.Columns.Count) { int srcindex = 0; foreach (var src in ts.Columns) { SqlBulkCopyColumnMapping map = new SqlBulkCopyColumnMapping(srcindex, dst_ts.Columns.IndexOfIf(col => col.ColumnName == src.ColumnName)); bcp.ColumnMappings.Add(map); srcindex++; } } DataQueueReaderAdapter reader = new DataQueueReaderAdapter(queue); try { bcp.BulkCopyTimeout = 0; bcp.WriteToServer(reader); ProgressInfo.LogMessage("INSERT", LogLevel.Info, Texts.Get("s_inserted_into_table$table$rows", "table", DestinationTable.FullName, "rows", reader.ReadedRows)); } catch (Exception err) { ILogger logger = ProgressInfo; if (err is QueueClosedError) { logger = Logging.Root; } logger.LogMessageDetail( "INSERT", LogLevel.Error, String.Format("{0}", Texts.Get("s_error_inserting_into_table$table", "table", DestinationTable.FullName)), err.ToString()); throw; } finally { reader.Close(); } } }
/// <summary> /// Initializes a new instance of the <see cref="DataFunction"/> class. /// </summary> /// <param name="notificationDataRepository">The notification data repository.</param> /// <param name="aggregateSentNotificationDataService">The service to aggregate the Sent /// Notification Data results.</param> /// <param name="updateNotificationDataService">The service to update the notification totals.</param> /// <param name="dataQueue">The data queue.</param> /// <param name="dataQueueMessageOptions">The data queue message options.</param> public DataFunction( INotificationDataRepository notificationDataRepository, AggregateSentNotificationDataService aggregateSentNotificationDataService, UpdateNotificationDataService updateNotificationDataService, IDataQueue dataQueue, IOptions <DataQueueMessageOptions> dataQueueMessageOptions) { this.notificationDataRepository = notificationDataRepository; this.aggregateSentNotificationDataService = aggregateSentNotificationDataService; this.updateNotificationDataService = updateNotificationDataService; this.dataQueue = dataQueue; this.firstTenMinutesRequeueMessageDelayInSeconds = dataQueueMessageOptions.Value.FirstTenMinutesRequeueMessageDelayInSeconds; this.requeueMessageDelayInSeconds = dataQueueMessageOptions.Value.RequeueMessageDelayInSeconds; }
public override void FillTable(ITableStructure table, IDataQueue queue, TableCopyOptions opts) { var colnames = from c in queue.GetRowFormat.Columns select c.ColumnName; try { if (Wcfg != null && Wcfg.ExtendedInserts) { int rowsInBatch = 0; while (!queue.IsEof) { if (Wcfg.BatchLimit > 0 && rowsInBatch >= Wcfg.BatchLimit) { m_dmp.EndCommand(); rowsInBatch = 0; } if (rowsInBatch == 0) { m_dmp.Put("^insert ^into %f (%,i) ^values\n", table, colnames); } else { m_dmp.Put(",\n"); } IBedRecord row = queue.GetRecord(); m_dmp.Put("(%,v)", row); rowsInBatch++; } if (rowsInBatch > 0) { m_dmp.EndCommand(); } } else { while (!queue.IsEof) { IBedRecord row = queue.GetRecord(); m_dmp.PutCmd("^insert ^into %f (%,i) ^values (%,v)", table, colnames, row); } } } finally { queue.CloseReading(); } }