public UserCompanyInfoVM GetUserComponyInfoByMobile(string mobile)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         var cb = ctx.CustomerBases.FirstOrDefault(o => o.Tel.Contains(mobile) && o.SendInterFace == 102);
         if (cb != null)
         {
             return(new UserCompanyInfoVM()
             {
                 AppAddressDesc = cb.AppAddressDesc,
                 AppBusinessDesc = cb.AppBusinessDesc,
                 AppCity = cb.AppCity,
                 AppCompanyName = cb.AppCompanyName,
                 AppCompanyPics = cb.AppCompanyPics,
                 AppCustomerName = cb.AppCustomerName,
                 AppIndustry = cb.AppIndustry,
                 AppProduct = cb.AppProduct,
                 AppProvince = cb.AppProvince,
                 AppTel = cb.AppTel,
                 IsOpenMsg = (cb.IsOpenMsg ?? false)
             });
         }
         else
         {
             return(null);
         }
     }
 }
示例#2
0
        //得到指定 Marketid 的当天所有评论 按倒序排列
        public List <AppPingLunVM> GetPinglunByMarketId(int marketId, DateTime start, DateTime end)
        {
            var list = new List <AppPingLunVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                var orderdProductIds = ctx.SmsProducts.Where(o => o.MarketId == marketId).Select(o => o.ProductId).ToList();

                var pls = ctx.Weixin_Pinglun.Where(o => orderdProductIds.Contains(o.productId) && o.create <end && o.create> start).OrderByDescending(o => o.create);

                foreach (var pl in pls)
                {
                    var product = ctx.SmsProducts.FirstOrDefault(o => o.ProductId == pl.productId);
                    var market  = ctx.Markets.FirstOrDefault(o => o.MarketId == product.MarketId);
                    var vm      = new AppPingLunVM();
                    vm.Id          = pl.productId;
                    vm.Title       = pl.title;
                    vm.MarketName  = (market == null ? "" : market.MarketName);
                    vm.ProductName = (product == null ? "" : product.ProductName);
                    vm.Icon        = pl.icon;
                    vm.Date        = pl.create.Value.ToString("yyyy-MM-dd HH:mm:ss fff");
                    vm.Url         = "http://app.shtx.com.cn/StaticHtml/WeixinPingLun.html?&id=" + pl.id;
                    list.Add(vm);
                }
            }
            return(list);
        }
        public List <UserCompanyInfoVM> getUserCompanyInfo(int id)
        {
            List <UserCompanyInfoVM> list = new List <UserCompanyInfoVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                var cbs = ctx.CustomerBases.Where(o => o.IsOpenMsg.Value && o.CustomerID > id).OrderBy(o => o.CustomerID).Take(30).ToList();
                foreach (var cb in cbs)
                {
                    var vm = new UserCompanyInfoVM();
                    vm.AppAddressDesc  = cb.AppAddressDesc;
                    vm.AppBusinessDesc = cb.AppBusinessDesc;
                    vm.AppCity         = cb.AppCity;
                    vm.AppCompanyName  = cb.AppCompanyName;
                    vm.AppCompanyPics  = cb.AppCompanyPics;
                    vm.AppCustomerName = cb.AppCustomerName;
                    vm.AppIndustry     = cb.AppIndustry;
                    vm.AppProduct      = cb.AppProduct;
                    vm.AppProvince     = cb.AppProvince;
                    vm.AppTel          = cb.AppTel;
                    vm.Id = cb.CustomerID;
                    list.Add(vm);
                }
            }
            return(list);
        }
 private List <int> GetProductIdsByMobileAndMarketId(string mobile, int marketId)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         return(ctx.Gps.Where(o => o.Tel.Contains(mobile) && o.MarketID == marketId).Select(o => o.ProductID.Value).ToList());
     }
 }
 public bool SaveUserCompany(string mobile, UserCompanyInfoVM company)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         try
         {
             var cb = ctx.CustomerBases.FirstOrDefault(o => o.SendInterFace == 102 && o.Tel.Contains(mobile));
             if (cb != null)
             {
                 cb.AppAddressDesc  = company.AppAddressDesc;
                 cb.AppBusinessDesc = company.AppBusinessDesc;
                 cb.AppCity         = company.AppCity;
                 cb.AppCompanyName  = company.AppCompanyName;
                 cb.AppCompanyPics  = company.AppCompanyPics;
                 cb.AppCustomerName = company.AppCustomerName;
                 cb.AppIndustry     = company.AppIndustry;
                 cb.AppProduct      = company.AppProduct;
                 cb.AppProvince     = company.AppProvince;
                 cb.IsOpenMsg       = company.IsOpenMsg;
                 cb.AppTel          = company.AppTel;
                 ctx.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception)
         {
             return(false);
         }
     }
 }
