Example #1
1
 public Order(Customer customer)
 {
   m_orderId = 0;
   m_customer = customer;
   m_customer.Orders.Add(this);
   m_payments = new VelocityDbList<Payment>();
 }
Example #2
0
        private void Create1000TestObjectsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem            menuItem = (MenuItem)sender;
            FederationViewModel view     = (FederationViewModel)menuItem.DataContext;
            FederationInfo      info     = view.Federationinfo;
            SessionBase         session  = view.Session;

            if (session.InTransaction)
            {
                session.Commit();
            }
            session.BeginUpdate();
            //session.EnableSyncByTrackingChanges = true;
            try
            {
                for (int i = 0; i < 1000; i++)
                {
                    VelocityDbList <OptimizedPersistable> list = new VelocityDbList <OptimizedPersistable>();
                    //for (int j = 0; j < 10; j++)
                    //  list.Add(new OptimizedPersistable());
                    session.Persist(list);
                }
                session.Commit();
                m_viewModel      = new AllFederationsViewModel();
                base.DataContext = m_viewModel;
            }
            catch (Exception ex)
            {
                session.Abort();
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="IdentityUser"/> class.
 /// </summary>
 public IdentityUser()
 {
     m_userLoginIds      = new VelocityDbList <UserLoginInfo>();
     m_roles             = new VelocityDbList <IdentityRole>();
     m_claims            = new VelocityDbList <Claim>();
     m_lockoutEndDateUtc = null;
 }
Example #4
0
 static void CreateData()
 {
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     bool dirExist = Directory.Exists(session.SystemDirectory);
     if (dirExist)
       Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
     Directory.CreateDirectory(session.SystemDirectory);
     File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"));
     DataCache.MaximumMemoryUse = 10000000000; // 10 GB, set this to what fits your case
     SessionBase.DefaultCompressPages = PageInfo.compressionKind.LZ4;
     session.BeginUpdate();
     BTreeMap<Int64, VelocityDbList<Person>> btreeMap = new BTreeMap<Int64, VelocityDbList<Person>>(null, session);
     session.Persist(btreeMap);
     for (int i = 0; i < 100000; i++)
     {
       Person p = new Person();
       GeoHash geohash = GeoHash.WithBitPrecision(p.Lattitude, p.Longitude);
       VelocityDbList<Person> personList;
       if (btreeMap.TryGetValue(geohash.LongValue, out personList))
         personList.Add(p);
       else
       {
         personList = new VelocityDbList<Person>(1);
         //session.Persist(p);
         personList.Add(p);
         session.Persist(personList);
         btreeMap.Add(geohash.LongValue, personList);
       }
     }
     session.Commit();
   }
 }
Example #5
0
 public Order(Customer customer)
 {
     m_orderId  = 0;
     m_customer = customer;
     m_customer.Orders.Add(this);
     m_payments = new VelocityDbList <Payment>();
 }
Example #6
0
 private void Create1000TestObjectsMenuItem_Click(object sender, RoutedEventArgs e)
 {
   MenuItem menuItem = (MenuItem)sender;
   FederationViewModel view = (FederationViewModel)menuItem.DataContext;
   FederationInfo info = view.Federationinfo;
   SessionBase session = view.Session;
   if (session.InTransaction)
     session.Commit();
   session.BeginUpdate();
   //session.EnableSyncByTrackingChanges = true;
   try
   {
     for (int i = 0; i < 1000; i++)
     {
       VelocityDbList<OptimizedPersistable> list = new VelocityDbList<OptimizedPersistable>();
       //for (int j = 0; j < 10; j++)
       //  list.Add(new OptimizedPersistable());
       session.Persist(list);
     }
     session.Commit();
     m_viewModel = new AllFederationsViewModel();
     base.DataContext = m_viewModel;
   }
   catch (Exception ex)
   {
     session.Abort();
     MessageBox.Show(ex.Message);
   }
 }
Example #7
0
 public Store(string name)
 {
     this.m_name       = name;
     m_dateTimeCreated = m_modifyDate = DateTime.Now;
     m_categoryList    = new VelocityDbList <StoreInCategory>();
     m_isValid         = true;
 }
Example #8
0
 /// <summary>
 /// Creates a new edge type.
 /// </summary>
 /// <param name="aTypeId">The id to use for the new edge type</param>
 /// <param name="aTypeName">A type name to use</param>
 /// <param name="tailType">Restrict tail vertex to a certain vertex type</param>
 /// <param name="headType">Restrict head vertex to a certain vertex type</param>
 /// <param name="birectional">Is this edge type bidirectional (going both ways)</param>
 /// <param name="baseType">A base type can be specified</param>
 /// <param name="graph">The owning graph</param>
 public EdgeType(TypeId aTypeId, string aTypeName, VertexType tailType, VertexType headType, bool birectional, EdgeType baseType, Graph graph)
 {
     this.graph    = graph;
     this.baseType = baseType;
     subType       = new VelocityDbList <EdgeType>();
     if (baseType != null)
     {
         baseType.subType.Add(this);
     }
     this.birectional = birectional;
     typeId           = aTypeId;
     typeName         = aTypeName;
     this.tailType    = tailType;
     this.headType    = headType;
     if (Unrestricted)
     {
         unrestrictedEdges = new BTreeMap <EdgeId, UnrestrictedEdge>(null, graph.Session);
     }
     else
     {
         restrictedEdges = new BTreeMap <EdgeId, ulong>(null, graph.Session);
     }
     stringToPropertyType = new BTreeMap <string, PropertyType>(null, graph.Session);
     edgeRanges           = new VelocityDbList <Range <EdgeId> >();
 }
