Example #1
0
        private void importToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var    path         = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaNotes.json";
            string input_string = File.ReadAllText(path);

            JsonSerializer serializer = new JsonSerializer();

            using (StreamReader sr = new StreamReader(path))
            {
                ISession session = SQLiteSessionManager.GetCurrentSession();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    while (sr.Peek() >= 0)
                    {
                        var jsonString = sr.ReadLine();
                        var resnote    = JsonConvert.DeserializeObject <Note>(jsonString);
                        if (resnote.Term != null)
                        {
                            Term term = DBHelper.GetAllWithRestrictionsEq <Term>("Name", resnote.Term.Name)[0];
                            term.AddNote(resnote);
                            DBUtil <Term> dBUtilTerm = new DBUtil <Term>();
                            dBUtilTerm.save(term);
                        }

                        session.Merge(resnote);
                    }

                    transaction.Commit();
                }
            }
        }
Example #2
0
        private static void CloseSession()
        {
            try
            {
                var session2 = SQLiteSessionManager.Unbind();

                if (session2 != null)
                {
                    if (session2.Transaction.IsActive)
                    {
                        try
                        {
                            session2.Transaction.Commit();
                        }
                        catch
                        {
                            session2.Transaction.Rollback();
                        }
                    }
                    session2.Close();
                }
            }
            catch
            {
            }
        }
Example #3
0
        public IList <T> GetAll()
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T)).List <T>();

            return(runs);
        }
Example #4
0
        public static void build_characters_aenaes()
        {
            var aeneid = DBHelper.GetAllWithRestrictionsEq <Poem>("Name", "Aeneid")[0];


            var ch_silvius = new Character
            {
                Name = "Silvius"
            };
            var ch_aeneas = new Character
            {
                Name = "Aeneas"
            };

            var ch_anchises = new Character
            {
                Name = "Anchises"
            };
            var ch_aphrodite = new Character
            {
                Name = "Aphrodite"
            };

            ch_anchises.AddChild(ch_aeneas);
            ch_aphrodite.AddMotherChild(ch_aeneas);

            var ch_latinus = new Character
            {
                Name = "Latinus"
            };


            var ch_lavinia = new Character
            {
                Name = "Lavinia"
            };

            ch_latinus.AddChild(ch_lavinia);
            ch_lavinia.AddMotherChild(ch_silvius);
            ch_aeneas.AddChild(ch_silvius);

            ch_aeneas.AddSpouse(ch_lavinia);


            aeneid.AddCharacter(ch_aeneas);
            aeneid.AddCharacter(ch_latinus);
            aeneid.AddCharacter(ch_lavinia);

            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(aeneid);
                session1.SaveOrUpdate(ch_aeneas);
                session1.SaveOrUpdate(ch_lavinia);
                session1.SaveOrUpdate(ch_silvius);

                transaction.Commit();
            }
        }
Example #5
0
        private void exportToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaNotes.json";

            ISession session = SQLiteSessionManager.GetCurrentSession();
            {
                using (session.BeginTransaction())
                {
                    var resnotes = session.CreateCriteria(typeof(Note))
                                   .List <Note>();

                    using (StreamWriter sw = new StreamWriter(path))
                    {
                        foreach (var note in resnotes)
                        {
                            string x = JsonConvert.SerializeObject(note, new JsonSerializerSettings()
                            {
                                ContractResolver = new NHibernateContractResolver()
                            });

                            sw.WriteLine(x);
                        }
                    }
                }
            }
        }
Example #6
0
        public static void Import_Book(string name, int number, string text0)
        {
            Book book = new Book
            {
                Number = number,
                Name   = name,
            };
            Canto canto = new Canto {
            };


            using (var reader = new StringReader(text0))
            {
                string txtline     = string.Empty;
                var    cantoNumber = 1;
                int    lineNumber  = 1;
                do
                {
                    txtline = reader.ReadLine();
                    if (txtline == null)
                    {
                        break;
                    }
                    txtline = txtline.Replace("\t", "").Trim(' ');
                    if (!string.IsNullOrEmpty(txtline))
                    {
                        if (txtline.StartsWith("##"))
                        {
                            cantoNumber = int.Parse(Regex.Replace(txtline, "## (.*)", "$1", RegexOptions.IgnoreCase));
                            lineNumber  = 1;
                            canto       = new Canto
                            {
                                Number = cantoNumber
                            };
                            book.AddCanto(canto);
                        }
                        else
                        {
                            var line = new Line
                            {
                                Number = lineNumber,
                                Text   = txtline
                            };
                            canto.AddLine(line);
                            lineNumber++;
                        }
                    }
                }while (txtline != null);
            }

            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.Save(book);

                transaction.Commit();
            }
        }
