示例#1
0
        public DataServiceImpl(IAdoRepository adoRepository, INameMapper nameMapper) {
            adoRepository.ShouldNotBeNull("adoRepository");
            nameMapper.ShouldNotBeNull("nameMapper");

            AdoRepository = adoRepository;
            NameMapper = nameMapper;
        }
示例#2
0
        public DataServiceImpl(IAdoRepository adoRepository, INameMapper nameMapper)
        {
            adoRepository.ShouldNotBeNull("adoRepository");
            nameMapper.ShouldNotBeNull("nameMapper");

            AdoRepository = adoRepository;
            NameMapper    = nameMapper;
        }
        /// <summary>
        /// 요청정보 중에 RequestType이 <see cref="XmlDataRequestKind.Method"/> 인 경우에는 Method를 실제 실행할 Query 문장으로 변경한다.
        /// </summary>
        /// <param name="repository"><see cref="IIniQueryProvider"/>를 가진 기본 <see cref="IAdoRepository"/></param>
        /// <param name="request">요청 정보</param>
        public static void ConvertToQuery(IAdoRepository repository, XdsRequestItem request)
        {
            repository.ShouldNotBeNull("repository");
            request.ShouldNotBeNull("request");

            if (IsDebugEnabled)
            {
                log.Debug("요청정보의 Method에 해당하는 실제 Query String을 읽어옵니다.");
            }

            if (repository.QueryProvider == null)
            {
                if (IsDebugEnabled)
                {
                    log.Debug("AdoRepository.QueryProvider가 제공되지 않아, 조회 작업이 취소되었습니다.");
                }

                return;
            }

            foreach (XdsQuery query in request.PreQueries)
            {
                if (query.RequestKind == XmlDataRequestKind.Method)
                {
                    query.Query       = repository.QueryProvider.GetQuery(query.Query);
                    query.RequestKind = AdoTool.IsSqlString(query.Query)
                                            ? XmlDataRequestKind.Query
                                            : XmlDataRequestKind.StoredProc;
                }
            }

            if (request.RequestKind == XmlDataRequestKind.Method)
            {
                request.Query       = repository.QueryProvider.GetQuery(request.Query);
                request.RequestKind = AdoTool.IsSqlString(request.Query)
                                          ? XmlDataRequestKind.Query
                                          : XmlDataRequestKind.StoredProc;
            }

            foreach (XdsQuery query in request.PostQueries)
            {
                if (query.RequestKind == XmlDataRequestKind.Method)
                {
                    query.Query       = repository.QueryProvider.GetQuery(query.Query);
                    query.RequestKind = AdoTool.IsSqlString(query.Query)
                                            ? XmlDataRequestKind.Query
                                            : XmlDataRequestKind.StoredProc;
                }
            }

            if (IsDebugEnabled)
            {
                log.Debug("요청 정보의 Method에 해당하는 실제 Query String을 모두 읽었습니다.");
            }
        }
示例#4
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="repository">Ado Repository</param>
        /// <param name="sqlStatements">실행할 쿼리문의 컬렉션</param>
        public AdoPreCacheService(IAdoRepository repository, IEnumerable<string> sqlStatements)
        {
            repository.ShouldNotBeNull("repository");
            sqlStatements.ShouldNotBeEmpty<string>("sqlStatements");

            _adoRepository = repository;
            SqlStatements = sqlStatements.ToArray();

            if(log.IsInfoEnabled)
                log.Debug(@"AdoPreCacheService 의 인스턴스가 생성되었습니다.");
        }
