--- a/client/src/Iri.Modernisation.Data/Models/VideoBook.cs Wed Jan 27 10:55:59 2010 +0100
+++ b/client/src/Iri.Modernisation.Data/Models/VideoBook.cs Thu Feb 04 16:38:04 2010 +0100
@@ -12,6 +12,7 @@
using System.Xml.Linq;
using System.Threading;
using Iri.Modernisation.Data.LDTClass;
+using System.IO;
namespace Iri.Modernisation.Data.Models
{
/// <summary>
@@ -73,6 +74,8 @@
}
+
+
/// <summary>
/// Méthode static pour le Loader de la list de videoBook
/// </summary>
@@ -99,7 +102,109 @@
}
+ public class VideoBookUploader
+ {
+ private static Loader<LDTFile> loaderLdt = new Loader<LDTFile>(LDTFile.FromXML);
+ private static LDTFile ldt = new LDTFile();
+ private static VideoBook videoBookToUpdate;
+ private static StreamWriter Sw;
+ public static void UpdateAnnotation(VideoBook update,StreamWriter sw)
+ {
+ Sw = sw;
+ videoBookToUpdate = update;
+ loaderLdt.LoaderFinished += new EventHandler<EventArgs>(loaderLdt_LoaderFinished);
+ loaderLdt.Load(videoBookToUpdate.LdtPath);
+ }
+ public static void UpdateAnnotation(VideoBook update)
+ {
+ videoBookToUpdate = update;
+ loaderLdt.LoaderFinished += new EventHandler<EventArgs>(loaderLdt_LoaderFinished);
+ loaderLdt.Load(videoBookToUpdate.LdtPath);
+
+ }
+
+ static void loaderLdt_LoaderFinished(object sender, EventArgs e)
+ {
+ ldt = ((LoaderEventArgs<LDTFile>)e).CreatedObject;
+ ldt.Annotations.Clear();
+ foreach (VideoChapter Vc in videoBookToUpdate.Chapters)
+ {
+ LDTAnnotationsDecoupage decoupage = new LDTAnnotationsDecoupage()
+ {
+ Title = Vc.Title,
+ Id = Vc.IdChap.ToString()
+ };
+ foreach(Annotation An in Vc.Annotations)
+ {
+ decoupage.Elements.Add(
+ new LDTElement()
+ {
+ Title = An.Title,
+ Abstract = An.Description,
+ Date = DateTime.Now,
+ Begin = An.TimerIn.TotalMilliseconds,
+ Dur = An.Duration.TotalMilliseconds,
+ Tags = An.Tags,
+ Type = An.Type.Id
+ }
+ );
+ }
+
+ ldt.Annotations.Add(
+ new LDTAnnotationsContent()
+ {
+ Content = new List<LDTAnnotationsDecoupage>() { decoupage},
+ });
+ }
+
+ WebClient WebWriter = new WebClient();
+
+
+ WebWriter.OpenWriteCompleted +=new OpenWriteCompletedEventHandler(WebWriter_OpenWriteCompleted);
+ WebWriter.OpenWriteAsync(new Uri(videoBookToUpdate.LdtPath, UriKind.RelativeOrAbsolute));
+ // WebWriter.UploadStringCompleted += new UploadStringCompletedEventHandler(WebWriter_UploadStringCompleted);
+ // WebWriter.UploadStringAsync(new Uri(videoBookToUpdate.LdtPath, UriKind.RelativeOrAbsolute),"azerty");
+
+ }
+
+
+ static void WebWriter_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
+ {
+
+ }
+
+
+ static void WebWriter_OpenWriteCompleted(object sender, OpenWriteCompletedEventArgs e)
+ {
+
+
+ /*using (Stream fs = e.Result)
+ {
+
+ // Add some information to the file.
+ byte[] info = new System.Text.UTF8Encoding(true).GetBytes("This is some text in the file.");
+
+ fs.Write(info, 0, info.Length);
+
+ fs.Close();
+
+ }*/
+
+ using (StreamWriter fs = Sw)
+ {
+
+ fs.Write(ldt.ToString());
+ fs.Close();
+ }
+
+ /*StreamWriter fs = new StreamWriter(e.Result);
+ //MessageBox.Show(ldt.ToString());
+ fs.Write(ldt.ToString());
+ fs.Flush();
+ fs.Close();*/
+ }
+ }
public class VideoBookLoader
{
private Loader<IRIFile> _iriFile;
@@ -117,16 +222,21 @@
void _iriFile_LoaderFinished(object sender, EventArgs e)
{
_loadedIriFile = ((LoaderEventArgs<IRIFile>)e).CreatedObject;
+
LoaderFinished(this,new LoaderEventArgs<VideoBook>(LDTFileReader.ConvertToVideoBook(_loadedLdtFile,_loadedIriFile)));
}
void _ldtFile_LoaderFinished(object sender, EventArgs e)
{
_loadedLdtFile = ((LoaderEventArgs<LDTFile>)e).CreatedObject;
+ _loadedLdtFile.Path = _ldtFile.Path;
_iriFile.Load(_loadedLdtFile.Medias[0].Src);
}
-
+ public void Load(String ldtPath)
+ {
+ _ldtFile.Load(ldtPath);
+ }
public event EventHandler<LoaderEventArgs<VideoBook>> LoaderFinished;