Ejemplo n.º 1
0
        public void GetPoiCategory()
        {
            var accessToken = AccessTokenContainer.GetToken(_appId);

            var result = PoiApi.GetCategory(accessToken);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Ejemplo n.º 2
0
        public void GetPoiListTest()
        {
            var accessToken = AccessTokenContainer.GetAccessToken(_appId);

            var result = PoiApi.GetPoiList(accessToken, 0);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Ejemplo n.º 3
0
        public bool AddPoi(CreateStoreData createStoreData)
        {
            WxJsonResult wxJsonResult = PoiApi.AddPoi(_accessToken, createStoreData, 10000);

            if (wxJsonResult.errcode != ReturnCode.请求成功)
            {
                throw new Exception(wxJsonResult.errmsg);
            }
            return(true);
        }
Ejemplo n.º 4
0
        public string UploadImage(string filePath)
        {
            var result = PoiApi.UploadImage(this._accessToken, filePath);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            return(result.url);
        }
Ejemplo n.º 5
0
        public GetStoreBaseInfo GetPoi(string poiId)
        {
            GetStoreResultJson poi = PoiApi.GetPoi(_accessToken, poiId, 10000);

            if (poi.errcode != ReturnCode.请求成功)
            {
                throw new Exception(poi.errmsg);
            }
            return(poi.business.base_info);
        }
Ejemplo n.º 6
0
        public string UploadImage(string filePath)
        {
            UploadImageResultJson uploadImageResultJson = PoiApi.UploadImage(_accessToken, filePath, 10000);

            if (uploadImageResultJson.errcode != ReturnCode.请求成功)
            {
                throw new Exception(uploadImageResultJson.errmsg);
            }
            return(uploadImageResultJson.url);
        }
Ejemplo n.º 7
0
        public bool AddPoi(CreateStoreData createStoreData)
        {
            var result = PoiApi.AddPoi(this._accessToken, createStoreData);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            return(true);
        }
Ejemplo n.º 8
0
        public List <WXCategory> GetCategory()
        {
            PoiCategory category = PoiApi.GetCategory(_accessToken, 10000);

            if (category.errcode != ReturnCode.请求成功)
            {
                throw new Exception(category.errmsg);
            }
            List <WXCategory> wXCategories = new List <WXCategory>();

            foreach (string categoryList in category.category_list)
            {
                string[] strArrays = categoryList.Split(new char[] { ',' });
                if (strArrays.Count() == 1)
                {
                    WXCategory wXCategory = new WXCategory()
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = strArrays[0]
                    };
                    wXCategories.Add(wXCategory);
                }
                else if (!wXCategories.Exists((WXCategory p) => p.Name == strArrays[0]))
                {
                    WXCategory wXCategory1 = new WXCategory()
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = strArrays[0]
                    };
                    WXCategory wXCategory2 = new WXCategory()
                    {
                        Id   = wXCategory1.Id,
                        Name = strArrays[1]
                    };
                    wXCategory1.Child.Add(wXCategory2);
                    wXCategories.Add(wXCategory1);
                }
                else
                {
                    WXCategory wXCategory3 = wXCategories.FirstOrDefault((WXCategory p) => p.Name == strArrays[0]);
                    if (wXCategory3.Child.Exists((WXCategory p) => p.Name == strArrays[1]))
                    {
                        continue;
                    }
                    WXCategory wXCategory4 = new WXCategory()
                    {
                        Id   = wXCategory3.Id,
                        Name = strArrays[1]
                    };
                    wXCategory3.Child.Add(wXCategory4);
                }
            }
            return(wXCategories);
        }
Ejemplo n.º 9
0
        public GetStoreBaseInfo GetPoi(string poiId)
        {
            var result = PoiApi.GetPoi(this._accessToken, poiId);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }

            return(result.business.base_info);
        }
Ejemplo n.º 10
0
        public void UploadImageTest()
        {
            var accessToken = AccessTokenContainer.GetAccessToken(_appId);

            string file = @"E:\1.jpg";

            var result = PoiApi.UploadImage(accessToken, file);

            Assert.IsNotNull(result);
            Assert.AreEqual(result.errcode, ReturnCode.请求成功);
        }
Ejemplo n.º 11
0
        public List <GetStoreList_BaseInfo> GetPoiList()
        {
            GetStoreListResultJson poiList = PoiApi.GetPoiList(_accessToken, 0, 50, 10000);

            if (poiList.errcode != ReturnCode.请求成功)
            {
                throw new Exception(poiList.errmsg);
            }
            return((
                       from l in poiList.business_list
                       select l.base_info).ToList());
        }
Ejemplo n.º 12
0
        public List <GetStoreList_BaseInfo> GetPoiList()
        {
            var result = PoiApi.GetPoiList(this._accessToken, 0, 50);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            var obj = (from l in result.business_list
                       select l.base_info).ToList();

            return(obj);
        }
