コード例 #1
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 /// <param name="houseCache">房屋缓存</param>
 /// <param name="siteHouseSearch">大频道帖子关键字查询接口</param>
 /// <param name="houseSearch">房屋交易检索接口</param>
 public HouseBuySearchController(HouseCache houseCache,
                                 Fx.Domain.Base.IService.ISiteSearch <HouseBuyInfo> siteHouseSearch,
                                 Fx.Domain.Base.IService.IHouseSearch <HouseBuyInfo> houseSearch)
 {
     this.houseCache      = houseCache;
     this.siteHouseSearch = siteHouseSearch;
     this.houseSearch     = houseSearch;
 }
コード例 #2
0
        /// <summary>
        /// The one method to put different types of estate objects into caches. <br/>
        /// Key is chosen automatically. <br/>
        /// Method checks referential integrity on: <br/>
        /// EstateObject.SellerID - Person.key. <br/>
        /// EstateObject.LocationID - Location.key.
        /// </summary>
        /// <param name="value">Estate object to put into cache.</param>
        public static void PutEstateObject (EstateObject value)
        {
            using (var tx = Client.GetTransactions().TxStart())
            {
                // Error if Person with key = value.SellerID is not found.
                if (!(PersonCache.ContainsKey(value.SellerID)))
                {
                    tx.Commit();
                    throw new ReferentialException ("Can not put new entry into EstateObject cache.")
                    {
                        Operation = "put",
                        TableName = "EstateObject",
                        FieldName = "SellerID",
                        ReadableMessage = $"Can not put new entry into EstateObject cache because Person with key {value.SellerID} does not exist."
                    };
                }

                // Error if Location not found.
                if (!(LocationCache.ContainsKey(value.LocationID)))
                {
                    tx.Commit();
                    throw new ReferentialException ("Can not put new entry into EstateObject cache.")
                    {
                        Operation = "put",
                        TableName = "EstateObject",
                        FieldName = "LocationID",
                        ReadableMessage = $"Can not put new entry into EstateObject cache because Location with key {value.LocationID} does not exist."
                    };
                }

                // Normal operation.
                int key = LastUsedKeys.Get("estateobject");
                switch ((char)value.Variant)
                {
                    case 'o':
                    ObjectCache.Put (key, value);
                    break;

                    case 'h':
                    HouseCache.Put (key, (House)value);
                    break;
                    
                    case 'f':
                    FlatCache.Put (key, (Flat)value);
                    break;

                    case 'l':
                    LandplotCache.Put (key, (Landplot)value);
                    break;

                    default: 
                    break;
                }
                LastUsedKeys.Put("estateobject", key+1);
                tx.Commit();
            }
        }
コード例 #3
0
        /// <summary>
        /// Get houses in mentioned location, optionally order and set max price.
        /// </summary>
        /// <param name="location"></param>
        /// <param name="price"></param>
        /// <param name="order"></param>
        /// <returns></returns>
        public static Dictionary <int, House> GetHouses(int location, int price = 0, string order = "")
        {
            string querystring1 = "", querystring2 = "";

            switch (order)
            {
            case "new":
                querystring1 = $"select _key, _val, PostDate, Price, LocationID, isOpen from Houses where LocationID={location} and isOpen=true ";
                querystring2 = " order by PostDate desc;";
                break;

            case "price":
                querystring1 = $"select _key, _val, Price, LocationID, isOpen from Houses where LocationID={location} and isOpen=true ";
                querystring2 = " order by Price;";
                break;

            case "prisqm":
                querystring1 = $"select _key, _val, Price, HomeArea, (Price/HomeArea) as SqmPrice, LocationID, isOpen from Houses where LocationID={location} and isOpen=true ";
                querystring2 = " order by SqmPrice;";
                break;

            case "pop":
                querystring1 = $"select A._key, A._val, A.Price, B.Cnt, A.LocationID, A.isOpen from \"estateobject\".HOUSES as A left join (select ObjectID, count(PersonID) as Cnt from \"bookmark\".BOOKMARKS group by ObjectID) as B on A._key = B.ObjectID where A.LocationID={location} and A.isOpen=true ";
                querystring2 = " order by B.Cnt desc;";
                break;

            case "state":
                querystring1 = $"select _key, _val, Price, LocationID, State, isOpen from Houses where LocationID={location} and isOpen=true ";
                querystring2 = " order by State desc;";
                break;

            default:
                querystring1 = $"select _key, _val, Price, LocationID, isOpen from Houses where LocationID={location} and isOpen=true ";
                querystring2 = ";";
                break;
            }

            if (price > 0)
            {
                querystring1 += $" and Price<={price} " + querystring2;
            }
            else
            {
                querystring1 += querystring2;
            }
            Dictionary <int, House> result = new Dictionary <int, House>();

            foreach (var row in HouseCache.Query(new SqlFieldsQuery(querystring1)))
            {
                result[(int)row[0]] = row[1] as House;
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// Simply get all estate objects
        /// </summary>
        /// <returns></returns>
        public static Dictionary <int, EstateObject> GetEstateObjects()
        {
            Dictionary <int, EstateObject> result = new Dictionary <int, EstateObject>();

            foreach (var row in ObjectCache.Query(new SqlFieldsQuery("select _key, _val from EstateObjects order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as EstateObject);
            }
            foreach (var row in HouseCache.Query(new SqlFieldsQuery("select _key, _val from Houses order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as House);
            }
            foreach (var row in FlatCache.Query(new SqlFieldsQuery("select _key, _val from Flats order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as Flat);
            }
            foreach (var row in LandplotCache.Query(new SqlFieldsQuery("select _key, _val from Landplots order by PostDate;")))
            {
                result[(int)row[0]] = (row[1] as Landplot);
            }
            return(result);
        }
コード例 #5
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 /// <param name="houseCache">房屋缓存</param>
 public HouseListController(HouseCache houseCache)
 {
     this.houseCache = houseCache;
 }