client/src/Iri.Modernisation.Data/Models/VideoBook.cs
changeset 39 0f2bde8fdfeb
parent 38 bd33267300aa
child 40 581829b5ddd9
--- a/client/src/Iri.Modernisation.Data/Models/VideoBook.cs	Thu Feb 04 16:38:04 2010 +0100
+++ b/client/src/Iri.Modernisation.Data/Models/VideoBook.cs	Tue Feb 09 15:30:46 2010 +0100
@@ -55,13 +55,17 @@
         /// </summary>
         public String IriPath { get; set; }
 
-        
 
+        public List<PolemicLink> BasicLinks { get; set; }
+
+        public List<PolemicLink> PolemicLinks { get; set; }
         /// <summary>
         /// Constructeur par défaut
         /// </summary>
         public VideoBook()
         {
+            BasicLinks = new List<PolemicLink>();
+            PolemicLinks = new List<PolemicLink>();
             Chapters = new VideoChapter[FactoryVideoLivre.VideoChapterDescriptions.Length];
             for (int nbChapitre = 0; nbChapitre < FactoryVideoLivre.VideoChapterDescriptions.Length; nbChapitre++)
             {
@@ -74,6 +78,78 @@
          
         }
 
+        public LDTFile GetLDTFile()
+        {
+            LDTFile ldt = new LDTFile();
+            ldt.Project = new LDTProject()
+             {
+                 
+             };
+            ldt.Medias = new List<LDTMedia>()
+             {
+                 new LDTMedia()
+                 {
+                     Src = IriPath
+                 }
+             };
+            foreach (VideoChapter Vc in Chapters)
+            {
+                ldt.Annotations.Add(
+                       new LDTAnnotationsContent()
+                       {
+
+                       });
+                foreach (Annotation An in Vc.Annotations)
+                {
+                    LDTAnnotationsDecoupage decoupage = new LDTAnnotationsDecoupage()
+                    {
+                        Title = Vc.Title,
+                        Author = SettingsProject.ActualUser.UserName
+                    };
+                    decoupage.Elements.Add(
+                                            new LDTElement()
+                                            {
+                                                Id = An.Id,
+                                                Title = An.Title,
+                                                Abstract = An.Description,
+                                                Date = DateTime.Now,
+                                                Begin = An.TimerIn.TotalMilliseconds,
+                                                Dur = An.Duration.TotalMilliseconds,
+                                                Tags = An.Tags,
+                                                Author = SettingsProject.ActualUser.UserName,
+                                            }
+                                                );
+
+
+
+                    ldt.Annotations[ldt.Annotations.Count - 1].Content.Add(decoupage);
+                }
+                foreach (PolemicLink Pl in BasicLinks)
+                {
+                    ldt.BasicRelations.Add(new LDTRelation()
+                    {
+                        Type = Pl.Type.Title,
+                        IdElementFrom = Pl.FromElement.Id,
+                        IdElementTo = Pl.ToElement.Id,
+                        Title = Pl.ToElement.Title
+                    });
+                }
+                foreach (PolemicLink Pl in PolemicLinks)
+                {
+                    ldt.PolemicRelations.Add(new LDTRelation()
+                    {
+                        Type = Pl.Type.Title,
+                        IdElementFrom = Pl.FromElement.Id,
+                        IdElementTo = Pl.ToElement.Id,
+                        Title = Pl.ToElement.Title
+                    });
+                   
+                }
+               
+            }
+            return ldt;
+        }
+
       
 
         /// <summary>
@@ -128,36 +204,61 @@
         {
             ldt = ((LoaderEventArgs<LDTFile>)e).CreatedObject;
             ldt.Annotations.Clear();
+            
             foreach (VideoChapter Vc in videoBookToUpdate.Chapters)
             {
-                LDTAnnotationsDecoupage decoupage = new LDTAnnotationsDecoupage()
+                 ldt.Annotations.Add(
+                        new LDTAnnotationsContent()
+                        {
+                         
+                        });
+                foreach(Annotation An in Vc.Annotations)
+                {
+                    LDTAnnotationsDecoupage decoupage = new LDTAnnotationsDecoupage()
                     {
                         Title = Vc.Title,
-                        Id = Vc.IdChap.ToString()
+                        Author = SettingsProject.ActualUser.UserName
                     };
-                foreach(Annotation An in Vc.Annotations)
-                {
                     decoupage.Elements.Add(
                                             new LDTElement()
                                             {
+                                                Id = An.Id,
                                                 Title = An.Title,
                                                 Abstract = An.Description,
                                                 Date = DateTime.Now,
                                                 Begin = An.TimerIn.TotalMilliseconds,
                                                 Dur = An.Duration.TotalMilliseconds,
                                                 Tags = An.Tags,
-                                               Type =  An.Type.Id
+                                                Author = SettingsProject.ActualUser.UserName,
                                             }
-                                            );
-                }
+                                                );
+                  
+
 
-                ldt.Annotations.Add(
-                        new LDTAnnotationsContent()
+                    ldt.Annotations[ldt.Annotations.Count - 1].Content.Add(decoupage);
+                }
+                foreach (PolemicLink Pl in videoBookToUpdate.BasicLinks)
+                {
+                    ldt.BasicRelations.Add(new LDTRelation()
                         {
-                            Content = new List<LDTAnnotationsDecoupage>() { decoupage},
+                            Type = Pl.Type.Title,
+                            IdElementFrom = Pl.FromElement.Id,
+                            IdElementTo = Pl.ToElement.Id,
+                            Title = Pl.ToElement.Title
                         });
+                }
+                foreach (PolemicLink Pl in videoBookToUpdate.PolemicLinks)
+                {
+                    ldt.PolemicRelations.Add(new LDTRelation()
+                    {
+                        Type = Pl.Type.Title,
+                        IdElementFrom = Pl.FromElement.Id,
+                        IdElementTo = Pl.ToElement.Id,
+                        Title = Pl.ToElement.Title
+                    });
+                }
             }
-
+           
                      WebClient WebWriter = new WebClient();
             
                
@@ -190,13 +291,13 @@
                 fs.Close();
 
             }*/
-           
-                using (StreamWriter fs = Sw)
-                {
+
+            StreamWriter fs = Sw;
+         
                   
                     fs.Write(ldt.ToString());
                     fs.Close();
-                }
+               
             
             /*StreamWriter fs = new StreamWriter(e.Result);
             //MessageBox.Show(ldt.ToString());