示例#5
0
        //! ======================================================================================

        /// <summary>
        /// <see cref="IAdoRepository.ExecuteScalar(string,IAdoParameter[])"/> 를
        /// 비동기 방식으로 수행하는 <see cref="Task{TResult}"/>를 빌드합니다.
        /// </summary>
        /// <param name="repository"><see cref="IAdoRepository"/> 인스턴스</param>
        /// <param name="query">실행할 쿼리 문</param>
        /// <param name="parameters">파라미터 정보</param>
        /// <returns>Scalar 값을 결과값으로 가진 Task</returns>
        public static Task <object> ExecuteScalarAsync(this IAdoRepository repository, string query, params IAdoParameter[] parameters)
        {
            repository.ShouldNotBeNull("repository");
            query.ShouldNotBeWhiteSpace("query");

            if (IsDebugEnabled)
            {
                log.Debug("비동기 방식으로 ExecuteScalar()을 수행합니다... query=[{0}], parameters=[{1}]",
                          query, parameters.CollectionToString());
            }

            return(Task.Factory.StartNew(() => repository.ExecuteScalar(query, parameters)));
        }
示例#6
0
        /// <summary>
        /// <see cref="IAdoRepository.ExecuteScalarByProcedure"/> 를 비동기 방식으로 수행하는 <see cref="Task{TResult}"/>를 빌드합니다.
        /// </summary>
        /// <param name="repository"><see cref="IAdoRepository"/> 인스턴스</param>
        /// <param name="spName">실행할 Procedure Name</param>
        /// <param name="parameters">파라미터 정보</param>
        /// <returns>Scalar 값을 결과값으로 가진 Task</returns>
        public static Task <object> ExecuteScalarTaskByProcedureAsync(this IAdoRepository repository, string spName,
                                                                      params IAdoParameter[] parameters)
        {
            repository.ShouldNotBeNull("repository");
            spName.ShouldNotBeWhiteSpace("spName");

            if (IsDebugEnabled)
            {
                log.Debug("비동기 방식으로 ExecuteScalarByProcedure()을 수행합니다... spName=[{0}], parameters=[{1}]",
                          spName, parameters.CollectionToString());
            }

            return(Task.Factory.StartNew(() => repository.ExecuteScalarByProcedure(spName, parameters)));
        }
示例#7
0
        /// <summary>
        /// 생성자 
        /// </summary>
        /// <param name="repository">IAdoRepository 인스턴스</param>
        /// <param name="tableName">String Resources 정보를 담은 Table 명</param>
        /// <param name="assemblyName">대분류</param>
        /// <param name="resourceName">String Resources의 중분류</param>
        public AdoResourceRepository(IAdoRepository repository, string resourceName = null, string assemblyName = null,
                                     string tableName = null) {
            repository.ShouldNotBeNull("repository");

            if(IsDebugEnabled)
                log.Debug("AdoResourceRepository 인스턴스 생성. databaseName=[{0}], tableName=[{1}], assemblyName=[{2}], resourceName=[{3}]",
                          repository.DbName, tableName, assemblyName, resourceName);

            DatabaseName = repository.DbName ?? AdoTool.DefaultDatabaseName;
            TableName = tableName ?? AdoResourceProvider.DefaultStringResourceTableName;
            AssemblyName = assemblyName ?? AdoResourceProvider.DefaultAssemblyName;
            ResourceName = resourceName ?? string.Empty;

            Ado = repository;
        }
示例#8
0
        /// <summary>
        /// 비동기 방식으로 쿼리문을 실행해서, PagingDataTable을 반환하는 Task를 빌드합니다.
        /// </summary>
        /// <param name="repository"><see cref="IAdoRepository"/></param>
        /// <param name="sqlString">실행할 쿼리문</param>
        /// <param name="pageIndex">Page index (0부터 시작합니다.)</param>
        /// <param name="pageSize">Page당 Item 수 (보통 10개)</param>
        /// <param name="parameters">파라미터 컬렉션</param>
        /// <returns>PagingDataTable을 반환하는 Task</returns>
        public static Task <PagingDataTable> ExecutePagingDataTableByQueryStringAsync(this IAdoRepository repository,
                                                                                      string sqlString,
                                                                                      int?pageIndex,
                                                                                      int?pageSize,
                                                                                      params IAdoParameter[] parameters)
        {
            repository.ShouldNotBeNull("repository");
            sqlString.ShouldNotBeWhiteSpace("sqlString");

            if (IsDebugEnabled)
            {
                log.Debug("비동기 방식으로 쿼리를 수행하여 PagingDataTable을 빌드합니다... sqlString=[{0}], pageIndex=[{1}], pageSize=[{2}]",
                          sqlString, pageIndex, pageSize);
            }

            return(Task.Factory.StartNew(() => repository.ExecutePagingDataTableBySqlString(sqlString, pageIndex, pageSize, parameters)));
        }
