示例#1
0
        public void ModelInfo()
        {
            ModelInfo model = new ModelInfo();
            BomTable  bt    = new BomTable()
            {
                BomName = Guid.NewGuid().ToString(),
                Header  = new List <string>()
                {
                    Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString()
                },
                TotalCols = 2,
                TotalRow  = 10,
                //Rows = new List<BomTableRow>()
            };

            //for (int i = 0; i < 10; i++)
            //{
            //    BomTableRow row = new BomTableRow();

            //    //for (int j = 0; j < 10; j++)
            //    //{
            //    //    row.Cells.Add("Value " + j.ToString());
            //    //}

            //    bt.Rows.Add(row);

            //}
            model.BomTables = new List <BomTable>();
            model.BomTables.Add(bt);

            try
            {
                using (SessionNoServerShared session = new SessionNoServerShared(s_systemDir))
                {
                    session.BeginUpdate();
                    //session.Persist(model.BomTables);
                    session.Persist(model);
                    session.Commit();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }

            try
            {
                using (SessionNoServerShared session = new SessionNoServerShared(s_systemDir))
                {
                    session.BeginRead();
                    //var models1 = session.AllObjects<List<BomTable>>().ToList();
                    var models = session.AllObjects <ModelInfo>().ToList();
                    session.Commit();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.ToString());
            }
        }
示例#2
0
 public void CreateTicksCompareFieldsOidShort(int numberOfTicks, int nodeSize)
 {
     using (var session = new SessionNoServer(systemDir))
     {
         session.BeginRead();
         session.Open(10, 1, 1, false);
         session.Open(10, 1, 2, false);
         session.Open(10, 2, 1, false);
         session.Open(10, 2, 2, false);
         session.Commit();
     }
     using (var session = new SessionNoServerShared(systemDir, 2000, false))
     {
         //session.SetTraceAllDbActivity();
         //session.ClientCache.MinimumAvailableMegaBytes = 1100;
         session.BeginUpdate();
         CompareByField <Tick> compareByField = new CompareByField <Tick>("<Bid>k__BackingField", session, true);
         //compareByField.AddFieldToCompare("<Timestamp>k__BackingField");
         BTreeSetOidShort <Tick> bTree = new BTreeSetOidShort <Tick>(compareByField, session, (UInt16)nodeSize, sizeof(double), true);
         Placement place      = new Placement((UInt32)numberOfTicks, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
         Placement ticksPlace = new Placement((UInt32)numberOfTicks, 10000, 1, UInt16.MaxValue, UInt16.MaxValue);
         bTree.Persist(place, session);
         int i          = 0;
         int dublicates = 0;
         foreach (var record in Tick.GenerateRandom((ulong)numberOfTicks))
         {
             session.Persist(record, ticksPlace);
             if (bTree.Add(record))
             {
                 i++;
             }
             else
             {
                 dublicates++;
             }
         }
         session.Commit();
         Console.WriteLine("Done creating and sorting with BTreeSetOidShort<Tick>" + i + " Tick objects by Bid value. Number of dublicates (not added to BTreeSet): " + dublicates);
     }
 }
示例#3
0
        public void Create4Projects(int numberOfProjects)
        {
            Project project      = null;
            Project priorProject = null;

            for (int i = 0; i < numberOfProjects; i++)
            {
                using (var session = new SessionNoServerShared(systemDir))
                {
                    session.BeginUpdate();
                    IssueTracker issueTracker = session.AllObjects <IssueTracker>(false).FirstOrDefault();
                    User         user         = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Keys.Count - 1)];
                    string       p            = "project" + i.ToString();
                    string       d            = "pdescription" + i.ToString();
                    project = new Project(user, p, d);
                    session.Persist(project);
                    priorProject = project;
                    issueTracker.ProjectSet.Add(project);
                    session.Commit();
                }
            }
        }
        public void CreateDataAndIterateDb(int numObj)
        {
            using (SessionNoServer session = new SessionNoServer(s_systemDir))
            {
                session.Verify();
                session.BeginUpdate();
                UInt32   dbNum = session.DatabaseNumberOf(typeof(NotSharingPage));
                Database db    = session.OpenDatabase(dbNum, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA));
                db    = session.OpenDatabase(dbNum, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB));
                db    = session.OpenDatabase(dbNum, true, false);
                if (db != null)
                {
                    session.DeleteDatabase(db);
                }
                session.Commit();
            }

            using (var session = new SessionNoServerShared(s_systemDir))
            {
                session.Verify();
                session.BeginUpdate();
                UInt32    dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB));
                Placement place = new Placement(dbNum, 100);
                for (int i = 0; i < numObj; i++)
                {
                    NotSharingPage ns = new NotSharingPage();
                    session.Persist(ns);
                    SharingPageTypeA sA = new SharingPageTypeA();
                    session.Persist(sA);
                    SharingPageTypeB sB = new SharingPageTypeB();
                    if (i % 5 == 0)
                    {
                        sB.Persist(session, place);
                    }
                    else if (i % 1001 == 0)
                    {
                        sB.Persist(session, sA);
                    }
                    else if (i % 3001 == 0)
                    {
                        sB.Persist(session, ns);
                    }
                    else
                    {
                        session.Persist(sB);
                    }
                }
                session.Commit();
            }

            using (SessionNoServer session = new SessionNoServer(s_systemDir))
            {
                session.BeginRead();
                session.Verify();
                UInt32   dbNum = session.DatabaseNumberOf(typeof(NotSharingPage));
                Database db    = session.OpenDatabase(dbNum);
                AllObjects <NotSharingPage> all = db.AllObjects <NotSharingPage>();
                ulong ct = all.Count();
                dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeA));
                OfType ofType = db.OfType(typeof(NotSharingPage));
                ulong  ct2    = ofType.Count();
                Assert.AreEqual(ct, ct2);
                Database dbA = session.OpenDatabase(dbNum);
                dbNum = session.DatabaseNumberOf(typeof(SharingPageTypeB));
                Database dbB = session.OpenDatabase(dbNum);
                AllObjects <SharingPageTypeA> allA = dbA.AllObjects <SharingPageTypeA>();
                AllObjects <SharingPageTypeB> allB = dbB.AllObjects <SharingPageTypeB>();
                OfType           allA2             = dbA.OfType(typeof(SharingPageTypeA));
                int              start             = numObj / 2;
                NotSharingPage   ns  = all.ElementAt(numObj);
                SharingPageTypeA sA  = allA.ElementAt(numObj);
                SharingPageTypeA sA2 = (SharingPageTypeA)allA2.ElementAt(numObj);
                Assert.AreEqual(sA, sA2);
                sA  = allA.ElementAt(10);
                sA2 = (SharingPageTypeA)allA2.ElementAt(10);
                Assert.AreEqual(sA, sA2);
                //MethodInfo method = typeof(Database).GetMethod("AllObjects");
                //MethodInfo generic = method.MakeGenericMethod(sA.GetType());
                //dynamic itr = generic.Invoke(dbA, new object[]{ true });
                //SharingPageTypeA sAb = itr.ElementAt(numObj);
                //Assert.AreEqual(sA, sAb);
                //SharingPageTypeA sAc = itr.ElementAt(numObj);
                SharingPageTypeB        sB = allB.ElementAt(numObj);
                List <NotSharingPage>   notSharingPageList = all.Skip(100).ToList();
                List <SharingPageTypeA> sharingPageTypeA   = allA.Take(5).Skip(100).ToList();
                for (int i = start; i < numObj; i++)
                {
                    sA = allA.ElementAt(i);
                }
                for (int i = start; i < numObj; i += 5)
                {
                    ns = all.ElementAt(i);
                }
                for (int i = start; i < numObj; i += 5)
                {
                    sB = allB.ElementAt(i);
                }
                for (int i = 0; i < numObj; i += 45000)
                {
                    ns = all.ElementAt(i);
                }
                int allB_count = (int)allB.Count();
                for (int i = 0; i < allB_count - 1; i++)
                {
                    Assert.NotNull(allB.ElementAt(i));
                }
                session.Checkpoint();
                session.DeleteDatabase(db);
                session.DeleteDatabase(dbA);
                session.DeleteDatabase(dbB);
                session.Commit();
            }
        }