加入日志远程记录能力
This commit is contained in:
parent
a5c55fedc3
commit
60a74d2b29
@ -131,34 +131,34 @@ namespace GisDevelop_Exp
|
|||||||
|
|
||||||
private void OperatorButtonClick(object sender, RoutedEventArgs e)
|
private void OperatorButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Button btn = (Button)sender;//获取button按钮对象
|
Button btn = (Button)sender;
|
||||||
switch (btn.Name)//根据button对象的名称来判断当前按下的按钮
|
switch (btn.Name)
|
||||||
{
|
{
|
||||||
case "buttonEqual"://等于
|
case "buttonEqual":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "= ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "= ''");
|
||||||
break;
|
break;
|
||||||
case "buttonNotEqual"://不等
|
case "buttonNotEqual":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<> ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<> ''");
|
||||||
break;
|
break;
|
||||||
case "buttonLike"://模糊谓词like
|
case "buttonLike":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "like '%%'");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "like '%%'");
|
||||||
break;
|
break;
|
||||||
case "buttonLessThan"://小于
|
case "buttonLessThan":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "< ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "< ''");
|
||||||
break;
|
break;
|
||||||
case "buttonLessEqual"://小于等于
|
case "buttonLessEqual":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<= ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "<= ''");
|
||||||
break;
|
break;
|
||||||
case "buttonAnd"://与谓词and
|
case "buttonAnd":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "and");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "and");
|
||||||
break;
|
break;
|
||||||
case "buttonGreaterThan"://大于
|
case "buttonGreaterThan":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "> ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "> ''");
|
||||||
break;
|
break;
|
||||||
case "buttonGreaterEqual"://大于等于
|
case "buttonGreaterEqual":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", ">= ''");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", ">= ''");
|
||||||
break;
|
break;
|
||||||
case "buttonOr"://或谓词or
|
case "buttonOr":
|
||||||
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "or");
|
textBoxWhere.Text = string.Concat(textBoxWhere.Text, " ", "or");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
<Version>200.5.0</Version>
|
<Version>200.5.0</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
<PackageReference Include="ModernWpfUI" Version="0.9.6" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json">
|
||||||
|
<Version>13.0.3</Version>
|
||||||
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -12,7 +12,8 @@
|
|||||||
MouseLeftButtonDown="LayerListBox_OnPreviewMouseLeftButtonDown"
|
MouseLeftButtonDown="LayerListBox_OnPreviewMouseLeftButtonDown"
|
||||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||||
ui:WindowHelper.UseModernWindowStyle="True"
|
ui:WindowHelper.UseModernWindowStyle="True"
|
||||||
ui:ThemeManager.RequestedTheme="Light">
|
ui:ThemeManager.RequestedTheme="Light"
|
||||||
|
Loaded="MainWindow_OnLoaded">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<local:MapViewModel x:Key="MapViewModel" />
|
<local:MapViewModel x:Key="MapViewModel" />
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
@ -73,6 +74,9 @@
|
|||||||
<MenuItem x:Name="Menu_Add" Header="增加面" Click="Menu_Add_OnClick"></MenuItem>
|
<MenuItem x:Name="Menu_Add" Header="增加面" Click="Menu_Add_OnClick"></MenuItem>
|
||||||
<MenuItem x:Name="Menu_Modify" Header="修改" Click="Menu_Modify_OnClick"></MenuItem>
|
<MenuItem x:Name="Menu_Modify" Header="修改" Click="Menu_Modify_OnClick"></MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
<MenuItem Header="测试">
|
||||||
|
<MenuItem x:Name="Menu_Test1" Header="Test1" Click="Menu_Test1_OnClick"></MenuItem>
|
||||||
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Grid Margin="0,0,0,0">
|
<Grid Margin="0,0,0,0">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using Esri.ArcGISRuntime.Mapping;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -22,6 +23,7 @@ using Esri.ArcGISRuntime.Security;
|
|||||||
using Esri.ArcGISRuntime.Symbology;
|
using Esri.ArcGISRuntime.Symbology;
|
||||||
using Esri.ArcGISRuntime.UI;
|
using Esri.ArcGISRuntime.UI;
|
||||||
using Esri.ArcGISRuntime.UI.Controls;
|
using Esri.ArcGISRuntime.UI.Controls;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Color = System.Drawing.Color;
|
using Color = System.Drawing.Color;
|
||||||
using Geometry = Esri.ArcGISRuntime.Geometry.Geometry;
|
using Geometry = Esri.ArcGISRuntime.Geometry.Geometry;
|
||||||
using Polygon = Esri.ArcGISRuntime.Geometry.Polygon;
|
using Polygon = Esri.ArcGISRuntime.Geometry.Polygon;
|
||||||
@ -138,6 +140,28 @@ namespace GisDevelop_Exp
|
|||||||
listOfClipGraphics = new List<Graphic>();
|
listOfClipGraphics = new List<Graphic>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
MainMapView.Map = new Map(_basemapOptions.Values.First());
|
MainMapView.Map = new Map(_basemapOptions.Values.First());
|
||||||
@ -233,7 +257,7 @@ namespace GisDevelop_Exp
|
|||||||
Color fillColor = Color.FromArgb(0, 0, 0, 0);
|
Color fillColor = Color.FromArgb(0, 0, 0, 0);
|
||||||
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, fillColor, lineSymbol);
|
SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbolStyle.Solid, fillColor, lineSymbol);
|
||||||
var graphicOverlay = new Esri.ArcGISRuntime.UI.GraphicsOverlay();
|
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);
|
graphicOverlay.Graphics.Add(envGraphic);
|
||||||
EagleMapView.GraphicsOverlays.Add(graphicOverlay);
|
EagleMapView.GraphicsOverlays.Add(graphicOverlay);
|
||||||
}
|
}
|
||||||
@ -1580,7 +1604,6 @@ namespace GisDevelop_Exp
|
|||||||
pSymbol = null;
|
pSymbol = null;
|
||||||
SetSimpleRender((FeatureLayer)symbologyLayer, null);
|
SetSimpleRender((FeatureLayer)symbologyLayer, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1858,5 +1881,18 @@ namespace GisDevelop_Exp
|
|||||||
{
|
{
|
||||||
_featureLayer.ClearSelection();
|
_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<Feature> list = qr.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
await LogCheck();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
63
GisDevelop_Exp/PcLog.cs
Normal file
63
GisDevelop_Exp/PcLog.cs
Normal file
@ -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<string> 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<string>();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user