コード例 #1
0
    void TestCreateNewRootKeys()
    {
        // Show root language editor window and get root values
        EditRootLanguageFileWindow           window = EditRootLanguageFileWindow.ShowWindow();
        Dictionary <string, LocalizedObject> dict   = LanguageHandlerEditor.LoadParsedLanguageFile(string.Empty, true);

        // Add any missing TEXT.RSC records
        DaggerfallUnity dfUnity = DaggerfallUnity.Instance;

        if (dfUnity.IsReady)
        {
            TextResourceFile rscFile = new TextResourceFile(dfUnity.Arena2Path, "TEXT.RSC");
            for (int i = 0; i < rscFile.RecordCount; i++)
            {
                TextResourceFile.TextRecord record = rscFile.GetTextRecordByIndex(i);
                string key = RSCNamespacePrefix + record.id.ToString();
                if (!dict.ContainsKey(key))
                {
                    LocalizedObject obj = new LocalizedObject();
                    obj.ObjectType = LocalizedObjectType.STRING;
                    obj.TextValue  = record.text;
                    LanguageDictionaryHelper.AddNewKeyPersistent(dict, key, obj);
                }
            }
        }

        //// Add new root keys and values
        //LocalizedObject obj = new LocalizedObject();
        //obj.ObjectType = LocalizedObjectType.STRING;
        //obj.TextValue = "This is a new text key.";
        //LanguageDictionaryHelper.AddNewKeyPersistent(dict, "NewKey.Test", obj);

        // Set new root values
        window.SetRootValues(dict);
    }
コード例 #2
0
        /// <summary>
        /// 从硬件位置导航到指定地点
        /// </summary>
        /// <param name="destination">目的地</param>
        public async void NavigateToSomeWhereAsync(MapPoint destination)
        {
            if (mapView.LocationDisplay.IsEnabled && mapView.LocationDisplay.Location != null)
            {
                //if(GetDistance(mapView.LocationDisplay.Location.Position.Y, mapView.LocationDisplay.Location.Position.X, destination.Y, destination.X) > 100000)
                //{
                //    MessageboxMaster.Show(LanguageDictionaryHelper.GetString("ShowSpot_DistanceTooLong"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                //    return;
                //}
                try
                {
                    List <MapPoint> stopList = await GraphHooperHelper.GetRouteStopsAsync(mapView.LocationDisplay.Location.Position, destination);

                    routeStops.Clear();
                    AddNavigateRouteToGraphicsOverlay(LineOverlay, stopList, SimpleLineSymbolStyle.Dash, Colors.Blue, 5);
                }
                catch
                {
                    MessageboxMaster.Show(LanguageDictionaryHelper.GetString("ShowSpot_FailedToGetRoute"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                }
            }
            else
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("ShowSpot_LocationOff"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                return;
            }
        }
コード例 #3
0
        /// <summary>
        /// 查询按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SpotSearchBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (StartPointAddress.Text == null || StartPointAddress.Text == string.Empty)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Input_Empty"), LanguageDictionaryHelper.GetString("MessageBox_Warning_Title"));
                return;
            }

            //用户输入的内容
            string input_spot_name = StartPointAddress.Text;

            //逐一分词之后的内容
            char[] input_spot_name_spited = input_spot_name.ToCharArray();

            //模糊查询中的内容
            string sql_regexp = "%";
            {
                foreach (char siglechar in input_spot_name_spited)
                {
                    sql_regexp += siglechar + "%";
                }
            }

            //API返回内容
            string jsonString = string.Empty;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VIEW_INFO_BY_NAME"] + "?name=" + sql_regexp, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(ObservableCollection <ViewSpot>));
                    ViewSpotList = (ObservableCollection <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < ViewSpotList.Count; i++)
            {
                ViewSpotList[i].CheckData();
            }
        }
