示例#1
0
        public static ObjectStore <Guid, Notification> Notifications()
        {
            string storename = typeof(Notification).Name;

            lock (_websiteobject)
            {
                var paras = new ObjectStoreParameters();
                paras.AddColumn <Notification>(o => o.Id);
                paras.AddColumn <Notification>(o => o.UserId);
                paras.AddColumn <Notification>(o => o.WebSiteId);
                return(Global().GetOrCreateObjectStore <Guid, Notification>(storename, paras));
            }
        }
示例#2
0
        public static void InitDatabase(bool CreateFolder = false)
        {
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            string path          = Path.Combine(baseDirectory, "IpData");

            if (CreateFolder)
            {
                IOHelper.EnsureDirectoryExists(path);
            }

            if (Directory.Exists(path))
            {
                if (!CreateFolder)
                {
                    string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);

                    if (files == null || files.Length == 0)
                    {
                        return;
                    }
                }

                if (Database == null)
                {
                    Database = new Database(path);
                }


                if (CityStore == null)
                {
                    ObjectStoreParameters paras = new ObjectStoreParameters();
                    paras.SetPrimaryKeyField <CityInfo>(o => o.Id);
                    paras.EnableLog     = false;
                    paras.EnableVersion = false;

                    CityStore = Database.GetOrCreateObjectStore <int, CityInfo>("City", paras);
                }

                if (StateStore == null)
                {
                    ObjectStoreParameters parastate = new ObjectStoreParameters();
                    parastate.SetPrimaryKeyField <StateInfo>(o => o.Id);
                    parastate.EnableVersion = false;
                    parastate.EnableLog     = false;

                    StateStore = Database.GetOrCreateObjectStore <int, StateInfo>("State", parastate);
                }

                if (IpCityStore == null)
                {
                    ObjectStoreParameters paracity = new ObjectStoreParameters();
                    paracity.SetPrimaryKeyField <IPCity>(o => o.IpStart);
                    paracity.AddColumn <IPCity>(o => o.IpEnd);
                    paracity.EnableLog     = false;
                    paracity.EnableVersion = false;

                    IpCityStore = Database.GetOrCreateObjectStore <int, IPCity>("IpCity", paracity);
                }


                if (IPCountryStore == null)
                {
                    ObjectStoreParameters paracountry = new ObjectStoreParameters();
                    paracountry.SetPrimaryKeyField <IPCity>(o => o.IpStart);
                    paracountry.AddColumn <IPCity>(o => o.IpEnd);
                    paracountry.EnableVersion = false;
                    paracountry.EnableLog     = false;

                    IPCountryStore = Database.GetOrCreateObjectStore <int, IPCountry>("IpCountry", paracountry);
                }
            }
        }