Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
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);
            }
        }