示例#6
0
        public bool deleteSupply(int id)
        {
            bool flag = false;

            using (TransactionScope tran = new TransactionScope())
            {
                using (var ctx = new ShtxSms2008Entities())
                {
                    var images = ctx.Images.Where(o => o.SupplyID == id).ToList();
                    foreach (var image in images)
                    {
                        ctx.Images.Remove(image);
                    }
                    var supply = ctx.Supplies.FirstOrDefault(o => o.ID == id);
                    if (supply != null)
                    {
                        ctx.Supplies.Remove(supply);
                    }
                    ctx.SaveChanges();
                    tran.Complete();
                    flag = true;
                }
            }

            return(flag);
        }
示例#7
0
        public List <MarketGroupVM> GetMarkets(string mobile, int flag, string fla1)
        {
            var list = new List <MarketGroupVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                //change://
                //var groups = ctx.XHMarketGroups.Where(o => o.Flag == flag && o.IsForApp);
                var groups = CacheService.GetMarketGroupForApp(flag);
                foreach (var group in groups)
                {
                    var groupId = group.GroupID;
                    var vm      = new MarketGroupVM()
                    {
                        Id = groupId, Name = group.GroupName
                    };
                    //change://
                    //vm.Market = ctx.Markets.Where(o => o.GroupID == groupId).Select(o => new MarketVM { Id = o.MarketId, Name = o.MarketName, Order = (int)o.DisplayOrder }).OrderBy(o => o.Order).ToList();
                    vm.Market = CacheService.GetMarketByGroupId(groupId).Select(o => new MarketVM {
                        Id = o.MarketId, Name = o.MarketName, Order = (int)o.DisplayOrder
                    }).OrderBy(o => o.Order).ToList();
                    list.Add(vm);
                }
            }
            return(list);
        }
 public bool CheckTokenByMobile(string tel, string token)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         var cb = ctx.CustomerBases.FirstOrDefault(o => o.SendInterFace == 102 && o.Tel.Contains(tel));
         if (cb == null)
         {
             return(false);
         }
         else
         {
             var ce = ctx.CustomerExtend.FirstOrDefault(o => o.Tel == cb.Tel && o.SendInterFace == 102 && (o.Valid ?? false));
             if (ce == null)
             {
                 return(false);
             }
             else
             {
                 var appToken = ctx.AppCustomerTokens.FirstOrDefault(o => o.tel.Contains(tel));
                 if (appToken.devicetoken != token)
                 {
                     return(false);
                 }
                 else
                 {
                     return(true);
                 }
             }
         }
     }
 }
