コード例 #1
0
        void Recognition()
        {
            if (string.IsNullOrEmpty(txtAddress.Text.Trim()))
            {
                XtraMessageBox.Show("地址必填", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtAddress.Focus();
                txtAddress.Select();
            }
            var baiAddressEntity = BaiduMapHelper.GetProvCityDistFromBaiduMap(txtAddress.Text);

            if (baiAddressEntity != null)
            {
                txtJson.Text = JsonConvert.SerializeObject(baiAddressEntity);
                // {"status":0,"result":{"location":{"lng":117.27923772506,"lat":23.787243812736},"formatted_address":"福建省漳州市诏安县G324","business":"","addressComponent":{"city":"漳州市","country":"中国","direction":"","distance":"","district":"诏安县","province":"福建省","street":"G324","street_number":"","country_code":0},"poiRegions":[],"sematic_description":"诏安县四都派出所东北78米","cityCode":255}}
                txtCountry.Text            = baiAddressEntity.Result.AddressComponent.Country;
                txtProvinceCityCounty.Text = string.Format("{0}-{1}-{2}",
                                                           baiAddressEntity.Result.AddressComponent.Province,
                                                           baiAddressEntity.Result.AddressComponent.City,
                                                           baiAddressEntity.Result.AddressComponent.District);
                txtTown.Text   = "";
                txtStreet.Text = baiAddressEntity.Result.AddressComponent.Street;
                //
                txtLocation.Text = baiAddressEntity.Result.Location.Lng + "," + baiAddressEntity.Result.Location.Lat;
            }
            else
            {
                XtraMessageBox.Show("未能识别成功", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        public override IResponseMessageBase OnLocationRequest(RequestMessageLocation requestMessage)
        {
            //返回的是图文消息,是关于地址的图文消息。
            var responseLocation = base.CreateResponseMessage <ResponseMessageNews>();

            var markersList = new List <BaiduMarkers>();

            markersList.Add(new BaiduMarkers()
            {
                Size      = BaiduMarkerSize.m,
                Color     = "red",
                Label     = "A",
                Latitude  = requestMessage.Location_X,
                Longitude = requestMessage.Location_Y,
            });
            var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_Y, requestMessage.Location_X, 1, 13, markersList);

            responseLocation.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", requestMessage.Location_X, requestMessage.Location_Y, requestMessage.Scale, requestMessage.Label),
                PicUrl      = "http://pic.cnblogs.com/avatar/679140/20141128195544.png",
                Title       = "张辉的地图",
                Url         = mapUrl
            });
            //responseLocation.Articles.Add(new Article()
            //{
            //    Title="小辉博客",
            //    Description = "这个阿辉的博客地址,记录笔记和学习的地方",
            //    PicUrl = "http://pic.cnblogs.com/avatar/679140/20141128195544.png",
            //    Url = "http://www.cnblogs.com/netxiaohui"
            //});
            return(responseLocation);
        }
コード例 #3
0
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSearch2_Click(object sender, EventArgs e)
        {
            var sendArea    = BaiduMapHelper.GetProvCityDistFromBaiduMap(txtSendAddress.Text);
            var receiveArea = BaiduMapHelper.GetProvCityDistFromBaiduMap(txtReceiveAddress.Text);

            if (sendArea != null && receiveArea != null)
            {
                var selectedRemark = new List <string>()
                {
                    sendArea.Result.AddressComponent.Province, sendArea.Result.AddressComponent.City, sendArea.Result.AddressComponent.District
                };
                var selectedReceiveMark = new List <string>()
                {
                    receiveArea.Result.AddressComponent.Province, receiveArea.Result.AddressComponent.City, receiveArea.Result.AddressComponent.District
                };
                var printMarkEntity = BillPrintHelper.GetZtoPrintMark(string.Join(",", selectedRemark), txtSendAddress.Text, string.Join(",", selectedReceiveMark), txtReceiveAddress.Text);
                if (printMarkEntity != null)
                {
                    txtMark2.Text      = printMarkEntity.Result.Mark;
                    txtPrintMark2.Text = printMarkEntity.Result.PrintMark;
                }
                else
                {
                    XtraMessageBox.Show(@"未提取到大头笔信息", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                XtraMessageBox.Show(@"地址填写不详细", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #4
0
        public override IResponseMessageBase OnLocationRequest(RequestMessageLocation requestMessage)
        {
            var responseMessage = base.CreateResponseMessage <ResponseMessageNews>();
            var locationService = new LocationService();
            var markersList     = new List <BaiduMarkers>();

            markersList.Add(new BaiduMarkers
            {
                Color     = "0xFFFF00",
                Label     = "S",
                Latitude  = requestMessage.Location_Y,
                Longitude = requestMessage.Location_X,
                Size      = BaiduMarkerSize.Default
            });
            var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 16, 12, markersList);

            responseMessage.Articles.Add(new Article
            {
                Title       = "使用百度地图定位地点周边地图",
                Description = String.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}", requestMessage.Location_X, requestMessage.Location_Y, requestMessage.Scale, requestMessage.Label),
                PicUrl      = mapUrl,
                Url         = mapUrl
            });
            return(responseMessage);
        }
コード例 #5
0
        public void GetBaiduStaticMapTest()
        {
            var markersList = new List <BaiduMarkers>();

            markersList.Add(new BaiduMarkers()
            {
                Longitude = 31.285774,
                Latitude  = 120.597610,
                Color     = "red",
                Label     = "O",
                Size      = BaiduMarkerSize.Default,
            });
            markersList.Add(new BaiduMarkers()
            {
                Longitude = 31.289774,
                Latitude  = 120.597910,
                Color     = "blue",
                Label     = "T",
                Size      = BaiduMarkerSize.Default,
            });

            var url = BaiduMapHelper.GetBaiduStaticMap(31.285774, 120.597610, 2, 16, markersList);

            Console.WriteLine(url);
            Assert.IsNotNull(url);
        }
コード例 #6
0
        private void method_14()
        {
            string text = "18";

            if (this.oQuestion.QDefine.NOTE != "")
            {
                text = this.oQuestion.QDefine.NOTE;
            }
            string text2 = this.txtFill.Text;

            this.SearchClick = true;
            JGeocoding geocodingFromAddress = new BaiduMapHelper().GetGeocodingFromAddress(this.strCity, this.strCity + text2);

            if (geocodingFromAddress.status == 0)
            {
                this.PanelConnet.Visibility = Visibility.Collapsed;
                this.scrollNote.Visibility  = Visibility.Visible;
                this.c_webBrowser.Document.InvokeScript("remove_overlay");
                this.c_webBrowser.Document.InvokeScript("AddMovePoint", new object[]
                {
                    this.lng,
                    this.lat,
                    text2,
                    text
                });
                return;
            }
            this.PanelConnet.Visibility = Visibility.Visible;
            this.scrollNote.Visibility  = Visibility.Collapsed;
            System.Windows.MessageBox.Show(string.Format(SurveyMsg.MsgMapNotFound, this.strCity + ":" + text2, geocodingFromAddress.status.ToString()), SurveyMsg.MsgCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
            this.txtFill.Focus();
        }
コード例 #7
0
        private void txtReceiveAddress_Leave(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtReceiveAddress.Text))
            {
                BindPrintMark();
            }
            // 如果收件的省市区存在的话就对的,不用提取收件省市区了。
            if (!string.IsNullOrEmpty(dgvReceiveArea.Text))
            {
                return;
            }
            // 根据收件的地址,获取到百度地图提供的省市区信息
            var result = BaiduMapHelper.GetProvCityDistFromBaiduMap(txtReceiveAddress.Text);

            if (result != null)
            {
                var area = string.Format("{0}-{1}-{2}", result.Result.AddressComponent.Province.Trim(), result.Result.AddressComponent.City.Trim(), result.Result.AddressComponent.District.Trim());
                dgvReceiveArea.Text = area;
                if (string.IsNullOrEmpty(dgvReceiveArea.Text))
                {
                    BaseAreaManager areaManager = new BaseAreaManager(BillPrintHelper.DbHelper);
                    // 去数据库找
                    var countyEntity = areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, result.Result.AddressComponent.District.Trim())).FirstOrDefault();
                    if (countyEntity != null)
                    {
                        var cityEntity     = areaManager.GetObject(countyEntity.ParentId);
                        var provinceEntity = areaManager.GetObject(cityEntity.ParentId);
                        dgvReceiveArea.Text = string.Format("{0}-{1}-{2}", provinceEntity.FullName, cityEntity.FullName, countyEntity.FullName);
                    }
                }
            }
        }
コード例 #8
0
        public ActionResult SendLocation(int taskId, double lat, double lon)
        {
            var m = BaiduMapHelper.CoordinateToAddress(lat, lon);

            var addr = m.Result.AddressComponent.Street + m.Result.AddressComponent.Street_number;

            _weixinAppService.InsertRouteArriveEvent(taskId, addr);
            return(Content(m.Result.AddressComponent.Street));
        }
コード例 #9
0
ファイル: LocationService.cs プロジェクト: LoveTry/MC
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var    responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);
            double lat, lng;

            lat = requestMessage.Location_X;
            lng = requestMessage.Location_Y;

            Convert_GCJ02_To_BD09(ref lat, ref lng);

            var markersList = new List <BaiduMarkers>();

            markersList.Add(new BaiduMarkers()
            {
                Latitude  = lat,
                Longitude = lng,
                Color     = "red",
                Label     = "S",
                Size      = BaiduMarkerSize.l,
            });
            //var mapSize = "480x600";
            int scale = requestMessage.Scale;

            scale = 17;
            var mapUrl = BaiduMapHelper.GetBaiduStaticMap(lng, lat, 1,
                                                          scale, markersList, 800, 600);

            //http://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&name=%E4%B8%AD%E5%9B%BD%2C%E8%BE%BD%E5%AE%81%E7%9C%81%2C%E5%A4%A7%E8%BF%9E%E5%B8%82%2C%E4%B8%AD%E5%B1%B1%E5%8C%BA&addr=%E7%8B%AC%E7%AB%8B%E8%A1%9730%E5%8F%B7%E8%91%B5%E8%8B%B1%E8%A1%97&pointy=38.9159&pointx=121.643&coord=38.9159%2C121.643&ref=WeChat
            responseMessage.Articles.Add(new Article()
            {
                //Description = string.Format("您刚才发送了地理位置信息。lng:{0},lat:{1},Scale:{2},标签:{3}",
                //              lng, lat, scale, requestMessage.Label),
                Description = string.Format("您刚才发送了地理位置信息。" + System.Environment.NewLine + "经度:{0}" + System.Environment.NewLine + "纬度:{1}" + System.Environment.NewLine + "{2}",
                                            lng, lat, requestMessage.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });



            //responseMessage.Articles.Add(new Article()
            //{
            //    Title = "微信公众平台SDK 官网链接",
            //    Description = "Senparc.Weixin.MK SDK地址",
            //    PicUrl = "http://weixin.senparc.com/images/logo.jpg",
            //    Url = "http://weixin.senparc.com"
            //});



            return(responseMessage);
        }
