public void UpdateDataFileSource(IDataInterface dataInterface, string dataSourceFileName) { var connectionBuilder = DataInterfaceManager.GetBlaiseConnectionStringBuilder(); connectionBuilder.DataSource = dataSourceFileName; dataInterface.ConnectionInfo.SetConnectionString(connectionBuilder.ConnectionString); }
static void Main(string[] args) { DataInterfaceManager dim = new DataInterfaceManager(); DateTime refDate = new DateTime(); dim.generateParaXml(refDate); }
public IDataInterface GetDataInterfaceForFile(string dataSourceFileName) { var dataInterface = DataInterfaceManager.GetDataInterface(); dataInterface.ConnectionInfo.DataSourceType = DataSourceType.Blaise; dataInterface.ConnectionInfo.DataProviderType = DataProviderType.BlaiseDataProviderForDotNET; dataInterface.DataPartitionType = DataPartitionType.Stream; var connectionBuilder = DataInterfaceManager.GetBlaiseConnectionStringBuilder(); connectionBuilder.DataSource = dataSourceFileName; dataInterface.ConnectionInfo.SetConnectionString(connectionBuilder.ConnectionString); return(dataInterface); }
public IGeneralDataInterface GetSettingsDataInterfaceForSql(string databaseConnectionString, ApplicationType applicationType) { var dataInterface = DataInterfaceManager.Create(applicationType); dataInterface.ConnectionInfo.DataSourceType = DataSourceType.MySQL; dataInterface.ConnectionInfo.DataProviderType = DataProviderType.MySQLDataProvider; var connectionBuilder = DataInterfaceManager.GetBlaiseConnectionStringBuilder(); connectionBuilder.ConnectionString = databaseConnectionString; dataInterface.ConnectionInfo.SetConnectionString(connectionBuilder.ConnectionString); return(dataInterface); }
public IDataInterface GetDataInterfaceForSql(string databaseConnectionString) { var dataInterface = DataInterfaceManager.GetDataInterface(); dataInterface.ConnectionInfo.DataSourceType = DataSourceType.MySQL; dataInterface.ConnectionInfo.DataProviderType = DataProviderType.MySQLDataProvider; dataInterface.DataPartitionType = DataPartitionType.Stream; var connectionStringBuilder = DataInterfaceManager.GetBlaiseConnectionStringBuilder(); connectionStringBuilder.ConnectionString = databaseConnectionString; dataInterface.ConnectionInfo.SetConnectionString(connectionStringBuilder.ConnectionString); return(dataInterface); }
private void batchPLBtn_Click(object sender, RoutedEventArgs e) { //PL_Calculator pl_cal = new PL_Calculator(); //pl_cal.dataLoad(); //pl_cal.doDBInsertJob(); SettingInitializer ini = new SettingInitializer(); ini.initialze(1); OutputLogViewModel.OutputList_ = new System.Collections.ObjectModel.ObservableCollection <IOutput>(); DataInterfaceManager dim = new DataInterfaceManager(); //DateTime refDate = new DateTime(); DateTime refDate = DateTime.Now; dim.generateParaXml(refDate); }
/// <summary> /// Method for consuming and processing messages on the RabbitMQ queue. /// </summary> public void ConsumeMessage() { // Objects for working with Blaise data sets. IDataLink4 dl_source = null; IDatamodel dm_source = null; IDataLink4 dl_dest_sql = null; IDataLink dl_dest_file = null; // Functionality to be performed when a message is received. (digestion) consumer.Received += (model, ea) => { // Extract the message and encode it. var body = ea.Body; var message = Encoding.UTF8.GetString(body); log.Info("Message received - " + message); MessageData data = null; try { // Take the serialized JSON string and deserialize it into a MessageData object. data = new JavaScriptSerializer().Deserialize <MessageData>(message); // Connect to the Blaise source data set. dl_source = GetDataLink(data.source_hostname, data.source_instrument, data.source_server_park); dm_source = dl_source.Datamodel; // Identify the primary key in the source data set. var key = DataRecordManager.GetKey(dm_source, "PRIMARY"); // Assign the primary key the value of the 'serial_number' recieved from the RabbitMQ message. key.Fields[0].DataValue.Assign(data.serial_number); // Check if a case with this key exists in the source data set. if (dl_source.KeyExists(key)) { // Read in the case. var case_record = dl_source.ReadRecord(key); if (data.action == "delete") { dl_source.Delete(key); SendStatus(MakeStatusJson(data, "Case Deleted")); } else { // Connect to the Blaise sql database destination data set if provided in payload. if ((data.dest_hostname != "" && data.dest_hostname != null) && (data.dest_server_park != "" && data.dest_server_park != null)) { dl_dest_sql = GetDataLink(data.dest_hostname, data.dest_instrument, data.dest_server_park); // Copy or move the case from the source to destination based on the 'action' received from the message. switch (data.action) { // Copy action received. case "copy": dl_dest_sql.Write(case_record); if (!dl_dest_sql.KeyExists(key)) { SendStatus(MakeStatusJson(data, "Error")); log.Error(data.dest_instrument + " case " + data.serial_number + " NOT copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_server_park + "@" + data.dest_hostname + "."); } if (dl_dest_sql.KeyExists(key)) { SendStatus(MakeStatusJson(data, "Case Copied")); log.Info(data.dest_instrument + " case " + data.serial_number + " copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_server_park + "@" + data.dest_hostname + "."); } break; // Move action received. case "move": dl_dest_sql.Write(case_record); dl_source.Delete(key); if (!dl_dest_sql.KeyExists(key)) { SendStatus(MakeStatusJson(data, "Error")); log.Error(data.dest_instrument + " case " + data.serial_number + " NOT moved from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_server_park + "@" + data.dest_hostname + "."); } if ((dl_dest_sql.KeyExists(key)) && (dl_source.KeyExists(key))) { SendStatus(MakeStatusJson(data, "Warn")); log.Warn(data.dest_instrument + " case " + data.serial_number + " copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_server_park + "@" + data.dest_hostname + " but also still exists in " + data.source_server_park + "@" + data.source_hostname + "."); } if ((dl_dest_sql.KeyExists(key)) && (!dl_source.KeyExists(key))) { SendStatus(MakeStatusJson(data, "Case Moved")); log.Info(data.dest_instrument + " case " + data.serial_number + " moved from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_server_park + "@" + data.dest_hostname + "."); } break; // Invalid action received. default: SendStatus(MakeStatusJson(data, "Invalid Action")); log.Error("Invalid action requested - " + data.action); break; } } // Connect to the Blaise file database destination data set if provided in payload. if (data.dest_filepath != "" && data.dest_filepath != null) { // Check destination file database exists, and if not create it. if (!File.Exists(data.dest_filepath + "\\" + data.dest_instrument + ".bdbx")) { // Get source BMI and BDI to setup new file destination data set. string sourceBMI = GetSourceBMI(data.source_hostname, data.source_server_park, data.source_instrument); string sourceBDI = GetSourceBDI(data.source_hostname, data.source_server_park, data.source_instrument); // Create source directory from destination file path recieved in payload. Directory.CreateDirectory(data.dest_filepath); // Copy BMI from source to destination file path recieved in payload. File.Copy(sourceBMI, data.dest_filepath + "\\" + data.dest_instrument + ".bmix", true); // Create destination file data set. IDataInterface di = DataInterfaceManager.GetDataInterface(); di.ConnectionInfo.DataSourceType = DataSourceType.Blaise; di.ConnectionInfo.DataProviderType = DataProviderType.BlaiseDataProviderForDotNET; di.DataPartitionType = DataPartitionType.Stream; IBlaiseConnectionStringBuilder csb = DataInterfaceManager.GetBlaiseConnectionStringBuilder(); csb.DataSource = data.dest_filepath + "\\" + data.dest_instrument + ".bdbx"; di.ConnectionInfo.SetConnectionString(csb.ConnectionString); di.DatamodelFileName = data.dest_filepath + "\\" + data.dest_instrument + ".bmix"; di.FileName = data.dest_filepath + "\\" + data.dest_instrument + ".bdix"; di.CreateTableDefinitions(); di.CreateDatabaseObjects(null, true); di.SaveToFile(true); } // Connect to the Blaise file database destination data set. dl_dest_file = DataLinkManager.GetDataLink(data.dest_filepath + "\\" + data.dest_instrument + ".bdix"); // Copy or move the case from the source to destination based on the 'action' received from the message. switch (data.action) { // Copy action received. case "copy": dl_dest_file.Write(case_record); if (dl_dest_file.ReadRecord(key) == null) { SendStatus(MakeStatusJson(data, "Error")); log.Error(data.dest_instrument + " case " + data.serial_number + " NOT copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_filepath + "."); } if (dl_dest_file.ReadRecord(key) != null) { SendStatus(MakeStatusJson(data, "Case Copied")); log.Info(data.dest_instrument + " case " + data.serial_number + " copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_filepath + "."); } break; // Move action received. case "move": dl_dest_file.Write(case_record); dl_source.Delete(key); if (dl_dest_file.ReadRecord(key) == null) { SendStatus(MakeStatusJson(data, "Error")); log.Error(data.dest_instrument + " case " + data.serial_number + " NOT moved from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_filepath + "."); } if ((dl_dest_file.ReadRecord(key) != null) && (dl_source.KeyExists(key))) { SendStatus(MakeStatusJson(data, "Warn")); log.Warn(data.dest_instrument + " case " + data.serial_number + " copied from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_filepath + " but also still exists in " + data.source_server_park + "@" + data.source_hostname + "."); } if ((dl_dest_file.ReadRecord(key) != null) && (!dl_source.KeyExists(key))) { SendStatus(MakeStatusJson(data, "Case Moved")); log.Info(data.dest_instrument + " case " + data.serial_number + " moved from " + data.source_server_park + "@" + data.source_hostname + " to " + data.dest_filepath + "."); } break; // Invalid action received. default: SendStatus(MakeStatusJson(data, "Invalid Action")); log.Error("Invalid action requested - " + data.action); break; } } } } else { SendStatus(MakeStatusJson(data, "Case NOT Found")); log.Error("Case " + data.serial_number.ToString() + " doesn't exist in source database."); } } catch (Exception e) { SendStatus(MakeStatusJson(data, "Error")); log.Error(e); } // Remove from queue when done processing channel.BasicAck(ea.DeliveryTag, false); }; // Consume and process any messages already held on the queue. string queueName = ConfigurationManager.AppSettings["HandlerQueueName"]; channel.BasicConsume(queue: queueName, autoAck: false, consumer: consumer); }