Example #9
0
 public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
 {
     m_firstName  = firstName;
     m_lastName   = lastName;
     m_age        = age;
     m_bestFriend = bestFriend;
     m_friends    = new VelocityDbList <Person>();
 }
Example #10
0
 public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
 {
   this.firstName = firstName;
   this.lastName = lastName;
   this.age = age;
   this.bestFriend = bestFriend;
   friends = new VelocityDbList<Person>();
 }
Example #11
0
 public Person(string firstName, string lastName, UInt16 age, Person bestFriend = null)
 {
     this.firstName  = firstName;
     this.lastName   = lastName;
     this.age        = age;
     this.bestFriend = bestFriend;
     friends         = new VelocityDbList <Person>();
 }
Example #12
0
 public StoreProducts(string storeStr, string fileName, string description, string link, string image)
 {
     storeName        = storeStr;
     this.fileName    = fileName;
     this.description = description;
     this.link        = link;
     this.image       = image;
     productList      = new VelocityDbList <StoreProduct>();
 }
Example #13
0
 public void InitChildrenIfNecessary()
 {
   if (childrenWeakReference == null)
   {
     var childrenList = new VelocityDbList<DataBaseFileEntry>();
     childrenList.Persist(Session, this);
     childrenWeakReference = new WeakIOptimizedPersistableReference<VelocityDbList<DataBaseFileEntry>>(childrenList);
     Update();
   }
 }
Example #14
0
 public StoreCoupons(Store store, string fileName, string description, string image, string link, int stars)
 {
     name             = store.Name;
     this.fileName    = fileName;
     this.description = description;
     this.image       = image;
     this.link        = link;
     this.stars       = stars;
     couponList       = new VelocityDbList <Coupon>();
 }
Example #15
0
 public void InitChildrenIfNecessary()
 {
     if (childrenWeakReference == null)
     {
         var childrenList = new VelocityDbList <DataBaseFileEntry>();
         childrenList.Persist(Session, this);
         childrenWeakReference = new WeakIOptimizedPersistableReference <VelocityDbList <DataBaseFileEntry> >(childrenList);
         Update();
     }
 }
Example #16
0
 public Store(string name, string description, string keyWords, int rating)
 {
     this.m_name        = name;
     this.m_description = description;
     this.m_keyWords    = keyWords;
     this.m_rating      = rating;
     m_dateTimeCreated  = DateTime.Now;
     m_modifyDate       = DateTime.Now;
     m_categoryList     = new VelocityDbList <StoreInCategory>();
     m_isValid          = true;
 }
Example #17
0
 public Store(string name, string description, string keyWords, string rating, string dateTimeCreated, string dateTimeUpdated, string isValid)
 {
     this.m_name        = name;
     this.m_description = description;
     this.m_keyWords    = description;
     int.TryParse(rating, out this.m_rating);
     DateTime.TryParse(dateTimeCreated, out this.m_dateTimeCreated);
     DateTime.TryParse(dateTimeUpdated, out this.m_modifyDate);
     m_categoryList = new VelocityDbList <StoreInCategory>();
     this.m_isValid = bool.Parse(isValid);
 }
Example #18
0
 public Person(Person person = null) // creates a random Person object
 {
   int r = randGen.Next(99999);
   firstName = r.ToString();
   r = randGen.Next(99999999);
   lastName = r.ToString();
   VelocityDbList<Person> personList = new VelocityDbList<Person>();
   if (person != null && person.IsPersistent)
   {
     personList.Persist(person.Session, person);
     personList.Add(person);
     friendsRef = new WeakIOptimizedPersistableReference<VelocityDbList<Person>>(personList);
   }
 }
Example #19
0
 internal VertexType(TypeId aTypeId, string aTypeName, VertexType baseType, Graph graph)
 {
   this.graph = graph;
   this.baseType = baseType;
   subType = new VelocityDbList<VertexType>();
   if (baseType != null)
     baseType.subType.Add(this);
   typeId = (TypeId)aTypeId;
   typeName = aTypeName;
   vertecis = new VelocityDbList<Range<VertexId>>();
   stringToPropertyType = new BTreeMap<string, PropertyType>(null, graph.Session);
   edgeTypes = new BTreeSet<EdgeType>(null, graph.Session);
   tailToHeadEdges = new BTreeMap<EdgeType, BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>(null, graph.Session);
   headToTailEdges = new BTreeMap<EdgeType, BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>(null, graph.Session);
 }