コード例 #10
0
 /// <summary>
 /// 识别地址方法
 /// </summary>
 void Recognition()
 {
     if (!string.IsNullOrEmpty(txtContent.Text))
     {
         ClearContent();
         var result = RecognitionTaoBao();
         if (!result)
         {
             var result1 = RecognitionJD();
             if (!result1)
             {
                 RecognitionOther();
             }
         }
         var address = txtContent.Text.Replace(" ", "").Replace(",", "").Replace(",", "").Replace("\r\n", "");
         if (!string.IsNullOrEmpty(txtRealName.Text))
         {
             address = address.Replace(txtRealName.Text, "");
         }
         if (!string.IsNullOrEmpty(txtMobile.Text))
         {
             address = address.Replace(txtMobile.Text, "");
         }
         if (!string.IsNullOrEmpty(txtTelephone.Text))
         {
             address = address.Replace(txtTelephone.Text, "");
         }
         if (!string.IsNullOrEmpty(txtPostCode.Text))
         {
             address = address.Replace(txtPostCode.Text, "");
         }
         var resultAddress = BaiduMapHelper.GetProvCityDistFromBaiduMap(address);
         if (resultAddress != null)
         {
             txtProvince.Text = resultAddress.Result.AddressComponent.Province.Trim();
             txtCity.Text     = resultAddress.Result.AddressComponent.City.Trim();
             txtCounty.Text   = resultAddress.Result.AddressComponent.District.Trim();
             txtAddress.Text  = address.Replace(txtProvince.Text, "").Replace(txtCity.Text, "").Replace(txtCounty.Text, "");
             if (!string.IsNullOrEmpty(txtPostCode.Text))
             {
                 txtAddress.Text = txtAddress.Text.Replace(txtPostCode.Text, "");
             }
         }
     }
     else
     {
         XtraMessageBox.Show("识别内容不能为空", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         txtContent.Focus();
         txtContent.Select();
     }
 }
コード例 #11
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            var markersList = new List <BaiduMarkers>();

            markersList.Add(new BaiduMarkers()
            {
                Longitude = requestMessage.Location_X,
                Latitude  = requestMessage.Location_Y,
                Color     = "red",
                Label     = "S",
                Size      = BaiduMarkerSize.Default,
            });
            var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y,
                                                          1, 3, null, 600, 480);

            //var markersList = new List<GoogleMapMarkers>();
            //markersList.Add(new GoogleMapMarkers()
            //{
            //    X = requestMessage.Location_X,
            //    Y = requestMessage.Location_Y,
            //    Color = "red",
            //    Label = "S",
            //    Size = GoogleMapMarkerSize.Default,
            //});
            //var mapSize = "480x600";
            //var mapUrl = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
            //                                                markersList, mapSize);
            responseMessage.Articles.Add(new Article()
            {
                Description = string.Format("您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                            requestMessage.Location_X, requestMessage.Location_Y,
                                            requestMessage.Scale, requestMessage.Label),
                PicUrl = mapUrl,
                Title  = "定位地点周边地图",
                Url    = mapUrl
            });
            responseMessage.Articles.Add(new Article()
            {
                Title       = "微信公众平台SDK 百度地图",
                Description = "Senparc.Weixin.MK SDK地址",
                PicUrl      = "http://weixin.senparc.com/images/logo.jpg",
                Url         = "http://weixin.senparc.com"
            });

            return(responseMessage);
        }