Example #7
0
        public static IList <T> GetAllWithCriteriaInsentiveLike <T>(string criteria, string name, object value)
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();

            return(session.CreateCriteria(typeof(T))
                   .CreateCriteria(criteria)
                   .Add(Restrictions.InsensitiveLike(name, value))
                   .List <T>());
        }
Example #8
0
        public void merge(T t)
        {
            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.Merge(t);

                transaction.Commit();
            }
        }
Example #9
0
        private void importToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            // Import term first
            {
                var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaTerms.json";

                using (StreamReader sr = new StreamReader(path))
                {
                    ISession session = SQLiteSessionManager.GetCurrentSession();

                    while (sr.Peek() >= 0)
                    {
                        var jsonString = sr.ReadLine();
                        var resnote    = JsonConvert.DeserializeObject <Term>(jsonString);
                        using (ITransaction transaction = session.BeginTransaction())
                        {
                            resnote.Id = 0;



                            session.SaveOrUpdate(resnote);
                            transaction.Commit();
                        }
                    }
                }
            }
            {
                var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaNotes.json";

                using (StreamReader sr = new StreamReader(path))
                {
                    while (sr.Peek() >= 0)
                    {
                        var jsonString = sr.ReadLine();
                        var resnote    = JsonConvert.DeserializeObject <Note>(jsonString);
                        resnote.Id = 0;
                        ISession session = SQLiteSessionManager.GetCurrentSession();
                        using (ITransaction transaction = session.BeginTransaction())
                        {
                            if (resnote.Term != null)
                            {
                                Term term = DBHelper.GetAllWithRestrictionsEq <Term>("Name", resnote.Term.Name)[0];
                                term.AddNote(resnote);
                                session.SaveOrUpdate(term);
                            }


                            session.SaveOrUpdate(resnote);
                            transaction.Commit();
                        }
                    }
                }
            }
        }
Example #10
0
        public static void save <T>(T t)
        {
            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(t);

                transaction.Commit();
            }
        }
Example #11
0
        public static IList <T> GetAll <T>()
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T)).List <T>();

            if (runs.Count > 0)
            {
                return(runs);
            }

            return(null);
        }
Example #12
0
        public IList <T> GetAllWithRestrictionsLoc(string bookName, string cantoName, string beginName, string endName, string book, int canto, int begin, int end)
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T))
                               .Add(Restrictions.And(Restrictions.Eq(cantoName, canto),
                                                     Restrictions.Eq(bookName, book)))
                               .Add(Restrictions.And(Restrictions.Le(endName, end),
                                                     Restrictions.Ge(beginName, begin)))
                               .List <T>();

            return(runs);
        }
Example #13
0
        public static IList <T> GetAllWithRestrictionsLike <T>(string name, string value)
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T))
                               .Add(Restrictions.Like(name, value, MatchMode.Anywhere))
                               .List <T>();

            if (runs.Count > 0)
            {
                return(runs);
            }

            return(null);
        }
Example #14
0
        public static void build_characters_minos()
        {
            var ch_Minos = new Character
            {
                Name = "Minos"
            };

            var ch_pasiphae = new Character
            {
                Name = "Pasiphaë"
            };

            ch_Minos.AddSpouse(ch_pasiphae);

            var ch_Minotaur = new Character
            {
                Name = "Minotaur"
            };

            ch_pasiphae.AddMotherChild(ch_Minotaur);

            var ch_Theseus = new Character
            {
                Name  = "Theseus",
                Story = "Kills Minotaur"
            };
            var ch_Ariadne = new Character
            {
                Name  = "Ariadne",
                Story = "Madly loves Theseus"
            };

            ch_Minos.AddChild(ch_Ariadne);
            ch_pasiphae.AddMotherChild(ch_Ariadne);


            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(ch_Minos);
                session1.SaveOrUpdate(ch_pasiphae);
                session1.SaveOrUpdate(ch_Minotaur);

                session1.SaveOrUpdate(ch_Theseus);
                session1.SaveOrUpdate(ch_Ariadne);

                transaction.Commit();
            }
        }