Example #20
0
 public Person(int arrayCapacity = 0) 
 {
   m_autoIncrement = 0;
   int r = s_randGen.Next(99999);
   m_firstName = r.ToString();
   r = s_randGen.Next(99999999);
   m_lastName = r.ToString();
   m_age = (UInt16)s_randGen.Next(150);
   m_ssn = s_randGen.Next();
   m_friends = new VelocityDbList<WeakIOptimizedPersistableReference<Person>>(arrayCapacity);
   this.m_pets = new List<Pet>(arrayCapacity);
   PersonID = Guid.NewGuid();
   m_longitude = (s_randGen.Next(360) - 180) * s_randGen.NextDouble();
   m_latitude = (s_randGen.Next(180) - 90) * s_randGen.NextDouble();
 }
Example #21
0
    public Person(string firstName, string lastName, UInt16 age, long ssn, Person bestFriend, Person spouse)
		{
			m_firstName = firstName;
			m_lastName = lastName;
			m_age = age;
			m_ssn = ssn;
      if (spouse != null)
			  m_spouse = new WeakIOptimizedPersistableReference<Person>(spouse);
      m_pets = new List<Pet>();
      m_friends = new VelocityDbList<WeakIOptimizedPersistableReference<Person>>(0);
      if (bestFriend != null)
      {
        m_bestFriend = new WeakIOptimizedPersistableReference<Person>(bestFriend);
        m_friends.Add(new WeakIOptimizedPersistableReference<Person>(bestFriend));
      }
		}
Example #22
0
        public Person(int arrayCapacity = 0)
        {
            m_autoIncrement = 0;
            int r = s_randGen.Next(99999);

            m_firstName = r.ToString();
            r           = s_randGen.Next(99999999);
            m_lastName  = r.ToString();
            m_age       = (UInt16)s_randGen.Next(150);
            m_ssn       = s_randGen.Next();
            m_friends   = new VelocityDbList <WeakIOptimizedPersistableReference <Person> >(arrayCapacity);
            this.m_pets = new List <Pet>(arrayCapacity);
            PersonID    = Guid.NewGuid();
            m_longitude = (s_randGen.Next(360) - 180) * s_randGen.NextDouble();
            m_latitude  = (s_randGen.Next(180) - 90) * s_randGen.NextDouble();
        }
Example #23
0
        public Person(Person person = null) // creates a random Person object
        {
            int r = randGen.Next(99999);

            firstName = r.ToString();
            r         = randGen.Next(99999999);
            lastName  = r.ToString();
            VelocityDbList <Person> personList = new VelocityDbList <Person>();

            if (person != null && person.IsPersistent)
            {
                personList.Persist(person.Session, person);
                personList.Add(person);
                friendsRef = new WeakIOptimizedPersistableReference <VelocityDbList <Person> >(personList);
            }
        }
Example #24
0
 public Person(string firstName, string lastName, UInt16 age, long ssn, Person bestFriend, Person spouse)
 {
     m_firstName = firstName;
     m_lastName  = lastName;
     m_age       = age;
     m_ssn       = ssn;
     if (spouse != null)
     {
         m_spouse = new WeakIOptimizedPersistableReference <Person>(spouse);
     }
     m_pets    = new List <Pet>();
     m_friends = new VelocityDbList <WeakIOptimizedPersistableReference <Person> >(0);
     if (bestFriend != null)
     {
         m_bestFriend = new WeakIOptimizedPersistableReference <Person>(bestFriend);
         m_friends.Add(new WeakIOptimizedPersistableReference <Person>(bestFriend));
     }
 }
Example #25
0
        public StoreProducts(string path)
        {
            fileName    = path.Substring(0, path.LastIndexOf(".txt"));
            fileName    = fileName.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            productList = new VelocityDbList <StoreProduct>();
            StreamReader stream = new StreamReader(path);

            try
            {
                storeName   = stream.ReadLine();
                description = stream.ReadLine();
                image       = stream.ReadLine();
                link        = stream.ReadLine();
                string t = stream.ReadLine();
                stars = Int16.Parse(t);
                StoreProduct c = new StoreProduct(storeName);
                t = stream.ReadLine();
                while (t != null)
                {
                    if (t != null && t.Length > 0)
                    {
                        c.expireDate = DateTime.Parse(t);
                    }
                    else
                    {
                        c.expireDate = DateTime.MaxValue;
                    }
                    c.name        = stream.ReadLine();
                    c.description = stream.ReadLine();
                    c.image       = stream.ReadLine();
                    c.link        = stream.ReadLine();
                    productList.Add(c);
                    c = new StoreProduct(storeName);
                    t = stream.ReadLine();
                }
                stream.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                stream.Close();
            }
        }
