public static async Task <(bool, string)> ResetShop(Session session, string Param1, string Param2, string Param3, string Param4)
        {
            var shops = await ShopCache.Instance.GetEntities(session.member_no, session.user_no, true);

            foreach (var shop in shops)
            {
                await ShopQuery.Remove(session.member_no, shop);
            }
            await ShopCache.Instance.RemoveEntities(session.member_no, session.user_no);

            return(true, string.Empty);
        }
예제 #2
0
        public static async Task <bool> Refresh(Session session, List <Models.Shop> shops, bool is_only_check)
        {
            // 유효하지 않은 미션 리셋
            foreach (var shop_data in ACDC.ShopListData)
            {
                if (shop_data.Value.Enable == false)
                {
                    continue;
                }

                var db_shop = shops.Where(x => x.shop_id == shop_data.Value.Id).ToList();


                bool is_reset = false;
                if (db_shop.Count > 0)
                {
                    foreach (var shop_item in db_shop)
                    {
                        if (shop_data.Value.ResetType == (int)ShopResetType.Daily)
                        {
                            if (DateTime.UtcNow.Date != shop_item.occ_time.Date)
                            {
                                is_reset = true;
                                break;
                            }
                        }
                        else if (shop_data.Value.ResetType == (int)ShopResetType.Monthly)
                        {
                            if (DateTime.UtcNow.Date.Month != shop_item.occ_time.Date.Year ||
                                DateTime.UtcNow.Date.Month != shop_item.occ_time.Date.Month)
                            {
                                is_reset = true;
                                break;
                            }
                        }
                    }
                }

                // 시간 만료이거나, 스크립트 데이터와 수량이 다를 경우
                if (is_reset || db_shop.Count < shop_data.Value.ProductGroupId.Length)
                {
                    if (is_only_check)
                    {
                        return(true);
                    }
                    else
                    {
                        await _Refresh(session, shops, db_shop, shop_data);
                    }
                }

                // 스크립트 데이터보다 디비, 캐시 데이터가 많을 경우 삭제
                if (db_shop.Count > shop_data.Value.ProductGroupId.Length)
                {
                    if (is_only_check)
                    {
                        return(true);
                    }
                    else
                    {
                        for (int i = shop_data.Value.ProductGroupId.Length; i < db_shop.Count; ++i)
                        {
                            await ShopCache.Instance.RemoveEntity(session.member_no, db_shop[i]);

                            await ShopQuery.Remove(session.member_no, db_shop[i]);

                            shops.Remove(db_shop[i]);
                        }
                    }
                }
            }
            return(false);
        }