Example #15
0
        public static IList <T> GetAllWithRestrictionsInsentiveLike <T>(string name, object value)
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T))
                               .Add(Restrictions.InsensitiveLike(name, value))
                               .List <T>();

            if (runs.Count > 0)
            {
                return(runs);
            }

            return(null);
        }
Example #16
0
        private void exportToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            bool res = true;

            // Export Notes
            ISession session = SQLiteSessionManager.GetCurrentSession();

            using (session.BeginTransaction())
            {
                var resnotes = session.CreateCriteria(typeof(Note))
                               .List <Note>();
                var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaNotes.json";
                using (StreamWriter sw = new StreamWriter(path))
                {
                    foreach (var note in resnotes)
                    {
                        string x = JsonConvert.SerializeObject(note, new JsonSerializerSettings()
                        {
                            ContractResolver = new NHibernateContractResolver()
                        });

                        sw.WriteLine(x);
                    }
                }
            }

            // Export Terms
            session = SQLiteSessionManager.GetCurrentSession();
            using (session.BeginTransaction())
            {
                var resterms = session.CreateCriteria(typeof(Term))
                               .List <Term>();
                var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "//ComediaTerms.json";
                using (StreamWriter sw = new StreamWriter(path))
                {
                    foreach (var term in resterms)
                    {
                        string x = JsonConvert.SerializeObject(term, new JsonSerializerSettings()
                        {
                            ContractResolver = new NHibernateContractResolver()
                        });

                        sw.WriteLine(x);
                    }
                }
            }
            SetResult("export: " + ((res == true) ? "ok" : "fail"));
        }
Example #17
0
        public static IList <T> GetAllWithOrRestrictionsStringInsentiveLike <T>(string name, object value, string name2)
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();
            var      runs    = session.CreateCriteria(typeof(T))
                               .Add(Restrictions.Or(
                                        Restrictions.InsensitiveLike(name, (string)value, MatchMode.Anywhere),
                                        Restrictions.InsensitiveLike(name2, (string)value, MatchMode.Anywhere)))
                               .List <T>();

            if (runs.Count > 0)
            {
                return(runs);
            }

            return(null);
        }
Example #18
0
        public static void build_terms()
        {
            string poets_str     = "dante,  virgil,  homer, horice, ovid, lucan";
            string character_str = "beatrice";

            string[] arr_metaphors  = poets_str.Split(',');
            string[] arr_characters = character_str.Split(',');
            ISession session1       = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                for (int i = 0; i < arr_metaphors.Length; i++)
                {
                    if (string.IsNullOrEmpty(arr_metaphors[i]))
                    {
                        continue;
                    }


                    var term = new Term
                    {
                        Name = arr_metaphors[i].Trim(new char[] { ',', ' ' }),
                    };
                    term.SetMetaphorItem("category", "poet");
                    session1.SaveOrUpdate(term);
                }

                for (int i = 0; i < arr_characters.Length; i++)
                {
                    if (string.IsNullOrEmpty(arr_characters[i]))
                    {
                        continue;
                    }


                    var term = new Term
                    {
                        Name = arr_characters[i].Trim(new char[] { ',', ' ' }),
                    };
                    term.SetMetaphorItem("category", "character");
                    session1.SaveOrUpdate(term);
                }

                transaction.Commit();
            }
        }