示例#9
0
        /// <summary>
        /// 생성자
        /// </summary>
        /// <param name="repository">IAdoRepository 인스턴스</param>
        /// <param name="tableName">String Resources 정보를 담은 Table 명</param>
        /// <param name="assemblyName">대분류</param>
        /// <param name="resourceName">String Resources의 중분류</param>
        public AdoResourceRepository(IAdoRepository repository, string resourceName = null, string assemblyName = null,
                                     string tableName = null)
        {
            repository.ShouldNotBeNull("repository");

            if (IsDebugEnabled)
            {
                log.Debug("AdoResourceRepository 인스턴스 생성. databaseName=[{0}], tableName=[{1}], assemblyName=[{2}], resourceName=[{3}]",
                          repository.DbName, tableName, assemblyName, resourceName);
            }

            DatabaseName = repository.DbName ?? AdoTool.DefaultDatabaseName;
            TableName    = tableName ?? AdoResourceProvider.DefaultStringResourceTableName;
            AssemblyName = assemblyName ?? AdoResourceProvider.DefaultAssemblyName;
            ResourceName = resourceName ?? string.Empty;

            Ado = repository;
        }
示例#10
0
        /// <summary>
        /// 비동기 방식으로 쿼리문을 실행해서, DataTable을 반환하는 Task를 빌드합니다.
        /// </summary>
        /// <param name="repository"><see cref="IAdoRepository"/></param>
        /// <param name="sqlString">실행할 쿼리문</param>
        /// <param name="firstResult">첫번째 레코드 인덱스</param>
        /// <param name="maxResults">최대 레코드 갯수</param>
        /// <param name="parameters">파라미터 컬렉션</param>
        /// <returns>DataTable을 반환하는 Task</returns>
        public static Task <DataTable> ExecuteDataTableByQueryStringAsync(this IAdoRepository repository,
                                                                          string sqlString,
                                                                          int?firstResult,
                                                                          int?maxResults,
                                                                          params IAdoParameter[] parameters)
        {
            repository.ShouldNotBeNull("repository");
            sqlString.ShouldNotBeWhiteSpace("sqlString");

            if (IsDebugEnabled)
            {
                log.Debug("비동기 방식으로 쿼리를 수행하여 DataTable을 빌드합니다... sqlString=[{0}], firstResult=[{1}], maxResults=[{2}]",
                          sqlString, firstResult, maxResults);
            }

            return(Task.Factory.StartNew(() => repository.ExecuteDataTableBySqlString(sqlString,
                                                                                      firstResult ?? 0,
                                                                                      maxResults ?? 0,
                                                                                      parameters)));
        }
示例#11
0
        /// <summary>
        /// 비동기 방식으로 Procedure를 실행해서, PagingDataTable을 반환하는 Task를 빌드합니다.
        /// </summary>
        /// <param name="repository"><see cref="IAdoRepository"/></param>
        /// <param name="spName">실행할 Procedure Name</param>
        /// <param name="pageIndex">Page index (0부터 시작합니다.)</param>
        /// <param name="pageSize">Page당 Item 수 (보통 10개)</param>
        /// <param name="parameters">파라미터 컬렉션</param>
        /// <returns>DataTable을 반환하는 Task</returns>
        public static Task <PagingDataTable> ExecutePagingDataTableByProcedureAsync(this IAdoRepository repository,
                                                                                    string spName,
                                                                                    int?pageIndex,
                                                                                    int?pageSize,
                                                                                    params IAdoParameter[] parameters)
        {
            repository.ShouldNotBeNull("repository");
            spName.ShouldNotBeWhiteSpace("spName");

            if (IsDebugEnabled)
            {
                log.Debug("비동기 방식으로 Procedure를 수행하여, PagingDataTable을 얻습니다... spName=[{0}], pageIndex=[{1}], pageSize=[{2}]",
                          spName, pageIndex, pageSize);
            }

            return(Task.Factory.StartNew(() => repository.ExecutePagingDataTableByProcedure(spName,
                                                                                            pageIndex,
                                                                                            pageSize,
                                                                                            parameters)));
        }