コード例 #4
0
        private async void HotelPackIconModern_MouseDown(object sender, MouseButtonEventArgs e)
        {
            int distance = 1000;

            MapPoint centerMercator = GeometryEngine.Project(new MapPoint(DetailShowItem.GetLng(), DetailShowItem.GetLat(), SpatialReferences.Wgs84),
                                                             SpatialReferences.WebMercator) as MapPoint;

            MapPoint leftTopMercator     = new MapPoint(centerMercator.X - distance, centerMercator.Y + distance, centerMercator.SpatialReference);
            MapPoint rightBottomMercator = new MapPoint(centerMercator.X + distance, centerMercator.Y - distance, centerMercator.SpatialReference);

            MapPoint leftTopWgs84     = GeometryEngine.Project(leftTopMercator, SpatialReferences.Wgs84) as MapPoint;
            MapPoint rightBottomWgs84 = GeometryEngine.Project(rightBottomMercator, SpatialReferences.Wgs84) as MapPoint;

            double minLng = leftTopWgs84.X;
            double maxLng = rightBottomWgs84.X;
            double minLat = rightBottomWgs84.Y;
            double maxLat = leftTopWgs84.Y;

            List <MapPoint> points = new List <MapPoint>();

            //API返回内容
            string jsonString = string.Empty;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_HOTEL"] + "?minLng=" + minLng + "&maxLng=" + maxLng + "&minLat=" + minLat + "&maxLat=" + maxLat, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                JToken content = jobject["HotelInfo"];

                foreach (JToken pointToken in content)
                {
                    points.Add(WGSGCJLatLonHelper.GCJ02ToWGS84(new MapPoint(Convert.ToDouble(pointToken["Lng"].ToString()), Convert.ToDouble(pointToken["Lat"].ToString()), SpatialReferences.Wgs84)));
                }

                Dictionary <string, object> param = new Dictionary <string, object>(2)
                {
                    { "type", ViewSpotArounds.Hotel },
                    { "points", points }
                };

                ArcGISMapCommands.AddViewSpotAround.Execute(param, Application.Current.MainWindow);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }
        }
コード例 #5
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            double cost    = (double)value;
            string precost = LanguageDictionaryHelper.GetString("ShowSpot_PreCost");

            if (precost == "$")
            {
                cost /= 6;
            }
            return(precost + cost.ToString("f1"));
        }
コード例 #6
0
        //获取数据
        private async void GetVisitorFlowDataAsync()
        {
            // int VisitorCount = -1;

            string jsonString = string.Empty;

            List <VisitorItem> visitorflowList = new List <VisitorItem>(15);

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync("http://39.108.171.209:2901/viewspot/viewbyvisitor?year=2015&month=1&limit=15", string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <VisitorItem>));
                    visitorflowList = (List <VisitorItem>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }
            VisitorflowList = new ObservableCollection <VisitorItem>(visitorflowList);
            GetXYData();
            //显示柱状图
            SeriesCollection = new SeriesCollection
            {
                new RowSeries
                {
                    StrokeThickness = 0.2,
                    // Stroke=new SolidColorBrush(Color.FromArgb(150,100,100,100))
                    Stroke = Brushes.Olive,

                    Width  = 0.1,
                    Title  = "人流量",
                    Values = new ChartValues <int>(VisitorNumber),
                }
            };

            Formatter = value => value.ToString("N");

            DataContext = this;
        }
コード例 #7
0
        private async void GetVisitorsInfoFromJsonAsync(SeriesCollection SeriesCollection, List <VisitorItem> visitorItemList, List <int> visitorMonthList, int year, long viewid)
        {
            string jsonString = string.Empty;

            for (int j = 0; j < 12; j++)
            {
                visitorMonthList.Add(new int());
            }
            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VISITORS_BY_YEAR"] + "?year=" + Convert.ToString(year) + "&viewid=" + Convert.ToString(viewid), string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["VisitorInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <VisitorItem>));
                    visitorItemList = (List <VisitorItem>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }
            for (int i = 0; i < visitorItemList.Count; i++)
            {
                for (int j = 0; j < 12; j++)
                {
                    if (visitorItemList[i].Month == j)
                    {
                        visitorMonthList[j] += visitorItemList[i].Visitors;
                    }
                }
            }
            SeriesCollection.Add(new LineSeries
            {
                Title  = Convert.ToString(year),
                Values = new ChartValues <int> {
                    visitorMonthList[0], visitorMonthList[1], visitorMonthList[2], visitorMonthList[3], visitorMonthList[4], visitorMonthList[5], visitorMonthList[6], visitorMonthList[7], visitorMonthList[8], visitorMonthList[9], visitorMonthList[10], visitorMonthList[11]
                },
            });
        }