Example #26
0
        internal void DeAllocateVertexId(VertexId vId, VelocityDbList <Range <VertexId> > vertecis = null)
        {
            if (vertecis == null)
            {
                if (this.vertecis == null)
                {
                    return;
                }
                vertecis = this.vertecis;
            }
            Range <VertexId> range = new Range <VertexId>(vId, vId);
            bool             isEqual;
            int pos = vertecis.BinarySearch(range, out isEqual);

            if (pos >= 0)
            {
                if (pos == vertecis.Count || (pos > 0 && vertecis[pos].Min > vId))
                {
                    --pos;
                }
                range = vertecis[pos];
                if (range.Min == vId)
                {
                    if (range.Max == vId)
                    {
                        vertecis.RemoveAt(pos);
                    }
                    else
                    {
                        vertecis[pos] = new Range <VertexId>(range.Min + 1, range.Max);
                    }
                }
                else if (range.Max == vId)
                {
                    vertecis[pos] = new Range <VertexId>(range.Min, range.Max + 1);
                }
                else
                {
                    vertecis[pos] = new Range <VertexId>(range.Min, vId - 1);
                    vertecis.Insert(pos + 1, new Range <VertexId>(vId + 1, range.Max));
                }
            }
        }
Example #27
0
 internal VertexType(TypeId aTypeId, string aTypeName, VertexType baseType, Graph graph)
 {
   m_graph = new WeakIOptimizedPersistableReference<Graph>(graph);
   m_baseType = baseType;
   m_subTypes = new List<VertexType>();
   if (baseType != null)
   {
     baseType.Update();
     baseType.m_subTypes.Add(this);
   }
   m_typeId = (TypeId)aTypeId;
   m_typeName = aTypeName;
   var vertices = new VelocityDbList<Range<VertexId>>();
   graph.Session.Persist(vertices);
   m_vertices = new WeakIOptimizedPersistableReference<VelocityDbList<Range<VertexId>>>(vertices);
   m_stringToPropertyType = new BTreeMap<string, PropertyType>(null, graph.Session);
   m_edgeTypes = new BTreeSet<EdgeType>(null, graph.Session);
   m_tailToHeadEdges = new BTreeMap<EdgeType, BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>(null, graph.Session);
   m_headToTailEdges = new BTreeMap<EdgeType, BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>(null, graph.Session);
   graph.Session.Persist(this);
 }
Example #28
0
 /// <summary>
 /// Creates a new <see cref="Graph"/>
 /// </summary>
 /// <param name="session">The active session</param>
 /// <param name="vertexIdSetPerVertexType">Set to <see langword="false"/> if you want graph wide unique <see cref="Vertex"/> ids, by default <see langword="true"/> each <see cref="VertexType"/> maintains its own set of <see cref="Vertex"/> ids</param>
 public Graph(SessionBase session, bool vertexIdSetPerVertexType = true)
 {
     flags              = 0;
     edgeTypeCt         = 0;
     vertexTypeCt       = 0;
     stringToVertexType = new BTreeMap <string, VertexType>(null, session);
     vertexType         = new VertexType[0];
     stringToEdgeType   = new BTreeMap <string, EdgeType>(null, session);
     if (vertexIdSetPerVertexType)
     {
         flags += (UInt32)GraphFlags.VertexIdSetPerType;
     }
     else
     {
         vertexIdToVertexType = new BTreeMap <EdgeTypeId, EdgeTypeId>(null, session);
         vertecis             = new VelocityDbList <Range <VertexId> >();
     }
     edgeType     = new EdgeType[0];
     propertyType = new PropertyType[0];
     this.session = session;
     NewVertexType("default");
     NewEdgeType("default", true); // not sure if we need "directed" or not as edge type parameter ???
 }
Example #29
0
 static void CreateData()
 {
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     {
         bool dirExist = Directory.Exists(session.SystemDirectory);
         if (dirExist)
         {
             Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
         }
         Directory.CreateDirectory(session.SystemDirectory);
         File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"));
         DataCache.MaximumMemoryUse       = 10000000000; // 10 GB, set this to what fits your case
         SessionBase.DefaultCompressPages = PageInfo.compressionKind.LZ4;
         session.BeginUpdate();
         BTreeMap <Int64, VelocityDbList <Person> > btreeMap = new BTreeMap <Int64, VelocityDbList <Person> >(null, session);
         session.Persist(btreeMap);
         for (int i = 0; i < 100000; i++)
         {
             Person  p       = new Person();
             GeoHash geohash = GeoHash.WithBitPrecision(p.Lattitude, p.Longitude);
             VelocityDbList <Person> personList;
             if (btreeMap.TryGetValue(geohash.LongValue, out personList))
             {
                 personList.Add(p);
             }
             else
             {
                 personList = new VelocityDbList <Person>(1);
                 //session.Persist(p);
                 personList.Add(p);
                 session.Persist(personList);
                 btreeMap.Add(geohash.LongValue, personList);
             }
         }
         session.Commit();
     }
 }
