示例#1
0
        public string GetBookPageByXmlId(string bookGuid, string pageXmlId, OutputFormatEnumContract resultFormat,
                                         BookTypeEnumContract bookTypeContract)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("Start MainService (BookManager) get page xmlId '{0}' of book '{1}'", pageXmlId,
                                  bookGuid);
            }

            m_authorizationManager.AuthorizeBook(bookGuid);

            OutputFormat outputFormat;

            if (!Enum.TryParse(resultFormat.ToString(), true, out outputFormat))
            {
                throw new ArgumentException(string.Format("Result format : '{0}' unknown", resultFormat));
            }

            BookTypeEnum bookType;

            if (!Enum.TryParse(bookTypeContract.ToString(), true, out bookType))
            {
                throw new ArgumentException(string.Format("Book type : '{0}' unknown", bookTypeContract));
            }

            var bookVersion         = m_bookRepository.GetLastVersionForBookWithType(bookGuid);
            var transformation      = m_bookRepository.FindTransformation(bookVersion, outputFormat, bookType);
            var transformationName  = transformation.Name;
            var transformationLevel = (ResourceLevelEnumContract)transformation.ResourceLevel;
            var pageText            = m_searchServiceClient.GetBookPageByXmlId(bookGuid, bookVersion.VersionId, pageXmlId,
                                                                               transformationName, resultFormat, transformationLevel);

            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("End MainService (BookManager) get page xmlId '{0}' of book '{1}'", pageXmlId,
                                  bookGuid);
            }

            return(pageText);
        }