Ejemplo n.º 13
0
        public bool DeletePoi(string poiId)
        {
            WxJsonResult wxJsonResult = PoiApi.DeletePoi(_accessToken, poiId, 10000);

            if (wxJsonResult.errcode == (ReturnCode.获取access_token时AppSecret错误或者access_token无效 | ReturnCode.合法的凭证类型 | ReturnCode.合法的OpenID | ReturnCode.合法的按钮个数1 | ReturnCode.合法的按钮个数2 | ReturnCode.合法的按钮名字长度 | ReturnCode.合法的按钮KEY长度 | ReturnCode.access_token超时 | ReturnCode.refresh_token超时 | ReturnCode.oauth_code超时 | ReturnCode.客服帐号个数超过限制 | ReturnCode.无效头像文件类型invalid_file_type) || wxJsonResult.errcode == ReturnCode.系统繁忙此时请开发者稍候再试)
            {
                throw new HimallException("系统繁忙,请稍后尝试!");
            }
            if (wxJsonResult.errcode != ReturnCode.请求成功)
            {
                throw new Exception(wxJsonResult.errmsg);
            }
            return(true);
        }
Ejemplo n.º 14
0
        public bool UpdatePoi(UpdateStoreData updateStoreData)
        {
            WxJsonResult wxJsonResult = PoiApi.UpdatePoi(_accessToken, updateStoreData, 10000);

            if (wxJsonResult.errcode != ReturnCode.请求成功)
            {
                throw new Exception(wxJsonResult.errmsg);
            }
            if (wxJsonResult.errcode == (ReturnCode.获取access_token时AppSecret错误或者access_token无效 | ReturnCode.合法的凭证类型 | ReturnCode.合法的OpenID | ReturnCode.合法的按钮个数1 | ReturnCode.合法的按钮个数2 | ReturnCode.合法的按钮名字长度 | ReturnCode.合法的按钮KEY长度 | ReturnCode.access_token超时 | ReturnCode.refresh_token超时 | ReturnCode.oauth_code超时 | ReturnCode.客服帐号个数超过限制 | ReturnCode.无效头像文件类型invalid_file_type))
            {
                throw new HimallException("暂时不允许修改");
            }
            return(true);
        }
Ejemplo n.º 15
0
        public bool UpdatePoi(UpdateStoreData updateStoreData)
        {
            var result = PoiApi.UpdatePoi(this._accessToken, updateStoreData);

            if (result.errcode != 0)
            {
                throw new Exception(result.errmsg);
            }
            else if ((int)result.errcode == 65107)
            {
                throw new HimallException("暂时不允许修改");
            }
            return(true);
        }
Ejemplo n.º 16
0
        public List <WXCategory> GetCategory()
        {
            var result = PoiApi.GetCategory(this._accessToken);

            if (result.errcode != 0)
            {
                Log.Debug("[WXPoi]" + result.errcode + ":" + result.errmsg);
                throw new Exception(result.errmsg);
            }

            List <WXCategory> c = new List <WXCategory>();

            foreach (string str in result.category_list)
            {
                string[] cateArr = str.Split(',');
                if (cateArr.Count() == 1)
                {
                    c.Add(new WXCategory
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = cateArr[0]
                    });
                }
                else if (c.Exists(p => p.Name == cateArr[0]))
                {
                    var parent = c.FirstOrDefault(p => p.Name == cateArr[0]);
                    if (!parent.Child.Exists(p => p.Name == cateArr[1]))
                    {
                        WXCategory child = new WXCategory();
                        child.Id   = parent.Id;
                        child.Name = cateArr[1];
                        parent.Child.Add(child);
                    }
                }
                else
                {
                    WXCategory item = new WXCategory();
                    item.Id   = Guid.NewGuid().ToString();
                    item.Name = cateArr[0];

                    WXCategory child = new WXCategory();
                    child.Id   = item.Id;
                    child.Name = cateArr[1];
                    item.Child.Add(child);
                    c.Add(item);
                }
            }
            return(c);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 查询门店列表
        /// </summary>
        /// <returns></returns>
        public List <string> fghj()
        {
            List <Senparc.Weixin.MP.AdvancedAPIs.Poi.GetStoreList_Business> ss = new List <Senparc.Weixin.MP.AdvancedAPIs.Poi.GetStoreList_Business>();
            var           accessToken = Token();
            var           result      = PoiApi.GetPoiList(accessToken, 0);
            List <string> sss         = new List <string>();

            for (int i = 0; i < result.business_list.Count; i++)
            {
                ss.Add(result.business_list[i]);

                sss.Add(result.business_list[i].base_info.poi_id);
            }

            return(sss);
        }
