public CacheFetchBooks(ZefaniaCache cache,bool zipped)
 {
     my_cache = cache;
     my_zipped=zipped;
 }
        /// <summary>
        /// Diese Methode erstelle mit Hilfe der <see cref="ZefaniaCache"/> Klasse das Cachverzeichnis für das Modul.
        /// </summary>
        /// <param name="ModulPath">Der Pfad zum Zefania XML Bibelmodul</param>
        /// <param name="ID">Integerkennzeichnung für die Instanz der <see cref="ZefaniaCache"/>Klasse </param>
        /// <param name="zipped">Wenn true, besteht der Cache aus zipped Files</param>
        /// <param name="chapters">Wenn true ist der Cache vom Type x-chapters, sonst x-books</param>
        public void CreateCacheFromModul(string ModulPath,int ID,bool zipped,bool chapters)
        {
            try
            {

                ZefaniaCache SingleCache=new ZefaniaCache(ModulPath);
                SingleCache.OnSplitted+=new NewTrueSharpSwordAPI.Cache.ZefaniaCache.OnSplittedEventHandler(SingleCache_OnSplitted);
                SingleCache.OnCachedSuccess+=new NewTrueSharpSwordAPI.Cache.ZefaniaCache.OnCachedEventHandler(SingleCache_OnCachedSuccess);
                SingleCache.OnInvalidFileFormat+=new NewTrueSharpSwordAPI.Cache.ZefaniaCache.OnInvalidFileFormatEventHandler(SingleCache_OnInvalidFileFormat);

                SingleCache.Tag=ID;

                if(chapters)
                {
                    CacheFetchChapters fetcher = new CacheFetchChapters (SingleCache,zipped);
                    new Thread (new ThreadStart (fetcher.Fetch)).Start();
                }
                else
                {
                    CacheFetchBooks fetcher = new CacheFetchBooks (SingleCache,zipped);
                    new Thread (new ThreadStart (fetcher.Fetch)).Start();
                }
            }
            catch(Exception e)
            {

            }
        }
示例#3
0
        static void CreateCache(string[] args)
        {
            try
            {
                string Path2ZefModul=args[1];

                string AppPath=GetApplicationFolderName();

                if(Path.GetDirectoryName(Path2ZefModul)=="")
                {

                    Path2ZefModul=AppPath+@"\"+ Path2ZefModul;
                }

                ZefaniaCache ZefCache = new ZefaniaCache(Path2ZefModul);
                ZefCache.BaseCacheDir=AppPath;
                Console.WriteLine(Path.GetFileName(Path2ZefModul));
                Console.WriteLine("Starte Cacherstellung.... bitte warten/wait");
                ZefCache.CreateCacheChapters(false);
                Console.WriteLine("Cache ist fertig/ready");

                System.Xml.XmlDocument Config=new XmlDocument();

                if(File.Exists(AppPath+@"\config.xml"))
                {

                    Config.Load(AppPath+@"\config.xml");

                }
                else
                {
                    Config.LoadXml("<module></module>");
                }

                XmlNode Modul=Config.DocumentElement.SelectSingleNode("descendant::modul[@name='"+ZefCache.GetBibleName+"' and text()='"+ZefCache.ModulMD5+"']");

                if(Modul==null)
                {
                    Modul =Config.CreateNode(XmlNodeType.Element,"modul","");
                    XmlNode Attrib=Config.CreateAttribute("name");
                    Attrib.InnerText=ZefCache.GetBibleName;
                    Modul.InnerText=ZefCache.ModulMD5;
                    Modul.Attributes.SetNamedItem(Attrib);
                    Config.DocumentElement.AppendChild(Modul);
                    Config.Save(AppPath+@"\config.xml");

                }
                Environment.Exit(1000);

            }
            catch( FormatException e)
            {

                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1200);

            }

            catch( FileNotFoundException e)
            {

                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1500);

            }
                // Verbleibende Ausnahmen auffangen
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1900);
            }
        }
 public CacheFetchChapters(ZefaniaCache cache,bool zipped)
 {
     my_cache = cache;
     my_zipped=zipped;
 }
