/// <summary>
        /// Initializes a new instance of the <see cref="ProjectNotesService"/> class.
        /// </summary>
        /// <param name="projectNotesLoader">The project notes loader.</param>
        /// <remarks></remarks>
        public ProjectNotesService(IProjectNotesLoader projectNotesLoader)
        {
            var aggregator = new Aggregator();

            aggregator.LoadMapping();
            _projectNotesLoader = projectNotesLoader;
            _projectNotes       =
                new List <IProjectNote>(
                    _projectNotesLoader.Import().ConvertAll(
                        line => new ProjectNote {
                Aggregator = aggregator, Line = line
            }));
            _projectNotes.RemoveAll(pn => !File.Exists(pn.FilepathXps));
            _metadata = new Dictionary <IMetadataType, ICollection <IMetadata> >();
            Action <IMetadata> func = m =>
            {
                if (!_metadata.ContainsKey(m.Type))
                {
                    _metadata[m.Type] = new SortedSet <IMetadata>(new MetadataComparer());
                }
                if (!_metadata[m.Type].Contains(m))
                {
                    _metadata[m.Type].Add(m);
                }
            };

            _projectNotes.ForEach(pn => pn.Metadata.ToList().ForEach(ms => ms.Value.ToList().ForEach(func)));
            aggregator.SaveMapping();
        }
 public ProjectNotesService(IProjectNotesLoader projectNotesLoader)
 {
     _projectNotesLoader = projectNotesLoader;
     _projectNotes       = new List <IProjectNote>(_projectNotesLoader.Import().ConvertAll(line => new ProjectNote {
         Line = line
     }));
     _projectNotes.RemoveAll(pn => !File.Exists(pn.FilepathXps));
 }
Esempio n. 3
0
        public ProjectNotesService(ILogService logService, IProjectNotesLoader projectNotesLoader)
        {
            _logService         = logService;
            _projectNotesLoader = projectNotesLoader;
            _projectNotes       = new List <IProjectNote>(_projectNotesLoader.Import().ConvertAll(line => new ProjectNote().InitByLine(line)));
            _projectNotes.RemoveAll(pn => !File.Exists(pn.FilepathXps));

            /*{
             *  var pn = _projectNotes[0];
             *  var doc = new XpsDocument(pn.FilepathXps, FileAccess.Read);
             *  var list = new List<IXpsFixedDocumentReader>(doc.FixedDocumentSequenceReader.FixedDocuments);
             *  foreach (var xpsFixedDocumentReader in list)
             *  {
             *      foreach (var image in xpsFixedDocumentReader.FixedPages[0].Images)
             *      {
             *          Console.WriteLine(image);
             *      }
             *  }
             *  Console.ReadLine();
             * }*/

            //for (int i = 0; i < 3; i++)
            //{
            //    _projectNotes.Add(new ProjectNote(@"..\..\..\Resources\Xps\test.xps"));
            //}

            if (false)
            {
                var container = new UnityContainer();
                container.RegisterType <IProjectNotesLoader, ProjectNotesLoader>();
                var loader = container.Resolve <IProjectNotesLoader>();
                var list   = loader.Import();
                foreach (var line in list)
                {
                    //    _projectNotes.Add(new ProjectNote());
                }
            }

            //_projectNotes.AddRange(
            //    new List<string>(
            //        Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures", "*.jpg"))
            //    .Select(f => new ProjectNote(f)));

            //var files = Directory.GetFiles(@"C:\Users\Public\Pictures\Sample Pictures", "*.jpg");
            //foreach (var file in files)
            //{
            //    _projectNotes.Add(new ProjectNote(file));
            //}
            //_logService.Log("Project notes loaded...");
        }