Ejemplo n.º 1
0
        public static List <ShopDetailModel> GetShopsByShopIds()
        {
            List <ShopDetailModel> shopDetailList     = new List <ShopDetailModel>();
            List <int>             specificshopIdList = new List <int>();

            if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["ShopIdList"]))
            {
                specificshopIdList = ConfigurationManager.AppSettings["ShopIdList"].Split(new char[] { ',' }).Select(q => Convert.ToInt32(q)).ToList();
            }

            try
            {
                if (specificshopIdList.Any())
                {
                    using (var client = new ShopClient())
                    {
                        var result = client.SelectShopDetails(specificshopIdList);
                        result.ThrowIfException();
                        if (result.Success && result.Result != null && result.Result.Any())
                        {
                            shopDetailList.AddRange(result.Result);
                        }
                    }
                    shopDetailList = shopDetailList.Where(q => (q.ServiceType & 4) == 4 || (q.ServiceType & 2) == 2).ToList();
                    shopDetailList = shopDetailList.Where(q => q.SuspendStartDateTime == null || q.SuspendEndDateTime == null || (DateTime.Now < q.SuspendStartDateTime) || DateTime.Now > q.SuspendEndDateTime.Value.AddDays(1)).ToList();
                }
            }
            catch (Exception ex)
            {
                TuhuShopSyncJob.Logger.Error(ex);
            }
            return(shopDetailList);
        }