コード例 #1
0
        private OrganisationKey OnPopulateResultListCallBack(DbDataReader dataReader)
        {
            OrganisationKey organisationKey = new OrganisationKey();

            PopulateOrganisationKey(organisationKey, dataReader);
            return(organisationKey);
        }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
        private Tuple <string, SqlParameter[]> GetUpdateOrganisationKeyQuery(OrganisationKey organisationKey)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter(OrganisationKeyParameter.ID, GetDBValue(organisationKey.Id)),
                new SqlParameter(OrganisationKeyParameter.NAME, GetDBValue(organisationKey.Name)),
                new SqlParameter(OrganisationKeyParameter.OKEY, GetDBValue(organisationKey.OKey)),
            };

            string updateTable = string.Format("UPDATE {0} SET", TableName);

            string setName = string.Format("{0} = {1}", OrganisationKeyColumn.NAME,
                                           OrganisationKeyParameter.NAME);

            string setOKey = string.Format("{0} = {1}", OrganisationKeyColumn.OKEY,
                                           OrganisationKeyParameter.OKEY);

            string whereId = string.Format("WHERE {0} = {1}", OrganisationKeyColumn.ID,
                                           OrganisationKeyParameter.ID);

            string query = string.Format("{0} {1}, {2} {3}", updateTable,
                                         setName,
                                         setOKey,
                                         whereId);

            return(Tuple.Create(query, parameters));
        }
コード例 #4
0
 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;
     }
 }
コード例 #5
0
        private Tuple <string, SqlParameter[]> InsertOrganisationQuery(OrganisationKey organisationKey)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter(OrganisationKeyParameter.NAME, GetDBValue(organisationKey.Name)),
                new SqlParameter(OrganisationKeyParameter.OKEY, GetDBValue(organisationKey.OKey)),
            };

            string insert = string.Format("INSERT INTO {0}({1}, {2})", TableName,
                                          OrganisationKeyColumn.NAME,
                                          OrganisationKeyColumn.OKEY);

            string values = string.Format("VALUES ({0}, {1})", OrganisationKeyParameter.NAME,
                                          OrganisationKeyParameter.OKEY);

            string stringquery = string.Format("{0} {1}", insert, values);

            return(Tuple.Create(stringquery, parameters));
        }
コード例 #6
0
        private void CheckKeyIsValid(string organisationName, string encrytedRequestOKey)
        {
            IOrganisationKeyRepository organisationKeyRepo = OrganisationKeyRepoFactory.GetOrganisationKeyRepository(DatabaseOption.DatabaseEngine,
                                                                                                                     DatabaseOption.DbConnectionString);
            OrganisationKey organisationKey = organisationKeyRepo.GetOrganisationKeyMatchingName(organisationName);

            if (organisationKey == null)
            {
                throw new ApplicationException("Could not find key matching rquested key name.");
            }

            //string requestOKey = SymmetricEncryption.Decrypt(encrytedRequestOKey);
            //string dbOKey = SymmetricEncryption.Decrypt(organisationKey.OKey);

            string requestOKey = encrytedRequestOKey;
            string dbOKey      = organisationKey.OKey;

            if (requestOKey != dbOKey)
            {
                throw new ApplicationException("The request OKey does not match OKey from the database.");
            }
        }
コード例 #7
0
        private void PopulateOrganisationKey(OrganisationKey organisationKey, DbDataReader dataReader)
        {
            string idColumn = dataReader[OrganisationKeyColumn.ID] != null ? dataReader[OrganisationKeyColumn.ID].ToString() :
                              string.Empty;

            long id;

            if (!string.IsNullOrEmpty(idColumn) &&
                long.TryParse(idColumn, out id))
            {
                organisationKey.Id = id;
            }

            if (dataReader[OrganisationKeyColumn.NAME] != null)
            {
                organisationKey.Name = dataReader[OrganisationKeyColumn.NAME].ToString();
            }

            if (dataReader[OrganisationKeyColumn.OKEY] != null)
            {
                organisationKey.OKey = dataReader[OrganisationKeyColumn.OKEY].ToString();
            }
        }
コード例 #8
0
        private void OnPopulateIdCallBack(OrganisationKey organisationKey, object result)
        {
            long id = Convert.ToInt64(result);

            organisationKey.Id = id;
        }