public void DeleteOrganisationKey(OrganisationKey organisationKey)
 {
     try
     {
         SqlParameter[] sqlParameters = new SqlParameter[]
         {
             new SqlParameter(OrganisationKeyParameter.ID, GetDBValue(organisationKey.Id))
         };
         string sqlQuery = string.Format("DELETE FROM {0} WHERE {1} = {2}", TableName,
                                         OrganisationKeyColumn.ID,
                                         OrganisationKeyParameter.ID);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(sqlQuery, sqlParameters,
                                                               connectionString))
         {
             mssqlDbEngine.ExecuteQuery();
         }
     }
     catch (Exception exception)
     {
         string eMessage = string.Format("Error encountered when executing {0} function in OrganisationKeyRepositoryMsSql. Error\n{1}",
                                         "Delete-OrganisationKey", exception.Message);
         WriteErrorLog(eMessage);
         throw;
     }
 }
Esempio n. 2
0
        public List <MessageDispatch> GetDispatchesBetweenSenderReceiver(string senderEmailAddress,
                                                                         string receiverEmailAddress,
                                                                         long messageIdThreshold,
                                                                         int numberOfMessages)
        {
            try
            {
                QueryBody queryBody = GetDispathedBetweenSenderReceiverQuery(senderEmailAddress, receiverEmailAddress,
                                                                             messageIdThreshold);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(queryBody.Query, queryBody.Parameters,
                                                                      connectionString))
                {
                    List <MessageDispatch> dispatches = new List <MessageDispatch>();
                    mssqlDbEngine.ExecuteReaderQuery(dispatches, OnPopulateResultListCallBack);
                    return(dispatches);
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "GetAlldispatchesBetweenSenderReceiver", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
Esempio n. 3
0
        public void DeleteDispatch(MessageDispatch dispatch)
        {
            try
            {
                SqlParameter[] sqlParameters = new SqlParameter[]
                {
                    new SqlParameter(MessageDispatchParameter.ID, GetDBValue(dispatch.Id))
                };

                string sqlQuery = string.Format("DELETE FROM {0} WHERE {1} = {2}", TableName,
                                                MessageDispatchColumn.ID,
                                                MessageDispatchParameter.ID);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(sqlQuery, sqlParameters,
                                                                      connectionString))
                {
                    mssqlDbEngine.ExecuteQuery();
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "Deletedispatch", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
        protected MssqlDbEngine GetMssqlDbEngine(string query, SqlParameter[] mssqlParameters,
                                                 string connectionString)
        {
            if (transactionModeEnabled &&
                repoTransaction != null)
            {
                MssqlDbEngine transactionMssqlEngine = new MssqlDbEngine(query, mssqlParameters,
                                                                         connectionString,
                                                                         repoTransaction);
                return(transactionMssqlEngine);
            }
            MssqlDbEngine mssqlDbEngine = new MssqlDbEngine(query, mssqlParameters,
                                                            connectionString);

            return(mssqlDbEngine);
        }
 public void UpdateOrganisationKey(OrganisationKey organisationKey)
 {
     try
     {
         Tuple <string, SqlParameter[]> query = GetUpdateOrganisationKeyQuery(organisationKey);
         using (MssqlDbEngine dbEngine = GetMssqlDbEngine(query.Item1, query.Item2,
                                                          connectionString))
         {
             dbEngine.ExecuteQuery();
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in OrganisationKeyRepositoryMsSql. Error\n{1}",
                                        "Update-OrganisationKey", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 6
0
 public void UpdateAccess(Access access)
 {
     try
     {
         QueryBody query = GetUpdateAccessQuery(access);
         using (MssqlDbEngine dbEngine = GetMssqlDbEngine(query.Query, query.Parameters,
                                                          connectionString))
         {
             dbEngine.ExecuteQuery();
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in AccessRepositoryMsSql. Error\n{1}",
                                        "Update-Access", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 7
0
 public void UpdateMessage(Message message) // Tuple<string, TParameter[]> query where TParameter : IDbDataParameter
 {
     try
     {
         Tuple <string, SqlParameter[]> query = GetUpdateQuery(message);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Item1, query.Item2,
                                                               connectionString))
         {
             mssqlDbEngine.ExecuteQuery();
         }
     }
     catch (Exception exception)
     {
         string eMessage = string.Format("Error encountered when executing {0} function in MessageRepositoryMsSql. Error\n{1}",
                                         "UpdateMessage", exception.Message);
         WriteErrorLog(eMessage);
         throw;
     }
 }
Esempio n. 8
0
 public void InsertMessage(Message message)
 {
     try
     {
         Tuple <string, SqlParameter[]> query = GetInsertQuery(message);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Item1, query.Item2,
                                                               connectionString))
         {
             mssqlDbEngine.ExecuteQueryInsertCallback(message, OnPopulateIdCallBack);
         }
     }
     catch (Exception exception)
     {
         string eMessage = string.Format("Error encountered when executing {0} function in MessageRepositoryMsSql. Error\n{1}",
                                         "InsertMessage", exception.Message);
         WriteErrorLog(eMessage);
         throw;
     }
 }
 public void DeleteAuthorisation(Authorisation authorisation)
 {
     try
     {
         QueryBody query = GetDeletionAuthorisationQuery(authorisation);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Query, query.Parameters,
                                                               connectionString))
         {
             mssqlDbEngine.ExecuteQuery();
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} in AuthorisationRepositoryMsSql. Error\n{1}",
                                        "Delete-Authorisation",
                                        exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 10
0
        public void UpdateDispatch(MessageDispatch dispatch) // Tuple<string, IDbDataParameter[]> query where TParameter : IDbDataParameter
        {
            try
            {
                QueryBody queryBody = GetDefaultDispatchUpdateQuery(dispatch);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(queryBody.Query, queryBody.Parameters,
                                                                      connectionString))
                {
                    mssqlDbEngine.ExecuteQuery();
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "Updatedispatch", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
Esempio n. 11
0
        public void InsertDispatch(MessageDispatch dispatch)
        {
            try
            {
                QueryBody queryBody = GetDispatchInsertQuery(dispatch);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(queryBody.Query, queryBody.Parameters,
                                                                      connectionString))
                {
                    mssqlDbEngine.ExecuteQueryInsertCallback(dispatch, OnPopulateIdCallBack);
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "Insertdispatch", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
 public OrganisationKey GetOrganisationKeyMatchingName(string name)
 {
     try
     {
         Tuple <string, SqlParameter[]> query = GetOrganisationKeyMatchingNameQuery(name);
         using (MssqlDbEngine dbEngine = GetMssqlDbEngine(query.Item1, query.Item2,
                                                          connectionString))
         {
             List <OrganisationKey> organisationKies = new List <OrganisationKey>();
             dbEngine.ExecuteReaderQuery(organisationKies, OnPopulateResultListCallBack);
             return(organisationKies.FirstOrDefault());
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in OrganisationKeyRepositoryMsSql. Error\n{1}",
                                        "Get-OrganisationKey-Matching-Name", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 13
0
 public Access GetAccessMatchingToken(string token)
 {
     try
     {
         QueryBody query = GetAccessMatchingTokenQuery(token);
         using (MssqlDbEngine dbEngine = GetMssqlDbEngine(query.Query, query.Parameters,
                                                          connectionString))
         {
             List <Access> accesses = new List <Access>();
             dbEngine.ExecuteReaderQuery(accesses, OnPopulateResultListCallBack);
             return(accesses.FirstOrDefault());
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in AccessRepositoryMsSql. Error\n{1}",
                                        "Get-Access-Matching-Token", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 14
0
 public List <Message> GetMessagesMatchingText(string text)
 {
     try
     {
         Tuple <string, SqlParameter[]> query = GetMessageMatchingTextQuery(text);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Item1, query.Item2,
                                                               connectionString))
         {
             List <Message> messages = new List <Message>();
             mssqlDbEngine.ExecuteReaderQuery(messages, OnPopulateResultListCallBack);
             return(messages);
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in MessageRepositoryMsSql. Error\n{1}",
                                        "GetMessagesMatchingText", exception.Message);
         WriteErrorLog(message);
         throw;
     }
 }
 public List <Authorisation> GetAuthorisationsGreaterThanEndTime(DateTime endtime)
 {
     try
     {
         QueryBody query = GetAuthorisationGreaterThanEndTimeQuery(endtime);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Query, query.Parameters,
                                                               connectionString))
         {
             List <Authorisation> authorisations = new List <Authorisation>();
             mssqlDbEngine.ExecuteReaderQuery(authorisations, OnPopulateResultListCallBack);
             return(authorisations);
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in AuthorsationRepositoryMsSql. Error\n{1}",
                                        "Get-Authorisation-Greater-Than-EndTime", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
 public Authorisation GetAuthorisationMatchingId(long id)
 {
     try
     {
         QueryBody query = GetAuthorisationMatchingIdQuery(id);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query.Query, query.Parameters,
                                                               connectionString))
         {
             List <Authorisation> authorisations = new List <Authorisation>();
             mssqlDbEngine.ExecuteReaderQuery(authorisations, OnPopulateResultListCallBack);
             return(authorisations.FirstOrDefault());
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in AuthorsationRepositoryMsSql. Error\n{1}",
                                        "Get-Authorisation-Matching-Id", exception.ToString());
         WriteErrorLog(message);
         throw;
     }
 }
Esempio n. 17
0
        public List <MessageDispatch> GetDispatchesNotReceivedMatchingEmail(string email)
        {
            try
            {
                QueryBody queryBody = GetDispatchesNotReceivedMatchingEmailQuery(email);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(queryBody.Query, queryBody.Parameters,
                                                                      connectionString))
                {
                    List <MessageDispatch> dispatches = new List <MessageDispatch>();
                    mssqlDbEngine.ExecuteReaderQuery(dispatches, OnPopulateResultListCallBack);
                    return(dispatches);
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "GetDispatchesNotReceivedMatchingEmail", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
Esempio n. 18
0
        public MessageDispatch GetDispatchMatchingId(long dispatchId)
        {
            try
            {
                QueryBody queryBody = GetdispatchMatchingIdQuery(dispatchId);

                using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(queryBody.Query, queryBody.Parameters,
                                                                      connectionString))
                {
                    List <MessageDispatch> dispatches = new List <MessageDispatch>();
                    mssqlDbEngine.ExecuteReaderQuery(dispatches, OnPopulateResultListCallBack);
                    return(dispatches.FirstOrDefault());
                }
            }
            catch (Exception exception)
            {
                string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                               "GetdispatchMatchingId", exception.Message);
                WriteErrorLog(message);
                throw;
            }
        }
Esempio n. 19
0
 public List <MessageDispatch> GetAllDispatches()
 {
     try
     {
         string columns = GetSelectColumns(dispatchIdColumn);
         string query   = string.Format("SELECT {0} FROM {1}", columns,
                                        TableName);
         using (MssqlDbEngine mssqlDbEngine = GetMssqlDbEngine(query, null,
                                                               connectionString))
         {
             List <MessageDispatch> dispatches = new List <MessageDispatch>();
             mssqlDbEngine.ExecuteReaderQuery(dispatches, OnPopulateResultListCallBack);
             return(dispatches);
         }
     }
     catch (Exception exception)
     {
         string message = string.Format("Error encountered when executing {0} function in MessageDispatchRepositoryMsSql. Error\n{1}",
                                        "GetAllDispatches", exception.Message);
         WriteErrorLog(message);
         throw;
     }
 }