protected override int ExecuteWorkImplementation()
        {
            var importHistory = m_importedRecordMetadataRepository.Load <ImportHistory>(m_importHistoryId);
            ImportedProjectMetadata importedProjectMetadata = null;
            Snapshot latestSnapshot = null;

            if (m_data.ImportedProjectMetadataId.HasValue)
            {
                importedProjectMetadata = m_importedRecordMetadataRepository.Load <ImportedProjectMetadata>(m_data.ImportedProjectMetadataId.Value);
            }

            if (!m_data.IsFailed)
            {
                latestSnapshot = m_projectRepository.GetLatestSnapshot(m_data.ProjectId);
            }

            var importMetadata = new ImportedRecordMetadata
            {
                LastUpdate              = importHistory,
                LastUpdateMessage       = m_data.FaultedMessage,
                Snapshot                = latestSnapshot,
                ImportedProjectMetadata = importedProjectMetadata
            };

            return((int)m_importedRecordMetadataRepository.Create(importMetadata));
        }
Esempio n. 2
0
        private int CreateImportedProjectMetadata()
        {
            var project            = m_projectRepository.Load <Project>(m_importedRecord.ProjectId);
            var externalRepository = m_projectRepository.Load <ExternalRepository>(m_externalRepositoryId);

            var importedProjectMetadata = new ImportedProjectMetadata
            {
                ExternalId         = m_importedRecord.ExternalId,
                Project            = project,
                ExternalRepository = externalRepository
            };

            return((int)m_projectRepository.Create(importedProjectMetadata));
        }
        public virtual TotalImportStatistics GetExternalRepositoryStatistics(int repositoryId)
        {
            ExternalRepository      externalRepository      = null;
            ImportedProjectMetadata importedProjectMetadata = null;
            TotalImportStatistics   totalImportStatistics   = null;

            var result = GetSession().QueryOver(() => externalRepository)
                         .JoinAlias(x => x.ImportedProjectMetadata, () => importedProjectMetadata, JoinType.LeftOuterJoin)
                         .Where(() => externalRepository.Id == repositoryId)
                         .SelectList(list => list
                                     .SelectCount(() => importedProjectMetadata.Id).WithAlias(() => totalImportStatistics.NewItems))
                         .TransformUsing(Transformers.AliasToBean <TotalImportStatistics>())
                         .SingleOrDefault <TotalImportStatistics>();

            return(result);
        }