示例#9
0
        public int createSupply(SupplyVM vm)
        {
            int ret = 0;


            using (var tran = new TransactionScope())
            {
                using (var ctx = new ShtxSms2008Entities())
                {
                    try
                    {
                        var supply = new Supply();
                        supply.CatalogID    = vm.CatalogId;
                        supply.Quantity     = vm.Quantity;
                        supply.Mobile       = vm.Mobile;
                        supply.Contact      = vm.Contact;
                        supply.Description  = vm.Description;
                        supply.DeliveryType = vm.DeliveryType;
                        supply.SupplyType   = vm.SupplyType;
                        supply.Product      = vm.Product;
                        supply.Creater      = vm.Creater;
                        supply.Price        = vm.Price;
                        //supply.isChecked = false;初始为空,0拒绝,1同意

                        var provice = ctx.Provinces.FirstOrDefault(o => o.Name == vm.Provice);
                        if (provice != null)
                        {
                            var city = ctx.Provinces.FirstOrDefault(o => o.ParentID == provice.ID && o.Name == vm.City);
                            if (city != null)
                            {
                                supply.ProviceID = city.ID;
                            }
                        }
                        supply.CreateDate = DateTime.Now;
                        ctx.Supplies.Add(supply);
                        ctx.SaveChanges();

                        foreach (var imgName in vm.Images)
                        {
                            Image img = new Image();
                            img.Name     = imgName;
                            img.SupplyID = supply.ID;
                            ctx.Images.Add(img);
                        }
                        ctx.SaveChanges();
                        tran.Complete();
                        ret = supply.ID;
                    }
                    catch (DbEntityValidationException)
                    {
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(ret);
        }
        public bool saveTrade(TradeVM tradeVm, string tradePics)
        {
            bool flag = false;

            using (var tran = new TransactionScope())
            {
                using (var ctx = new ShtxSms2008Entities())
                {
                    try
                    {
                        Supply supply = new Supply();
                        supply.buissnes     = tradeVm.Buissnes; //所属行业
                        supply.Product      = tradeVm.Product;  //名称
                        supply.Quantity     = tradeVm.Quantity;
                        supply.Price        = tradeVm.Price;
                        supply.Contact      = tradeVm.Contact;
                        supply.Mobile       = tradeVm.ContactTel;
                        supply.Description  = tradeVm.Description;
                        supply.DocumentType = tradeVm.DocumentType;
                        supply.provinceName = tradeVm.Province;
                        supply.cityName     = tradeVm.City;
                        supply.Creater      = tradeVm.Mobile;
                        supply.CreateDate   = DateTime.Now;

                        ctx.Supplies.Add(supply);

                        if (!string.IsNullOrWhiteSpace(tradePics))
                        {
                            string[] pics = tradePics.Split(new string[] { "|||" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (var pic in pics)
                            {
                                Image image = new Image();
                                image.SupplyID = supply.ID;
                                image.Name     = pic;
                                var path    = Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "upload");
                                var picPath = Path.Combine(path, pic);
                                var path1   = Path.GetFileNameWithoutExtension(picPath) + "-1" + Path.GetExtension(picPath);

                                System.Drawing.Image imgOutput  = System.Drawing.Bitmap.FromFile(picPath);
                                System.Drawing.Image imgOutput2 = imgOutput.GetThumbnailImage(60, 60, null, IntPtr.Zero);
                                imgOutput2.Save(path1);

                                ctx.Images.Add(image);
                            }
                        }

                        ctx.SaveChanges();

                        tran.Complete();
                        flag = true;
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            return(flag);
        }
示例#11
0
        public List <SearchPingLunVM> GetSearchPinglunResult(string mobile, string key)
        {
            List <SearchPingLunVM> result = new List <SearchPingLunVM>();
            var list = new List <AppPingLunVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                var today  = DateTime.Today;
                var start  = today.AddDays(-7);
                var end    = today.AddDays(1);
                var plList = ctx.Weixin_Pinglun.Where(o => o.title.Contains(key) && o.create.Value >= start && o.create <= end).OrderByDescending(o => o.create).ToList();
                if (plList.Count > 0)
                {
                    var orderdProductIds = ctx.Gps.Where(o => o.Tel.Contains(mobile)).Select(o => o.ProductID).ToList();

                    foreach (var pl in plList)
                    {
                        AppPingLunVM vm = new AppPingLunVM();

                        vm.Id          = pl.id;
                        vm.ProductName = CacheService.GetProductNameById(pl.productId);
                        if (vm.ProductName == string.Empty)
                        {
                            continue;
                        }
                        var market = CacheService.GetMarketByProductId(pl.productId);
                        vm.MarketId   = market.Item1;
                        vm.MarketName = market.Item2;
                        vm.Title      = pl.title;
                        vm.Icon       = pl.icon;
                        vm.Date       = pl.create.Value.ToString("yyyy-MM-dd");
                        vm.Url        = "http://app.shtx.com.cn/StaticHtml/WeixinPingLun.html?mobile=" + mobile + "&id=" + pl.id;
                        if (orderdProductIds.Contains(pl.productId))
                        {
                            vm.IsOrder = "YES";
                        }
                        else
                        {
                            vm.IsOrder = "NO";
                        }
                        list.Add(vm);
                    }

                    var group = list.GroupBy(o => o.MarketId);
                    foreach (var g in group)
                    {
                        SearchPingLunVM search = new SearchPingLunVM();
                        search.MarketId    = g.Key;
                        search.MarketName  = g.First().MarketName;
                        search.PingLunList = g.ToList();
                        result.Add(search);
                    }
                }
            }
            return(result);
        }
 public void addCount()
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         ApkDownload download = new ApkDownload()
         {
             downloadtime = DateTime.Now
         };
         ctx.ApkDownloads.Add(download);
         ctx.SaveChanges();
     }
 }
        //获得所有现货商品最近更新价格信息,,,,更改为mongo后,弃用了.
        //public List<ProductPriceVM> GetAllMarketLastPrice()
        public Dictionary <int, ProductPriceVM> GetAllMarketLastPrice()
        {
            //var listOrder = new List<ProductPriceVM>();
            var listDic = new Dictionary <int, ProductPriceVM>();

            using (var ctx = new ShtxSms2008Entities())
            {//ctx
                //inner join
                var listPrice = from f in
                                (from p in ctx.Prices
                                 where !ctx.Prices.Any(es => (es.MarketID == p.MarketID) && (es.ProductID == p.ProductID) && (es.AddDate > p.AddDate))
                                 orderby p.AddDate descending
                                 select p)
                                join dist in ctx.SmsProducts on new { mid = (int)f.MarketID, pid = (int)f.ProductID } equals new { mid = (int)dist.MarketId, pid = dist.ProductId }
                select new
                {
                    dist.ProductName,
                    dist.SName,
                    f.ProductID,
                    f.LPrice,
                    f.HPrice,
                    f.APrice,
                    f.AddDate,
                    f.PriceChange,
                    f.MarketID
                };

                //IEnumerable<IGrouping<int?, ProductPriceVM>> grouplist = listPrice.ToList().GroupBy(c => c.MarketID);
                //var g_Mapid = new Dictionary<int, int>();
                foreach (var product in listPrice)
                {
                    if (!listDic.ContainsKey((int)product.MarketID))
                    {
                        var vm = new ProductPriceVM
                        {
                            ProductId   = (int)product.ProductID,
                            ProductName = product.ProductName,
                        };
                        vm.AddDate  = (DateTime)product.AddDate;
                        vm.LPrice   = product.LPrice;
                        vm.HPrice   = product.HPrice;
                        vm.Change   = product.PriceChange;
                        vm.MarketID = (int)product.MarketID;
                        listDic.Add((int)product.MarketID, vm);
                        //listOrder.Add(vm);
                    }
                }

                return(listDic);
            }//ctx
        }
示例#14
0
        public List <SupplyViewVM> getSupply(int channelId, string creater)
        {
            var list = new List <SupplyViewVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                var      today = DateTime.Today;
                DateTime tom   = today.AddDays(1);
                //DateTime start = today.AddDays(-6);
                DateTime start = today.AddMonths(-6);
                //var supplies = ctx.Supplies.Where(o => o.CatalogID == channelId && o.CreateDate >= start && o.CreateDate < tom && o.isChecked == true).OrderByDescending(o => o.CreateDate);
                //change://
                //List<int> catalogIds = ctx.CataLogs.Where(o => o.ChannelId == channelId).Select(o => o.ID).ToList();
                List <int> catalogIds = CacheService.GetCataLogByChannelId(channelId).Select(o => o.Id).ToList();
                var        supplies   = ctx.Supplies.Where(o => catalogIds.Contains(o.CatalogID.Value) && o.CreateDate >= start && o.CreateDate < tom && o.isChecked == true).OrderByDescending(o => o.CreateDate);
                foreach (var supply in supplies)
                {
                    SupplyViewVM vm = new SupplyViewVM();
                    vm.Id         = supply.ID;
                    vm.Product    = supply.Product;
                    vm.SupplyType = supply.SupplyType.Value;
                    vm.Contact    = supply.Contact;
                    vm.isChecked  = supply.isChecked;
                    vm.Price      = supply.Price;

                    var img = ctx.Images.FirstOrDefault(o => o.SupplyID == supply.ID);
                    if (img != null)
                    {
                        vm.Avatar = "http://api.shtx.com.cn/Upload/" + getAvatarName(img.Name);
                    }
                    else
                    {
                        vm.Avatar = "http://api.shtx.com.cn/Upload/default.jpg";
                    }
                    var city     = ctx.Provinces.FirstOrDefault(o => o.ID == supply.ProviceID);
                    var province = ctx.Provinces.FirstOrDefault(o => o.ID == city.ParentID);
                    var address  = province.Name + city.Name;
                    vm.Address = address;
                    if (supply.CreateDate >= today)
                    {
                        vm.Date = supply.CreateDate.ToString("HH:mm");
                    }
                    else
                    {
                        vm.Date = supply.CreateDate.ToString("MM-dd");
                    }
                    list.Add(vm);
                }
            }
            return(list);
        }
示例#15
0
        public Dictionary <int, IEnumerable <Weixin_Pinglun> > TakeNPLEachGroup(int n)
        {
            var list = new Dictionary <int, IEnumerable <Weixin_Pinglun> >();

            using (var ctx = new ShtxSms2008Entities())
            {
                var query = ctx.Weixin_Pinglun.GroupBy(o => o.productId).Select(g => new { id = g.Key, list = g.OrderByDescending(p => p.create).Take(n) }).ToList();
                foreach (var q in query)
                {
                    list.Add(q.id, q.list);
                }
            }
            return(list);
        }
        public List <OrderVM> GetMyOrder(string mobile)
        {
            var        list        = new List <OrderVM>();
            List <int> xhmarketIds = new List <int>();
            var        xhMarkets   = new Dictionary <int, string>();

            using (var ctx = new ShtxSms2008Entities())
            {
                //change://
                //var groups = ctx.XHMarketGroups.Where(o => (o.Flag == 1 || o.Flag == 5) && o.IsForApp).Select(o => o.GroupID).ToList();
                var groups1 = CacheService.GetMarketGroupForApp(1);
                var groups5 = CacheService.GetMarketGroupForApp(5);
                groups1.AddRange(groups5);
                var          groups = groups1.Select(o => o.GroupID).ToList();
                CustomerBase cb     = ctx.CustomerBases.FirstOrDefault(o => o.Tel.Contains(mobile) && o.SendInterFace == 102);
                if (cb != null)
                {
                    mobile = cb.Tel;

                    foreach (var group in groups)
                    {
                        //change://
                        //var markets = ctx.Markets.Where(o => o.GroupID == group).ToList();
                        var markets = CacheService.GetMarketByGroupId(group);
                        foreach (var m in markets)
                        {
                            xhmarketIds.Add(m.MarketId);
                            xhMarkets.Add(m.MarketId, m.MarketName);
                        }
                    }

                    var orderIds = ctx.Gps.Where(o => o.Tel == mobile && xhmarketIds.Contains(o.MarketID.Value)).Select(o => o.ProductID.Value).ToList();

                    foreach (var productId in orderIds)
                    {
                        var product = ctx.SmsProducts.FirstOrDefault(o => o.ProductId == productId);
                        if (product != null)
                        {
                            OrderVM order = new OrderVM();
                            order.ProductId   = product.ProductId;
                            order.ProductName = product.ProductName;
                            order.MarketName  = xhMarkets[product.MarketId.Value];
                            list.Add(order);
                        }
                    }
                }
            }
            return(list.OrderBy(o => o.MarketName).ToList());
        }
        public List <ProductPriceVM> GetPricesByMobileAndMarketId(string mobile, int marketId)
        {
            var listOrder = new List <ProductPriceVM>();

            using (var ctx = new ShtxSms2008Entities())
            {
                CustomerBase cb = ctx.CustomerBases.FirstOrDefault(o => o.Tel.Contains(mobile) && o.SendInterFace == 102);
                if (cb != null)
                {
                    mobile = cb.Tel;
                    //change://
                    //var products = ctx.SmsProducts.Where(o => o.MarketId == marketId).OrderBy(p => p.DisplayOrder).ToList();
                    var products = CacheService.GetProductByMarketId(marketId).OrderBy(p => p.DisplayOrder).ToList();
                    var orderIds = ctx.Gps.Where(o => o.Tel == mobile && o.MarketID == marketId).Select(o => o.ProductID.Value).ToList();
                    foreach (var product in products)
                    {
                        var vm = new ProductPriceVM
                        {
                            ProductId   = product.ProductId,
                            ProductName = product.ProductName,
                            ParentName  = product.parentName,
                            Comment     = product.comment,
                            Spec        = product.spec
                        };
                        if (orderIds.Contains(product.ProductId))
                        {
                            vm.IsOrder = "YES";
                        }
                        else
                        {
                            vm.IsOrder = "NO";
                        }
                        //mongo:
                        //Price price = ctx.Prices.OrderByDescending(o => o.AddDate).FirstOrDefault(o => o.ProductID == product.ProductId);
                        Price price = MongoDBService.GetLastPricesByProductId(product.ProductId);
                        if (price != null)
                        {
                            vm.LPrice  = price.LPrice;
                            vm.HPrice  = string.IsNullOrEmpty(price.HPrice) ? price.LPrice : price.HPrice;
                            vm.Date    = price.AddDate.Value.ToString("yyyy-MM-dd");
                            vm.Change  = CommonService.ChangePrice(price.PriceChange);
                            vm.AddDate = price.AddDate.Value;
                            listOrder.Add(vm);
                        }
                    }
                }
                return(listOrder);
            }
        }
示例#18
0
        private static Tuple <int, string, int, string> GetProductAndMarketByProductId(int productId)
        {
            using (var ctx = new ShtxSms2008Entities())
            {
                var product = ctx.SmsProducts.FirstOrDefault(o => o.ProductId == productId);
                if (product == null)
                {
                    return(Tuple.Create(0, "", 0, ""));
                }
                var marketId   = product.MarketId.Value;
                var marketName = GetMarketNameById(marketId);

                return(Tuple.Create(productId, product.ProductName, marketId, marketName));
            }
        }
示例#19
0
 public static List <SmsProduct> GetSmsProductByMarketId(int marketId)
 {
     if (smsProductCache.ContainsKey(marketId))
     {
         return(smsProductCache[marketId]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var products = ctx.SmsProducts.Where(o => o.MarketId == marketId).OrderBy(p => p.DisplayOrder).ToList();
             smsProductCache.Add(marketId, products);
             return(products);
         }
     }
 }
示例#20
0
 public static List <SmsProduct> GetProductByMarketId(int marketId)
 {
     if (productCache.ContainsKey(marketId))
     {
         return(productCache[marketId]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var list = ctx.SmsProducts.Where(o => o.MarketId == marketId).ToList();
             productCache.Add(marketId, list);
             return(list);
         }
     }
 }
示例#21
0
 public static string GetMarketNameById(int id)
 {
     if (marketNameCache.ContainsKey(id))
     {
         return(marketNameCache[id]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var name = ctx.Markets.Single(o => o.MarketId == id).MarketName;
             marketNameCache.Add(id, name);
             return(name);
         }
     }
 }
示例#22
0
        public SupplyDetailVM getDeliver(int id)
        {
            using (var ctx = new ShtxSms2008Entities())
            {
                Supply         supply = ctx.Supplies.FirstOrDefault(o => o.ID == id);
                SupplyDetailVM vm     = new SupplyDetailVM();
                if (supply == null)
                {
                    vm.ErrorCode = "error";
                    return(vm);
                }
                else
                {
                    vm.ErrorCode = "ok";
                }

                vm.Id         = supply.ID;
                vm.Product    = supply.Product;
                vm.SupplyType = supply.SupplyType.Value;
                vm.Contact    = supply.Contact;
                var city     = ctx.Provinces.FirstOrDefault(o => o.ID == supply.ProviceID);
                var province = ctx.Provinces.FirstOrDefault(o => o.ID == city.ParentID);
                var address  = province.Name + city.Name;
                vm.Address      = address;
                vm.Quantity     = supply.Quantity;
                vm.Mobile       = supply.Mobile;
                vm.Description  = supply.Description;
                vm.DeliveryType = supply.DeliveryType.Value;
                vm.Price        = supply.Price;
                var imgs = ctx.Images.Where(o => o.SupplyID == supply.ID).ToList();
                var list = new List <string>();
                if (imgs.Count > 0)
                {
                    foreach (var img in imgs)
                    {
                        list.Add(img.Name);
                    }
                }
                else
                {
                    list.Add("default.jpg");
                }
                vm.Date   = supply.CreateDate.ToString("yyyy-MM-dd HH:mm:ss");
                vm.Avatar = list;
                return(vm);
            }
        }
 private string getMsg(string mobile, string pwd)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         var smsRoles = ctx.SmsRoles.FirstOrDefault(o => o.RoleType == 106);
         if (smsRoles != null)
         {
             var str = smsRoles.RoleDesc;
             str = str.Replace("CustomerMobile", mobile).Replace("AppPassWord", pwd);
             return(str);
         }
         else
         {
             return("您好,欢迎使用同鑫资讯移动客户端, 用户名:" + mobile + " 密码:" + pwd);
         }
     }
 }
示例#24
0
 public static List <Market> GetMarketByGroupId(int groupId)
 {
     if (marketCache.ContainsKey(groupId))
     {
         return(marketCache[groupId]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var markets = ctx.Markets.Where(o => o.GroupID == groupId).ToList();
             //marketCache[groupId] = markets;
             marketCache.Add(groupId, markets);
             return(markets);
         }
     }
 }
示例#25
0
 public static string GetProductNameById(int id)
 {
     if (productNameCache.ContainsKey(id))
     {
         return(productNameCache[id].Item2);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var obj  = GetProductAndMarketByProductId(id);
             var name = obj.Item2;
             productNameCache.Add(id, obj);
             return(name);
         }
     }
 }