Example #30
0
        /// <summary>
        /// Creates a new edge type.
        /// </summary>
        /// <param name="aTypeId">The id to use for the new edge type</param>
        /// <param name="aTypeName">A type name to use</param>
        /// <param name="tailType">Restrict tail vertex to a certain vertex type</param>
        /// <param name="headType">Restrict head vertex to a certain vertex type</param>
        /// <param name="birectional">Is this edge type bidirectional (going both ways)</param>
        /// <param name="baseType">A base type can be specified</param>
        /// <param name="graph">The owning graph</param>
        public EdgeType(TypeId aTypeId, string aTypeName, VertexType tailType, VertexType headType, bool birectional, EdgeType baseType, Graph graph)
        {
            m_graph    = new WeakIOptimizedPersistableReference <Graph>(graph);
            m_baseType = baseType;
            m_subTypes = new List <EdgeType>();
            if (baseType != null)
            {
                baseType.Update();
                baseType.m_subTypes.Add(this);
            }
            m_birectional = birectional;
            m_typeId      = aTypeId;
            m_typeName    = aTypeName;
            if (tailType != null)
            {
                m_tailType = new WeakIOptimizedPersistableReference <VertexType>(tailType);
            }
            if (headType != null)
            {
                m_headType = new WeakIOptimizedPersistableReference <VertexType>(headType);
            }
            if (Unrestricted)
            {
                m_unrestrictedEdges = new BTreeMap <EdgeId, UnrestrictedEdge>(null, graph.GetSession());
            }
            else
            {
                m_restrictedEdges = new BTreeMap <EdgeId, ulong>(null, graph.GetSession());
            }
            m_stringToPropertyType = new BTreeMap <string, PropertyType>(null, graph.GetSession());
            var edgeRanges = new VelocityDbList <Range <EdgeId> >();

            graph.GetSession().Persist(edgeRanges);
            m_edgeRanges = new WeakIOptimizedPersistableReference <VelocityDbList <Range <PropertyId> > >(edgeRanges);
            graph.GetSession().Persist(this);
        }
Example #31
0
        internal VertexId AllocateVertexId(VertexId vId = 0, VelocityDbList <Range <VertexId> > vertecis = null)
        {
            if (vertecis == null)
            {
                if (this.vertecis == null)
                {
                    return(vId);
                }
                vertecis = this.vertecis;
            }
            Range <VertexId> range;

            if (vId != 0)
            {
                range = new Range <VertexId>(vId, vId);
                if (vertecis.Count == 0)
                {
                    vertecis.Add(range);
                }
                else
                {
                    bool isEqual;
                    int  pos         = vertecis.BinarySearch(range, out isEqual);
                    int  originalPos = pos;
                    if (isEqual)
                    {
                        throw new VertexAllreadyExistException("Vertex with id " + vId + " allready exist");
                    }
                    Range <VertexId> existingRange = vertecis[pos == vertecis.Count ? pos - 1 : pos];
                    if (existingRange.Min == 0 && existingRange.Max == 0 || (pos > 0 && existingRange.Min > vId + 1))
                    {
                        existingRange = vertecis[--pos];
                    }
                    if (existingRange.Min - 1 == vId)
                    {
                        range = new Range <VertexId>(existingRange.Min - 1, existingRange.Max);
                        if (pos > 0)
                        {
                            Range <VertexId> priorRange = vertecis[pos - 1];
                            if (priorRange.Max + 1 == range.Min)
                            {
                                range             = new Range <VertexId>(priorRange.Min, range.Max);
                                vertecis[pos - 1] = range;
                                vertecis.RemoveAt(pos);
                            }
                            else
                            {
                                vertecis[pos] = range;
                            }
                        }
                        else
                        {
                            vertecis[pos] = range;
                        }
                    }
                    else if (existingRange.Max + 1 == vId)
                    {
                        range = new Range <VertexId>(existingRange.Min, existingRange.Max + 1);
                        if (vertecis.Count > pos)
                        {
                            Range <VertexId> nextRange = vertecis[pos + 1];
                            if (nextRange.Min == range.Max + 1)
                            {
                                range = new Range <VertexId>(range.Min, nextRange.Max);
                                vertecis.RemoveAt(pos);
                                vertecis[pos] = range;
                            }
                            else
                            {
                                vertecis[pos] = range;
                            }
                        }
                        else
                        {
                            vertecis[pos == vertecis.Count ? pos - 1 : pos] = range;
                        }
                    }
                    else if (vId >= existingRange.Min && vId <= existingRange.Max)
                    {
                        throw new VertexAllreadyExistException("Vertex with id " + vId + " allready exist");
                    }
                    else
                    {
                        vertecis.Insert(originalPos, range);
                    }
#if VERIFY
                    int i = 0;
                    Range <VertexId> p = default(Range <VertexId>);
                    foreach (Range <VertexId> r in vertecis)
                    {
                        if (i++ > 0)
                        {
                            if (p.Min >= r.Min)
                            {
                                throw new UnexpectedException("Wrong order");
                            }
                            if (p.Max == r.Min + 1)
                            {
                                throw new UnexpectedException("Failed to merge");
                            }
                        }
                        p = r;
                    }
#endif
                }
            }
            else
            {
                vId = 1;
                switch (vertecis.Count)
                {
                case 0:
                    range = new Range <VertexId>(1, 1);
                    vertecis.Add(range);
                    break;

                case 1:
                    range = vertecis.First();

                    if (range.Min == 1)
                    {
                        vId   = range.Max + 1;
                        range = new Range <VertexId>(1, vId);
                    }
                    else
                    {
                        vId   = range.Min - 1;
                        range = new Range <VertexId>(vId, range.Max);
                    }
                    vertecis[0] = range;
                    break;

                default:
                {
                    range = vertecis.First();
                    if (range.Min > 1)
                    {
                        vId         = range.Min - 1;
                        range       = new Range <VertexId>(vId, range.Max);
                        vertecis[0] = range;
                    }
                    else
                    {
                        Range <VertexId> nextRange = vertecis[1];
                        if (range.Max + 1 == nextRange.Min)
                        {
                            vertecis.RemoveAt(1);
                            vId         = nextRange.Min;
                            range       = new Range <VertexId>(range.Min, nextRange.Max);
                            vertecis[0] = range;
                        }
                        else
                        {
                            range       = new Range <VertexId>(range.Min, range.Max + 1);
                            vId         = range.Max;
                            vertecis[0] = range;
                        }
                    }
                }
                break;
                }
            }
            return(vId);
        }