Ejemplo n.º 18
0
        public GetStoreListResultJson GetPoiList(int page, int rows)
        {
            int num = 0;

            if (page > 1)
            {
                num = (page - 1) * rows;
            }
            GetStoreListResultJson poiList = PoiApi.GetPoiList(_accessToken, num, rows, 10000);

            if (poiList.errcode != ReturnCode.请求成功 && poiList.errcode != ReturnCode.api功能未授权)
            {
                throw new Exception(poiList.errmsg);
            }
            return(poiList);
        }
Ejemplo n.º 19
0
        public bool DeletePoi(string poiId)
        {
            var result = PoiApi.DeletePoi(this._accessToken, poiId);

            if ((int)result.errcode == 65107 || result.errcode == Senparc.Weixin.ReturnCode.系统繁忙此时请开发者稍候再试)
            {
                throw new HimallException("系统繁忙,请稍后尝试!");
            }
            else if (result.errcode == 0)
            {
                return(true);
            }
            else
            {
                throw new Exception(result.errmsg);
            }
        }
Ejemplo n.º 20
0
        public GetStoreListResultJson GetPoiList(int page, int rows)
        {
            int begin = 0;

            if (page > 1)
            {
                begin = (page - 1) * rows;
            }

            var result = PoiApi.GetPoiList(this._accessToken, begin, rows);

            if (result.errcode != 0 && result.errcode != Senparc.Weixin.ReturnCode.api功能未授权)
            {
                throw new Exception(result.errmsg);
            }
            return(result);
        }
Ejemplo n.º 21
0
        public static IEnumerable <WXCategory> GetCategory()
        {
            IList <WXCategory> list     = new List <WXCategory>();
            GetCategoryResult  category = PoiApi.GetCategory(WXStoreHelper.siteSettings.WeixinAppId);

            foreach (string item2 in category.category_list)
            {
                string[]   array = item2.Split(',');
                WXCategory item  = new WXCategory
                {
                    FirstCategoryName  = ((array.Count() > 0) ? array[0] : string.Empty),
                    SecondCategoryName = ((array.Count() > 1) ? array[1] : string.Empty),
                    ThridCategoryName  = ((array.Count() > 2) ? array[2] : string.Empty)
                };
                list.Add(item);
            }
            return(list);
        }
Ejemplo n.º 22
0
        public static List <Store> GetAllPoiList()
        {
            int                    num           = 0;
            int                    num2          = 20;
            List <Store>           business_list = new List <Store>();
            GetStoreListResultJson poiList       = PoiApi.GetPoiList(WXStoreHelper.siteSettings.WeixinAppId, num, num2, 10000);

            while (poiList.business_list.Count > 0)
            {
                poiList.business_list.ForEach(delegate(GetStoreList_Business c)
                {
                    business_list.Add(c);
                });
                num    += num2;
                poiList = PoiApi.GetPoiList(WXStoreHelper.siteSettings.WeixinAppId, num, num2, 10000);
            }
            return(business_list);
        }
Ejemplo n.º 23
0
 public static WxJsonResult CreateWXStore(CreateStoreData createStoreData)
 {
     return(PoiApi.AddPoi(WXStoreHelper.siteSettings.WeixinAppId, createStoreData, 10000));
 }
Ejemplo n.º 24
0
 public static WxJsonResult DeleteWXStore(string poiId)
 {
     return(PoiApi.DeletePoi(WXStoreHelper.siteSettings.WeixinAppId, poiId, 10000));
 }
Ejemplo n.º 25
0
 public static GetStoreListResultJson GetPoiList(int begin, int limit = 20)
 {
     return(PoiApi.GetPoiList(WXStoreHelper.siteSettings.WeixinAppId, begin, limit, 10000));
 }
Ejemplo n.º 26
0
 public static GetStoreResultJson GetPoi(string poiId)
 {
     return(PoiApi.GetPoi(WXStoreHelper.siteSettings.WeixinAppId, poiId, 10000));
 }
Ejemplo n.º 27
0
        public static IEnumerable <string> ImageUploadForStore(IEnumerable <string> files)
        {
            IList <string> list = new List <string>();

            foreach (string file2 in files)
            {
                string file = $"{HttpContext.Current.Server.MapPath(file2)}";
                Senparc.Weixin.MP.AdvancedAPIs.Poi.UploadImageResultJson uploadImageResultJson = PoiApi.UploadImage(WXStoreHelper.siteSettings.WeixinAppId, file, 10000);
                list.Add(uploadImageResultJson.url);
            }
            return(list);
        }
Ejemplo n.º 28
0
 public static WxJsonResult UpdateWXStore(UpdateStoreData updateStoreData)
 {
     return(PoiApi.UpdatePoi(WXStoreHelper.siteSettings.WeixinAppId, updateStoreData, 10000));
 }