Пример #1
0
        public long CreateProject(CreateProjectContract projectData)
        {
            var currentUserId = m_authenticationManager.GetCurrentUserId();
            var work          = new CreateProjectWork(m_projectRepository, projectData, currentUserId, m_defaultUserProvider, m_mapper);
            var resultId      = work.Execute();

            if (projectData.ProjectType == ProjectTypeContract.Community && projectData.BookTypesForForum != null)
            {
                m_forumSiteManager.CreateOrUpdateForums(resultId, projectData.BookTypesForForum.Select(x => (short)x).ToArray());
            }

            return(resultId);
        }
Пример #2
0
        public void ProcessSessionAsImport(string sessionId, long?projectId, string comment)
        {
            var userId = m_authenticationManager.GetCurrentUserId();
            var allAutoImportPermissions = m_permissionManager.GetAutoImportSpecialPermissions();
            var projectType         = m_portalTypeProvider.GetDefaultProjectType();
            var fulltextStorageType = m_fulltextStorageProvider.GetStorageType((ProjectTypeEnum)projectType);

            ImportResultContract importResult;

            using (var client = m_communicationProvider.GetFileProcessingClient())
            {
                try
                {
                    importResult = client.ProcessSession(sessionId, projectId, userId, comment, (ProjectTypeContract)projectType, (FulltextStoreTypeContract)fulltextStorageType, allAutoImportPermissions);
                    if (!importResult.Success)
                    {
                        throw new MainServiceException(MainServiceErrorCode.ImportFailed, "Import failed");
                    }
                }
                catch (FileProcessingImportFailedException exception)
                {
                    throw new MainServiceException(MainServiceErrorCode.ImportFailedWithError, $"Import failed with error: {exception.InnerException?.Message}", descriptionParams: exception.InnerException?.Message);
                }
            }

            if (projectType == DataContracts.Contracts.Type.ProjectTypeContract.Community)
            {
                try
                {
                    m_forumSiteManager.CreateOrUpdateForums(importResult.ProjectId);
                }
                catch (ForumException e)
                {
                    throw new MainServiceException(MainServiceErrorCode.ImportSucceedForumFailed,
                                                   $"Import succeeded. Forum creation failed. {e.Message}", HttpStatusCode.BadRequest, new object[] { e.Code });
                }
            }
        }