private void poiDownHandler(POIInfo poi, int index, int count)
        {
            MethodInvoker invoker = delegate
            {
                k++;
                DataRow row = this.dataTable.NewRow();
                row["name"] = poi.name;
                row["X"]    = poi.cx;
                row["Y"]    = poi.cy;
                //row["WGS84X"] = poi.cx;
                //row["WGS84Y"] = poi.cy;
                row["r_addr"] = poi.address.Replace(",", "");
                row["type"]   = poi.type;
                row["phone"]  = poi.phone.Replace(",", ";");
                this.dataTable.Rows.Add(row);
                if (this.dataTable.Rows.Count % 10 == 0 || index == count)
                {
                    try
                    {
                        string name = this.keyWords.Trim() != "" ? this.keyWords.Trim() : "_兴趣点";
                        SVCHelper.ExportToSvc(this.dataTable, this.path + "\\" + name + ".csv");
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                    }
                }
                if (index > count)
                {
                    index = count;
                }
                this.progressBar.Value = index * 100 / count;
                this.labMessage.Text   = "提示:已下载兴趣点:" + k.ToString() + "条," + index.ToString() + "/" + count.ToString();
                this.progressBar.Update();
            };

            if ((!base.IsDisposed) && base.InvokeRequired)
            {
                base.Invoke(invoker);
            }
            else
            {
                invoker();
            }
        }
Beispiel #2
0
        public void POIApiTest_Add()
        {
            var model = new POIInfo()
            {
                Address      = "湖南省长沙市岳麓区岳麓大道218号",
                AvgPrice     = 1,
                BranchName   = "岳麓店",
                Categorys    = "美食,粤菜,潮汕菜".Split(';'),
                City         = "长沙市",
                District     = "岳麓区",
                Introduction = "Test",
                Latitude     = 28.228209,
                Longitude    = 112.938812,
                Name         = "Test",
                OpenTime     = "8:00~22:00",
                Province     = "湖南省",
                Recommend    = "Test",
                Special      = "Test",
                SID          = System.Guid.NewGuid().ToString("N"),
                Telephone    = "13671974358",
                PhotoList    = new List <POIPhotoInfo>()
            };

            using (var fs = GetInputFile("qrcode.jpg"))
            {
                var result = _weChatApi.UploadImage("qrcode.jpg", fs);
                if (!result.IsSuccess())
                {
                    Assert.Fail("上传图片失败,返回结果如下:" + result.DetailResult + ";Msg:" + result.GetFriendlyMessage());
                }
                model.PhotoList.Add(new POIPhotoInfo()
                {
                    PhotoUrl = result.Url
                });
                var poiResult = _weChatApi.Add(model);
                if (!poiResult.IsSuccess())
                {
                    Assert.Fail("创建门店失败,返回结果如下:" + poiResult.DetailResult + ";Msg:" + poiResult.GetFriendlyMessage());
                }
            }
        }
        public ActionResult Add(Store_Info store_Info)
        {
            var ajaxMessage = new AjaxResponse {
                Success = true, Message = "操作成功!"
            };

            if (!ModelState.IsValid)
            {
                ajaxMessage.Success = false;
                var sb = new StringBuilder();
                foreach (var item in ModelState.Values)
                {
                    foreach (var error in item.Errors)
                    {
                        sb.AppendFormat("{0}<br />", error.ErrorMessage);
                    }
                }
                ajaxMessage.Message = sb.ToString();
                return(Json(ajaxMessage));
            }

            var model = new POIInfo()
            {
                Address      = store_Info.Address,
                AvgPrice     = store_Info.AvgPrice,
                BranchName   = store_Info.BranchName,
                Categorys    = store_Info.Categorys.Split(';'),
                City         = store_Info.City,
                District     = store_Info.District,
                Introduction = store_Info.Introduction,
                Latitude     = store_Info.Latitude,
                Longitude    = store_Info.Longitude,
                Name         = store_Info.Name,
                OpenTime     = store_Info.OpenTime,
                Province     = store_Info.Province,
                Recommend    = store_Info.Recommend,
                Special      = store_Info.Special,
                SID          = Guid.NewGuid().ToString("N"),
                Telephone    = store_Info.Telephone,
                PhotoList    = new List <POIPhotoInfo>()
            };

            if (!string.IsNullOrEmpty(store_Info.PhotoList))
            {
                var photos = store_Info.PhotoList.Split(',');
                foreach (var item in photos)
                {
                    model.PhotoList.Add(new POIPhotoInfo()
                    {
                        PhotoUrl = item
                    });
                }
            }

            var poiResult = WeChatApisContext.Current.POIApi.Add(model);

            if (!poiResult.IsSuccess())
            {
                ajaxMessage.Success = false;
                ajaxMessage.Message = poiResult.GetFriendlyMessage();
            }
            else
            {
                SetModelWithChangeStates(store_Info, default(int));
                db.SaveChanges();
            }
            return(Json(ajaxMessage));
        }