Пример #1
0
        private void ConfigureNHibernate(IKernel container)
        {
            #if EXPLODEDB
            //recreate Schema
            var sessionFactory = Fluently.Configure()
                                 .Database(
                MsSqlConfiguration.MsSql2008.ConnectionString(
                    c => c.FromConnectionStringWithKey("owDbConn")))
                                 .CurrentSessionContext("web")
                                 .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))
                                 .Mappings(m => m.FluentMappings.AddFromAssemblyOf <sysBaseRuleset>())
                                 .BuildSessionFactory();
            //seed data
                #if SEED_DATA
            var            session = sessionFactory.OpenSession();
            nwdbRepository nwRepo  = new nwdbRepository(session);
            nwRepo.SeedMockData();
                #endif
            #else
            var sessionFactory = Fluently.Configure()
                                 .Database(
                MsSqlConfiguration.MsSql2008.ConnectionString(
                    c => c.FromConnectionStringWithKey("owDbConn")))
                                 .CurrentSessionContext("web")
                                 .ExposeConfiguration(cfg => new SchemaUpdate(cfg).Execute(false, true))
                                 .Mappings(m => m.FluentMappings.AddFromAssemblyOf <sysBaseRuleset>())
                                 .BuildSessionFactory();
            #endif

            //Bind Created or Updated to Ninject
            container.Bind <ISessionFactory>().ToConstant(sessionFactory);
        }
Пример #2
0
 public sysDocuments(hostUser logon, hostChar ch, nwdbRepository repo, nwdbConnection nw)
 {
     this.Logon      = logon;
     this.Character  = ch;
     this.Repository = repo;
     this.Database   = nw;
     initData();
 }
Пример #3
0
        public void nwDB_SeedRepo()
        {
            nwdbConnection nw2 = new nwdbConnection(true);

            sessionFactory = nw.Factory;
            repo           = new nwdbRepository(sessionFactory.OpenSession());
            repo.SeedMockData();
        }
Пример #4
0
        public frmUserManager()
        {
            InitializeComponent();
            nw = new nwdbConnection();

            //Update
            //nw = new nwdbConnection();


            sessionFactory         = nw.Factory;
            repo                   = new nwdbRepository(sessionFactory.OpenSession());
            sess                   = repo.GetSession();
            stm                    = new sysTreeManager();
            bs_hostUser.DataSource = sess.QueryOver <hostUser>().List();
            bs_userType.DataSource = sess.QueryOver <hostUserType>().List();
        }
Пример #5
0
 private void FrmLogon_Load(object sender, EventArgs e)
 {
     Debug.Print("LOAD FIRED");
     //Create&Drop
     if (nw == null)
     {
         nw = new nwdbConnection();
     }
     sessionFactory = nw.Factory;
     if (repo == null)
     {
         repo = new nwdbRepository(sessionFactory.OpenSession());
     }
     sess = repo.GetSession();
     //this.btnLogin_Click(this, null);
 }
Пример #6
0
 protected void DropCreateDB(string dbname, string username, string password)
 {
     nw             = new nwdbConnection(true, dbname, username, password);
     sessionFactory = nw.Factory;
     repo           = new nwdbRepository(sessionFactory.OpenSession());
 }
Пример #7
0
        static void Main()
        {
            var nw             = new nwdbConnection();
            var sessionFactory = nw.Factory;
            var repo           = new nwdbRepository(sessionFactory.OpenSession());

            // retreive all dmgtypes and display them
            //var sorttypes = session.CreateCriteria(typeof(ConstSysStatisticSortGroup))
            //                .List<ConstSysStatisticSortGroup>();
            //campTree nwt;

            /*
             * nwdbDataType nws;
             * ConstSysItemFamily nwf;
             * ConstSysItemClass nwc;
             * nws = new ConstSysDmgType();
             * WritePretty(nws.asList(session), "Damage Type");
             * nws = new ConstSysAoeType();
             * WritePretty(nws.asList(session), "Aoe Type");
             * nws = new ConstSysCheckResult();
             * WritePretty(nws.asList(session), "Check Result");
             * nws = new ConstSysRange();
             * WritePretty(nws.asList(session), "Ranges");
             * nws = new ConstSysSchool();
             * WritePretty(nws.asList(session), "Schools");
             * nws = new ConstSysStatisticSortGroup();
             * WritePretty(nws.asList(session), "Stat groups");
             * nws = new ConstSysFrequency();
             * WritePretty(nws.asList(session), "Frequency");
             *
             * Debug.WriteLine("Start" );
             * nwf = repo.FindOrNew(typeof(ConstSysItemFamily), "Items", "General") as ConstSysItemFamily;
             *
             * Debug.WriteLine("Armor Family returned" + nwf.toString());
             * nwf.LongName = "Armor + Shields";
             * session.SaveOrUpdate(nwf);
             *
             *
             *
             * // WritePretty(nwf.asList(session), "Item Family");
             * nwc = repo.FindOrNew(typeof(ConstSysItemClass), "Amulets", "Amulets, Necklaces") as ConstSysItemClass;
             *
             *
             * var records = repo.asList(nwc);
             * foreach (nwdbDataType r in records)
             * {
             *  Debug.Print("Amulet Report:" + r.toString());
             * }
             *
             *
             * //WritePretty(nwc.asList(session), "Item Class");
             * nwc.item_family = nwf;
             * //int r = nwf.FindIDByName(session, "Armor");
             * //Debug.WriteLine("Armor returned" + r as string);
             * //Debug.WriteLine("Set ItemClass Family to" +nwc.item_family.toString());
             * session.SaveOrUpdate(nwc);
             * */


            //add a dmttype
            //ConstSysDmgType c = new ConstSysDmgType("Piercing","Piercing Damage");
            //repo.Add(typeof(hostChar), new hostChar("Brian", "Brian Walter","*****@*****.**"));

            //hostChar c = repo.FindbyID(typeof(hostChar), 1) as hostChar;
            //Debug.WriteLine(c.ToString());
            //session.SaveOrUpdate(c);
            //transaction.Commit();
            //int did = repo.FindIDByLongName(typeof(hostChar), "Derek Willow2");
            //hostChar d = repo.FindbyID(typeof(hostChar), did) as hostChar;
            //Debug.WriteLine(d.ToString());

            Debug.Print("Calling List of hostChar");
            IList <nwdbDataType> il = repo.asList(typeof(hostChar));

            foreach (nwdbDataType item in il)
            {
                Debug.Print(item.ToString());
            }
        }