Пример #1
0
        public void RegisterDocument(Document document)
        {
            try
            {
                document.ContentChanged += document_ContentChanged;
                document.SegmentsConfirmationLevelChanged += document_SegmentsConfirmationLevelChanged;

                var trackInfo = _trackingInfos.FirstOrDefault(x => x.FileId == document.ActiveFile.Id);
                if (trackInfo == null)
                {
                    trackInfo = new TrackInfo
                    {
                        FileId            = document.ActiveFile.Id,
                        FileName          = document.ActiveFile.Name,
                        Language          = document.ActiveFile.Language.CultureInfo.Name,
                        FileType          = document.ActiveFile.FileTypeId,
                        SegmentTrackInfos = new List <SegmentTrackInfo>()
                    };
                    _trackingInfos.Add(trackInfo);
                }
                ActiveDocument = document;

                _persistance.Save(_trackingInfos);
            }
            catch (Exception exception)
            {
                _logger.Debug(exception, @"Error appeared when UnregisterDocument");
            }
        }
Пример #2
0
        public void RegisterDocument(Document document)
        {
            try
            {
                document.ContentChanged += document_ContentChanged;
                document.SegmentsConfirmationLevelChanged += document_SegmentsConfirmationLevelChanged;
                var projectInfo = document.Project.GetProjectInfo();

                foreach (var file in document.Files)
                {
                    _logger.Info(string.Format("Registered file: {0}", file.Name));

                    var trackInfo = _trackingInfos.FirstOrDefault(x => x.FileId == file.Id);
                    if (trackInfo == null)
                    {
                        trackInfo = new TrackInfo
                        {
                            FileId      = file.Id,
                            FileName    = file.Name,
                            ProjectId   = projectInfo.Id,
                            ProjectName = projectInfo.Name,
                            Language    = file.Language.CultureInfo.Name,
                            FileType    = file.FileTypeId
                        };
                        _trackingInfos.Add(trackInfo);
                    }
                }

                ActiveDocument = document;

                _persistance.Save(_trackingInfos);
            }
            catch (Exception exception)
            {
                _logger.Debug(exception, @"Error appeared when RegisterDocument");
                _emailService.SendLogFile();
            }
        }