Example #1
0
        public IList <FindUserNodesResult> FindUserNodes(FindUserNodesParameters parameters)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                IList <FindUserNodesResult> result = null;

                using (IDbConnection connection = new DbConnection(ConnectionString))
                {
                    connection.Open();

                    using (IDbCommand command = connection.CreateCommand())
                    {
                        command.CommandText = StatementCache.Instance.GetCachedStatement("Imi.SupplyChain.Transportation.Authentication.DataAccess.Queries.FindUserNodes.sql");
                        ((OracleCommand)command).BindByName = true;

                        foreach (IDbDataParameter parameter in FindUserNodesTranslator.TranslateParameters(parameters))
                        {
                            command.Parameters.Add(parameter);
                        }

                        command.Prepare();

                        using (IDataReader reader = command.ExecuteReader())
                        {
                            result = FindUserNodesTranslator.TranslateResultSet(reader);
                        }
                    }
                }

                scope.Complete();

                return(result);
            }
        }
        public static IList <IDbDataParameter> TranslateParameters(FindUserNodesParameters parameters)
        {
            IList <IDbDataParameter> parameterList = new List <IDbDataParameter>();
            IDbDataParameter         dbParameter;

            dbParameter = new OracleParameter();
            dbParameter.ParameterName = "EMPID";
            dbParameter.DbType        = DbTypeConvertor.ConvertToDbType(typeof(string));
            dbParameter.Direction     = ParameterDirection.Input;
            dbParameter.Value         = parameters.UserIdentity;
            parameterList.Add(dbParameter);

            return(parameterList);
        }
        public IList <FindUserNodesResult> Execute(FindUserNodesParameters parameters)
        {
            ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[schemaName];
            string connectionString           = settings.ConnectionString;

            bool isAdministratorModeEnabled = false;

            bool.TryParse(ConfigurationManager.AppSettings["AdministratorMode"], out isAdministratorModeEnabled);

            IAuthenticationDao dao = new AuthenticationDao(connectionString);

            if (isAdministratorModeEnabled)
            {
                return(dao.FindAllNodes());
            }
            else
            {
                return(dao.FindUserNodes(parameters));
            }
        }