Example #19
0
        public static void build_characters_comedy()
        {
            var comedy = DBHelper.GetAllWithRestrictionsEq <Poem>("Name", "Divine Comedy")[0];

            var ch_dante = new Character
            {
                Name = "Dante-Pilgrim"
            };
            var ch_dante2 = new Character
            {
                Name = "Dante-Narrator"
            };

            var ch_virgil = new Character
            {
                Name = "Virgil"
            };
            var ch_beatrice = new Character
            {
                Name = "Beatrice"
            };

            var ch_Erichtho = new Character
            {
                Name  = "Erichtho",
                Story = "A Witch. Summon Virgil to the lowest hell. (Virgil's dark past)"
            };

            comedy.AddCharacter(ch_dante);
            comedy.AddCharacter(ch_dante2);
            comedy.AddCharacter(ch_beatrice);
            comedy.AddCharacter(ch_virgil);

            comedy.AddCharacter(ch_Erichtho);


            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(ch_Erichtho);
                session1.SaveOrUpdate(comedy);

                transaction.Commit();
            }
        }
Example #20
0
        public static void Import_line(int number, string text)
        {
            Line run = new Line {
            };

            run.Number = number;
            run.Text   = text;


            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.Save(run);

                transaction.Commit();
            }
        }
Example #21
0
        public static void build_characters_erinyes()
        {
            var ch_Tisiphone = new Character
            {
                Name  = "Tisiphone",
                Story = "Punisher of murderers"
            };
            var ch_Alecto = new Character
            {
                Name  = "Alecto",
                Story = "Punisher of moral crimes (angre, etc)"
            };
            var ch_Megaera = new Character
            {
                Name  = "Megaera",
                Story = "Punisher of infidelity, oath breakers, and theft"
            };

            var ch_Medusa = new Character
            {
                Name  = "Medusa",
                Story = "The ability to turn anyone to stone with her gaze"
            };

            var ch_Perseus = new Character
            {
                Name  = "Perseus",
                Story = "Kill Medusa"
            };
            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(ch_Tisiphone);
                session1.SaveOrUpdate(ch_Alecto);
                session1.SaveOrUpdate(ch_Megaera);

                session1.SaveOrUpdate(ch_Medusa);
                session1.SaveOrUpdate(ch_Perseus);
                transaction.Commit();
            }
        }
Example #22
0
        public static void Import_Poet(string name, string poem_name)
        {
            Poet poet = new Poet {
                Name = name
            };
            Poem poem = new Poem
            {
                Name   = poem_name,
                Author = poet
            };

            poet.Poems.Add(poem);

            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(poet);

                transaction.Commit();
            }
        }
Example #23
0
        public IList <T> GetAllWithOrRestrictionsStringInsentiveLike(string name, object value, string name2 = "")
        {
            ISession session = SQLiteSessionManager.GetCurrentSession();

            if (string.IsNullOrEmpty(name2))
            {
                var runs = session.CreateCriteria(typeof(T))
                           .Add(Restrictions.InsensitiveLike(name, (string)value, MatchMode.Anywhere))
                           .List <T>();

                return(runs);
            }
            else
            {
                var runs = session.CreateCriteria(typeof(T))
                           .Add(Restrictions.Or(
                                    Restrictions.InsensitiveLike(name, (string)value, MatchMode.Anywhere),
                                    Restrictions.InsensitiveLike(name2, (string)value, MatchMode.Anywhere)))
                           .List <T>();

                return(runs);
            }
        }
Example #24
0
        public static void build_politician()
        {
            var florence = DBHelper.GetAllWithRestrictionsEq <Place>("Name", "Florence")[0];

            var guido = new Poet
            {
                Name     = "Guido",
                FullName = "Guido Cavalcanti"
            };

            florence.AddPerson(guido);
            florence.AddPersonDead(guido);

            var cavalcanti10 = new Politician
            {
                Name     = "Cavalcante",
                FullName = "Cavalcante de' Cavalcanti"
            };

            cavalcanti10.AddChild(guido);

            var guido27 = new Politician
            {
                Name     = "Guido",
                FullName = "Guido Da Montefeltro"
            };
            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(guido);
                session1.SaveOrUpdate(cavalcanti10);
                session1.SaveOrUpdate(guido27);
                transaction.Commit();
            }
        }
Example #25
0
 public static bool Updatedb()
 {
     CloseSession();
     SQLiteSessionManager.UpdateSchema();
     return(true);
 }