コード例 #8
0
        private async void ShowDiscussCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            ViewSpot param = e.Parameter as ViewSpot;

            ViewComment.DetailShowItem = param;
            CurrentGrid = CurrentPanel.Comment;
            ViewMaster.DataItemListView.SelectedIndex = -1;

            if (ViewComment.DetailShowItem == null)
            {
                return;
            }

            string requestString = AppSettings["WEB_API_GET_COMMENT_INFO_BY_VIEW"] + "?viewid=" + ViewComment.DetailShowItem.id;

            //API返回内容
            string jsonString = string.Empty;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(requestString, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["CommentInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(ObservableCollection <CommentInfo>));
                    ViewComment.CommentList = (ObservableCollection <CommentInfo>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < ViewComment.CommentList.Count; i++)
            {
                ViewComment.CommentList[i].Spot = ViewComment.DetailShowItem;
                ViewComment.CommentList[i].CheckData();
            }
        }
コード例 #9
0
 private void mainWindow_Closing(object sender, CancelEventArgs e)
 {
     if (HaveEdited && _IsClickFork)
     {
         MessageboxMaster.DialogResults result = MessageboxMaster.Show(LanguageDictionaryHelper.GetString("UserInfoEdit_EditedTip"),
                                                                       LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"), MessageboxMaster.MyMessageBoxButtons.YesNoCancel,
                                                                       MessageboxMaster.MyMessageBoxButton.Yes);
         if (result == MessageboxMaster.DialogResults.Yes)
         {
             SaveButton_ClickAsync(null, null);
         }
         else if (result == MessageboxMaster.DialogResults.No)
         {
             CancelButton_Click(null, null);
         }
         else
         {
             this.DialogResult = false;
         }
     }
 }
コード例 #10
0
        private async void SettingBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            VisualizationParamsPicker picker = new VisualizationParamsPicker();

            if (picker.ShowDialog() == true)
            {
                CanDragSlider = false;
                StartDate     = picker.StartDate;
                EndDate       = picker.EndDate;
                if (picker.ModeCheckBox.IsChecked == true)
                {
                    ArcGISSceneCommands.ChangeBaseMap.Execute(AppSettings["ARCGIS_SATELLITE_BASEMAP"], Application.Current.MainWindow);
                }
                int limit = 100;
                if (EndDate <= StartDate || ((EndDate.Year == StartDate.Year) && (EndDate.Month == StartDate.Month)))
                {
                    MessageboxMaster.Show(LanguageDictionaryHelper.GetString("DataVisualization_DateChooseError"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                    return;
                }

                for (int month1 = StartDate.Month; month1 <= 12; month1++)
                {
                    string jsonString = string.Empty;
                    try
                    {
                        jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VISITORS_BY_YEAR_MONTH"] + "?year=" + Convert.ToString(StartDate.Year) + "&month=" + Convert.ToString(month1) + "&limit=" + Convert.ToString(limit), string.Empty, RestSharp.Method.GET)).Content;
                        if (jsonString == "")
                        {
                            throw new Exception("");
                        }

                        JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                        string content_string = jobject["VisitorInfo"].ToString();

                        using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                        {
                            DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <VisitorItem>));
                            VisitorsByMonthAndPlace.Add((List <VisitorItem>)deseralizer.ReadObject(ms));
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                        return;
                    }
                }

                if (StartDate.Year + 1 < EndDate.Year)
                {
                    for (int year = StartDate.Year; year < EndDate.Year; year++)
                    {
                        for (int i = 1; i <= 12; i++)
                        {
                            string jsonString = string.Empty;
                            try
                            {
                                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VISITORS_BY_YEAR_MONTH"] + "?year=" + Convert.ToString(year) + "&month=" + Convert.ToString(i) + "&limit=" + Convert.ToString(limit), string.Empty, RestSharp.Method.GET)).Content;
                                if (jsonString == "")
                                {
                                    throw new Exception("");
                                }

                                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                                string content_string = jobject["VisitorInfo"].ToString();

                                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                                {
                                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <VisitorItem>));
                                    VisitorsByMonthAndPlace.Add((List <VisitorItem>)deseralizer.ReadObject(ms));
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                                return;
                            }
                        }
                    }
                }

                if (StartDate.Year < EndDate.Year)
                {
                    for (int month2 = 1; month2 <= EndDate.Month; month2++)
                    {
                        string jsonString = string.Empty;
                        try
                        {
                            jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VISITORS_BY_YEAR_MONTH"] + "?year=" + Convert.ToString(EndDate.Year) + "&month=" + Convert.ToString(month2) + "&limit=" + Convert.ToString(limit), string.Empty, RestSharp.Method.GET)).Content;
                            if (jsonString == "")
                            {
                                throw new Exception("");
                            }

                            JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                            string content_string = jobject["VisitorInfo"].ToString();

                            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                            {
                                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <VisitorItem>));
                                VisitorsByMonthAndPlace.Add((List <VisitorItem>)deseralizer.ReadObject(ms));
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                            return;
                        }
                    }
                }

                MonthSlider.Minimum = 0;
                MonthSlider.Maximum = VisitorsByMonthAndPlace.Count - 1;
                MonthSlider.Value   = MonthSlider.Minimum;
                CanDragSlider       = true;

                if (VisitorsByMonthAndPlace.Count >= 1)
                {
                    ArcGISSceneCommands.AddVisitorsData.Execute(VisitorsByMonthAndPlace, Application.Current.MainWindow);
                    DateForShow.DisplayDate = StartDate;
                    DateForShow.Visibility  = Visibility.Visible;
                }
            }
        }