示例#26
0
 public static Tuple <int, string> GetMarketByProductId(int id)
 {
     if (productNameCache.ContainsKey(id))
     {
         return(Tuple.Create(productNameCache[id].Item3, productNameCache[id].Item4));
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var obj   = GetProductAndMarketByProductId(id);
             var tuple = Tuple.Create(obj.Item3, obj.Item4);
             productNameCache.Add(id, obj);
             return(tuple);
         }
     }
 }
 public UserInfoVM GetUserInfoByMobile(string mobile)
 {
     using (var ctx = new ShtxSms2008Entities())
     {
         CustomerExtend ce       = ctx.CustomerExtend.FirstOrDefault(o => o.SendInterFace == 102 && o.Tel.Contains(mobile));
         UserInfoVM     userInfo = new UserInfoVM()
         {
             EndDate = ce.EndDate.Value.ToString("yyyy-MM-dd")
         };
         var appCustomer = ctx.AppCustomerTokens.FirstOrDefault(o => o.tel == mobile);
         if (appCustomer != null)
         {
             userInfo.IsSound = appCustomer.isSound ?? false;
         }
         return(userInfo);
     }
 }
示例#28
0
 public static List <int> GetGroupsForApp(int flag)
 {
     if (defaultAppGroupsCache.ContainsKey(flag))
     {
         return(defaultAppGroupsCache[flag]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var list = ctx.XHMarketGroups.Where(o => o.Flag == flag && o.IsForApp && (o.IsDefault ?? false) && o.GroupID != 102 && o.GroupID != 103).Select(o => o.GroupID).ToList();
             //defaultAppGroupsCache[flag] = list;
             defaultAppGroupsCache.Add(flag, list);
             return(list);
         }
     }
 }