Example #26
0
        public static void build_notes()
        {
            var midway = new Note
            {
                Name       = "midway",
                Commentary = "Dante was 35 years old, 1300 C.E.",
                Loc        = new Loc
                {
                    Book  = "Inferno",
                    Canto = 1,
                    Start = 1,
                    End   = 1,
                }
            };
            var forest = new Note
            {
                Name = "wood",
                Loc  = new Loc
                {
                    Book  = "Inferno",
                    Canto = 1,
                    Start = 2,
                    End   = 2,
                }
            };
            Term wood = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "wood")[0];

            if (wood != null)
            {
                wood.AddNote(forest);
            }

            var leopardNote = new Note
            {
                Loc = new Loc
                {
                    Book  = "Inferno",
                    Canto = 1,
                    Start = 33,
                    End   = 33,
                }
            };
            Term leopard = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "leopard")[0];

            leopard.AddNote(leopardNote);

            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(midway);
                session1.SaveOrUpdate(forest);

                session1.SaveOrUpdate(leopard);
                if (wood != null)
                {
                    session1.SaveOrUpdate(wood);
                }
                session1.SaveOrUpdate(leopardNote);
                transaction.Commit();
            }
        }
Example #27
0
        public static void build_poets_elite_six()
        {
            string poet_str  = "Dante,          Virgil,      Homer,   Horace,        Ovid,          Lucan";
            string born_str  = "Florence,      Mantua,   Venusia,    Sumona,            ,               ";
            string dead_str  = "Ravenna,              ,      Rome,          ,        Rome,               ";
            string write_str = "Divine Comedy,  Aeneid,     Iliad,          , The Metamorphoses, Pharsalia";

            string[] arr_poets   = poet_str.Split(',');
            string[] arr_born    = born_str.Split(',');
            string[] arr_dead    = dead_str.Split(',');
            string[] arr_writing = write_str.Split(',');
            ISession session1    = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                int ind = 0;
                for (int i = 0; i < arr_poets.Length; i++)
                {
                    if (string.IsNullOrEmpty(arr_poets[i]))
                    {
                        continue;
                    }

                    var   str_born = arr_born[i].Trim(new char[] { ' ' });
                    var   str_dead = arr_dead[i].Trim(new char[] { ' ' });
                    Place pl_born;
                    Place pl_dead;
                    if (string.IsNullOrEmpty(str_born))
                    {
                        pl_born = null;
                    }
                    else
                    {
                        var places = DBHelper.GetAllWithRestrictionsEq <Place>("Name", str_born);
                        if (places != null)
                        {
                            pl_born = places[0];
                        }
                        else
                        {
                            pl_born = new Place
                            {
                                Name = str_born
                            };
                        }
                    }
                    if (string.IsNullOrEmpty(str_dead))
                    {
                        pl_dead = null;
                    }
                    else
                    {
                        var places = DBHelper.GetAllWithRestrictionsEq <Place>("Name", str_dead);
                        if (places != null)
                        {
                            pl_dead = places[0];
                        }
                        else
                        {
                            pl_dead = new Place
                            {
                                Name = str_dead
                            };
                        }
                    }

                    var objPoet = new Poet
                    {
                        Name = arr_poets[i].Trim(new char[] { ',', ' ' }),
                    };
                    if (pl_born != null)
                    {
                        pl_born.AddPerson(objPoet);
                    }
                    if (pl_dead != null)
                    {
                        pl_dead.AddPersonDead(objPoet);
                    }
                    var poem_name = arr_writing[i].Trim(new char[] { ',', ' ' });
                    if (!string.IsNullOrEmpty(poem_name))
                    {
                        var poem = new Poem
                        {
                            Name = poem_name
                        };
                        objPoet.AddPoem(poem);
                        session1.SaveOrUpdate(poem);
                    }

                    session1.SaveOrUpdate(objPoet);

                    if (pl_born != null)
                    {
                        session1.SaveOrUpdate(pl_born);
                    }
                    if (pl_dead != null)
                    {
                        session1.SaveOrUpdate(pl_dead);
                    }
                }


                transaction.Commit();
            }
        }