示例#5
0
        static void CreateCacheAndPack(string[] args)
        {
            try
            {
                string Path2ZefModul=args[1];

                string AppPath=GetApplicationFolderName();

                if(Path.GetDirectoryName(Path2ZefModul)=="")
                {

                    Path2ZefModul=AppPath+@"\"+ Path2ZefModul;
                }

                ZefaniaCache ZefCache = new ZefaniaCache(Path2ZefModul);

                ZefCache.BaseCacheDir=AppPath;
                Console.WriteLine(Path.GetFileName(Path2ZefModul));
                Console.WriteLine("Starte Cacherstellung.... bitte warten/wait");
                ZefCache.CreateCacheChapters(false);

                if(File.Exists(AppPath+@"\zefmodppc.xml"))
                {

                    System.Xml.XmlDocument ModullistePPC=new XmlDocument();
                    ModullistePPC.Load(AppPath+@"\zefmodppc.xml");
                    //nachsehen, ob ein Eintrag für dieses Modul schon in der Modulliste ist.
                    XmlNode ModulEntry=ModullistePPC.DocumentElement.SelectSingleNode("descendant::modul[@filename='"+ZefCache.ModulMD5+".zip']");
                    if(ModulEntry==null)
                    {
                        // nein neu anlegen
                        XmlDocument INFO=new XmlDocument();
                        INFO.Load(ZefCache.GetInfoPath);
                        ModulEntry=ModullistePPC.CreateNode(XmlNodeType.Element,"modul","");

                        XmlNode AttFilename=ModullistePPC.CreateNode(XmlNodeType.Attribute,"filename","");
                        AttFilename.Value=ZefCache.ModulMD5+".zip";
                        ModulEntry.Attributes.SetNamedItem(AttFilename);

                        XmlNode Attidentifier=ModullistePPC.CreateNode(XmlNodeType.Attribute,"identifier","");
                        Attidentifier.Value=INFO.SelectSingleNode("descendant::identifier").InnerText;
                        ModulEntry.Attributes.SetNamedItem(Attidentifier);

                        XmlNode Attlang=ModullistePPC.CreateNode(XmlNodeType.Attribute,"lang","");
                        Attlang.Value=INFO.SelectSingleNode("descendant::language").InnerText;
                        ModulEntry.Attributes.SetNamedItem(Attlang);

                        XmlNode Attlanguage=ModullistePPC.CreateNode(XmlNodeType.Attribute,"language","");
                        Attlanguage.Value=INFO.SelectSingleNode("descendant::language").InnerText;
                        ModulEntry.Attributes.SetNamedItem(Attlanguage);

                        XmlNode Attname=ModullistePPC.CreateNode(XmlNodeType.Attribute,"name","");
                        string name=ZefCache.GetBibleName;
                        name=name.Replace("XML","");
                        Attname.Value=name.Trim();
                        ModulEntry.Attributes.SetNamedItem(Attname);

                        XmlNode Attrevision=ModullistePPC.CreateNode(XmlNodeType.Attribute,"revision","");
                        Attrevision.Value=INFO.SelectSingleNode("descendant::revision").InnerText;
                        ModulEntry.Attributes.SetNamedItem(Attrevision);

                        XmlNode Atttype=ModullistePPC.CreateNode(XmlNodeType.Attribute,"type","");
                        Atttype.Value="bible";
                        ModulEntry.Attributes.SetNamedItem(Atttype);
                        // und einfügen
                        ModullistePPC.DocumentElement.SelectSingleNode("descendant::modules").AppendChild(ModulEntry);

                        ModullistePPC.Save(AppPath+@"\zefmodppc.xml");

                    }

                }

                Console.WriteLine("Cache ist fertig/ready");

                Console.WriteLine("Packe Cache..... bitte warten/wait");
                ZefCache.PackCache();
                Console.WriteLine("Cache ist gepackt-fertig/ready");

                System.Xml.XmlDocument Config=new XmlDocument();

                if(File.Exists(AppPath+@"\config.xml"))
                {

                    Config.Load(AppPath+@"\config.xml");

                }
                else
                {
                    Config.LoadXml("<module></module>");
                }

                XmlNode Modul=Config.DocumentElement.SelectSingleNode("descendant::modul[@name='"+ZefCache.GetBibleName+"' and text()='"+ZefCache.ModulMD5+"']");

                if(Modul==null)
                {
                    Modul =Config.CreateNode(XmlNodeType.Element,"modul","");
                    XmlNode Attrib=Config.CreateAttribute("name");
                    Attrib.InnerText=ZefCache.GetBibleName;
                    Modul.InnerText=ZefCache.ModulMD5;
                    Modul.Attributes.SetNamedItem(Attrib);
                    Config.DocumentElement.AppendChild(Modul);
                    Config.Save(AppPath+@"\config.xml");

                }

            }
            catch( FormatException e)
            {

                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1200);

            }

            catch( FileNotFoundException e)
            {

                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1500);

            }
                // Verbleibende Ausnahmen auffangen
            catch (Exception e)
            {
                Console.WriteLine("Exception {0}", e);
                Environment.Exit(1900);
            }
        }