private static string getHL7ValueSEL(HL7Message message, List <MessageGroupInstance> messageGroupInstances, List <MessageGroup> messageGroups, WebservicePropertySet wsProperty ) { // get the ms groups List <MessageGroup> msGroups = ConfigurationUtility.GetIncomingWebserviceMessageGroup(wsProperty, messageGroups); // get segment string type MessageGroupInstance messageGroupInstance = messageGroupInstances.Find(i => i.id == msGroups[ZERO].messageGroupInstanceId); // get the message position for this specific column List <Configuration> configMessagePoisition = ConfigurationDAO.GetMessagePosition(messageGroupInstance); // get the coordinates for the message item string messageCoordinates = HL7MessageUtility.getItemCoordinates(configMessagePoisition); // get segment string type string segmentType = configMessagePoisition[ZERO_ELEMENT].segmentType.name; // get the value for the database inside of the value position string hl7Value = HL7MessageUtility.getValueByPosition( message, HL7MessageUtility.getSegmentType(segmentType), messageCoordinates); return(hl7Value); }
protected override void OnStart(string[] args) { // log ErrorLogger.Log(ErrorLogger.LogType.OUTBOUND_SERVICE_STARTING, DateTime.Now.ToString()); // get all configuration data List <Configuration> configs = ConfigurationDAO.GetApplications(); // get the master configuration Configuration masterConfig = ConfigurationDAO.GetAllConfigurations(); // gets the outgoing webservice configuration only List <Configuration> applications = ConfigurationUtility.GetIncomingWebservice(configs); applications.ForEach(delegate(Configuration appConfig) { OutboundHandler outboundHandler = new OutboundHandler(); string appName = appConfig.application.name; // set the app name outboundHandler.setApplicationName(appName); // set the master config outboundHandler.setMasterConfiguration(masterConfig); // set the static worker outboundHandler.setProcessingWorker(OutboundHandlerDAO.handleProcessingForOutboundHandler); // add to queue and run ThreadPool.QueueUserWorkItem(new WaitCallback(startOutboundProcessing), outboundHandler); }); }
public IActionResult Recuperer_Style() { if (CstSortMusic.Instance.Styles.Count == 0) { ConfigurationDAO.GetStyle(); } return(Ok(CstSortMusic.Instance.Styles)); }
public ActionResult <IEnumerable <string> > CreateConfiguration([FromBody] ConfigurationDTO configuration) { string message = ConfigurationDAO.CreateConfiguration(configuration); if (message == null) { return(new JsonResult(rm.Success(message))); } return(new JsonResult(rm.Error(message))); }
public static void getConfigurerForm(Form form) { try { ConfigurationDAO.getConfigureForm(form); } catch (Exception ex) { throw new Exception("La configuration n'a pas pu se faire:", ex); } }
public static Configuration getReturnConfiguration() { try { return(ConfigurationDAO.getReturnConfiguration()); } catch (Exception ex) { throw new Exception("Impossible de retourner le fichier", ex); } }
public bool getUpdateConfiguration() { try { return(ConfigurationDAO.getUpdateConfiguration(uneConfig)); } catch (Exception ex) { throw new Exception("Echec de modification de fichier", ex); } }
public static void TestService() { // obtain a list of applications List <Application> applications = ApplicationDAO.Get(); // go through each application, get configurations foreach (Application app in applications) { // get the configuration List <Configuration> configurations = ConfigurationDAO.GetApplications(app); } }
public long Add(Model.Register pModel) { var config = new ConfigurationDAO().Get(); if (config != null && config.IdadeIntegracao < pModel.Idade) { int id = DAO.Add(pModel); SendMail(pModel, config); return(id); } throw new System.Exception("Erro ao cadastrar registro, verifique as configurações."); }
public IActionResult Ajouter_Style([FromQuery] string style) { if (!CstSortMusic.Instance.Styles.Contains(style) && !string.IsNullOrEmpty(style)) { CstSortMusic.Instance.Styles.Add(style); ConfigurationDAO.SaveStyle(); return(Ok()); } else { return(BadRequest()); } }
public IActionResult Supprimer_Style([FromQuery] string style) { if (CstSortMusic.Instance.Styles.Contains(style)) { CstSortMusic.Instance.Styles.Remove(style); ConfigurationDAO.SaveStyle(); return(NoContent()); } else { return(NotFound()); } }
private void startInterface(object state) { try { // create new configuration to get all configurations Configuration masterConfiguration = new Configuration(); // get all configurations masterConfiguration = ConfigurationDAO.GetAllConfigurations(); // pass configuration by reference, re-allocated the boject Configuration intConfig = (Configuration)state; // get the interface communication Communication incomingCommunication = intConfig.communication; // get the database communication from the list Communication outgoingCommunication = intConfig.communications[0]; // create new socket Socket socket = new Socket(intConfig.interfaceThread.ipAddress, intConfig.interfaceThread.port, intConfig.interfaceThread.maxConnections, incomingCommunication, outgoingCommunication); // set the master configuration socket.masterConfiguration = masterConfiguration; // set the incoming handler, [Coming to the Service] socket.setIncomingMessageHandler(SocketDAO.handleIncomingHL7MessageToBroker); // set the outgoing handler, [Leaving Service] socket.setOutgoingMessageHandler(SocketDAO.handleOutgoingHL7MessageToBroker); // add the socket to the dictionary so we can access it from OnStop() this.socketDictionary.Add(intConfig.communication.id, socket); // begin listening on the socket socket.Start(); } catch (Exception ex) { ErrorLogger.LogError(ex, "OnStart()", "See windows event log for details"); } }
protected override void OnStart(string[] args) { // log ErrorLogger.Log(ErrorLogger.LogType.INBOUND_SERVICE_STARTING, DateTime.Now.ToString()); // init thread dictionary this.socketDictionary = new Dictionary <int, Socket>(); // get all configuration data List <Configuration> configs = ConfigurationDAO.GetApplications(); // get return all incoming interface configurations List <Configuration> intefaceConfigs = ConfigurationUtility.GetIncomingInterfaces(configs); // start the interfaces by the database config intefaceConfigs.ForEach(delegate(Configuration appConfig) { // get the interfaces for this communication set List <Configuration> interfaces = ConfigurationDAO.GetInterfaceConfigration(appConfig.communication); // for each of the inbound interface threads, start them interfaces.ForEach(delegate(Configuration intConfig) { // get the outgoing database communication id Configuration brokerDBConfig = ConfigurationUtility.GetOutgoingDatabasesByApplicationId(configs, appConfig.application.id); // pass the db communication to the class's communication list since we intConfig.communications = new List <Communication>(); intConfig.communications.Add(brokerDBConfig.communication); // add to queue ThreadPool.QueueUserWorkItem(new WaitCallback(startInterface), intConfig); }); }); }
public void Start() { // based on the communication app id - get a list of applications that match this comm id List <Configuration> configurations = ConfigurationDAO.GetApplications(new Application() { id = this.incomingCommunication.applicationId }); // now get the app settings that are associated to this comm and app id ApplicationSetting appSetting = configurations.Find(c => c.communication.id == this.incomingCommunication.id) .applicationSetting; // changing this item in the db means you need to bounce the service if (appSetting.disabled) { return; } // changing this item in the db means you need to bounce the service if (appSetting.autoStart) { startListener(); } // anything in the while loop doesn't need to be bounced by the service while (true) { // set the broker each loop setBroker(); // check if it's running i.e. waiting/connected this.isStarted = (this.broker.interfaceStatusId == BrokerDAO.WAITING || this.broker.interfaceStatusId == BrokerDAO.CONNECTED); if (this.isStarted) { // if the system is already listening (from autoStart Flag) // begin accepting messages if (this.alreadyListening) { // begin feeding the messages in run(); } else { // otherwise, start the listener (i.e. waiting --> connected) startListener(); } } else { // if the system was already listening, and it's in "stopped" // then this means that someone shutdown the socket - so stop the listener if (this.alreadyListening) { stopListener(); } } // provide blocking on the thread if nothing is going on Thread.Sleep(1000); } }
public List <ConfigurationDTO> GetConfiguration(string value) { ConfigurationDAO dao = new ConfigurationDAO(); return(dao.GetConfiguration(value)); }
private static bool copyOutgoingDatabase(Application inFromApplication, Application inToApplication, string directionType, string communicationType) { try { int toApplicationIdentity = inFromApplication.id; int fromApplicationIdentity = inToApplication.id; // get all applications List <Configuration> applicationList = ConfigurationDAO.GetApplications(new Application() { id = fromApplicationIdentity }); // get all communuication and direction Types Configuration masterConfigration = ConfigurationDAO.GetAllConfigurations(); // get the specific application direction and comm you want Configuration fromApplication = applicationList.Find(a => a.communicationType.name == communicationType && a.directionType.name == directionType); // communication translation identities int toDirectionTypeId = masterConfigration.directionTypes.Find(d => d.name == fromApplication.directionType.name).id; int toCommunicationTypeId = masterConfigration.communicationTypes.Find(c => c.name == fromApplication.communicationType.name).id; // create a new application object with your current application identity Application toApplication = new Application() { id = toApplicationIdentity }; // insert a new communication with your exsisting application Communication toCommunication = CommunicationDAO.PostUpdate(new Communication() { applicationId = toApplication.id, communicationTypeId = toCommunicationTypeId, directionTypeId = toDirectionTypeId }); // get the database_instance information (credential id, name, server, ip) of the communication identity. DatabaseInstance fromDatabaseInstance = masterConfigration.databaseInstances.Find(i => i.communicationId == fromApplication.communication.id); // get database_instance id of the copy from insert into new database_instance with info prior step DatabaseInstance toDatabaseInstance = new DatabaseInstance(); // copy individual values as not top copy the reference (we need it later) toDatabaseInstance = fromDatabaseInstance.ShallowCopy(); // override the communication id w/ the "to" communication id toDatabaseInstance.id = 0; toDatabaseInstance.communicationId = toCommunication.id; // insert new database instance - get the id from this request toDatabaseInstance = DatabaseInstanceDAO.PostUpdate(toDatabaseInstance); // get all database tables from the fromDatabaseInstance List <Configuration> fromDatabaseTables = ConfigurationDAO.GetDatabaseTables(fromDatabaseInstance); // get the database table relations List <DatabaseTableRelation> databaseTableRelations = masterConfigration.databaseTableRelations; // create a new database relation object DatabaseTableRelation databaseTableRelation = new DatabaseTableRelation() { id = 0, requiresIdentity = true, sourceDatabaseTableId = -1, targetDatabaseTableId = -1 }; // foreach table that belongs to the from database_instance, get the from database_table information fromDatabaseTables.ForEach(delegate(Configuration configurationTable) { // extract the database table from the configuration DatabaseTable fromDatabaseTable = new DatabaseTable() { id = configurationTable.databaseTable.id, databaseInstanceId = fromDatabaseInstance.id, name = configurationTable.databaseTable.name }; // create new database table DatabaseTable toDatabaseTable = new DatabaseTable() { databaseInstanceId = toDatabaseInstance.id, name = fromDatabaseTable.name }; // insert new table into database_table with fromDatabaseTable information but use toDatabaseInstanceId toDatabaseTable = DatabaseTableDAO.PostUpdate(toDatabaseTable); // check for prior source relation if (ConfigurationUtility.IsDatabaseTableRelation(configurationTable.databaseTable, databaseTableRelations)) { databaseTableRelation.sourceDatabaseTableId = toDatabaseTable.id; } // check for prior target relation if (ConfigurationUtility.IsDatabaseTableRelation(configurationTable.databaseTable, databaseTableRelations, true)) { databaseTableRelation.targetDatabaseTableId = toDatabaseTable.id; } // based on the fromDatabaseTable get all column sets List <Configuration> fromColumnSets = ConfigurationDAO.GetDatabaseColumns(fromDatabaseTable); // foreach columnset that belongs to fromDatabaseColumn copy all information (except for the fromDatabaseTableId) fromColumnSets.ForEach(delegate(Configuration configurationColumnSet) { // define the column set ColumnSet fromColumnSet = new ColumnSet(); ColumnSet toColumnSet = new ColumnSet(); // get the column set from the configuration list fromColumnSet = configurationColumnSet.columnSet; fromColumnSet.databaseTableId = configurationColumnSet.databaseTable.id; // do a shallow copy of its properties and override the ones you need toColumnSet = fromColumnSet.ShallowCopy(); toColumnSet.id = 0; toColumnSet.databaseTableId = toDatabaseTable.id; // insert new toColumnSet using new toDAtabaseTable.id toColumnSet = ColumnSetDAO.PostUpdate(toColumnSet); }); }); // if relation source or target is not negative one - insert new relation if (databaseTableRelation.sourceDatabaseTableId != -1 && databaseTableRelation.targetDatabaseTableId != -1) { databaseTableRelation = DatabaseTableRelationDAO.PostUpdate(databaseTableRelation); } } catch (Exception ex) { string fromApplicationId = inFromApplication.id.ToString(); string toApplicationId = inToApplication.id.ToString(); ErrorLogger.LogError(ex, "CopyConfigurationUtility.CopyOutgoingDatabase(fromApplication, toApplication, directionType,communicationType)", fromApplicationId + "|" + toApplicationId + "|" + directionType + "|" + communicationType); return(false); } return(true); }
public void UpdateUriToWatchPath(string watherPath) { ConfigurationDAO.UpdateUriToWatchPath(watherPath); }
public string GetUriToWatchPath() { return(ConfigurationDAO.GetUriToWatchPath()); }
public string GetWatcherPath() { return(ConfigurationDAO.GetWatcherPath()); }
public ActionResult <IEnumerable <string> > GetAllCompany(bool isActive) { List <ConfigurationDTO> com = ConfigurationDAO.GetAllConfiguration(isActive); return(new JsonResult(rm.Success(com))); }
public ActionResult <IEnumerable <string> > GetConfigurationById(int id) { ConfigurationDTO com = ConfigurationDAO.GetConfigurationById(id); return(new JsonResult(rm.Success(com))); }
public Configuration() { DAO = new ConfigurationDAO(); }
public List <MailAddressSurrogate> GetRecipients() { return(ConfigurationDAO.GetRecipients()); }
public void UpdateRecipients(List <MailAddressSurrogate> recipients) { ConfigurationDAO.UpdateRecipients(recipients); }
public static void handleOutgoingHL7MessageToBrokerV1(string hl7Input, Communication databaseCommunication, HL7Broker.Model.Socket socket) { Dictionary <int, int> databaseTableRelationDictionary = new Dictionary <int, int>(); // get all database table relations List <DatabaseTableRelation> relations = DatabaseTableRelationDAO.Get(); // this identity is used for multiple inserts int identityNo = -1; // text string baseCommandText = BLANK; string tableName = BLANK; // these will help build the custom query List <string> columns = new List <string>(); List <string> columnValues = new List <string>(); // get message HL7Message hl7Message = socket.getHL7Message(); // get configurations for the database comminucation List <Configuration> configurations = ConfigurationDAO.GetDatabaseConfiguration(databaseCommunication); // get the credential Credential credential = configurations[ZERO_ELEMENT].credential; // get the database instance DatabaseInstance databaseInstance = configurations[ZERO_ELEMENT].databaseInstance; // build the connection string string connectionString = DAOUtility.GetConnectionString(credential, databaseInstance, true); // build database query to insert data into tables based on configuration using (SqlConnection connection = new SqlConnection(connectionString)) { try { // get a list of databses tables List <Configuration> configDatabaseTables = ConfigurationDAO.GetDatabaseTables(databaseInstance); // pick up all the tables for the config configDatabaseTables.ForEach(delegate(Configuration tableConfig) { // empty the db value string dbValue = BLANK; // reset variables baseCommandText = BLANK; // empty the stores columns.Clear(); columnValues.Clear(); SqlCommand command = new SqlCommand(); // set the database table DatabaseTable table = tableConfig.databaseTable; // init database table relation DatabaseTableRelation databaseTableRelation = tableConfig.databaseTableRelation; // based on the table instance id , get the column set List <Configuration> configDatabaseColumns = ConfigurationDAO.GetDatabaseColumns(table); // set the table name tableName = table.name; // for each column, get the column name configDatabaseColumns.ForEach(delegate(Configuration configColumn) { // set the column ColumnSet column = configColumn.columnSet; // get the data type to use SqlDbType sqlDbType = DAOUtility.GetSqlDataType(column.columnDataType); // if it's 0, there must be some special condition here, such as a primary key or handling a specific data type if (column.messageGroupInstanceId == ZERO && column.columnDataType == INTEGER_TYPE) { // if the source table does have a relationship, then we need to get it if (relations.Count(x => x.sourceDatabaseTableId == table.id) > ZERO) { if (column.isPrimaryKey) { // do something here int keyValue = -1; // get the target table based on the source table int targetTableId = relations.Find(r => r.sourceDatabaseTableId == table.id).targetDatabaseTableId; // get the identity databaseTableRelationDictionary.TryGetValue(targetTableId, out keyValue); // set the keyvalue to the db value dbValue = keyValue.ToString(); } else { // Throw Error - there is an issue if the column value is of interger type but no // key is assoicated it it. } } } // if this isn't bound to a column and it's of type text - then it should ALWAYS be an HL7 Message else if (column.messageGroupInstanceId == ZERO && column.columnDataType == TEXT_TYPE) { // apply hl7 message dbValue = hl7Input; } // database column is of current date type, so we set the value to the current date time else if (column.messageGroupInstanceId == ZERO && column.columnDataType == DATE_TYPE) { // set the value to the current date time dbValue = DateTime.Now.ToString(); } // search for it by hl7 position else { // init a message group instance MessageGroupInstance messageGroupInstance = new MessageGroupInstance() { id = column.messageGroupInstanceId }; // reset the message group instance configColumn.messageGroupInstance = messageGroupInstance; // get the message position for this specific column List <Configuration> configMessagePoisition = ConfigurationDAO.GetMessagePosition(configColumn.messageGroupInstance); // get the coordinates for the message item string messageCoordinates = HL7MessageUtility.getItemCoordinates(configMessagePoisition); // get segment string type string columnSegment = configMessagePoisition[ZERO_ELEMENT].segmentType.name; // get the value for the database inside of the value position string hl7Value = HL7MessageUtility.getValueByPosition( hl7Message, HL7MessageUtility.getSegmentType(columnSegment), messageCoordinates); // generate the value dbValue = (!String.IsNullOrEmpty(hl7Value) ? hl7Value : DBNull.Value.ToString()); } // initialize for each new table baseCommandText = DAOUtility.GetBaseQuery(DAOUtility.SERVICE_QUERY_TYPE.INSERT); // add to columns statement columns.Add(column.name); // add to values statement columnValues.Add(AT_SIGN + column.name); // set the command string command.Parameters.Add(AT_SIGN + column.name, sqlDbType); // set the values command.Parameters[AT_SIGN + column.name].Value = dbValue; }); // open the connection connection.Open(); // grab command text command.CommandText = DAOUtility.GetStatement(DAOUtility.SERVICE_QUERY_TYPE.INSERT, baseCommandText, tableName, columns, columnValues); // make new transaction to allow roll back SqlTransaction transaction = connection.BeginTransaction(); // initialize the connection command.Connection = connection; // initialize the transaction command.Transaction = transaction; // handle the database insert for message header instance handleDatabaseTableCaller(connection, command, transaction, hl7Message, table, hl7Input, socket, out identityNo); // if the "database table has dependencies" - store the relation id w/ the table id if (databaseTableRelation.id != ZERO) { // or in better terms - has a dependency that this ide requires if (databaseTableRelation.requiresIdentity) { // add to the dictionary if it does require depdents databaseTableRelationDictionary.Add(table.id, identityNo); } else { // reset if it doesn't need it identityNo = NEG_ONE; } } }); } catch (SqlException sqlex) { ErrorLogger.LogError(sqlex, "handleOutgoingHL7MessageToBroker()", hl7Input); connection.Close(); } } }
public static void TestConfigLoad() { Configuration masterConfig = ConfigurationDAO.GetAllConfigurations(); List <Application> applications = masterConfig.applications; List <Communication> communications = masterConfig.communications; List <WebserviceObject> webserviceObjects = masterConfig.webserviceObjects; List <WebserviceInstance> webserviceInstances = masterConfig.webserviceInstances; List <WebservicePropertySet> webserviceProperties = masterConfig.webservicePropertySets; List <MessageGroup> messageGroups = masterConfig.messageGroups; applications.ForEach(delegate(Application app) { if (app.name != RSERVER) { return; } // get the unprocessed message count for the application List <MessageBucket> brokerInformation = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(app); brokerInformation.ForEach(delegate(MessageBucket broker) { // get the message header and message MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance; Message message = broker.message; // locally retrieve the communication object from memory Communication communication = ConfigurationUtility.GetIncomingWebserviceCommunication(app, communications); // locally retrieve the webservice instance object from memory WebserviceInstance webserviceInstance = ConfigurationUtility.GetIncomingWebserviceInstance(communication, webserviceInstances); // locally retrieve the web service objects from memory List <WebserviceObject> wsObjects = ConfigurationUtility.GetIncomingWebserviceObjects(webserviceInstance, webserviceObjects); // for each object - for each property set for that object - handle accordingly wsObjects.ForEach(delegate(WebserviceObject wsObject) { Console.WriteLine("OBJECT:" + wsObject.name); List <WebservicePropertySet> wsProperties = ConfigurationUtility.GetIncomingWebservicePropertySets(wsObject, webserviceProperties); wsProperties.ForEach(delegate(WebservicePropertySet wsProperty) { Console.WriteLine("Property:" + wsProperty.name); List <MessageGroup> msGroups = ConfigurationUtility.GetIncomingWebserviceMessageGroup(wsProperty, messageGroups); Console.WriteLine("Group Count:" + msGroups.Count); }); }); // update the table to processed // BrokerDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true); }); }); }