Example #32
0
 public Store()
 {
     m_categoryList    = new VelocityDbList <StoreInCategory>();
     m_dateTimeCreated = DateTime.Now;
     m_isValid         = true;
 }
Example #33
0
        public void IndexSample(bool useServerSession)
        {
            string           brandName              = "Toyota";
            string           color                  = "Blue";
            int              maxPassengers          = 5;
            int              fuelCapacity           = 40;
            double           litresPer100Kilometers = 5;
            DateTime         modelYear              = new DateTime(2003, 1, 1);
            string           modelName              = "Highlander";
            int              maxSpeed               = 200;
            int              odometer               = 100000;
            string           registrationState      = "Texas";
            string           registrationPlate      = "TX343434";
            string           insurancePolicy        = "CAA7878787";
            DriversLicense   license                = new DriversLicense("California", "B7788888", DateTime.Now + new TimeSpan(1825, 0, 0, 0));
            Person           person                 = new Person("Mats Persson", license);
            InsuranceCompany insuranceCompany       = new InsuranceCompany("Allstate", "858727878");
            Car              car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                                           odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                foreach (Database db in session.OpenAllDatabases(true))
                {
                    if (db.DatabaseNumber >= 10 || db.DatabaseNumber == SessionBase.IndexDescriptorDatabaseNumber)
                    {
                        session.DeleteDatabase(db);
                    }
                }
                session.Commit();

                session.BeginUpdate();
                DatabaseLocation defaultLocation = session.DatabaseLocations.Default();
                List <Database>  dbList          = session.OpenLocationDatabases(defaultLocation, true);
                foreach (Database db in dbList)
                {
                    if (db.DatabaseNumber > Database.InitialReservedDatabaseNumbers)
                    {
                        session.DeleteDatabase(db);
                    }
                }
                session.DeleteLocation(defaultLocation);
                session.Commit();
                CreateDirectoryAndCopyLicenseDb();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                int ct     = 0;
                var mIndex = session.Index <Motorcycle>();
                if (mIndex != null)
                {
                    foreach (Motorcycle mc in session.Index <Motorcycle>())
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                }
                Assert.AreEqual(ct, 0);
                session.Commit();
            }
            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                }
                session.Commit();
                session.BeginUpdate();
                int ct     = 0;
                var mIndex = session.Index <Car>();
                if (mIndex != null)
                {
                    foreach (Car c in mIndex)
                    {
                        Assert.NotNull(c);
                        ++ct;
                    }
                }
                Assert.AreEqual(ct, 0);
                ct = 0;
                session.RegisterClass(typeof(Person));
                foreach (Person p in session.AllObjects <Person>(true, false))
                {
                    Assert.NotNull(p);
                    ++ct;
                }
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Abort();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Abort();
                session.BeginRead();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 10000);
                session.Commit();
                try
                {
                    ct = 0;
                    foreach (Motorcycle mc in session.Index <Motorcycle>())
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                    Assert.AreEqual(ct, 10000);
                }
                catch (NotInTransactionException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                session.BeginUpdate();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    if (++ct % 2 == 0)
                    {
                        mc.Unpersist(session);
                    }
                }
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                session.Abort();
                session.BeginUpdate();
                ct = 0;
                foreach (Motorcycle mc in session.AllObjects <Motorcycle>(false, true))
                {
                    if (++ct % 2 == 0)
                    {
                        mc.Unpersist(session);
                    }
                }
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 5000);
                ct = 0;
                try
                {
                    foreach (Motorcycle mc in session.Index <Motorcycle>("ccx"))
                    {
                        Assert.NotNull(mc);
                        ++ct;
                    }
                    Assert.AreEqual(ct, 5000);
                }
                catch (FieldDoesNotExistException)
                {
                }
                session.Commit();
                session.BeginUpdate();
                ct = 0;
                double prior = -44.0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    mc.CC = mc.CC - prior;
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 2500);
                for (int i = 0; i < 95000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                }
                session.FlushUpdates();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Abort();
                session.BeginUpdate();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                    if (ct < 25)
                    {
                        Console.Write(prior.ToString() + " ");
                    }
                }
                ct    = 0;
                prior = -44.0;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    mc.CC = mc.CC - prior;
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 2500);
                session.Commit();
                session.BeginUpdate();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                }
                for (int i = 0; i < 95000; i++)
                {
                    Motorcycle mc = new Motorcycle();
                    session.Persist(mc);
                    DataBaseFileEntry dbEntry = new DataBaseFileEntry {
                        Something = "Something"
                    };
                    session.Persist(dbEntry);
                    mc.AddChild(dbEntry);
                    mc.AddChild(dbEntry);
                }
                session.FlushUpdates();
                ct = 0;
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Commit();
                session.BeginRead();
                session.Abort();
                session.BeginUpdate();
                foreach (Motorcycle mc in session.Index <Motorcycle>())
                {
                    Assert.NotNull(mc);
                    VelocityDbList <DataBaseFileEntry> children = mc.Children;
                    if (children != null && children.Count > 0)
                    {
                        mc.RemoveChild(children[0]);
                    }
                    ++ct;
                }
                session.Commit();
                session.BeginRead();
                ct    = 0;
                prior = double.MinValue;
                foreach (Motorcycle mc in session.Index <Motorcycle>("cc"))
                {
                    Assert.NotNull(mc);
                    Assert.GreaterOrEqual(mc.CC, prior);
                    prior = mc.CC;
                    ++ct;
                }
                Assert.AreEqual(ct, 100000);
                session.Commit();
                Console.WriteLine("Motorcycle index Test OK");
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                session.Persist(car);
                registrationState = "Maine";
                car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                              odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                session.Persist(car);
                color                  = "Red";
                maxPassengers          = 5;
                fuelCapacity           = 50;
                litresPer100Kilometers = 8;
                modelYear              = new DateTime(2006, 1, 1);
                brandName              = "Toyota";
                modelName              = "Tacoma";
                maxSpeed               = 210;
                odometer               = 50000;
                registrationState      = "Texas";
                registrationPlate      = "TX343433";
                insurancePolicy        = "CAA7878777";
                car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed,
                              odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                session.Persist(car);
                color                  = "Black";
                maxPassengers          = 5;
                fuelCapacity           = 60;
                litresPer100Kilometers = 3;
                modelYear              = new DateTime(2001, 1, 1);
                brandName              = "Lincoln";
                modelName              = "Town Car";
                maxSpeed               = 220;
                odometer               = 250000;
                registrationState      = "Texas";
                registrationPlate      = "TX543433";
                insurancePolicy        = "CAA7878775";
                for (int i = 0; i < 1; i++)
                {
                    registrationState = RandomString(2);
                    registrationPlate = RandomString(12);
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, maxSpeed, odometer, registrationState, registrationPlate, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                    color                  = null;
                    maxPassengers          = i;
                    fuelCapacity           = 60;
                    litresPer100Kilometers = 3;
                    modelYear              = new DateTime(2001, 1, 1);
                    brandName              = "Null Car";
                    modelName              = null;
                    maxSpeed               = 220;
                    odometer               = 250000;
                    insurancePolicy        = null;
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Console.WriteLine("Blue Cars");
                BTreeSet <Car> bTree = session.Index <Car>("color");
                foreach (Car c in (from aCar in bTree where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Cars in fuel efficierncy order");
                foreach (Car c in session.Index <Car>("litresPer100Kilometers"))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Vehicles ordered modelYear, brandName, modelName, color");
                foreach (Vehicle v in session.Index <Vehicle>())
                {
                    Console.WriteLine(v.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                c.Color = "Green";
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Car    c  = (from aCar in session.Index <Car>("color") where aCar.Color == "Green" select aCar).First();
                UInt64 id = c.Id;
                session.DeleteObject(id);
                session.Abort();
                session.BeginUpdate();
                session.DeleteObject(id);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                session.BeginRead();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
                sw.Stop();
                Console.WriteLine(sw.Elapsed);
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                for (int i = 0; i < 10000; i++)
                { // add some junk to make search harder
                    car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, i,
                                  odometer, registrationState, registrationPlate + i, insuranceCompany, insurancePolicy);
                    session.Persist(car);
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                // these LINQ statements will trigger a binary search lookup (not a linear serach) of the matching Car objects in the BTreeSet
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                Car c = (from aCar in session.Index <Car>("color") where aCar.Color == "Blue" select aCar).First();
                c.Unpersist(session);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                foreach (Car c in session.Index <Car>())
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                Console.WriteLine("Blue Cars");
                foreach (Car c in (from aCar in session.Index <Car>() where aCar.Color == "Blue" select aCar))
                {
                    Console.WriteLine(c.ToStringDetails(session));
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                InsuranceCompany prior = insuranceCompany;
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompany("AAA", "858787878");
                        insuranceCompany.Persist(session, prior);
                        prior = insuranceCompany;
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompany)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                InsuranceCompany prior = insuranceCompany;
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompany("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompany)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                bool exists = (from anEntry in session.Index <InsuranceCompany>("name", db) where anEntry.Name == "AAA" select 0).Any();
                Assert.IsTrue(exists);
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompanySpecial("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginUpdate();
                try
                {
                    for (int i = 0; i < 100000; i++)
                    {
                        insuranceCompany = new InsuranceCompanySpecial2("AAA", "858787878");
                        session.Persist(insuranceCompany);
                    }
                    Assert.IsTrue(false); // should not get here
                }
                catch (UniqueConstraintException)
                {
                }
                session.Commit();
            }

            using (SessionBase session = useServerSession ? (SessionBase) new ServerClientSession(systemDir) : (SessionBase) new SessionNoServer(systemDir))
            {
                session.BeginRead();
                Database db = session.OpenDatabase(session.DatabaseNumberOf(typeof(InsuranceCompanySpecial)));
                var      q  = from company in session.Index <InsuranceCompany>("name", db) where company.Name == "AAA" select company;
                foreach (InsuranceCompany company in q)
                {
                    Console.WriteLine(company.ToStringDetails(session)); // only one will match
                }
                bool exists = (from anEntry in session.Index <InsuranceCompanySpecial>("name", db) where anEntry.Name == "AAA" select 0).Any();
                Assert.IsTrue(exists);
                session.Commit();
            }
        }
Example #34
0
 public Customer(string name)
 {
   m_customerId = 0;
   m_name = name;
   m_orders = new VelocityDbList<Order>();
 }
Example #35
0
 public StoreCategory()
 {
     storeInCategoryList = new VelocityDbList <StoreInCategory>();
     categoryList        = new VelocityDbList <StoreCategory>();
     adList = new VelocityDbList <CategoryAd>();
 }
Example #36
0
 public Customer(string name)
 {
     m_customerId = 0;
     m_name       = name;
     m_orders     = new VelocityDbList <Order>();
 }
Example #37
0
        public StoreCoupons(string path)
        {
            fileName   = path.Substring(0, path.LastIndexOf(".txt"));
            fileName   = fileName.Substring(path.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            couponList = new VelocityDbList <Coupon>();
            StreamReader stream = new StreamReader(path);

            try
            {
                name        = stream.ReadLine();
                description = stream.ReadLine();
                image       = stream.ReadLine();
                link        = stream.ReadLine();
                string t = stream.ReadLine();
                stars = Int16.Parse(t);
                Coupon c = new Coupon();
                c.Category = stream.ReadLine();
                while (c.Category != null && !c.Category.Equals("."))
                {
                    t = stream.ReadLine();
                    if (t != null && t.Length > 0)
                    {
                        c.StartDate = DateTime.Parse(t);
                    }
                    else
                    {
                        c.StartDate = DateTime.MinValue;
                    }
                    t = stream.ReadLine();
                    if (t != null && t.Length > 0)
                    {
                        DateTime dt;
                        DateTime.TryParse(t, out dt);
                        c.ExpireDate = dt;
                    }
                    else
                    {
                        c.ExpireDate = DateTime.MaxValue;
                    }
                    t = stream.ReadLine();
                    if (t != null && t.Length > 0)
                    {
                        c.PromotionalType = Int16.Parse(t);
                    }
                    else
                    {
                        c.PromotionalType = 0;
                    }
                    c.Description = stream.ReadLine();
                    t             = stream.ReadLine();
                    if (t.CompareTo("inLinkActivated") == 0)
                    {
                        c.Code = null;
                    }
                    else
                    {
                        c.Code = t;
                    }
                    c.Image = stream.ReadLine();
                    c.Link  = stream.ReadLine();
                    couponList.Add(c);
                    c          = new Coupon();
                    c.Category = stream.ReadLine();
                }
                stream.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                stream.Close();
            }
        }
Example #38
0
 public MotorcycleList()
 {
     _motorcycles = new VelocityDbList <Motorcycle>();
 }