Example #28
0
        public static void build_characters_electra()
        {
            var poem_Iliad = DBHelper.GetAllWithRestrictionsEq <Poem>("Name", "Iliad")[0];

            var ch_electra = new Character
            {
                Name = "Electra"
            };
            var ch_Agamemnon = new Character
            {
                Name = "Agamemnon"
            };
            var ch_Clytemnestra = new Character
            {
                Name = "Clytemnestra"
            };
            var ch_Orestes = new Character
            {
                Name = "Orestes"
            };



            var ch_Iphigenia = new Character
            {
                Name = "Iphigenia"
            };
            var ch_Chrysothemis = new Character
            {
                Name = "Chrysothemis"
            };

            ch_Agamemnon.AddSpouse(ch_Clytemnestra);

            ch_Agamemnon.AddChild(ch_Iphigenia);
            ch_Agamemnon.AddChild(ch_electra);
            ch_Agamemnon.AddChild(ch_Chrysothemis);
            ch_Agamemnon.AddChild(ch_Orestes);


            ch_Clytemnestra.AddMotherChild(ch_Iphigenia);
            ch_Clytemnestra.AddMotherChild(ch_electra);
            ch_Clytemnestra.AddMotherChild(ch_Chrysothemis);
            ch_Clytemnestra.AddMotherChild(ch_Orestes);

            poem_Iliad.AddCharacter(ch_Agamemnon);
            poem_Iliad.AddCharacter(ch_Iphigenia);
            poem_Iliad.AddCharacter(ch_electra);
            poem_Iliad.AddCharacter(ch_Chrysothemis);
            poem_Iliad.AddCharacter(ch_Orestes);

            ISession session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(ch_Iphigenia);
                session1.SaveOrUpdate(ch_electra);
                session1.SaveOrUpdate(ch_Chrysothemis);
                session1.SaveOrUpdate(ch_Orestes);


                session1.SaveOrUpdate(ch_Agamemnon);
                session1.SaveOrUpdate(ch_Clytemnestra);

                session1.SaveOrUpdate(poem_Iliad);
                transaction.Commit();
            }
        }
Example #29
0
 public static bool Initdb()
 {
     CloseSession();
     SQLiteSessionManager.ExportSchema();
     return(true);
 }
Example #30
0
        public static void build_metaphors_inferno()
        {
            string metaphor_str = "wood,  leopard,  lion, she-wolf, dove ";

            string[] arr_metaphors = metaphor_str.Split(',');
            ISession session1      = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                for (int i = 0; i < arr_metaphors.Length; i++)
                {
                    if (string.IsNullOrEmpty(arr_metaphors[i]))
                    {
                        continue;
                    }


                    var term = new Term
                    {
                        Name = arr_metaphors[i].Trim(new char[] { ',', ' ' }),
                    };

                    session1.SaveOrUpdate(term);
                }

                transaction.Commit();
            }
            Term wood = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "wood")[0];

            wood.Alias = "forest";

            Term leopard = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "leopard")[0];
            Term lion    = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "lion")[0];
            Term shewolf = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "she-wolf")[0];
            Term dove    = DBHelper.GetAllWithRestrictionsEq <Term>("Name", "dove")[0];

            leopard.SetMetaphorItem("sin", "lust");
            leopard.SetMetaphorItem("trinity", "leopard, lion, she-wolf");

            lion.SetMetaphorItem("sin", "pride");
            lion.SetMetaphorItem("trinity", "leopard, lion, she-wolf");

            shewolf.Alias = "shewolf";
            shewolf.SetMetaphorItem("sin", "avarice");
            shewolf.SetMetaphorItem("trinity", "leopard, lion, she-wolf");


            dove.SetMetaphorItem("aphrodite", "love");
            dove.SetMetaphorItem("christian", "holy spirit");

            session1 = SQLiteSessionManager.GetCurrentSession();

            using (ITransaction transaction = session1.BeginTransaction())
            {
                session1.SaveOrUpdate(wood);
                session1.SaveOrUpdate(leopard);
                session1.SaveOrUpdate(lion);
                session1.SaveOrUpdate(shewolf);

                transaction.Commit();
            }
        }