コード例 #11
0
        private async void SaveButton_ClickAsync(object sender, RoutedEventArgs e)
        {
            try
            {
                //数据库信息
                string mysql_host     = AppSettings["MYSQL_HOST"];
                string mysql_port     = AppSettings["MYSQL_PORT"];
                string mysql_user     = AppSettings["MYSQL_USER"];
                string mysql_password = AppSettings["MYSQK_PASSWORD"];
                string mysql_database = AppSettings["MYSQK_DATABASE"];

                //用户信息
                string DisplayName        = CurrentUser_Copy.DisplayName;
                string Name               = CurrentUser_Copy.Name;
                string Gender             = CurrentUser_Copy.Gender;
                string Age                = CurrentUser_Copy.Age.ToString();
                string Constellation      = CurrentUser_Copy.Constellation;
                string Hometown           = CurrentUser_Copy.Hometown;
                string Country            = CurrentUser_Copy.Country;
                string Province           = CurrentUser_Copy.Province;
                string City               = CurrentUser_Copy.City;
                string Admin              = CurrentUser_Copy.Admin;
                string Profession         = CurrentUser_Copy.Profession;
                string Company            = CurrentUser_Copy.Company;
                string SchoolOrUniversity = CurrentUser_Copy.SchoolOrUniversity;
                string Mail               = CurrentApp.CurrentUser.Mail;

                string sql_string = "UPDATE " + AppSettings["MYSQK_TABLE_USER"] + " SET Name='" + Name + "', DisplayName='" + DisplayName +
                                    "',Gender='" + Gender + "',Age='" + Age + "',Constellation='" + Constellation + "',Hometown='" + Hometown + "',Country='" +
                                    Country + "',Province='" + Province + "',City='" + City + "',Admin='" + Admin + "',Profession='" + Profession + "',Company='" +
                                    Company + "',SchoolOrUniversity='" + SchoolOrUniversity + "' WHERE Mail='" + Mail + "';";

                //执行SQL查询
                string qury_result = await MySqlHelper.ExcuteNonQueryAsync(mysql_host, mysql_port, mysql_user, mysql_password, mysql_database, sql_string);

                //判断返回
                if (qury_result != "true" && qury_result != "false")
                {
                    //连接服务器错误
                    MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Exception_Title"));
                    return;
                }
                else if (qury_result != "true")
                {
                    MessageboxMaster.Show(LanguageDictionaryHelper.GetString("UserInfoEdit_EditError"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                    return;
                }
                else
                {
                    CurrentApp.CurrentUser = _CurrentUser_Copy;
                    _IsClickFork           = false;
                    HaveEdited             = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Config_File_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }
        }
コード例 #12
0
        /// <summary>
        /// 从服务器上获取景点数据
        /// </summary>
        public void GetViewSpotsData()
        {
            //API返回内容
            string jsonString = string.Empty;

            //景点数量
            int viewCount = -1;

            try
            {
                jsonString = (WebServiceHelper.GetHttpResponse(AppSettings["WEB_API_GET_VIEW_COUNT_BY_NAME"] + "?name=%", string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                JToken jtoken = jobject["ViewCount"][0];

                viewCount = (int)jtoken["COUNT(*)"];
            }
            catch
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            if (viewCount <= 0)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("SpotSearch_Null"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                return;
            }

            List <ViewSpot> viewSpotList = new List <ViewSpot>(viewCount);

            try
            {
                jsonString = (WebServiceHelper.GetHttpResponse(AppSettings["WEB_API_GET_VIEW_INFO_BY_NAME"] + "?name=%", string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <ViewSpot>));
                    viewSpotList = (List <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                LogManager.LogManager.Warn(LanguageDictionaryHelper.GetString("Server_Connect_Error"), ex);
                return;
            }

            //检查数据
            for (int i = 0; i < viewSpotList.Count; i++)
            {
                viewSpotList[i].CheckData();
            }

            ViewSpotList = new ObservableCollection <ViewSpot>(viewSpotList);
        }
コード例 #13
0
        /// <summary>
        /// 查询按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SpotSearchBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            int selectedIndex = ModeCombox.SelectedIndex;

            string requestString = null;

            string AscOrDescString = Desc.IsChecked == true ? "desc" : "asc";

            if (selectedIndex == 0)
            {
                requestString = AppSettings["WEB_API_GET_VIEW_INFO_BY_RATING"] + "?limit=100&ascordesc=" + AscOrDescString;
            }
            else if (selectedIndex == 1)
            {
                requestString = AppSettings["WEB_API_GET_VIEW_INFO_BY_COST"] + "?limit=100&ascordesc=" + AscOrDescString;
            }
            else
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Input_Empty"), LanguageDictionaryHelper.GetString("MessageBox_Warning_Title"));
                return;
            }

            //API返回内容
            string jsonString = string.Empty;

            List <ViewSpot> viewSpotList = new List <ViewSpot>(100);

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(requestString, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <ViewSpot>));
                    viewSpotList = (List <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < viewSpotList.Count; i++)
            {
                viewSpotList[i].CheckData();
            }

            //设置显示数据
            ViewMaster.ViewSpotList = new ObservableCollection <ViewSpot>(viewSpotList);

            //定义当前显示的面板
            CurrentGrid = CurrentPanel.List;

            //设置面板可见
            PanelVisibility = Visibility.Visible;

            //清除点图层要素
            ArcGISMapCommands.ClearFeatures.Execute(2, this);

            //绘制要素
            foreach (ViewSpot viewSpot in viewSpotList)
            {
                MapPoint gcjpoint = new MapPoint(viewSpot.lng, viewSpot.lat);
                MapPoint wgspoint = WGSGCJLatLonHelper.GCJ02ToWGS84(gcjpoint);
                viewSpot.lng = wgspoint.X;
                viewSpot.lat = wgspoint.Y;
                Dictionary <string, object> commandParams = new Dictionary <string, object>(8)
                {
                    { "Lng", viewSpot.lng },
                    { "Lat", viewSpot.lat },
                    { "IconUri", IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue] },
                    { "Width", 16.0 },
                    { "Height", 24.0 },
                    { "OffsetX", 0.0 },
                    { "OffsetY", 9.5 },
                    { "Data", viewSpot }
                };

                ArcGISMapCommands.ShowFeatureOnMap.Execute(commandParams, this);
            }
        }
コード例 #14
0
        /// <summary>
        /// 查询按钮响应函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void SpotSearchBtn_ClickAsync(object sender, RoutedEventArgs e)
        {
            if (StartPointAddress.Text == null || StartPointAddress.Text == string.Empty)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Input_Empty"), LanguageDictionaryHelper.GetString("MessageBox_Warning_Title"));
                return;
            }

            //用户输入的内容
            string input_spot_name = StartPointAddress.Text;

            //逐一分词之后的内容
            char[] input_spot_name_spited = input_spot_name.ToCharArray();

            //模糊查询中的内容
            string sql_regexp = "%";
            {
                foreach (char siglechar in input_spot_name_spited)
                {
                    sql_regexp += siglechar + "%";
                }
            }

            //API返回内容
            string jsonString = string.Empty;

            //景点数量
            int viewCount = -1;

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VIEW_COUNT_BY_NAME"] + "?name=" + sql_regexp, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                JToken jtoken = jobject["ViewCount"][0];

                viewCount = (int)jtoken["COUNT(*)"];
            }
            catch
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            if (viewCount <= 0)
            {
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("SpotSearch_Null"), LanguageDictionaryHelper.GetString("MessageBox_Tip_Title"));
                return;
            }

            List <ViewSpot> viewSpotList = new List <ViewSpot>(viewCount);

            try
            {
                jsonString = (await WebServiceHelper.GetHttpResponseAsync(AppSettings["WEB_API_GET_VIEW_INFO_BY_NAME"] + "?name=" + sql_regexp, string.Empty, RestSharp.Method.GET)).Content;
                if (jsonString == "")
                {
                    throw new Exception("");
                }

                JObject jobject = (JObject)JsonConvert.DeserializeObject(jsonString);

                string content_string = jobject["ViewInfo"].ToString();

                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content_string)))
                {
                    DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(List <ViewSpot>));
                    viewSpotList = (List <ViewSpot>)deseralizer.ReadObject(ms);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageboxMaster.Show(LanguageDictionaryHelper.GetString("Server_Connect_Error"), LanguageDictionaryHelper.GetString("MessageBox_Error_Title"));
                return;
            }

            //检查数据
            for (int i = 0; i < viewSpotList.Count; i++)
            {
                viewSpotList[i].CheckData();
            }

            //设置显示数据
            ViewMaster.ViewSpotList = new ObservableCollection <ViewSpot>(viewSpotList);

            //定义当前显示的面板
            CurrentGrid = CurrentPanel.List;

            //设置面板可见
            PanelVisibility = Visibility.Visible;

            //清除点图层要素
            ArcGISMapCommands.ClearFeatures.Execute(2, this);

            //绘制要素
            foreach (ViewSpot viewSpot in viewSpotList)
            {
                MapPoint gcjpoint = new MapPoint(viewSpot.lng, viewSpot.lat);
                MapPoint wgspoint = WGSGCJLatLonHelper.GCJ02ToWGS84(gcjpoint);
                viewSpot.lng = wgspoint.X;
                viewSpot.lat = wgspoint.Y;
                Dictionary <string, object> commandParams = new Dictionary <string, object>(8)
                {
                    { "Lng", viewSpot.lng },
                    { "Lat", viewSpot.lat },
                    { "IconUri", IconDictionaryHelper.IconDictionary[IconDictionaryHelper.Icons.pin_blue] },
                    { "Width", 16.0 },
                    { "Height", 24.0 },
                    { "OffsetX", 0.0 },
                    { "OffsetY", 9.5 },
                    { "Data", viewSpot }
                };

                ArcGISMapCommands.ShowFeatureOnMap.Execute(commandParams, this);
            }
        }