示例#29
0
 public static List <XHMarketGroup> GetMarketGroupForApp(int flag)
 {
     if (marketGroupForAppCache.ContainsKey(flag))
     {
         return(marketGroupForAppCache[flag]);
     }
     else
     {
         using (var ctx = new ShtxSms2008Entities())
         {
             var groups = ctx.XHMarketGroups.Where(o => o.Flag == flag && o.IsForApp && o.GroupID != 102 && o.GroupID != 103).ToList();
             marketGroupForAppCache.Add(flag, groups);
             //marketGroupForAppCache[flag] = groups;
             return(groups);
         }
     }
 }
        public TrialError canotAdd(string mobile)
        {
            //手机号是否合法
            string dianxin = @"^1[3578][01379]\d{8}$";
            Regex  dReg    = new Regex(dianxin);
            //联通手机号正则
            string liantong = @"^1[34578][01256]\d{8}$";
            Regex  tReg     = new Regex(liantong);
            //移动手机号正则
            string yidong = @"^(134[012345678]\d{7}|1[34578][012356789]\d{8})$";
            Regex  yReg   = new Regex(yidong);

            if (mobile.Length < 11)
            {
                return(TrialError.Invalid);
            }

            if (!dReg.IsMatch(mobile.Substring(0, 11)) && !tReg.IsMatch(mobile.Substring(0, 11)) && !yReg.IsMatch(mobile.Substring(0, 11)))
            {
                return(TrialError.Invalid);
            }

            using (var ctx = new ShtxSms2008Entities())
            {
                //var count = ctx.CustomerBases.Count(o => o.Tel.Contains(mobile) && o.SendInterFace == 102);
                //if (count > 0)
                //    return TrialError.Registered;
                App_user user = ctx.App_user.FirstOrDefault(o => o.Tel == mobile);
                if (user != null)
                {
                    if (user.applyCount >= 1)
                    {
                        return(TrialError.TooManyTrial);
                    }
                    else
                    {
                        return(TrialError.OK);
                    }
                }
                else
                {
                    return(TrialError.OK);
                }
            }
        }