コード例 #12
0
 /// <summary>
 /// 识别京东收货人地址
 /// </summary>
 /// <returns></returns>
 bool RecognitionJD()
 {
     try
     {
         /*
          * 收 货 人:劉志
          *     地    址:广东佛山市顺德区陈村镇石洲村太平街路29号
          *     手机号码:13980755856
          */
         var count     = 0;
         var jdContent = txtContent.Text.Replace(":", ":").Split(new string[] { "\r\n" }, StringSplitOptions.None);
         foreach (var s in jdContent)
         {
             if (s.Replace(" ", "").Contains("收货人"))
             {
                 txtRealName.Text = s.Replace(" ", "").Replace("收货人:", "");
                 count++;
             }
             if (s.Replace(" ", "").Contains("手机号码"))
             {
                 txtMobile.Text = s.Replace(" ", "").Replace("手机号码:", "");
                 count++;
             }
             if (s.Replace(" ", "").Contains("地址"))
             {
                 var address = s.Replace(" ", "").Replace("地址:", "");
                 var result  = BaiduMapHelper.GetProvCityDistFromBaiduMap(address);
                 if (result != null)
                 {
                     txtProvince.Text = result.Result.AddressComponent.Province.Trim();
                     txtCity.Text     = result.Result.AddressComponent.City.Trim();
                     txtCounty.Text   = result.Result.AddressComponent.District.Trim();
                     txtAddress.Text  = address.Replace(txtProvince.Text, "").Replace(txtCity.Text, "").Replace(txtCounty.Text, "");
                     count++;
                 }
             }
         }
         return(count > 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #13
0
 /// <summary>
 /// 自动获取到地址所在省市区
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void txtSendAddress_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(txtSendAddress.Text))
     {
         var result = BaiduMapHelper.GetProvCityDistFromBaiduMap(dgvSearchSendArea.Text + txtSendAddress.Text);
         if (result != null)
         {
             var area = string.Format("{0}-{1}-{2}", result.Result.AddressComponent.Province.Trim(),
                                      result.Result.AddressComponent.City.Trim(),
                                      result.Result.AddressComponent.District.Trim());
             dgvSearchSendArea.Text = area;
             if (string.IsNullOrEmpty(dgvSearchSendArea.Text))
             {
                 BaseAreaManager areaManager = new BaseAreaManager(BillPrintHelper.DbHelper);
                 // 去数据库找
                 var countyEntity =
                     areaManager.GetList <BaseAreaEntity>(
                         new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName,
                                                           result.Result.AddressComponent.District.Trim())).
                     FirstOrDefault();
                 if (countyEntity != null)
                 {
                     var cityEntity     = areaManager.GetObject(countyEntity.ParentId);
                     var provinceEntity = areaManager.GetObject(cityEntity.ParentId);
                     dgvSearchSendArea.Text = string.Format("{0}-{1}-{2}", provinceEntity.FullName,
                                                            cityEntity.FullName, countyEntity.FullName);
                     // 详细地址把省市区过滤掉
                     txtSendAddress.Text =
                         txtSendAddress.Text.Replace(provinceEntity.FullName, "").Replace(
                             cityEntity.FullName, "").Replace(
                             countyEntity.FullName, "");
                 }
             }
             else
             {
                 // 详细地址把省市区过滤掉
                 txtSendAddress.Text =
                     txtSendAddress.Text.Replace(result.Result.AddressComponent.Province.Trim(), "").Replace(
                         result.Result.AddressComponent.City.Trim(), "").Replace(
                         result.Result.AddressComponent.District.Trim(), "");
             }
         }
     }
 }