示例#12
0
        /// <summary>
        /// <paramref name="repository"/>에 해당하는 Database에 연결이 제대뢰 되는지 확인합니다.
        /// </summary>
        /// <param name="repository"></param>
        /// <returns></returns>
        public static bool Ping(this IAdoRepository repository)
        {
            repository.ShouldNotBeNull("repository");

            if (IsDebugEnabled)
            {
                log.Debug("Database[{0}] 에 연결을 시도합니다...", repository.DbName);
            }

            try {
                using (var conn = repository.Db.CreateConnection()) {
                    conn.Open();
                    return(conn.State == ConnectionState.Open);
                }
            }
            catch (Exception ex) {
                if (log.IsErrorEnabled)
                {
                    log.Error("Database[{0}]에 접속할 수 없습니다.", repository.DbName);
                    log.Error(ex);
                }
            }
            return(false);
        }
示例#13
0
 public DataServiceImpl(IAdoRepository adoRepository) {
     adoRepository.ShouldNotBeNull("adoRepository");
     AdoRepository = adoRepository;
 }
示例#14
0
        /// <summary>
        /// 요청정보 중에 RequestType이 <see cref="XmlDataRequestKind.Method"/> 인 경우에는 Method를 실제 실행할 Query 문장으로 변경한다.
        /// </summary>
        /// <param name="repository"><see cref="IIniQueryProvider"/>를 가진 기본 <see cref="IAdoRepository"/></param>
        /// <param name="request">요청 정보</param>
        public static void ConvertToQuery(IAdoRepository repository, XdsRequestItem request) {
            repository.ShouldNotBeNull("repository");
            request.ShouldNotBeNull("request");

            if(IsDebugEnabled)
                log.Debug("요청정보의 Method에 해당하는 실제 Query String을 읽어옵니다.");

            if(repository.QueryProvider == null) {
                if(IsDebugEnabled)
                    log.Debug("AdoRepository.QueryProvider가 제공되지 않아, 조회 작업이 취소되었습니다.");

                return;
            }

            foreach(XdsQuery query in request.PreQueries) {
                if(query.RequestKind == XmlDataRequestKind.Method) {
                    query.Query = repository.QueryProvider.GetQuery(query.Query);
                    query.RequestKind = AdoTool.IsSqlString(query.Query)
                                            ? XmlDataRequestKind.Query
                                            : XmlDataRequestKind.StoredProc;
                }
            }

            if(request.RequestKind == XmlDataRequestKind.Method) {
                request.Query = repository.QueryProvider.GetQuery(request.Query);
                request.RequestKind = AdoTool.IsSqlString(request.Query)
                                          ? XmlDataRequestKind.Query
                                          : XmlDataRequestKind.StoredProc;
            }

            foreach(XdsQuery query in request.PostQueries) {
                if(query.RequestKind == XmlDataRequestKind.Method) {
                    query.Query = repository.QueryProvider.GetQuery(query.Query);
                    query.RequestKind = AdoTool.IsSqlString(query.Query)
                                            ? XmlDataRequestKind.Query
                                            : XmlDataRequestKind.StoredProc;
                }
            }

            if(IsDebugEnabled)
                log.Debug("요청 정보의 Method에 해당하는 실제 Query String을 모두 읽었습니다.");
        }
示例#15
0
 public DataServiceImpl(IAdoRepository adoRepository)
 {
     adoRepository.ShouldNotBeNull("adoRepository");
     AdoRepository = adoRepository;
 }
示例#16
0
 public XmlDataManager(IAdoRepository ado)
 {
     ado.ShouldNotBeNull("ado");
     Ado = ado;
 }
示例#17
0
 public XmlDataManager(IAdoRepository ado) {
     ado.ShouldNotBeNull("ado");
     Ado = ado;
 }