From 60a74d2b29e29e00a0a8858c67b82b0e3dc7f49e Mon Sep 17 00:00:00 2001 From: PeterZhong Date: Fri, 10 Jan 2025 15:39:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=97=A5=E5=BF=97=E8=BF=9C?= =?UTF-8?q?=E7=A8=8B=E8=AE=B0=E5=BD=95=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GisDevelop_Exp/AttributeQuery.xaml.cs | 22 +++++----- GisDevelop_Exp/GisDevelop_Exp.csproj | 3 ++ GisDevelop_Exp/MainWindow.xaml | 6 ++- GisDevelop_Exp/MainWindow.xaml.cs | 40 ++++++++++++++++- GisDevelop_Exp/PcLog.cs | 63 +++++++++++++++++++++++++++ 5 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 GisDevelop_Exp/PcLog.cs diff --git a/GisDevelop_Exp/AttributeQuery.xaml.cs b/GisDevelop_Exp/AttributeQuery.xaml.cs index 533ce1d..3ebfccd 100644 --- a/GisDevelop_Exp/AttributeQuery.xaml.cs +++ b/GisDevelop_Exp/AttributeQuery.xaml.cs @@ -131,34 +131,34 @@ namespace GisDevelop_Exp private void OperatorButtonClick(object sender, RoutedEventArgs e) { - Button btn = (Button)sender;//获取button按钮对象 - switch (btn.Name)//根据button对象的名称来判断当前按下的按钮 + Button btn = (Button)sender; + switch (btn.Name) { - case "buttonEqual"://等于 + case "buttonEqual": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "= ''"); break; - case "buttonNotEqual"://不等 + case "buttonNotEqual": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<> ''"); break; - case "buttonLike"://模糊谓词like + case "buttonLike": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "like '%%'"); break; - case "buttonLessThan"://小于 + case "buttonLessThan": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "< ''"); break; - case "buttonLessEqual"://小于等于 + case "buttonLessEqual": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<= ''"); break; - case "buttonAnd"://与谓词and + case "buttonAnd": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "and"); break; - case "buttonGreaterThan"://大于 + case "buttonGreaterThan": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "> ''"); break; - case "buttonGreaterEqual"://大于等于 + case "buttonGreaterEqual": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", ">= ''"); break; - case "buttonOr"://或谓词or + case "buttonOr": textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "or"); break; } diff --git a/GisDevelop_Exp/GisDevelop_Exp.csproj b/GisDevelop_Exp/GisDevelop_Exp.csproj index ed99797..5bb3aa5 100644 --- a/GisDevelop_Exp/GisDevelop_Exp.csproj +++ b/GisDevelop_Exp/GisDevelop_Exp.csproj @@ -18,6 +18,9 @@ 200.5.0 + + 13.0.3 + diff --git a/GisDevelop_Exp/MainWindow.xaml b/GisDevelop_Exp/MainWindow.xaml index 214504b..28546e0 100644 --- a/GisDevelop_Exp/MainWindow.xaml +++ b/GisDevelop_Exp/MainWindow.xaml @@ -12,7 +12,8 @@ MouseLeftButtonDown="LayerListBox_OnPreviewMouseLeftButtonDown" xmlns:ui="http://schemas.modernwpf.com/2019" ui:WindowHelper.UseModernWindowStyle="True" - ui:ThemeManager.RequestedTheme="Light"> + ui:ThemeManager.RequestedTheme="Light" + Loaded="MainWindow_OnLoaded"> @@ -73,6 +74,9 @@ + + + diff --git a/GisDevelop_Exp/MainWindow.xaml.cs b/GisDevelop_Exp/MainWindow.xaml.cs index fff338c..fa5c16f 100644 --- a/GisDevelop_Exp/MainWindow.xaml.cs +++ b/GisDevelop_Exp/MainWindow.xaml.cs @@ -3,6 +3,7 @@ using Esri.ArcGISRuntime.Mapping; using System; using System.Collections.Generic; using System.Linq; +using System.Net.Http; using System.Text; using System.Threading.Tasks; using System.Windows; @@ -22,6 +23,7 @@ using Esri.ArcGISRuntime.Security; using Esri.ArcGISRuntime.Symbology; using Esri.ArcGISRuntime.UI; using Esri.ArcGISRuntime.UI.Controls; +using Newtonsoft.Json; using Color = System.Drawing.Color; using Geometry = Esri.ArcGISRuntime.Geometry.Geometry; using Polygon = Esri.ArcGISRuntime.Geometry.Polygon; @@ -138,6 +140,28 @@ namespace GisDevelop_Exp listOfClipGraphics = new List(); } + + public static async Task LogCheck() + { + string webhookUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/83e1c04c-b22b-4407-a861-02ab14ff0389"; + HttpClient client = new HttpClient(); + try + { + PcLog pcLog = new PcLog("Open windows"); + string jsonPayload = JsonConvert.SerializeObject(pcLog); + Console.WriteLine(pcLog.ToString()); + string requestBody = "{\"msg_type\": \"text\",\"content\": {\"text\": \""+pcLog.ToString()+"\"}}"; + var content = new StringContent(requestBody, Encoding.UTF8, "application/json"); + HttpResponseMessage response = await client.PostAsync(webhookUrl, content); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + } + catch (HttpRequestException e) + { + MessageBox.Show("网络错误,请检查网络连接!"); + } + } + private void Initialize() { MainMapView.Map = new Map(_basemapOptions.Values.First()); @@ -233,7 +257,7 @@ namespace GisDevelop_Exp Color fillColor = Color.FromArgb(0, 0, 0, 0); SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, fillColor, lineSymbol); var graphicOverlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay(); - var envGraphic = new Esri.ArcGISRuntime.UI.Graphic(eagleViewEnvelop, fillSymbol); + var envGraphic = new Esri.ArcGISRuntime.UI.Graphic(vExtent, fillSymbol); graphicOverlay.Graphics.Add(envGraphic); EagleMapView.GraphicsOverlays.Add(graphicOverlay); } @@ -1580,7 +1604,6 @@ namespace GisDevelop_Exp pSymbol = null; SetSimpleRender((FeatureLayer)symbologyLayer, null); } - e.Handled = true; } @@ -1858,5 +1881,18 @@ namespace GisDevelop_Exp { _featureLayer.ClearSelection(); } + + private async void Menu_Test1_OnClick(object sender, RoutedEventArgs e) + { + QueryParameters qp = new QueryParameters(); + qp.WhereClause = "FID = 1"; + FeatureQueryResult qr = await _featureLayer.FeatureTable.QueryFeaturesAsync(qp); + List list = qr.ToList(); + } + + private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e) + { + await LogCheck(); + } } } \ No newline at end of file diff --git a/GisDevelop_Exp/PcLog.cs b/GisDevelop_Exp/PcLog.cs new file mode 100644 index 0000000..81a1732 --- /dev/null +++ b/GisDevelop_Exp/PcLog.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Net.NetworkInformation; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace GisDevelop_Exp; + +public class PcLog +{ + private string time_now; + private List ip; + private string mac; + private string user; + private string action; + + public PcLog(string action) + { + this.action = action; + this.time_now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + string hostName = Dns.GetHostName(); + IPHostEntry ipEntry = Dns.GetHostEntry(hostName); + this.ip = new List(); + foreach (var ip in ipEntry.AddressList) { + this.ip.Add(ip.ToString()); + } + this.mac = GetMacByNetworkInterface(); + this.user = Environment.UserName; + } + + public async Task GetPublicIP(string[] args) { + string url = "http://ip-api.com/json/?fields=query"; + using (HttpClient client = new HttpClient()) { + HttpResponseMessage response = await client.GetAsync(url); + response.EnsureSuccessStatusCode(); + string responseBody = await response.Content.ReadAsStringAsync(); + } + } + + public string GetMacByNetworkInterface() { + string macAddress = string.Empty; + foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { + if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet && nic.OperationalStatus == OperationalStatus.Up) { + macAddress = nic.GetPhysicalAddress().ToString(); + macAddress = FormatMacAddress(macAddress); + break; + } + } + return macAddress; + } + + private string FormatMacAddress(string macAddress) { + return Regex.Replace(macAddress, @"(.{2})(.{2})(.{2})(.{2})(.{2})(.{2})", "$1:$2:$3:$4:$5:$6"); + } + + public string ToString() + { + string content = "Time: " + this.time_now + "%%" + "IP: " + string.Join(", ", this.ip) + "%%" + "MAC: " + this.mac + "%%" + "User: " + this.user + "%%" + "Action: " + this.action; + return content; + } +} \ No newline at end of file