コード例 #14
0
        public void BaiduMapHelperTest()
        {
            var markers = new List <BaiduMarkers>();

            markers.Add(new BaiduMarkers()
            {
                url       = "http://www.senparc.com",
                Color     = "#ff0000",
                Label     = "A",
                Latitude  = 31.3,
                Longitude = 120.6,
                Size      = BaiduMarkerSize.m
            });

            var result = BaiduMapHelper.GetBaiduStaticMap(120.6, 31.3, 2, 15, markers, 400, 300);

            Console.WriteLine(result);
            Assert.IsTrue(result.Contains("api.map.baidu.com"));
        }
コード例 #15
0
        private void btnSearch_Click(object sender = null, RoutedEventArgs e = null)
        {
            string text = "18";

            if (this.oQuestion.QDefine.NOTE != "")
            {
                text = this.oQuestion.QDefine.NOTE;
            }
            this.txtFill.Text = this.oQuestion.ConvertText(this.txtFill.Text, this.oQuestion.QDefine.CONTROL_MASK);
            string text2 = this.txtFill.Text;

            if (text2.Trim() == "")
            {
                System.Windows.MessageBox.Show(SurveyMsg.MsgNotFill, SurveyMsg.MsgCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
                this.txtFill.Focus();
                return;
            }
            this.SearchClick = true;
            JGeocoding geocodingFromAddress = new BaiduMapHelper().GetGeocodingFromAddress(this.strCity, this.strCity + text2);

            if (geocodingFromAddress.status == 0)
            {
                this.PanelConnet.Visibility = Visibility.Collapsed;
                this.scrollNote.Visibility  = Visibility.Visible;
                this.c_webBrowser.Document.InvokeScript("remove_overlay");
                this.c_webBrowser.Document.InvokeScript("AddMovePoint", new object[]
                {
                    geocodingFromAddress.result.location.lng,
                    geocodingFromAddress.result.location.lat,
                    text2,
                    text
                });
                return;
            }
            this.PanelConnet.Visibility = Visibility.Visible;
            this.scrollNote.Visibility  = Visibility.Collapsed;
            System.Windows.MessageBox.Show(string.Format(SurveyMsg.MsgMapNotFound, this.strCity + ":" + text2, geocodingFromAddress.status.ToString()), SurveyMsg.MsgCaption, MessageBoxButton.OK, MessageBoxImage.Hand);
            this.txtFill.Focus();
        }
コード例 #16
0
        /// <summary>
        /// 导入Excel数据到本地数据库
        /// </summary>
        public bool Import()
        {
            if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
            {
                XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            if (!File.Exists(txtFileFullPath.Text))
            {
                XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnOpenExcel_Click(this, null);
                return(false);
            }
            var startDateTime = DateTime.Now;

            StartDt = startDateTime;
            if (!splashScreenManagerImportExcel.IsSplashFormVisible)
            {
                splashScreenManagerImportExcel.ShowWaitForm();
            }
            Application.DoEvents();
            splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
            splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据...");
            try
            {
                DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 11, 0, 1);
                if (chooseDt != null && chooseDt.Rows.Count > 0)
                {
                    var           list              = new List <ZtoPrintBillEntity>();
                    int           temp              = 0;
                    var           defaultUserList   = new ZtoUserManager(BillPrintHelper.DbHelper).GetList <ZtoUserEntity>(new KeyValuePair <string, object>(ZtoUserEntity.FieldIsDefault, 1), new KeyValuePair <string, object>(ZtoUserEntity.FieldIssendorreceive, 1));
                    ZtoUserEntity defaultUserEntity = null;
                    if (defaultUserList.Any())
                    {
                        defaultUserEntity = defaultUserList.First();
                    }
                    foreach (DataRow dr in chooseDt.Rows)
                    {
                        ++temp;
                        splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                        ZtoPrintBillEntity entity = new ZtoPrintBillEntity();
                        if (ckTodaySend.Checked)
                        {
                            entity.SendDate = DateTime.Now.ToString(BaseSystemInfo.DateFormat);
                        }
                        if (ckUserDefaultSendMan.Checked)
                        {
                            if (defaultUserEntity != null)
                            {
                                entity.SendMan        = defaultUserEntity.Realname;
                                entity.SendPhone      = defaultUserEntity.Mobile + " " + defaultUserEntity.TelePhone;
                                entity.SendProvince   = defaultUserEntity.Province;
                                entity.SendCity       = defaultUserEntity.City;
                                entity.SendCounty     = defaultUserEntity.County;
                                entity.SendAddress    = defaultUserEntity.Address;
                                entity.SendDeparture  = entity.SendProvince;
                                entity.SendCompany    = defaultUserEntity.Company;
                                entity.SendDepartment = defaultUserEntity.Department;
                                entity.SendPostcode   = defaultUserEntity.Postcode;
                            }
                        }
                        else
                        {
                            // 使用Excel里面的发件人
                            entity.SendMan     = BaseBusinessLogic.ConvertToString(dr[6]);
                            entity.SendPhone   = BaseBusinessLogic.ConvertToString(dr[7]);
                            entity.SendAddress = BaseBusinessLogic.ConvertToString(dr[8]);
                            if (string.IsNullOrEmpty(entity.SendProvince) && string.IsNullOrEmpty(entity.SendCity) && string.IsNullOrEmpty(entity.SendCounty))
                            {
                                if (!string.IsNullOrEmpty(entity.SendAddress))
                                {
                                    var baiAddressEntity = BaiduMapHelper.GetProvCityDistFromBaiduMap(entity.SendAddress);
                                    if (baiAddressEntity != null)
                                    {
                                        entity.SendProvince = baiAddressEntity.Result.AddressComponent.Province;
                                        entity.SendCity     = baiAddressEntity.Result.AddressComponent.City;
                                        entity.SendCounty   = baiAddressEntity.Result.AddressComponent.District;
                                    }
                                }
                            }
                            entity.SendDeparture = entity.SendProvince;
                            if (string.IsNullOrEmpty(entity.SendDeparture))
                            {
                                entity.SendDeparture = entity.SendProvince;
                            }
                            entity.SendCompany    = BaseBusinessLogic.ConvertToString(dr[10]);
                            entity.SendDepartment = BaseBusinessLogic.ConvertToString(dr[11]);
                            entity.SendPostcode   = BaseBusinessLogic.ConvertToString(dr[9]);
                        }
                        entity.ReceiveMan     = BaseBusinessLogic.ConvertToString(dr[0]);
                        entity.ReceivePhone   = BaseBusinessLogic.ConvertToString(dr[1]);
                        entity.ReceiveAddress = BaseBusinessLogic.ConvertToString(dr[2]);
                        //if (string.IsNullOrEmpty(entity.ReceiveProvince) && string.IsNullOrEmpty(entity.ReceiveCity) && string.IsNullOrEmpty(entity.ReceiveCounty))
                        //{
                        //    if (!string.IsNullOrEmpty(entity.ReceiveAddress))
                        //    {
                        //        var baiAddressEntity = BaiduHelper.GetProvCityDistFromBaiduMap(entity.ReceiveAddress);
                        //        if (baiAddressEntity != null)
                        //        {
                        //            entity.ReceiveProvince = baiAddressEntity.Result.AddressComponent.Province;
                        //            entity.ReceiveCity = baiAddressEntity.Result.AddressComponent.City;
                        //            entity.ReceiveCounty = baiAddressEntity.Result.AddressComponent.District;
                        //        }
                        //    }
                        //}
                        entity.ReceiveDestination = entity.ReceiveProvince;
                        if (string.IsNullOrEmpty(entity.ReceiveDestination))
                        {
                            entity.ReceiveDestination = entity.ReceiveProvince;
                        }
                        //entity.ReceiveCompany = BaseBusinessLogic.ConvertToString(dr[31]);
                        //entity.ReceivePostcode = BaseBusinessLogic.ConvertToString(dr[32]);
                        //entity.GoodsName = BaseBusinessLogic.ConvertToString(dr[14]);
                        //entity.Weight = BaseBusinessLogic.ConvertToString(dr[15]);
                        //entity.TranFee = BaseBusinessLogic.ConvertToString(dr[16]);
                        //entity.Length = BaseBusinessLogic.ConvertToString(dr[33]);
                        //entity.Width = BaseBusinessLogic.ConvertToString(dr[34]);
                        //entity.Height = BaseBusinessLogic.ConvertToString(dr[35]);
                        //entity.TotalNumber = BaseBusinessLogic.ConvertToString(dr[36]);
                        entity.Remark      = BaseBusinessLogic.ConvertToString(dr[4]);
                        entity.OrderNumber = BaseBusinessLogic.ConvertToString(dr[3]);
                        entity.TranFee     = BaseBusinessLogic.ConvertToString(dr[5]);
                        entity.CreateOn    = DateTime.Now;
                        if (!ckGetServerPrintMark.Checked)
                        {
                            entity.BigPen = string.Format("{0} {1} {2}", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty);
                        }
                        else
                        {
                            entity.BigPen = "";
                        }
                        list.Add(entity);
                    }
                    if (!ckGetServerPrintMark.Checked)
                    {
                        var manager = new ZtoPrintBillManager(BillPrintHelper.DbHelper);
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in list)
                        {
                            manager.Add(ztoPrintBillEntity, true);
                        }
                        if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                        {
                            splashScreenManagerImportExcel.CloseWaitForm();
                        }
                        GridDataBind();
                        var ts = DateTime.Now - startDateTime;
                        lblTime.Text = string.Format("耗时:{0}时{1}分{2}秒{3}毫秒", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
                        Close();
                    }
                    else
                    {
                        splashScreenManagerImportExcel.SetWaitFormDescription("正在联网获取大头笔信息");
                        if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                        {
                            splashScreenManagerImportExcel.CloseWaitForm();
                        }
                        // 开线程去读取大头笔的
                        CheckBillCode(list);
                    }
                }
                else
                {
                    XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
                return(false);
            }
            finally
            {
                if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
                {
                    splashScreenManagerImportExcel.CloseWaitForm();
                }
            }
            return(true);
        }
コード例 #17
0
        public ResponseMessageNews GetResponseMessage(RequestMessageLocation requestMessage)
        {
            var responseMessage = ResponseMessageBase.CreateFromRequestMessage <ResponseMessageNews>(requestMessage);

            #region 百度地图

            {
                var markersList = new List <BaiduMarkers>();
                markersList.Add(new BaiduMarkers()
                {
                    Longitude = requestMessage.Location_X,
                    Latitude  = requestMessage.Location_Y,
                    Color     = "red",
                    Label     = "S",
                    Size      = BaiduMarkerSize.m
                });

                var mapUrl = BaiduMapHelper.GetBaiduStaticMap(requestMessage.Location_X, requestMessage.Location_Y, 1, 6, markersList);
                responseMessage.Articles.Add(new Article()
                {
                    Description = string.Format("【来自百度地图】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                                requestMessage.Location_X, requestMessage.Location_Y,
                                                requestMessage.Scale, requestMessage.Label),
                    PicUrl = mapUrl,
                    Title  = "定位地点周边地图",
                    Url    = mapUrl
                });
            }

            #endregion

            #region GoogleMap

            {
                var markersList = new List <GoogleMapMarkers>();
                markersList.Add(new GoogleMapMarkers()
                {
                    X     = requestMessage.Location_X,
                    Y     = requestMessage.Location_Y,
                    Color = "red",
                    Label = "S",
                    Size  = GoogleMapMarkerSize.Default,
                });
                var mapSize = "480x600";
                var mapUrl  = GoogleMapHelper.GetGoogleStaticMap(19 /*requestMessage.Scale*//*微信和GoogleMap的Scale不一致,这里建议使用固定值*/,
                                                                 markersList, mapSize);
                responseMessage.Articles.Add(new Article()
                {
                    Description = string.Format("【来自GoogleMap】您刚才发送了地理位置信息。Location_X:{0},Location_Y:{1},Scale:{2},标签:{3}",
                                                requestMessage.Location_X, requestMessage.Location_Y,
                                                requestMessage.Scale, requestMessage.Label),
                    PicUrl = mapUrl,
                    Title  = "定位地点周边地图",
                    Url    = mapUrl
                });
            }

            #endregion


            responseMessage.Articles.Add(new Article()
            {
                Title       = "微信公众平台SDK 官网链接",
                Description = "",
                PicUrl      = "",
                Url         = ""
            });

            return(responseMessage);
        }
コード例 #18
0
ファイル: FrmImportExcel.cs プロジェクト: zanderzhg/STO.Print
        /// <summary>
        /// 线程执行校验单号函数
        /// </summary>
        /// <param name="updateBillItem"></param>
        public void CheckBillList(object updateBillItem)
        {
            var item = updateBillItem as LoadPrintMarkEntity;

            try
            {
                if (item != null)
                {
                    // 循环次数 65  2
                    var length = item.PrintBillEntities.Count > 50 ? Convert.ToInt32(Math.Ceiling(item.PrintBillEntities.Count / 50.0)) : 1;
                    // 每次循环单号个数 33
                    var listNo = item.PrintBillEntities.Count / length;

                    for (int i = 1; i < length + 1; i++)
                    {
                        List <ZtoPrintBillEntity> billCodeListSend;
                        if (i == 1)
                        {
                            billCodeListSend = item.PrintBillEntities.Skip((i - 1) * listNo).Take(listNo + 1).ToList();
                        }
                        else
                        {
                            billCodeListSend = item.PrintBillEntities.Skip((i - 1) * listNo + i - 1).Take(listNo + 1).ToList();
                        }
                        // 获取发件人的省市区
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in billCodeListSend)
                        {
                            if (string.IsNullOrEmpty(ztoPrintBillEntity.SendProvince) && string.IsNullOrEmpty(ztoPrintBillEntity.SendCity) && string.IsNullOrEmpty(ztoPrintBillEntity.SendCounty))
                            {
                                if (!string.IsNullOrEmpty(ztoPrintBillEntity.SendAddress))
                                {
                                    var baiAddressEntity = BaiduMapHelper.GetProvCityDistFromBaiduMap(ztoPrintBillEntity.SendAddress);
                                    if (baiAddressEntity != null)
                                    {
                                        ztoPrintBillEntity.SendProvince = baiAddressEntity.Result.AddressComponent.Province;
                                        ztoPrintBillEntity.SendCity     = baiAddressEntity.Result.AddressComponent.City;
                                        ztoPrintBillEntity.SendCounty   = baiAddressEntity.Result.AddressComponent.District;
                                        ZtoPrintBillEntity entity = ztoPrintBillEntity;
                                        marqueeProgressBarControl1.BeginInvoke(new Action(() =>
                                        {
                                            marqueeProgressBarControl1.Text = string.Format("正在获取发件人省市区({0}-{1}-{2}),数据加载中,请稍后...", entity.SendProvince, entity.SendCity, entity.SendCounty);
                                        }));
                                    }
                                }
                            }
                        }
                        // 获取收件人的省市区
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in billCodeListSend)
                        {
                            if (string.IsNullOrEmpty(ztoPrintBillEntity.ReceiveProvince) && string.IsNullOrEmpty(ztoPrintBillEntity.ReceiveCity) && string.IsNullOrEmpty(ztoPrintBillEntity.ReceiveCounty))
                            {
                                if (!string.IsNullOrEmpty(ztoPrintBillEntity.ReceiveAddress))
                                {
                                    var baiAddressEntity = BaiduMapHelper.GetProvCityDistFromBaiduMap(ztoPrintBillEntity.ReceiveAddress);
                                    if (baiAddressEntity != null)
                                    {
                                        ztoPrintBillEntity.ReceiveProvince = baiAddressEntity.Result.AddressComponent.Province;
                                        ztoPrintBillEntity.ReceiveCity     = baiAddressEntity.Result.AddressComponent.City;
                                        ztoPrintBillEntity.ReceiveCounty   = baiAddressEntity.Result.AddressComponent.District;
                                        ZtoPrintBillEntity entity = ztoPrintBillEntity;
                                        marqueeProgressBarControl1.BeginInvoke(new Action(() =>
                                        {
                                            marqueeProgressBarControl1.Text = string.Format("正在获取收件人省市区({0}-{1}-{2}),数据加载中,请稍后...", entity.ReceiveProvince, entity.ReceiveCity, entity.ReceiveCounty);
                                        }));
                                    }
                                }
                            }
                        }
                        // 绑定大头笔信息
                        foreach (ZtoPrintBillEntity ztoPrintBillEntity in billCodeListSend)
                        {
                            // 如果大头笔已经有了就不用联网获取了
                            var selectedRemark = new List <string> {
                                ztoPrintBillEntity.SendProvince, ztoPrintBillEntity.SendCity, ztoPrintBillEntity.SendCounty
                            };
                            var selectedReceiveMark = new List <string> {
                                ztoPrintBillEntity.ReceiveProvince, ztoPrintBillEntity.ReceiveCity, ztoPrintBillEntity.ReceiveCounty
                            };
                            var printMark = BillPrintHelper.GetRemaike(string.Join(",", selectedRemark), ztoPrintBillEntity.SendAddress, string.Join(",", selectedReceiveMark), ztoPrintBillEntity.ReceiveAddress);
                            ztoPrintBillEntity.BigPen = printMark;
                            PrintBillEntities.Add(ztoPrintBillEntity);
                            ZtoPrintBillEntity entity = ztoPrintBillEntity;
                            marqueeProgressBarControl1.BeginInvoke(new Action(() =>
                            {
                                marqueeProgressBarControl1.Text = string.Format("正在获取大头笔({0}),数据加载中,请稍后...", entity.BigPen);
                            }));
                        }
                        BillCodeIndex += billCodeListSend.Count;
                        //指定委托方法
                        CheckDelegate refresh = Refresh;
                        Invoke(refresh, item.Code);
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
コード例 #19
0
 /// <summary>
 /// 导入Excel数据到本地数据库
 /// </summary>
 public bool Import()
 {
     if (string.IsNullOrEmpty(txtFileFullPath.Text.Trim()))
     {
         XtraMessageBox.Show(@"请选择录单模板", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     if (!File.Exists(txtFileFullPath.Text))
     {
         XtraMessageBox.Show(@"选中文件不存在,请重新选择导入Excel文件", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
         btnOpenExcel_Click(this, null);
         return(false);
     }
     if (!splashScreenManagerImportExcel.IsSplashFormVisible)
     {
         splashScreenManagerImportExcel.ShowWaitForm();
     }
     Application.DoEvents();
     splashScreenManagerImportExcel.SetWaitFormCaption("请稍后");
     splashScreenManagerImportExcel.SetWaitFormDescription("开始导入Excel数据...");
     try
     {
         int crossRow = int.Parse(cmbPrintNumber.Text) - 1;
         if (crossRow < 0)
         {
             crossRow = 1;
         }
         DataTable chooseDt = ExcelHelper.ExcelToDataTable(txtFileFullPath.Text.Trim(), 38, 0, crossRow);
         if (chooseDt != null && chooseDt.Rows.Count > 0)
         {
             var list = new List <ZtoUserEntity>();
             int temp = 0;
             foreach (DataRow dr in chooseDt.Rows)
             {
                 ++temp;
                 splashScreenManagerImportExcel.SetWaitFormDescription(string.Format("正在导入Excel数据:{0}/{1}", temp, chooseDt.Rows.Count));
                 var userEntity = new ZtoUserEntity {
                     Realname = BaseBusinessLogic.ConvertToString(dr[8])
                 };
                 if (ValidateUtil.IsMobile(BaseBusinessLogic.ConvertToString(dr[9])))
                 {
                     userEntity.Mobile = BaseBusinessLogic.ConvertToString(dr[9]);
                 }
                 else
                 {
                     userEntity.TelePhone = BaseBusinessLogic.ConvertToString(dr[9]);
                 }
                 var tempProvince = BaseBusinessLogic.ConvertToString(dr[10]);
                 // 收件人地址(有可能用户不填写收件省市区)
                 userEntity.Address = BaseBusinessLogic.ConvertToString(dr[13]);
                 if (tempProvince != null)
                 {
                     userEntity.Province = tempProvince.Trim();
                 }
                 var tempCity = BaseBusinessLogic.ConvertToString(dr[11]);
                 if (tempCity != null)
                 {
                     userEntity.City = tempCity.Trim();
                 }
                 var tempCounty = BaseBusinessLogic.ConvertToString(dr[12]);
                 if (tempCounty != null)
                 {
                     userEntity.County = tempCounty.Trim();
                 }
                 if (string.IsNullOrEmpty(userEntity.Province) && string.IsNullOrEmpty(userEntity.City) && string.IsNullOrEmpty(userEntity.County))
                 {
                     if (!string.IsNullOrEmpty(userEntity.Address))
                     {
                         var result = BaiduMapHelper.GetProvCityDistFromBaiduMap(userEntity.Address);
                         if (result != null)
                         {
                             userEntity.Province = result.Result.AddressComponent.Province;
                             userEntity.City     = result.Result.AddressComponent.City;
                             userEntity.County   = result.Result.AddressComponent.District;
                         }
                     }
                 }
                 userEntity.Company         = BaseBusinessLogic.ConvertToString(dr[31]);
                 userEntity.Postcode        = BaseBusinessLogic.ConvertToString(dr[32]);
                 userEntity.Issendorreceive = "0";
                 if (string.IsNullOrEmpty(userEntity.Postcode))
                 {
                     if (!string.IsNullOrEmpty(userEntity.City) && !string.IsNullOrEmpty(userEntity.County))
                     {
                         userEntity.Postcode = NetworkHelper.GetPostCodeByAddress(userEntity.City, userEntity.County);
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.Province))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.Province)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.ProvinceId = areaEntity.Id;
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.City))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.City)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.CityId = areaEntity.Id;
                     }
                 }
                 if (!string.IsNullOrEmpty(userEntity.County))
                 {
                     var areaEntity = _areaManager.GetList <BaseAreaEntity>(new KeyValuePair <string, object>(BaseAreaEntity.FieldFullName, userEntity.County)).FirstOrDefault();
                     if (areaEntity != null)
                     {
                         userEntity.CountyId = areaEntity.Id;
                     }
                 }
                 userEntity.CreateOn = DateTime.Now;
                 list.Add(userEntity);
             }
             using (IDbHelper dbHelper = DbHelperFactory.GetHelper(CurrentDbType.SQLite, BillPrintHelper.BillPrintConnectionString))
             {
                 try
                 {
                     dbHelper.BeginTransaction();
                     var manager = new ZtoUserManager(dbHelper);
                     foreach (ZtoUserEntity ztoUserEntity in list)
                     {
                         manager.Add(ztoUserEntity, true);
                     }
                     dbHelper.CommitTransaction();
                     GridDataBind();
                 }
                 catch (Exception ex)
                 {
                     dbHelper.RollbackTransaction();
                     ProcessException(ex);
                 }
             }
             if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
             {
                 splashScreenManagerImportExcel.CloseWaitForm();
             }
             Close();
         }
         else
         {
             XtraMessageBox.Show(@"模板没有填写任何数据,导入失败", AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
         return(false);
     }
     finally
     {
         if (splashScreenManagerImportExcel != null && splashScreenManagerImportExcel.IsSplashFormVisible)
         {
             splashScreenManagerImportExcel.CloseWaitForm();
         }
     }
     return(true);
 }