commit 0c0f9f371adfd8bec2b68ee0684b7e4f23a0c931 Author: XuMin <3529987066@qq.com> Date: Thu Aug 22 13:55:37 2024 +0800 基本框架搭建完成; 实时数据展示页面和日志记录页面部分完成; diff --git a/FujianEarthquake/.vs/FujianEarthquake/DesignTimeBuild/.dtbcache.v2 b/FujianEarthquake/.vs/FujianEarthquake/DesignTimeBuild/.dtbcache.v2 new file mode 100644 index 0000000..7e2e413 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/DesignTimeBuild/.dtbcache.v2 differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/10c565fe-680c-40cf-b79e-060cd029704d.vsidx b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/10c565fe-680c-40cf-b79e-060cd029704d.vsidx new file mode 100644 index 0000000..9bf6725 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/10c565fe-680c-40cf-b79e-060cd029704d.vsidx differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3bc74704-1514-448d-a222-700cb78b0dd6.vsidx b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3bc74704-1514-448d-a222-700cb78b0dd6.vsidx new file mode 100644 index 0000000..9a5d9e2 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3bc74704-1514-448d-a222-700cb78b0dd6.vsidx differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3ff06650-aa4d-4eff-8667-4d77c3b2964e.vsidx b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3ff06650-aa4d-4eff-8667-4d77c3b2964e.vsidx new file mode 100644 index 0000000..9554426 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/3ff06650-aa4d-4eff-8667-4d77c3b2964e.vsidx differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/420723f8-429f-49a2-8d6c-eaa584ff10e5.vsidx b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/420723f8-429f-49a2-8d6c-eaa584ff10e5.vsidx new file mode 100644 index 0000000..dd1e536 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/420723f8-429f-49a2-8d6c-eaa584ff10e5.vsidx differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/868e1cfb-1f42-45a5-a348-4ac1a55cc79d.vsidx b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/868e1cfb-1f42-45a5-a348-4ac1a55cc79d.vsidx new file mode 100644 index 0000000..8691567 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/FileContentIndex/868e1cfb-1f42-45a5-a348-4ac1a55cc79d.vsidx differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/v17/.futdcache.v2 b/FujianEarthquake/.vs/FujianEarthquake/v17/.futdcache.v2 new file mode 100644 index 0000000..f1099de Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/v17/.futdcache.v2 differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/v17/.suo b/FujianEarthquake/.vs/FujianEarthquake/v17/.suo new file mode 100644 index 0000000..caea239 Binary files /dev/null and b/FujianEarthquake/.vs/FujianEarthquake/v17/.suo differ diff --git a/FujianEarthquake/.vs/FujianEarthquake/v17/DocumentLayout.json b/FujianEarthquake/.vs/FujianEarthquake/v17/DocumentLayout.json new file mode 100644 index 0000000..7f1fe2b --- /dev/null +++ b/FujianEarthquake/.vs/FujianEarthquake/v17/DocumentLayout.json @@ -0,0 +1,225 @@ +{ + "Version": 1, + "WorkspaceRootPath": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\", + "Documents": [ + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\viewmodels\\logrecordviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\viewmodels\\logrecordviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\views\\logrecordview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\views\\logrecordview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\app.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\app.config||{FA3CD31E-987B-443A-9B81-186104E8DAC1}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\common\\csvdownload.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\common\\csvdownload.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\models\\shorebasestationstatedatamodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\models\\shorebasestationstatedatamodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\viewmodels\\mainviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\viewmodels\\mainviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\viewmodels\\alarmrecordviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\viewmodels\\alarmrecordviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\app.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\views\\realtimedataview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\views\\realtimedataview.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\models\\junctionboxenvironmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\models\\junctionboxenvironmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + }, + { + "AbsoluteMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|f:\\code\\fjeq\\20240801_fjeq_upperpc\\fujianearthquake\\fujianearthquake\\viewmodels\\realtimedataviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", + "RelativeMoniker": "D:0:0:{BC950963-02DC-4704-A532-8D46CE8933E5}|FujianEarthquake\\FujianEarthquake.csproj|solutionrelative:fujianearthquake\\viewmodels\\realtimedataviewmodel.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" + } + ], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [ + { + "DockedWidth": 163, + "SelectedChildIndex": 7, + "Children": [ + { + "$type": "Document", + "DocumentIndex": 2, + "Title": "App.config", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\App.config", + "RelativeDocumentMoniker": "FujianEarthquake\\App.config", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\App.config", + "RelativeToolTip": "FujianEarthquake\\App.config", + "ViewState": "AQIAAAAAAAAAAAAAAAAAABAAAAAQAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000601|", + "WhenOpened": "2024-07-30T08:37:35.106Z", + "IsPinned": true, + "EditorCaption": "" + }, + { + "$type": "Bookmark", + "Name": "ST:0:0:{1c4feeaa-4718-4aa9-859d-94ce25d182ba}" + }, + { + "$type": "Document", + "DocumentIndex": 3, + "Title": "CSVDownload.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Common\\CSVDownload.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\Common\\CSVDownload.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Common\\CSVDownload.cs", + "RelativeToolTip": "FujianEarthquake\\Common\\CSVDownload.cs", + "ViewState": "AQIAAB8AAAAAAAAAAAAQwHsAAAASAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-08-22T02:52:28.362Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 4, + "Title": "MainWindow.xaml", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\MainWindow.xaml", + "RelativeDocumentMoniker": "FujianEarthquake\\MainWindow.xaml", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\MainWindow.xaml", + "RelativeToolTip": "FujianEarthquake\\MainWindow.xaml", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", + "WhenOpened": "2024-08-22T00:51:43.018Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 8, + "Title": "App.xaml", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\App.xaml", + "RelativeDocumentMoniker": "FujianEarthquake\\App.xaml", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\App.xaml", + "RelativeToolTip": "FujianEarthquake\\App.xaml", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", + "WhenOpened": "2024-08-22T00:51:15.265Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 1, + "Title": "LogRecordView.xaml", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Views\\LogRecordView.xaml", + "RelativeDocumentMoniker": "FujianEarthquake\\Views\\LogRecordView.xaml", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Views\\LogRecordView.xaml", + "RelativeToolTip": "FujianEarthquake\\Views\\LogRecordView.xaml", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", + "WhenOpened": "2024-08-22T00:45:32.052Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 7, + "Title": "AlarmRecordViewModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\AlarmRecordViewModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\ViewModels\\AlarmRecordViewModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\AlarmRecordViewModel.cs", + "RelativeToolTip": "FujianEarthquake\\ViewModels\\AlarmRecordViewModel.cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAAA8AAAAFAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-30T08:15:25.234Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 0, + "Title": "LogRecordViewModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\LogRecordViewModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\ViewModels\\LogRecordViewModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\LogRecordViewModel.cs", + "RelativeToolTip": "FujianEarthquake\\ViewModels\\LogRecordViewModel.cs", + "ViewState": "AQIAANAAAAAAAAAAAAAmwPEAAAAJAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-30T08:14:39.106Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 5, + "Title": "ShoreBaseStationStateDataModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Models\\ShoreBaseStationStateDataModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\Models\\ShoreBaseStationStateDataModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Models\\ShoreBaseStationStateDataModel.cs", + "RelativeToolTip": "FujianEarthquake\\Models\\ShoreBaseStationStateDataModel.cs", + "ViewState": "AQIAABkAAAAAAAAAAAAQwBcAAAAeAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-30T01:38:07.375Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 10, + "Title": "JunctionBoxEnvironModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Models\\JunctionBoxEnvironModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\Models\\JunctionBoxEnvironModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Models\\JunctionBoxEnvironModel.cs", + "RelativeToolTip": "FujianEarthquake\\Models\\JunctionBoxEnvironModel.cs", + "ViewState": "AQIAAAAAAAAAAAAAAAAAADAAAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-30T00:57:05.061Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 9, + "Title": "RealTimeDataView.xaml", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Views\\RealTimeDataView.xaml", + "RelativeDocumentMoniker": "FujianEarthquake\\Views\\RealTimeDataView.xaml", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\Views\\RealTimeDataView.xaml", + "RelativeToolTip": "FujianEarthquake\\Views\\RealTimeDataView.xaml", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", + "WhenOpened": "2024-07-30T00:30:47.27Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 11, + "Title": "RealTimeDataViewModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\RealTimeDataViewModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\ViewModels\\RealTimeDataViewModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\RealTimeDataViewModel.cs", + "RelativeToolTip": "FujianEarthquake\\ViewModels\\RealTimeDataViewModel.cs", + "ViewState": "AQIAADUBAAAAAAAAAAAowHoBAAAAAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-30T00:23:05.266Z", + "EditorCaption": "" + }, + { + "$type": "Document", + "DocumentIndex": 6, + "Title": "MainViewModel.cs", + "DocumentMoniker": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\MainViewModel.cs", + "RelativeDocumentMoniker": "FujianEarthquake\\ViewModels\\MainViewModel.cs", + "ToolTip": "F:\\Code\\FJEQ\\20240801_FJEQ_upperpc\\FujianEarthquake\\FujianEarthquake\\ViewModels\\MainViewModel.cs", + "RelativeToolTip": "FujianEarthquake\\ViewModels\\MainViewModel.cs", + "ViewState": "AQIAAF4AAAAAAAAAAAAwwGsAAABHAAAA", + "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", + "WhenOpened": "2024-07-29T02:48:21.6Z", + "EditorCaption": "" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.metadata.v8.bin b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.metadata.v8.bin new file mode 100644 index 0000000..9543926 Binary files /dev/null and b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.metadata.v8.bin differ diff --git a/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.projects.v8.bin b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.projects.v8.bin new file mode 100644 index 0000000..4ed72fe Binary files /dev/null and b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.projects.v8.bin differ diff --git a/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.strings.v8.bin b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.strings.v8.bin new file mode 100644 index 0000000..ef5526f Binary files /dev/null and b/FujianEarthquake/.vs/ProjectEvaluation/fujianearthquake.strings.v8.bin differ diff --git a/FujianEarthquake/FujianEarthquake.sln b/FujianEarthquake/FujianEarthquake.sln new file mode 100644 index 0000000..1b8db19 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.10.35027.167 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FujianEarthquake", "FujianEarthquake\FujianEarthquake.csproj", "{BC950963-02DC-4704-A532-8D46CE8933E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BC950963-02DC-4704-A532-8D46CE8933E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BC950963-02DC-4704-A532-8D46CE8933E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BC950963-02DC-4704-A532-8D46CE8933E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BC950963-02DC-4704-A532-8D46CE8933E5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F862342A-C548-4103-9912-3CE4031CBCB4} + EndGlobalSection +EndGlobal diff --git a/FujianEarthquake/FujianEarthquake/App.config b/FujianEarthquake/FujianEarthquake/App.config new file mode 100644 index 0000000..cf3fb95 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/App.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FujianEarthquake/FujianEarthquake/App.xaml b/FujianEarthquake/FujianEarthquake/App.xaml new file mode 100644 index 0000000..a13aa33 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/App.xaml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + pack://application:,,,/FujianEarthquake;component/Assets/Fonts/#方正楷体简体 + + pack://application:,,,/FujianEarthquake;component/Assets/Fonts/#iconfont + + + + + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/App.xaml.cs b/FujianEarthquake/FujianEarthquake/App.xaml.cs new file mode 100644 index 0000000..f0af7f1 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/App.xaml.cs @@ -0,0 +1,14 @@ +using System.Configuration; +using System.Data; +using System.Windows; + +namespace FujianEarthquake +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } + +} diff --git a/FujianEarthquake/FujianEarthquake/AssemblyInfo.cs b/FujianEarthquake/FujianEarthquake/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/FujianEarthquake/FujianEarthquake/Assets/Fonts/digital_display.ttf b/FujianEarthquake/FujianEarthquake/Assets/Fonts/digital_display.ttf new file mode 100644 index 0000000..a006032 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Fonts/digital_display.ttf differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Fonts/iconfont.ttf b/FujianEarthquake/FujianEarthquake/Assets/Fonts/iconfont.ttf new file mode 100644 index 0000000..e317628 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Fonts/iconfont.ttf differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Fonts/方正楷体简体.ttf b/FujianEarthquake/FujianEarthquake/Assets/Fonts/方正楷体简体.ttf new file mode 100644 index 0000000..1ef7053 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Fonts/方正楷体简体.ttf differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmCycle.png b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmCycle.png new file mode 100644 index 0000000..9b8b38b Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmCycle.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmTri.png b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmTri.png new file mode 100644 index 0000000..442c705 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmTri.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmWhite.png b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmWhite.png new file mode 100644 index 0000000..7157bc1 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/AlarmWhite.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/AskData.png b/FujianEarthquake/FujianEarthquake/Assets/Images/AskData.png new file mode 100644 index 0000000..b5f2c9e Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/AskData.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Check.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Check.png new file mode 100644 index 0000000..978233a Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Check.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Close.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Close.png new file mode 100644 index 0000000..a0c41fd Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Close.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Close1.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Close1.png new file mode 100644 index 0000000..98e51fd Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Close1.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/ConnectState.png b/FujianEarthquake/FujianEarthquake/Assets/Images/ConnectState.png new file mode 100644 index 0000000..0727dfe Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/ConnectState.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGray.png b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGray.png new file mode 100644 index 0000000..29122f2 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGray.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGreen.png b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGreen.png new file mode 100644 index 0000000..611febb Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleGreen.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/CycleOrange.png b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleOrange.png new file mode 100644 index 0000000..954107a Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleOrange.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/CycleRed.png b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleRed.png new file mode 100644 index 0000000..93b9e31 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleRed.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/CycleYellow.png b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleYellow.png new file mode 100644 index 0000000..06aabda Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/CycleYellow.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Delete.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Delete.png new file mode 100644 index 0000000..38dc3f7 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Delete.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOff.png b/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOff.png new file mode 100644 index 0000000..e4d7399 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOff.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOn.png b/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOn.png new file mode 100644 index 0000000..165f052 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/DeviceOn.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/DisLink.png b/FujianEarthquake/FujianEarthquake/Assets/Images/DisLink.png new file mode 100644 index 0000000..f459004 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/DisLink.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Download.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Download.png new file mode 100644 index 0000000..cd6e386 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Download.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Ensure.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Ensure.png new file mode 100644 index 0000000..da43101 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Ensure.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Left.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Left.png new file mode 100644 index 0000000..ce5d919 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Left.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Left2.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Left2.png new file mode 100644 index 0000000..e26350b Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Left2.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Link.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Link.png new file mode 100644 index 0000000..2667ece Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Link.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Max.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Max.png new file mode 100644 index 0000000..504e054 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Max.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Min.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Min.png new file mode 100644 index 0000000..e2a20f1 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Min.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/NoDevice.png b/FujianEarthquake/FujianEarthquake/Assets/Images/NoDevice.png new file mode 100644 index 0000000..c268116 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/NoDevice.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Open.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Open.png new file mode 100644 index 0000000..b8344ea Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Open.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Refresh.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Refresh.png new file mode 100644 index 0000000..34d4af3 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Refresh.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Reset.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Reset.png new file mode 100644 index 0000000..4f1fdd4 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Reset.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/ReturnHigh.png b/FujianEarthquake/FujianEarthquake/Assets/Images/ReturnHigh.png new file mode 100644 index 0000000..a9acb04 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/ReturnHigh.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Right.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Right.png new file mode 100644 index 0000000..931d9c4 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Right.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Right2.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Right2.png new file mode 100644 index 0000000..8c0e1d6 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Right2.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Robot.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Robot.png new file mode 100644 index 0000000..d98699b Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Robot.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Set.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Set.png new file mode 100644 index 0000000..716d62b Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Set.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Start.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Start.png new file mode 100644 index 0000000..d25ee7c Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Start.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Stop.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Stop.png new file mode 100644 index 0000000..f2a5c7e Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Stop.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Images/Trademark.png b/FujianEarthquake/FujianEarthquake/Assets/Images/Trademark.png new file mode 100644 index 0000000..ed534b2 Binary files /dev/null and b/FujianEarthquake/FujianEarthquake/Assets/Images/Trademark.png differ diff --git a/FujianEarthquake/FujianEarthquake/Assets/Styles/DefaultStyle.xaml b/FujianEarthquake/FujianEarthquake/Assets/Styles/DefaultStyle.xaml new file mode 100644 index 0000000..c041d8e --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Assets/Styles/DefaultStyle.xaml @@ -0,0 +1,29 @@ + + + \ No newline at end of file diff --git a/FujianEarthquake/FujianEarthquake/Common/CSVDownload.cs b/FujianEarthquake/FujianEarthquake/Common/CSVDownload.cs new file mode 100644 index 0000000..b7ee8a6 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Common/CSVDownload.cs @@ -0,0 +1,127 @@ +using FujianEarthquake.Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace FujianEarthquake.Common +{ + public class CSVDownload + { + /// + /// Create target file + /// + /// folder + /// folder name + /// file extension + /// file path + public static string CreateFile(string folder, string fileName, string fileExtension) + { + FileStream fs = null; + string filePath = folder + fileName + "." + fileExtension; + try + { + if (!Directory.Exists(folder)) + { + Directory.CreateDirectory(folder); + } + fs = File.Create(filePath); + } + catch (Exception ex) + { } + finally + { + if (fs != null) + { + fs.Dispose(); + } + } + return filePath; + } + + + #region LogRecord + /// + /// 获取类的属性集合(以便生成CSV文件的所有Column标题) + /// + /// + public static PropertyInfo[] GetLogRecordPropertyInfoArray() + { + PropertyInfo[] props = null; + try + { + Type type = typeof(LogRecordModel); + object obj = Activator.CreateInstance(type); + props = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); + } + catch (Exception ex) + { } + return props; + } + + + /// + /// Save the List data to CSV file + /// + /// data source + /// file path + /// success flag + public static bool SaveLogRecordDataToCSVFile(ObservableCollection LogRecordList, string filePath) + { + bool successFlag = true; + + StringBuilder strColumn = new StringBuilder(); + StringBuilder strValue = new StringBuilder(); + StreamWriter sw = null; + PropertyInfo[] props = GetLogRecordPropertyInfoArray(); + + try + { + sw = new StreamWriter(filePath); + for (int i = 0; i < props.Length; i++) + { + strColumn.Append(props[i].Name); + strColumn.Append(","); + } + strColumn.Remove(strColumn.Length - 1, 1); + sw.WriteLine(strColumn); //write the column name + + for (int i = 0; i < LogRecordList.Count; i++) + { + strValue.Remove(0, strValue.Length); //clear the temp row value + strValue.Append(LogRecordList[i].Index); + strValue.Append(","); + strValue.Append(LogRecordList[i].RecordTime); + strValue.Append(","); + strValue.Append(LogRecordList[i].Device_Name); + strValue.Append(","); + strValue.Append(LogRecordList[i].Operation_Type); + strValue.Append(","); + strValue.Append(LogRecordList[i].Record); + + sw.WriteLine(strValue); //write the row value + } + } + catch (Exception ex) + { + successFlag = false; + } + finally + { + if (sw != null) + { + sw.Dispose(); + } + } + + return successFlag; + } + #endregion + + } +} diff --git a/FujianEarthquake/FujianEarthquake/Common/CommandBase.cs b/FujianEarthquake/FujianEarthquake/Common/CommandBase.cs new file mode 100644 index 0000000..fb3e82c --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Common/CommandBase.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace FujianEarthquake.Common +{ + public class CommandBase : ICommand + { + public event EventHandler CanExecuteChanged; + + public bool CanExecute(object parameter) + { + return DoCanExcute?.Invoke(parameter) == true; + } + + public void Execute(object parameter) + { + DoExcute?.Invoke(parameter); + } + + public Action DoExcute { set; get; } + + public Func DoCanExcute { set; get; } + + public void RaiseCanExecuteChanged() + { + CanExecuteChanged?.Invoke(this, new EventArgs()); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Common/NotifyBase.cs b/FujianEarthquake/FujianEarthquake/Common/NotifyBase.cs new file mode 100644 index 0000000..125b800 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Common/NotifyBase.cs @@ -0,0 +1,44 @@ +using GalaSoft.MvvmLight; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.Common +{ + public class NotifyBase : ObservableObject, INotifyPropertyChanged + { + public event PropertyChangedEventHandler? PropertyChanged; + + //[CallerMemberName]string propName = "" 设置一个默认值 提高容错性 + public void DoNotify([CallerMemberName] string propName = "") + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); + } + + + /// + /// Sets property if it does not equal existing value. Notifies listeners if change occurs. + /// + /// Type of property. + /// The property's backing field. + /// The new value. + /// Name of the property used to notify listeners. This + /// value is optional and can be provided automatically when invoked from compilers + /// that support . + protected virtual bool SetProperty(ref T member, T value, [CallerMemberName] string? propertyName = null) + { + if (EqualityComparer.Default.Equals(member, value)) + { + return false; + } + + member = value; + DoNotify(propertyName); + return true; + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Common/Tools.cs b/FujianEarthquake/FujianEarthquake/Common/Tools.cs new file mode 100644 index 0000000..382d693 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Common/Tools.cs @@ -0,0 +1,658 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net.NetworkInformation; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace FujianEarthquake.Common +{ + public static class Tools + { + /// + /// IP地址是否ping通 + /// + /// IP地址例如“10.8.2.1” + /// + public static bool PingIp(string strIP) + { + bool bRet = false; + try + { + Ping pingSend = new Ping(); + PingReply reply = pingSend.Send(strIP, 1000); + if (reply.Status == IPStatus.Success) + bRet = true; + } + catch (Exception) + { + bRet = false; + } + return bRet; + } + + + /// + /// 添加日志 + /// + /// + public static void AddLog(string logstring) + { + AddLgoToTXT("解析数据.txt", System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + @"数据记录\" + System.DateTime.Now.ToString("yyyy_MM_dd") + @"\", logstring); + } + + + /// + /// 文件自动保存 + /// + /// 文件名称 + /// 保存路径 + /// 文件内容 + public static void AddLgoToTXT(string _file_name, string path, string logstring) + { + //检查是否存在该路径 + if (!System.IO.Directory.Exists(path)) + { + Directory.CreateDirectory(path); + } + + path = path + _file_name; + //检查该路径下是否存在该文件 + if (!System.IO.File.Exists(path)) + { + FileStream stream = null; + try + { + stream = System.IO.File.Create(path); + stream.Close(); + stream.Dispose(); + } + catch (Exception ex) + { + + } + finally + { + if (stream != null) + { + stream.Close(); + stream.Dispose(); + } + } + + } + if (!Txt_Used.ContainsKey(path)) + { + Txt_Used.Add(path, true); + } + else + { + if (Txt_Used[path]) + { + return; + } + else + { + Txt_Used[path] = true; + } + } + FileStream fs = null; + try + { + //[1]创建文件流 文件路径 和枚举类型的文件操作类型 + fs = new FileStream(path, FileMode.Append); + //[2]创建写入器 + StreamWriter sw = new StreamWriter(fs); + //[3]以流的方式写入数据 + sw.Write(logstring); + //[4]关闭写入器 + sw.Close(); + //[5]关闭文件流 + fs.Close(); + Txt_Used[path] = false; + } + catch (Exception ex) + { + + } + finally + { + if (fs != null) + { + fs.Close(); + fs.Dispose(); + } + } + } + + static Dictionary Txt_Used = new Dictionary(); + + + /// + /// 读取本地TXT文件 + /// + /// + /// + /// + public static string ReadFromTXT(string _file_name, string path) + { + //检查是否存在该路径 + if (!System.IO.Directory.Exists(path)) + return "所选时间段没有系统日志"; + path = path + _file_name; + //检查该路径下是否存在该文件 + if (!System.IO.File.Exists(path)) + return "所选时间段没有系统日志"; + //如果文件占用就 + if (FileIsInUse(new FileInfo(path))) + return ""; + //[1]创建文件流 + FileStream fs = new FileStream(path, FileMode.Open); + //【2】创建读取器 + //Encoding.Default 读取未知文件是使用default格式 + //StreamReader sr = new StreamReader(fs,Encoding.Default); + StreamReader sr = new StreamReader(fs); + //【3】以流的方式读取数据 + string txt = sr.ReadToEnd(); + //[4]关闭读取器 + sr.Close(); + //【5】关闭文件流 + fs.Close(); + + return txt; + } + + + /// + /// 判断文件是否被占用 + /// + /// + /// + static bool FileIsInUse(FileInfo file) + { + FileStream stream = null; + try + { + stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None); + } + catch (IOException) + { + //如果文件被占用,即 + //1.文件正在被另一个线程处理 + //2.或者正在被另一个线程处理 + //3.或者文件不存在 + return true; + } + finally + { + if (stream != null) + stream.Close(); + } + return false; + } + + + #region CRC校验 + private static readonly byte[] aucCRCHi = { + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40 + }; + private static readonly byte[] aucCRCLo = { + 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, + 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, + 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, + 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, + 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, + 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, + 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, + 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, + 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, + 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, + 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, + 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, + 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, + 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, + 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, + 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, + 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, + 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, + 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, + 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, + 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, + 0x41, 0x81, 0x80, 0x40 + }; + + public static byte[] Crc16(byte[] pucFrame, int usLen) + { + int i = 0; + byte crcHi = 0xFF; + byte crcLo = 0xFF; + UInt16 iIndex = 0x0000; + + while (usLen-- > 0) + { + iIndex = (UInt16)(crcLo ^ pucFrame[i++]); + crcLo = (byte)(crcHi ^ aucCRCHi[iIndex]); + crcHi = aucCRCLo[iIndex]; + } + + return new byte[] { crcLo, crcHi }; + } + + + /// + /// CRC校验,参数data为byte数组 + /// + /// 校验数据,字节数组 + /// 字节1是高8位,字节0是低8位 + public static byte[] CRCCalc(byte[] data) + { + //crc计算赋初始值 + int crc = 0xffff; + for (int i = 0; i < data.Length; i++) + { + crc = crc ^ data[i]; + for (int j = 0; j < 8; j++) + { + int temp; + temp = crc & 1; + crc = crc >> 1; + crc = crc & 0x7fff; + if (temp == 1) + { + crc = crc ^ 0xa001; + } + crc = crc & 0xffff; + } + } + //CRC寄存器的高低位进行互换 + byte[] crc16 = new byte[2]; + crc16[0] = (byte)((crc >> 8) & 0xff); + crc16[1] = (byte)(crc & 0xff); + return crc16; + } + + + /// + /// CRC校验,参数data为byte数组 + /// + /// 校验数据,字节数组 + /// 字节0是高8位,字节1是低8位 + public static byte[] CRCCalcRev(byte[] data) + { + //crc计算赋初始值 + int crc = 0xffff; + for (int i = 0; i < data.Length; i++) + { + crc = crc ^ data[i]; + for (int j = 0; j < 8; j++) + { + int temp; + temp = crc & 1; + crc = crc >> 1; + crc = crc & 0x7fff; + if (temp == 1) + { + crc = crc ^ 0xa001; + } + crc = crc & 0xffff; + } + } + //CRC寄存器的高低位进行互换 + byte[] crc16 = new byte[2]; + crc16[1] = (byte)((crc >> 8) & 0xff); + crc16[0] = (byte)(crc & 0xff); + return crc16; + } + #endregion + + + #region CRC16-8005 + private static readonly ushort[] _table = new ushort[256] + { + 0,32773,32783,10,32795,30,20,32785,32819,54,60,32825,40,32813,32807,34, + 32867,102,108,32873,120,32893,32887,114,80,32853,32863,90,32843,78,68,32833, + 32963,198,204,32969,216,32989,32983,210,240,33013,33023,250,33003,238,228,32993, + 160,32933,32943,170,32955,190,180,32945,32915,150,156,32921,136,32909,32903,130, + 33155,390,396,33161,408,33181,33175,402,432,33205,33215,442,33195,430,420,33185, + 480,33253,33263,490,33275,510,500,33265,33235,470,476,33241,456,33229,33223,450, + 320,33093,33103,330,33115,350,340,33105,33139,374,380,33145,360,33133,33127,354, + 33059,294,300,33065,312,33085,33079,306,272,33045,33055,282,33035,270,260,33025, + 33539,774,780,33545,792,33565,33559,786,816,33589,33599,826,33579,814,804,33569, + 864,33637,33647,874,33659,894,884,33649,33619,854,860,33625,840,33613,33607,834, + 960,33733,33743,970,33755,990,980,33745,33779,1014,1020,33785,1000,33773,33767,994, + 33699,934,940,33705,952,33725,33719,946,912,33685,33695,922,33675,910,900,33665, + 640,33413,33423,650,33435,670,660,33425,33459,694,700,33465,680,33453,33447,674, + 33507,742,748,33513,760,33533,33527,754,720,33493,33503,730,33483,718,708,33473, + 33347,582,588,33353,600,33373,33367,594,624,33397,33407,634,33387,622,612,33377, + 544,33317,33327,554,33339,574,564,33329,33299,534,540,33305,520,33293,33287,514 + }; + + + /// + /// C#CRC16 8005 + /// + /// + /// + public static byte[] ComputeChecksum(byte[] buffer) + { + ushort crc = 0; + for (int i = 0; i < buffer.Length; ++i) + { + crc = (ushort)((crc << 8) ^ _table[(crc >> 8) ^ buffer[i]]); + } + + return new byte[] + { + (byte)(crc >> 8), // High byte + (byte)crc // Low byte + }; + } + #endregion + + + #region 16进制转字符串ASCII + /// + /// 16进制转字符串ASCII + /// + /// + /// + /// + public static string HexStringToString(string hs, Encoding encode) + { + StringBuilder strTemp = new StringBuilder(); + byte[] b = new byte[hs.Length / 2]; + for (int i = 0; i < hs.Length / 2; i++) + { + strTemp.Clear(); + strTemp.Append(hs.Substring(i * 2, 2)); + b[i] = Convert.ToByte(strTemp.ToString(), 16); + } + return encode.GetString(b); + } + #endregion + + + #region 16进制转2进制 + /// + /// //16转2方法 + /// + /// + /// + public static string HexString2BinString(string hexString) + { + try + { + string result = string.Empty; + foreach (char c in hexString) + { + int v = Convert.ToInt32(c.ToString(), 16); + int v2 = int.Parse(Convert.ToString(v, 2)); + // 去掉格式串中的空格,即可去掉每个4位二进制数之间的空格, + result += string.Format("{0:d4} ", v2); + } + return result; + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + throw; + } + } + #endregion + + + #region 16进制字符串转byte数组 + // 将十六进制字符串转换为字节数组 + public static byte[] HexStringToByteArray(string hexString) + { + if (!IsHexStringValid(hexString)) + { + throw new ArgumentException("无效的十六进制字符串!", nameof(hexString)); + } + + return Enumerable.Range(0, hexString.Length / 2).Select(x => Convert.ToByte(hexString.Substring(x * 2, 2), 16)).ToArray(); + } + + // 验证十六进制字符串格式是否正确 + private static bool IsHexStringValid(string hexString) + { + Regex regex = new Regex(@"^[A-Fa-f\d]+$"); + return regex.Match(hexString).Success && hexString.Length % 2 == 0; + } + #endregion + + + #region 校验和 + public static byte CheckSum(byte[] buffer) + { + byte sum = 0; + foreach (byte b in buffer) + { + sum += b; + } + + return sum; + } + #endregion + + + #region 配置文件操作 + private static Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); + + + /// + /// 获取配置文件 + /// + /// + /// + public static string GetAppSetting(string key) + { + if (ConfigurationManager.AppSettings.AllKeys.Contains(key)) + { + string value = config.AppSettings.Settings[key].Value; + return value; + } + else + { + return null; + } + } + + + /// + /// 更新配置文件信息 + /// + /// + /// + public static void UpdateAppSettings(string key, string value) + { + if (GetAppSetting(key) == value) //如果写入的配置文件和之前一致 就不写入了 + return; + if (ConfigurationManager.AppSettings.AllKeys.Contains(key)) + { + config.AppSettings.Settings[key].Value = value; + config.Save(ConfigurationSaveMode.Modified); + ConfigurationManager.RefreshSection("appSettings");//刷新数据 + } + else + { + Console.WriteLine("当前节点不存在!"); + } + } + #endregion + + + #region 内存清理 + /// + /// 设置线程工作的空间 + /// + /// 线程 + /// 最小空间 + /// 最大空间 + /// + [System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)] + private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize); + + + public static void ClearMemory(object o) + { + GC.Collect(); + GC.SuppressFinalize(o); + + + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + { + SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1); + } + } + #endregion + + + public static float ConvertStringToTwoDecimalPlaces(string value) + { + try + { + return float.Parse(value, CultureInfo.CreateSpecificCulture("en-US")); + } + catch + { + // 处理转换失败的情况,例如value不是有效的两位小数字符串 + return 0.0f; + } + } + + + /// + /// 获取当前设备的所有端口号 + /// + /// + public static string[] GetSerialPort() + { + string[] ports = null; + ports = System.IO.Ports.SerialPort.GetPortNames(); + return ports; + } + + + /// + /// 比较两个byte数组是否相等 + /// + /// + /// + /// + public static bool CompareByte(byte[] array1, byte[] array2) + { + if (array1 == null || array2 == null) + return false; + + return array1.SequenceEqual(array2); + } + + + #region 判断byte数组特定位置是否为1 + public static bool IsBitSet(byte[] bytes, int position) + { + int arrayIndex = position / 8; // 计算byte数组的索引 + int bitIndex = position % 8; // 计算位的索引(0-7) + + // 确保索引没有超出数组范围 + if (arrayIndex >= bytes.Length) + throw new IndexOutOfRangeException("Position is out of range of the byte array."); + + byte b = bytes[arrayIndex]; + // 使用位运算检查位是否为1 + bool isSet = (b & (1 << bitIndex)) != 0; + return isSet; + } + #endregion + + + #region 十六进制数组转二进制数组 + public static byte[] ConvertHexToBinary(byte[] hexArray) + { + byte[] binaryArray = new byte[hexArray.Length * 8]; + for (int i = 0; i < hexArray.Length; i++) + { + string binaryString = Convert.ToString(hexArray[i], 2); + // 补充到8位,以确保每个byte都是8位 + binaryString = binaryString.PadLeft(8, '0'); + // 将二进制字符串转换为byte数组 + for (int j = 0; j < 8; j++) + { + binaryArray[i * 8 + j] = Convert.ToByte(binaryString[j] - '0'); + } + } + return binaryArray; + } + #endregion + + + #region IntToByte[4] + /// + /// int转化为byte[4] + /// + /// + /// + public static byte[] IntToBytes(int value) + { + byte[] src = new byte[4]; + src[0] = (byte)((value >> 24) & 0xFF); + src[1] = (byte)((value >> 16) & 0xFF); + src[2] = (byte)((value >> 8) & 0xFF);//高8位 + src[3] = (byte)(value & 0xFF);//低位 + return src; + } + #endregion + + + #region byte数组按长度在前面补0 + /// + /// byte数组按长度在前面补0 + /// + /// + /// + /// + /// + /// + public static byte[] PadArrayWithZeros(byte[] array, int targetLength) + { + if (array == null) + throw new ArgumentNullException(nameof(array)); + if (targetLength <= 0) + throw new ArgumentOutOfRangeException(nameof(targetLength), "Target length must be a positive integer."); + if (targetLength <= array.Length) + return array; // No need to pad + + byte[] paddedArray = new byte[targetLength]; + Array.Copy(array, 0, paddedArray, targetLength - array.Length, array.Length); + return paddedArray; + } + #endregion + + } +} diff --git a/FujianEarthquake/FujianEarthquake/DataAccess/CmdInfo.cs b/FujianEarthquake/FujianEarthquake/DataAccess/CmdInfo.cs new file mode 100644 index 0000000..8eae198 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/DataAccess/CmdInfo.cs @@ -0,0 +1,32 @@ +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.DataAccess +{ + //封装事务中的每个操作类,包括命令名称,类型,参数 + public class CmdInfo + { + public string CommandText;//sql或存储过程名称 + public MySqlParameter[] Parameters;//参数列表 + public int CmdType;//是存储过程还是T-SQL语句 + public CmdInfo() + { } + + public CmdInfo(string comText, int cmdType) + { + this.CommandText = comText; + this.CmdType = cmdType; + } + + public CmdInfo(string commandText, MySqlParameter[] parameters, int cmdType) + { + CommandText = commandText; + Parameters = parameters; + CmdType = cmdType; + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/DataAccess/DBHelper.cs b/FujianEarthquake/FujianEarthquake/DataAccess/DBHelper.cs new file mode 100644 index 0000000..3070e44 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/DataAccess/DBHelper.cs @@ -0,0 +1,316 @@ +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.DataAccess +{ + public class DBHelper + { + //连接钥匙 + private static readonly string ConnStr = ConfigurationManager.ConnectionStrings["db"].ConnectionString; + private static readonly string ConnStr_Server = ConfigurationManager.ConnectionStrings["db_Sever"].ConnectionString; + MySqlConnection conn = null; + + /// + /// 增删改 + /// + /// 增删改 + /// 1代表是查询过程 2 是代表存储过程 + /// + /// + public static int ExecuteNonQuery(string sql, int cmdType, params MySqlParameter[] paras) + { + int count = 0; + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + count = cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); //清空数组集合 + conn.Close(); + } + ////向服务器发送数据 + //if (tools.TcpClientCheck(ConnStr_Server.Split(';')[0].Split('=')[1], 3306)) + //{ + // using (MySqlConnection conn = new MySqlConnection(ConnStr_Server)) + // { + // MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + // count = cmd.ExecuteNonQuery(); + // cmd.Parameters.Clear(); //清空数组集合 + // conn.Close(); + // } + //} + return count; + } + + + /// + /// 查询一个值 + /// + /// + /// + /// + /// + public static object ExecuteScalar(string sql, int cmdType, params MySqlParameter[] paras) + { + object o = 0; + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + o = cmd.ExecuteScalar(); + cmd.Parameters.Clear(); + conn.Close(); + } + return o; + } + + + /// + /// 查询多行值 + /// + /// + /// + /// + /// + /// + public static MySqlDataReader ExecuteReader(string sql, int cmdType, params MySqlParameter[] paras) + { + MySqlDataReader dr = null; + MySqlConnection conn = new MySqlConnection(ConnStr); + MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + try + { + dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); + cmd.Parameters.Clear(); + } + catch (MySqlException ex) + { + conn.Close(); + throw new Exception("执行查询异常", ex); + } + + return dr; + } + + + /// + /// 填充DataSet + /// + /// + /// + /// + /// + public static DataSet GetDataSet(string sql, int cmdType, MySqlParameter[] paras) + { + DataSet ds = new DataSet(); + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + MySqlDataAdapter da = new MySqlDataAdapter(cmd); + //conn.Open(); + da.Fill(ds); + conn.Close(); + } + return ds; + } + + + /// + /// 填充DataTable 一个结果集 + /// + /// + /// + /// + /// + public static DataTable GetDataTable(string sql, int cmdType, MySqlParameter[] paras) + { + DataTable dt = new DataTable(); + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + MySqlCommand cmd = BuildCommand(conn, sql, cmdType, null, paras); + MySqlDataAdapter da = new MySqlDataAdapter(cmd); + //conn.Open(); + da.Fill(dt); + conn.Close(); + } + return dt; + } + + + /// + /// 事务 一系列的sql语句 针对增删该查 + /// + /// + /// + public static bool ExecuteTrans(List listSQL) + { + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + conn.Open(); + MySqlTransaction trans = conn.BeginTransaction(); + //MySqlCommand cmd = conn.CreateCommand(); + //cmd.Transaction = trans; + MySqlCommand cmd = BuildCommand(conn, "", 1, trans); + try + { + for (int i = 0; i < listSQL.Count; i++) + { + cmd.CommandText = listSQL[i]; + cmd.ExecuteNonQuery(); + } + trans.Commit(); + return true; + } + catch (MySqlException ex) + { + trans.Rollback();//回滚 + throw new Exception("执行事务出现异常", ex); + } + finally + { + trans.Dispose(); + cmd.Dispose(); + conn.Close(); + } + } + } + + + /// + /// 执行事务 每个操作分装到cmdInfo中 + /// + /// + /// + /// + public static bool ExecuteTrans(List listCmd) + { + using (MySqlConnection conn = new MySqlConnection(ConnStr)) + { + conn.Open(); + MySqlTransaction trans = conn.BeginTransaction(); + //MySqlCommand cmd = conn.CreateCommand(); + //cmd.Transaction = trans; + MySqlCommand cmd = BuildCommand(conn, "", 1, trans); + try + { + for (int i = 0; i < listCmd.Count; i++) + { + cmd.CommandText = listCmd[i].CommandText; + if (listCmd.Count == 2) + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.Clear(); //很重要 + if (cmd.Parameters != null && cmd.Parameters.Count > 0) + cmd.Parameters.AddRange(listCmd[i].Parameters); + cmd.ExecuteNonQuery(); + cmd.Parameters.Clear(); //很重要 + } + trans.Commit(); + return true; + } + catch (MySqlException ex) + { + trans.Rollback();//回滚 + throw new Exception("执行事务出现异常", ex); + } + finally + { + trans.Dispose(); + cmd.Dispose(); + conn.Close(); + } + } + } + + + /// + /// 构造SqlCommand + /// + /// + /// + /// + /// + /// + /// + private static MySqlCommand BuildCommand(MySqlConnection conn, string sql, int cmdType, MySqlTransaction trans, params MySqlParameter[] paras) + { + MySqlCommand cmd = new MySqlCommand(sql, conn); + if (cmdType == 2) + cmd.CommandType = CommandType.StoredProcedure; //代表是存储过程 + if (paras != null && paras.Length > 0) + cmd.Parameters.AddRange(paras); + if (conn.State == ConnectionState.Closed) + conn.Open(); + if (trans != null) + cmd.Transaction = trans; + return cmd; + } + + + /// + /// 对数据库插入数据 + /// + /// 表名 + /// 站点ID + /// 数据记录时间 + /// 需要插入的值的名称 + /// 值 + public static void InsertData(string tablename, int stationId, DateTime RecordTime, string key, object value) + { + //首先判断数据库中是否有这一条数据 + string sql = string.Format("select id from {0} where RecordTime = '{1}' && StationID = {2}", tablename, RecordTime, stationId); + if (ExecuteScalar(sql, 1) == null) + { + string valuechange = typeof(string).Equals(value.GetType()) ? "'{5}'" : "{5}"; + sql = string.Format("insert into {0}(StationID,RecordTime,DataTime,{1}) VALUES({2},'{3}','{4}'," + valuechange + ");", tablename, key, stationId, RecordTime, System.DateTime.Now, value.ToString()); + } + else + { + //如果数据不同才更新 + if (ExecuteScalar(string.Format("select {0} from {1} where id = {2}", key, tablename, Convert.ToInt32(ExecuteScalar(sql, 1))), 1) != value) + { + string valuechange = typeof(string).Equals(value.GetType()) ? "'{2}'" : "{2}"; + sql = string.Format("update {0} set {1}=" + valuechange + " where RecordTime='{3}' && StationID = {4};", tablename, key, value.ToString(), RecordTime, stationId); + } + } + ExecuteNonQuery(sql, 1); + } + + //public static void InsertAlarmInfo(AlarmRecordModel alarmInfo) + //{ + ////首先判断数据库中是否有这一条数据 + //string sql = string.Format("select id from alarminfo where ParaName = '{0}';", alarmInfo.ParaName); + //if (ExecuteScalar(sql, 1) == null) //如果没有那就新增一条信息 + //{ + // sql = string.Format("insert into alarminfo(StationID,RecordTime,DataTime,ParaName,ParaState,IsHandled) VALUES({0},'{1}','{2}','{3}','{4}',{5})", alarmInfo.StationID, alarmInfo.RecordTime, alarmInfo.DataTime, alarmInfo.ParaName, alarmInfo.ParaState, 0); + //} + //else //如果有那就更新这条信息 + //{ + // sql = string.Format("update alarminfo set ParaState='{0}',IsHandled={1},RecordTime='{2}',DataTime='{3}' where ParaName = '{4}'", alarmInfo.ParaState, alarmInfo.IsHandled, alarmInfo.RecordTime, alarmInfo.DataTime, alarmInfo.ParaName); + //} + //ExecuteNonQuery(sql, 1); + //sql = string.Format("insert into alarm_info(StationID,RecordTime,DataTime,ParaName,ParaState,IsHandled) VALUES({0},'{1}','{2}','{3}','{4}',{5})", alarmInfo.StationID, alarmInfo.RecordTime, alarmInfo.DataTime, alarmInfo.ParaName, alarmInfo.ParaState, 0); + //ExecuteNonQuery(sql, 1); + //} + + //public static void InsertSwitchInfo(SwitchInfoModel switchInfo) + //{ + // //首先判断数据库中是否有这一条数据 + // string sql = string.Format("select id from switch_info where SwitchName = '{0}';", switchInfo.SwitchName); + // if (ExecuteScalar(sql, 1) == null) //如果没有那就新增一条信息 + // { + // sql = string.Format("insert into switch_info(StationID,RecordTime,DataTime,SwitchName,SwitchState) VALUES({0},'{1}','{2}','{3}','{4}')", switchInfo.StationID, switchInfo.RecordTime, switchInfo.DataTime, switchInfo.SwitchName, switchInfo.SwitchState); + // } + // else //如果有那就更新这条信息 + // { + // sql = string.Format("update switch_info set SwitchState='{0}',RecordTime='{1}',DataTime='{2}' where SwitchName = '{3}'", switchInfo.SwitchState, switchInfo.RecordTime, switchInfo.DataTime, switchInfo.SwitchName); + // } + // ExecuteNonQuery(sql, 1); + // sql = string.Format("insert into switch_info_his(StationID,RecordTime,DataTime,SwitchName,SwitchState) VALUES({0},'{1}','{2}','{3}','{4}')", switchInfo.StationID, switchInfo.RecordTime, switchInfo.DataTime, switchInfo.SwitchName, switchInfo.SwitchState); + // ExecuteNonQuery(sql, 1); + //} + } +} diff --git a/FujianEarthquake/FujianEarthquake/FujianEarthquake - Backup.csproj b/FujianEarthquake/FujianEarthquake/FujianEarthquake - Backup.csproj new file mode 100644 index 0000000..ca926e5 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/FujianEarthquake - Backup.csproj @@ -0,0 +1,17 @@ + + + + WinExe + net6.0-windows + enable + enable + true + + + + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj b/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj new file mode 100644 index 0000000..c76570f --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj @@ -0,0 +1,193 @@ + + + + WinExe + net6.0-windows + enable + enable + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + + diff --git a/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj.user b/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj.user new file mode 100644 index 0000000..63eebe7 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/FujianEarthquake.csproj.user @@ -0,0 +1,71 @@ + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + Designer + + + \ No newline at end of file diff --git a/FujianEarthquake/FujianEarthquake/MainWindow.xaml b/FujianEarthquake/FujianEarthquake/MainWindow.xaml new file mode 100644 index 0000000..d9455e2 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/MainWindow.xaml @@ -0,0 +1,305 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/MainWindow.xaml.cs b/FujianEarthquake/FujianEarthquake/MainWindow.xaml.cs new file mode 100644 index 0000000..c6cb1db --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/MainWindow.xaml.cs @@ -0,0 +1,120 @@ +using FujianEarthquake.ViewModels; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; + +namespace FujianEarthquake +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + static public MainViewModel mainViewModel { set; get; } = new MainViewModel(); + + private DispatcherTimer ShowTimer; + + public MainWindow() + { + InitializeComponent(); + + this.DataContext = mainViewModel; + this.MaxHeight = SystemParameters.PrimaryScreenHeight;//防止最大化时系统任务栏被遮盖 + + //添加timer + ShowTimer = new System.Windows.Threading.DispatcherTimer(); + ShowTimer.Tick += new EventHandler(ShowTime); + ShowTimer.Interval = new TimeSpan(0, 0, 0, 1, 0); + ShowTimer.Start(); + } + + /// + /// 时间、日期显示 + /// + /// + /// + public void ShowTime(object sender, EventArgs e) + { + this.DataTime.Text = ""; + this.Date.Text = ""; + this.Week.Text = ""; + + //获得年月日 + this.DataTime.Text += " " + DateTime.Now.ToString("HH:mm:ss"); //yyyy年MM月dd日 + this.Date.Text += " " + DateTime.Now.ToString("yyyy-MM-dd"); + this.Week.Text += System.DateTime.Today.ToString("dddd", new System.Globalization.CultureInfo("zh-CN")); + } + + /// + /// 主窗体关闭 + /// + /// + /// + private void Button_Click(object sender, RoutedEventArgs e) + { + //主窗体关闭之前调用通信断开 + //if (mainViewModel.clientModel1 != null && mainViewModel.clientModel1.IsConnected) + // mainViewModel.clientModel1.DisConnect(); + //if (mainViewModel.clientModel2 != null && mainViewModel.clientModel2.IsConnected) + // mainViewModel.clientModel2.DisConnect(); + //if (mainViewModel.serverModel1 != null && mainViewModel.serverModel1.IsOpened) + // mainViewModel.serverModel1.DoStop(); + //if (mainViewModel.serverModel2 != null && mainViewModel.serverModel2.IsOpened) + // mainViewModel.serverModel2.DoStop(); + + this.Close(); + } + + + /// + /// 左键点击顶栏拖动窗体 + /// + /// + /// + private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) + { + if (e.LeftButton == MouseButtonState.Pressed) + this.DragMove(); + + //双击最大化 + //switch (e.ClickCount) + //{ + // case 2: + // { + // WindowState = WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; + // break; + // } + //} + } + + + /// + /// 最小化按钮 + /// + /// + /// + private void MinButton_Click(object sender, RoutedEventArgs e) + { + this.WindowState = WindowState.Minimized; + } + + + /// + /// 最大化按钮 + /// + /// + /// + private void MaxButton_Click(object sender, RoutedEventArgs e) + { + this.WindowState = this.WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized; + } + } +} \ No newline at end of file diff --git a/FujianEarthquake/FujianEarthquake/Models/AlarmRecordModel.cs b/FujianEarthquake/FujianEarthquake/Models/AlarmRecordModel.cs new file mode 100644 index 0000000..48ce249 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/AlarmRecordModel.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace FujianEarthquake.Models +{ + public class AlarmRecordModel : ParameterModel + { + public int Index { get; set; } + + public DateTime DataTime { get; set; } + + + private string paraName; + + /// + /// 故障参数名称 + /// + public string ParaName + { + get { return paraName; } + set { paraName = value; } + } + + + private int paraNum; + + /// + /// 故障发生次数 + /// + public int ParaNum + { + get { return paraNum; } + set { paraNum = value; } + } + + + private string paraContent; + + /// + /// 故障事件全称 + /// + public string ParaContent + { + get { return paraContent; } + set { paraContent = value; } + } + + + private string isHandled; + + /// + /// 故障事件是否处理 0未处理 1已处理 2处理中 + /// + public string IsHandled + { + get { return isHandled; } + set { isHandled = value; } + } + + public string ProcessingMethod { get; set; } + + public ImageSource UrgencyLevel { get; set; } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/BaseStationGestureModel.cs b/FujianEarthquake/FujianEarthquake/Models/BaseStationGestureModel.cs new file mode 100644 index 0000000..985c32a --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/BaseStationGestureModel.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.Models +{ + public class BaseStationGestureModel : ParameterModel + { + private float rollAngle; + + /// + /// 横滚角 + /// + public float RollAngle + { + get { return rollAngle; } + set { rollAngle = value; this.DoNotify(); } + } + + + private float pitchAngle; + + /// + /// 俯仰角 + /// + public float PitchAngle + { + get { return pitchAngle; } + set { pitchAngle = value; this.DoNotify(); } + } + + + private float headingAngle; + + /// + /// 航向角 + /// + public float HeadingAngle + { + get { return headingAngle; } + set { headingAngle = value; this.DoNotify(); } + } + + + private float pY_HG; + + /// + /// 横滚角偏移度数 + /// + public float PY_HG + { + get { return pY_HG; } + set { pY_HG = value; this.DoNotify(); } + } + + + private float pY_FY; + + /// + /// 俯仰角度偏移度数 + /// + public float PY_FY + { + get { return pY_FY; } + set { pY_FY = value; this.DoNotify(); } + } + + + private float pY_PH; + + /// + /// 航向角偏移度数 + /// + public float PY_PH + { + get { return pY_PH; } + set { pY_PH = value; this.DoNotify(); } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/HelpModels/KeypaiValueModel.cs b/FujianEarthquake/FujianEarthquake/Models/HelpModels/KeypaiValueModel.cs new file mode 100644 index 0000000..8c65c81 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/HelpModels/KeypaiValueModel.cs @@ -0,0 +1,21 @@ +using FujianEarthquake.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.Models.HelpModels +{ + public class KeypaiValueModel : NotifyBase + { + public string Header { get; set; } + + private string _value; + public string Value + { + get { return _value; } + set { SetProperty(ref _value, value); } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/JunctionBoxEnvironModel.cs b/FujianEarthquake/FujianEarthquake/Models/JunctionBoxEnvironModel.cs new file mode 100644 index 0000000..75ce73e --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/JunctionBoxEnvironModel.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace FujianEarthquake.Models +{ + public class JunctionBoxEnvironModel : ParameterModel + { + private float temperature; + + /// + /// 接驳盒温度 + /// + public float Temperature + { + get { return temperature; } + set { temperature = value; } + } + + + private float humidity; + + /// + /// 接驳盒湿度 + /// + public float Humidity + { + get { return humidity; } + set { humidity = value; } + } + + + private ImageSource leakage; + + /// + /// 接驳盒漏水 + /// + public ImageSource Leakage + { + get { return leakage; } + set { leakage = value; } + } + + + //private ImageSource hatch_State; + + ///// + ///// 舱门状态 + ///// + //public ImageSource Hatch_State + //{ + // get { return hatch_State; } + // set { hatch_State = value; } + //} + + + private float attitudeX; + + /// + /// 接驳盒姿态x轴 + /// + public float AttitudeX + { + get { return attitudeX; } + set { attitudeX = value; this.DoNotify(); } + } + + + private float attitudeY; + + /// + /// 接驳盒姿态y轴 + /// + public float AttitudeY + { + get { return attitudeY; } + set { attitudeY = value; this.DoNotify(); } + } + + + private float attitudeZ; + + /// + /// 接驳盒姿态z轴 + /// + public float AttitudeZ + { + get { return attitudeZ; } + set { attitudeZ = value; this.DoNotify(); } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/LogRecordModel.cs b/FujianEarthquake/FujianEarthquake/Models/LogRecordModel.cs new file mode 100644 index 0000000..78f59bd --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/LogRecordModel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.Models +{ + public class LogRecordModel + { + public int Index { get; set; } + + public DateTime RecordTime { get; set; } + + public string Device_Name { get; set; } + + public string Operation_Type { get; set; } + + public string Record { get; set; } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/ParameterModel.cs b/FujianEarthquake/FujianEarthquake/Models/ParameterModel.cs new file mode 100644 index 0000000..16ff818 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/ParameterModel.cs @@ -0,0 +1,58 @@ +using FujianEarthquake.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.Models +{ + public class ParameterModel : NotifyBase + { + private int stationId; + + /// + /// 站点ID + /// + public int StationID + { + get { return stationId; } + set { stationId = value; } + } + + + private int index; + + /// + /// ID + /// + public int Index + { + get { return index; } + set { index = value; } + } + + + private DateTime recordTime; + + /// + /// 数据记录时间 + /// + public DateTime RecordTime + { + get { return recordTime; } + set { recordTime = value; } + } + + private DateTime dataTime; + + /// + /// 数据上报时间 + /// + public DateTime DataTime + { + get { return dataTime; } + set { dataTime = value; } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Models/ShoreBaseStationStateDataModel.cs b/FujianEarthquake/FujianEarthquake/Models/ShoreBaseStationStateDataModel.cs new file mode 100644 index 0000000..cb4b46b --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Models/ShoreBaseStationStateDataModel.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace FujianEarthquake.Models +{ + public class ShoreBaseStationStateDataModel : ParameterModel + { + private float out_Vol; + + /// + /// 输出电压 + /// + public float Out_Vol + { + get { return out_Vol; } + set { out_Vol = value; } + } + + + private float out_Cur; + + /// + /// 输出电流 + /// + public float Out_Cur + { + get { return out_Cur; } + set { out_Cur = value; } + } + + + private float rated_Vol; + + /// + /// 额定电压/电压设置值 + /// + public float Rated_Vol + { + get { return rated_Vol; } + set { rated_Vol = value; } + } + + + private float rated_Cur; + + /// + /// 额定电流/电流设置值 + /// + public float Rated_Cur + { + get { return rated_Cur; } + set { rated_Cur = value; } + } + + + private float pro_Vol; + + /// + /// 输出过压保护值 + /// + public float Pro_Vol + { + get { return pro_Vol; } + set { pro_Vol = value; } + } + + + private float pro_Cur; + + /// + /// 输出过流保护值 + /// + public float Pro_Cur + { + get { return pro_Cur; } + set { pro_Cur = value; } + } + + + private ImageSource relayStatus; + + /// + /// 继电器状态 + /// + public ImageSource RelayStatus + { + get { return relayStatus; } + set { relayStatus = value; } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/AlarmRecordViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/AlarmRecordViewModel.cs new file mode 100644 index 0000000..ac21633 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/AlarmRecordViewModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.ViewModels +{ + public class AlarmRecordViewModel + { + public AlarmRecordViewModel(int id) + { + + } + + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/BaseStationModelViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/BaseStationModelViewModel.cs new file mode 100644 index 0000000..56e2d08 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/BaseStationModelViewModel.cs @@ -0,0 +1,21 @@ +using FujianEarthquake.Common; +using FujianEarthquake.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.ViewModels +{ + public class BaseStationModelViewModel : NotifyBase + { + private BaseStationGestureModel baseStationGesture = new BaseStationGestureModel(); + + public BaseStationGestureModel BaseStationGesture + { + get { return baseStationGesture; } + set { baseStationGesture = value; this.DoNotify(); } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/DialogViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/DialogViewModel.cs new file mode 100644 index 0000000..13eb964 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/DialogViewModel.cs @@ -0,0 +1,23 @@ +using FujianEarthquake.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FujianEarthquake.ViewModels +{ + public class DialogViewModel : NotifyBase + { + private string content; + public string Content + { + get { return content; } + set + { + content = value; + this.DoNotify(); + } + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/LogRecordViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/LogRecordViewModel.cs new file mode 100644 index 0000000..a874ae3 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/LogRecordViewModel.cs @@ -0,0 +1,466 @@ +using FujianEarthquake.Common; +using FujianEarthquake.DataAccess; +using FujianEarthquake.Models; +using FujianEarthquake.Views.UserControls; +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows; +using System.Windows.Threading; + +namespace FujianEarthquake.ViewModels +{ + public class LogRecordViewModel : NotifyBase + { + + #region Search Data + private DateTime _startDateTime; + + public DateTime StartDateTime + { + get { return _startDateTime; } + set { Set(ref _startDateTime, value); } + } + + private DateTime _endDateTime; + + public DateTime EndDateTime + { + get { return _endDateTime; } + set { Set(ref _endDateTime, value); } + } + + int PageIndex = 0; + + private int recordCount; + + public int RecordCount + { + get { return recordCount; } + set { recordCount = value; this.DoNotify(); } + } + + private int totalPage; + + public int TotalPage + { + get { return totalPage; } + set { totalPage = value; this.DoNotify(); } + } + + private string logMsg; + + public string LogMsg + { + get { return logMsg; } + set { logMsg = value; this.DoNotify(); } + } + #endregion + + + private ObservableCollection logRecordList = new ObservableCollection(); + + public ObservableCollection LogRecordList + { + get { return logRecordList; } + set { logRecordList = value; this.DoNotify(); } + } + + private ObservableCollection totalLogRecordList = new ObservableCollection(); + + public ObservableCollection TotalLogRecordList + { + get { return totalLogRecordList; } + set { totalLogRecordList = value; this.DoNotify(); } + } + + + #region Data Filtering + public static DialogViewModel vm; + + private bool _isChecked; + + public bool IsChecked + { + get { return _isChecked; } + set + { + _isChecked = value; + this.DoNotify(); + + if (IsChecked) + { + if (string.IsNullOrEmpty(EndDateTime.ToString()) || string.IsNullOrEmpty(StartDateTime.ToString())) + { + IsChecked = false; + return; + } + + if (EndDateTime < StartDateTime) + { + HandyControl.Controls.Dialog.Show(new TextDialog("起始时间大于结束时间,\n请重新输入!")); + IsChecked = false; + //this.EndDateTime = DateTime.Now; + //this.StartDateTime = DateTime.Now.AddDays(-1); + return; + } + + timeSearch = " and DataTime BETWEEN '" + StartDateTime + "' and '" + EndDateTime + "' "; + } + else + { + timeSearch = ""; + } + + //设置当前页为1 + PageIndex = 1; + + TotalLogRecordList.Clear(); + LogRecordList.Clear(); + + string sqlName = ""; + string deviceName = ""; + + if (station_id==1|| station_id==2|| station_id==3) + { + sqlName = "underjuncbox_log_record"; + deviceName = "海底地震监测站"; + } + else if(station_id==4) + { + sqlName = "intejunctionbox_log_record"; + deviceName = "一体式地震监测站点"; + } + else + { + sqlName = "seisverfyplatform_log_record"; + deviceName = "地震校验平台"; + } + + string sql = String.Format("select * from {0} where StationID = {1} {2} ORDER by id desc limit 100", sqlName, station_id, timeSearch); + MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1); + int index = 1; + while (dataReader.Read()) + { + LogRecordModel logRecord = new LogRecordModel(); + logRecord.Index = index++; + logRecord.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]); + logRecord.Device_Name = dataReader["Device_Name"].ToString(); + logRecord.Operation_Type = dataReader["Operation_Type"].ToString(); + logRecord.Record = dataReader["Record"].ToString(); + TotalLogRecordList.Add(logRecord); + } + dataReader.Dispose(); + + RecordCount = index - 1; + if (RecordCount <= 10) + { + TotalPage = 1; + + LogRecordList = TotalLogRecordList; + } + else + { + TotalPage = (int)Math.Ceiling((double)RecordCount / 10); + + for (int i = 0; i < 10; i++) + { + LogRecordList.Add(TotalLogRecordList[i]); + } + } + + LogMsg = string.Format("共计{0}页,当前第{1}页", TotalPage, PageIndex); + + string record = "查询日志记录历史记录,查询时间范围为:" + StartDateTime + "至" + EndDateTime + ",共查询到" + RecordCount + "条历史记录"; + + sql = $"insert into {sqlName}(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','{deviceName},'日志查询','{record}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + } + #endregion + + + #region CommandBase Define + public CommandBase ForwordLogCommand { get; set; } //读取日志信息 + + public CommandBase NextLogCommand { get; set; } //读取日志信息 + + public CommandBase RefreshDataCommand { get; set; } + + public CommandBase DownloadDataCommand { get; set; } + #endregion + + + int station_id = 1; + + string timeSearch = ""; + + public DispatcherTimer timerDownloadDataMsgHidden = new DispatcherTimer(); + + + public LogRecordViewModel(int id) + { + // 默认查询1天内的日志 + this.EndDateTime = DateTime.Now; + this.StartDateTime = DateTime.Now.AddDays(-1); + + PageIndex = 1; + station_id = id; + + vm = new DialogViewModel + { + Content = "" + }; + + + #region Command Set + this.ForwordLogCommand = new CommandBase(); + this.ForwordLogCommand.DoExcute = new Action(ForwordLog); + this.ForwordLogCommand.DoCanExcute = new Func((o) => true); + + this.NextLogCommand = new CommandBase(); + this.NextLogCommand.DoExcute = new Action(NextLog); + this.NextLogCommand.DoCanExcute = new Func((o) => true); + + this.RefreshDataCommand = new CommandBase(); + this.RefreshDataCommand.DoExcute = new Action(RefreshData); + this.RefreshDataCommand.DoCanExcute = new Func((o) => true); + + this.DownloadDataCommand = new CommandBase(); + this.DownloadDataCommand.DoExcute = new Action(DownloadData); + this.DownloadDataCommand.DoCanExcute = new Func((o) => true); + #endregion + + + timerDownloadDataMsgHidden.Interval = TimeSpan.FromSeconds(2); + timerDownloadDataMsgHidden.Tick += TimerDownloadDataMsgHidden_Tick; + } + + + #region RefreshData + public void RefreshData(object o) + { + if (IsChecked) + { + timeSearch = " and DataTime BETWEEN '" + StartDateTime + "' and '" + EndDateTime + "' "; + } + else + { + timeSearch = ""; + } + + //设置当前页为1 + PageIndex = 1; + + TotalLogRecordList.Clear(); + LogRecordList.Clear(); + + string sqlName = ""; + string deviceName = ""; + + if (station_id == 1 || station_id == 2 || station_id == 3) + { + sqlName = "underjuncbox_log_record"; + deviceName = "海底地震监测站"; + } + else if (station_id == 4) + { + sqlName = "intejunctionbox_log_record"; + deviceName = "一体式地震监测站点"; + } + else + { + sqlName = "seisverfyplatform_log_record"; + deviceName = "地震校验平台"; + } + + string sql = String.Format("select * from {0} where StationID = {1} {2} ORDER by id desc limit 100", sqlName, station_id, timeSearch); + MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1); + int index = 1; + while (dataReader.Read()) + { + LogRecordModel logRecord = new LogRecordModel(); + logRecord.Index = index++; + logRecord.RecordTime = Convert.ToDateTime(dataReader["RecordTime"]); + logRecord.Device_Name = dataReader["Device_Name"].ToString(); + logRecord.Operation_Type = dataReader["Operation_Type"].ToString(); + logRecord.Record = dataReader["Record"].ToString(); + TotalLogRecordList.Add(logRecord); + } + dataReader.Dispose(); + + RecordCount = index - 1; + if (RecordCount <= 10) + { + TotalPage = 1; + + LogRecordList = TotalLogRecordList; + } + else + { + TotalPage = (int)Math.Ceiling((double)RecordCount / 10); + + for (int i = 0; i < 10; i++) + { + LogRecordList.Add(TotalLogRecordList[i]); + } + } + + LogMsg = string.Format("共计{0}页,当前第{1}页", TotalPage, PageIndex); + + string record = "查询日志记录历史记录,查询时间范围为:" + StartDateTime + "至" + EndDateTime + ",共查询到" + RecordCount + "条历史记录"; + + sql = $"insert into {sqlName}(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','{deviceName},'日志查询','{record}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + #endregion + + + #region DownloadData + private void TimerDownloadDataMsgHidden_Tick(object sender, EventArgs e) + { + DownloadDataMsgVisibility = Visibility.Hidden; + + // 停止定时器 + (sender as DispatcherTimer).Stop(); + } + + private string downloadDataMsg; + + public string DownloadDataMsg + { + get { return downloadDataMsg; } + set { downloadDataMsg = value; this.DoNotify(); } + } + + private Brush downloadDataMsgForeground; + + public Brush DownloadDataMsgForeground + { + get { return downloadDataMsgForeground; } + set { downloadDataMsgForeground = value; this.DoNotify(); } + } + + private bool downloadDataBtnIsEnabled = true; + + public bool DownloadDataBtnIsEnabled + { + get { return downloadDataBtnIsEnabled; } + set { downloadDataBtnIsEnabled = value; this.DoNotify(); } + } + + private Visibility downloadDataMsgVisibility = Visibility.Visible; + + public Visibility DownloadDataMsgVisibility + { + get { return downloadDataMsgVisibility; } + set { downloadDataMsgVisibility = value; this.DoNotify(); } + } + + public void DownloadData(object o) + { + DownloadDataBtnIsEnabled = false; + + string baseStationFolder = Tools.GetAppSetting("LogRecordFolder"); + + string savePath = ""; + string deviceName = ""; + string sqlName = ""; + if (station_id == 1 || station_id == 2 || station_id == 3) + { + savePath = CSVDownload.CreateFile(baseStationFolder, "UnderJuncboxLogRecord_" + DateTime.Now.ToString("yyyyMMddhhMMss"), "csv"); + deviceName = "海底地震监测站"; + sqlName = "underjuncbox_log_record"; + } + else if (station_id == 4) + { + savePath = CSVDownload.CreateFile(baseStationFolder, "InteJunctionboxLogRecord_" + DateTime.Now.ToString("yyyyMMddhhMMss"), "csv"); + deviceName = "一体式地震监测站点"; + sqlName = "intejunctionbox_log_record"; + } + else + { + savePath = CSVDownload.CreateFile(baseStationFolder, "SeisVerfyPlatformLogRecord_" + DateTime.Now.ToString("yyyyMMddhhMMss"), "csv"); + deviceName = "地震校验平台"; + sqlName = "seisverfyplatform_log_record"; + } + + bool result = CSVDownload.SaveLogRecordDataToCSVFile(TotalLogRecordList, savePath); + if (result) + { + DownloadDataMsg = "下载数据成功!"; + DownloadDataMsgVisibility = Visibility.Visible; + DownloadDataMsgForeground = new SolidColorBrush(Colors.Green); + } + else + { + DownloadDataMsg = "下载数据失败!"; + DownloadDataMsgVisibility = Visibility.Visible; + DownloadDataMsgForeground = new SolidColorBrush(Colors.Red); + } + + timerDownloadDataMsgHidden.Start(); + DownloadDataBtnIsEnabled = true; + + string record = "下载日志记录," + DownloadDataMsg; + + string sql = $"insert into {sqlName}(StationID,RecordTime,Device_Name,Operation_Type,Record) values('{station_id}','{DateTime.Now}','{deviceName}','数据下载','{record}');"; + DBHelper.ExecuteNonQuery(sql, 1); + } + #endregion + + + #region Page Switching + public void ForwordLog(object o) + { + if (PageIndex == 1) + return; + + try + { + PageIndex -= 1; + + LogRecordList.Clear(); + for (int i = 0; i < 10; i++) + { + LogRecordList.Add(TotalLogRecordList[i + (PageIndex - 1) * 10]); + } + LogMsg = string.Format("共计{0}页,当前第{1}页", TotalPage, PageIndex); + } + catch + { + LogRecordList.Clear(); + TotalLogRecordList.Clear(); + } + } + + public void NextLog(object o) + { + if (PageIndex == TotalPage) + return; + + try + { + PageIndex += 1; + + LogRecordList.Clear(); + for (int i = 0; i < (PageIndex == TotalPage ? (RecordCount - (PageIndex - 1) * 10) : 10); i++) + { + LogRecordList.Add(TotalLogRecordList[i + (PageIndex - 1) * 10]); + } + LogMsg = string.Format("共计{0}页,当前第{1}页", TotalPage, PageIndex); + } + catch + { + LogRecordList.Clear(); + TotalLogRecordList.Clear(); + } + } + #endregion + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/MainViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..9e064b8 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/MainViewModel.cs @@ -0,0 +1,238 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows; +using FujianEarthquake.Common; + +namespace FujianEarthquake.ViewModels +{ + public class MainViewModel : NotifyBase + { + #region ViewModel Define + public static RealTimeDataViewModel realTimeDataViewModel1 = new RealTimeDataViewModel(1); + public static RealTimeDataViewModel realTimeDataViewModel2 = new RealTimeDataViewModel(2); + public static RealTimeDataViewModel realTimeDataViewModel3 = new RealTimeDataViewModel(3); + public static RealTimeDataViewModel realTimeDataViewModel4 = new RealTimeDataViewModel(4); + public static RealTimeDataViewModel realTimeDataViewModel5 = new RealTimeDataViewModel(5); + public static AlarmRecordViewModel alarmRecordViewModel1 = new AlarmRecordViewModel(1); + public static AlarmRecordViewModel alarmRecordViewModel2 = new AlarmRecordViewModel(2); + public static AlarmRecordViewModel alarmRecordViewModel3 = new AlarmRecordViewModel(3); + public static AlarmRecordViewModel alarmRecordViewModel4 = new AlarmRecordViewModel(4); + public static AlarmRecordViewModel alarmRecordViewModel5 = new AlarmRecordViewModel(5); + public static LogRecordViewModel logRecordViewModel1 = new LogRecordViewModel(1); + public static LogRecordViewModel logRecordViewModel2 = new LogRecordViewModel(2); + public static LogRecordViewModel logRecordViewModel3 = new LogRecordViewModel(3); + public static LogRecordViewModel logRecordViewModel4 = new LogRecordViewModel(4); + public static LogRecordViewModel logRecordViewModel5 = new LogRecordViewModel(5); + #endregion + + + #region Something Define + public int station_id { get; set; } = 1; + + string Title_Name = ""; //设置当前显示的标题 + + private FrameworkElement _pageContent; + + public FrameworkElement PageContent + { + get { return _pageContent; } + set { _pageContent = value; this.DoNotify(); } + } + #endregion + + + #region CommandBase Define + public CommandBase NavChangedCommand { get; set; } + + public CommandBase Switch { set; get; } + #endregion + + public MainViewModel() + { + #region Command Define + this.NavChangedCommand = new CommandBase(); + this.NavChangedCommand.DoExcute = new Action(DoNavChanged); + this.NavChangedCommand.DoCanExcute = new Func((o) => true); + + //this.Switch = new CommandBase(); + //this.Switch.DoExcute = new Action(Btn_Switch); + //this.Switch.DoCanExcute = new Func((o) => true); + #endregion + + + //默认打开第一个界面 + DoNavChanged("RealTimeDataView"); + } + + + + #region Page Switching + public void DoNavChanged(object obj) + { + if (obj.ToString() == "1" || obj.ToString() == "2" || obj.ToString() == "3" || obj.ToString() == "4" || obj.ToString() == "5") //说明是站点切换按钮 + { + if (station_id == Convert.ToInt32(obj)) //如果切换的界面和之前一样 那就不切换 + return; + station_id = Convert.ToInt32(obj); + } + else if (obj.ToString() == "") + { + + } + else + { + if (Title_Name == obj.ToString()) + return; + Title_Name = obj.ToString(); + } + + //切换页面之前清理一下内存 + Tools.ClearMemory(this); + + Type type = Type.GetType("FujianEarthquake.Views." + Title_Name); + ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes); + FrameworkElement page = (FrameworkElement)cti.Invoke(null); + if (station_id == 1) + { + switch (Title_Name) + { + case "RealTimeDataView": + page.DataContext = realTimeDataViewModel1; + break; + //case "SystemEnvironDataView": + // systemEnvironDataViewModel1.RefreshFile(obj); + // page.DataContext = systemEnvironDataViewModel1; + // break; + //case "SystemMonitorDataView": + // page.DataContext = systemMonitorDataViewModel1; + // break; + //case "BoosterStationStateDataView": + // page.DataContext = boosterStationStateDataViewModel1; + // break; + //case "SeismometerStateDataView": + // MainViewModel.seismometerStateDataViewModel1.MainSeisIsChecked = true; + // page.DataContext = seismometerStateDataViewModel1; + // break; + //case "SeismometerParameterView": + // MainViewModel.seismometerParameterViewModel1.BackupSeisIsChecked = false; + // page.DataContext = seismometerParameterViewModel1; + // break; + //case "SystemControlView": + // MainSeisIsChecked = true; + // baseStationStateModel1.JunBox_Elect = (ImageSource)Application.Current.FindResource("NoDevice"); + // ElectPowerOpenBtnIsEnabled = false; + // ElectPowerCloseBtnIsEnabled = false; + + // BSSM = baseStationStateModel1; + // break; + case "LogRecordView": + page.DataContext = logRecordViewModel1; + break; + case "AlarmRecordView": + page.DataContext = alarmRecordViewModel1; + break; + default: + break; + } + } + else if (station_id == 2) + { + switch (Title_Name) + { + case "RealTimeDataView": + page.DataContext = realTimeDataViewModel2; + break; + //case "SystemEnvironDataView": + // page.DataContext = systemEnvironDataViewModel2; + // break; + //case "SystemMonitorDataView": + // page.DataContext = systemMonitorDataViewModel2; + // break; + //case "BoosterStationStateDataView": + // page.DataContext = boosterStationStateDataViewModel2; + // break; + //case "SeismometerStateDataView": + // MainViewModel.seismometerStateDataViewModel2.MainSeisIsChecked = true; + // page.DataContext = seismometerStateDataViewModel2; + // break; + //case "SeismometerParameterView": + // MainViewModel.seismometerParameterViewModel1.BackupSeisIsChecked = false; + // page.DataContext = seismometerParameterViewModel2; + // break; + //case "SystemControlView": + // MainSeisIsChecked = true; + // ElectPowerOpenBtnIsEnabled = true; + // ElectPowerCloseBtnIsEnabled = true; + // BSSM = baseStationStateModel2; + // break; + case "LogRecordView": + page.DataContext = logRecordViewModel2; + break; + case "AlarmRecordView": + page.DataContext = alarmRecordViewModel2; + break; + default: + break; + } + } + else if (station_id == 3) + { + switch (Title_Name) + { + case "RealTimeDataView": + page.DataContext = realTimeDataViewModel3; + break; + case "LogRecordView": + page.DataContext = logRecordViewModel3; + break; + case "AlarmRecordView": + page.DataContext = alarmRecordViewModel3; + break; + default: + break; + } + } + else if (station_id == 4) + { + switch (Title_Name) + { + case "RealTimeDataView": + page.DataContext = realTimeDataViewModel4; + break; + case "LogRecordView": + page.DataContext = logRecordViewModel4; + break; + case "AlarmRecordView": + page.DataContext = alarmRecordViewModel4; + break; + default: + break; + } + } + else if (station_id == 5) + { + switch (Title_Name) + { + case "RealTimeDataView": + page.DataContext = realTimeDataViewModel5; + break; + case "LogRecordView": + page.DataContext = logRecordViewModel5; + break; + case "AlarmRecordView": + page.DataContext = alarmRecordViewModel5; + break; + default: + break; + } + } + this.PageContent = page; + } + #endregion + } +} diff --git a/FujianEarthquake/FujianEarthquake/ViewModels/RealTimeDataViewModel.cs b/FujianEarthquake/FujianEarthquake/ViewModels/RealTimeDataViewModel.cs new file mode 100644 index 0000000..4f2852a --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/ViewModels/RealTimeDataViewModel.cs @@ -0,0 +1,378 @@ +using FujianEarthquake.Common; +using FujianEarthquake.Models; +using FujianEarthquake.DataAccess; +using FujianEarthquake.Models.HelpModels; +using FujianEarthquake.Views; +using HandyControl.Tools; +using LiveCharts; +using MySql.Data.MySqlClient; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; + +namespace FujianEarthquake.ViewModels +{ + public class RealTimeDataViewModel : NotifyBase + { + public JunctionBoxEnvironModel junctionBoxEnvironModel { get; set; }=new JunctionBoxEnvironModel(); + + public ShoreBaseStationStateDataModel shoreBaseStationStateModel { get;set; }=new ShoreBaseStationStateDataModel(); + + public BaseStationModelView baseStationModelView { get; set; } = new BaseStationModelView(); + + private BaseStationGestureModel baseStationGesture = new BaseStationGestureModel(); + + public BaseStationGestureModel BaseStationGesture + { + get { return baseStationGesture; } + set + { + baseStationGesture = value; + this.DoNotify(); + //DoFresh(); + } + } + + + #region SeriesCollection + public SeriesCollection seriesCollectionConboxTem; + + public SeriesCollection SeriesCollectionConboxTem + { + get { return seriesCollectionConboxTem; } + set + { + seriesCollectionConboxTem = value; + this.DoNotify(); + } + } + + public SeriesCollection seriesCollectionConboxHum; + + public SeriesCollection SeriesCollectionConboxHum + { + get { return seriesCollectionConboxHum; } + set + { + seriesCollectionConboxHum = value; + this.DoNotify(); + } + } + + //public SeriesCollection seriesCollectionMainSeis; + + //public SeriesCollection SeriesCollectionMainSeis + //{ + // get { return seriesCollectionMainSeis; } + // set + // { + // seriesCollectionMainSeis = value; + // this.DoNotify(); + // } + //} + + //public SeriesCollection seriesCollectionBackupSeis; + + //public SeriesCollection SeriesCollectionBackupSeis + //{ + // get { return seriesCollectionBackupSeis; } + // set + // { + // seriesCollectionBackupSeis = value; + // this.DoNotify(); + // } + //} + + public SeriesCollection seriesCollectionShoreBaseStationVol; + + public SeriesCollection SeriesCollectionShoreBaseStationVol + { + get { return seriesCollectionShoreBaseStationVol; } + set + { + seriesCollectionShoreBaseStationVol = value; + this.DoNotify(); + } + } + + public SeriesCollection seriesCollectionShoreBaseStationCur; + + public SeriesCollection SeriesCollectionShoreBaseStationCur + { + get { return seriesCollectionShoreBaseStationCur; } + set + { + seriesCollectionShoreBaseStationCur = value; + this.DoNotify(); + } + } + #endregion + + + #region Formatter + private Func _xFormatter; + + public Func XFormatter + { + get { return _xFormatter; } + set + { + _xFormatter = value; + this.DoNotify(); + } + } + + private Func _yFormatterVol; + + public Func YFormatterVol + { + get { return _yFormatterVol; } + set + { + _yFormatterVol = value; + this.DoNotify(); + } + } + + private Func _yFormatterCur; + + public Func YFormatterCur + { + get { return _yFormatterCur; } + set + { + _yFormatterCur = value; + this.DoNotify(); + } + } + + private Func _yFormatterTem; + + public Func YFormatterTem + { + get { return _yFormatterTem; } + set + { + _yFormatterTem = value; + this.DoNotify(); + } + } + + private Func _yFormatterHum; + + public Func YFormatterHum + { + get { return _yFormatterHum; } + set + { + _yFormatterHum = value; + this.DoNotify(); + } + } + #endregion + + + #region RecordTime + public DateTime dataTimeConboxTem; + + public DateTime DataTimeConboxTem + { + get { return dataTimeConboxTem; } + set + { + dataTimeConboxTem = value; + this.DoNotify(); + } + } + + public DateTime dataTimeConboxHum; + + public DateTime DataTimeConboxHum + { + get { return dataTimeConboxHum; } + set + { + dataTimeConboxHum = value; + this.DoNotify(); + } + } + + //public DateTime dataTimeMainSeis; + + //public DateTime DataTimeMainSeis + //{ + // get { return dataTimeMainSeis; } + // set + // { + // dataTimeMainSeis = value; + // this.DoNotify(); + // } + //} + + //public DateTime dataTimeBackupSeis; + + //public DateTime DataTimeBackupSeis + //{ + // get { return dataTimeBackupSeis; } + // set + // { + // dataTimeBackupSeis = value; + // this.DoNotify(); + // } + //} + + public DateTime dataTimeShoreBaseStationVol; + + public DateTime DataTimeShoreBaseStationVol + { + get { return dataTimeShoreBaseStationVol; } + set + { + dataTimeShoreBaseStationVol = value; + this.DoNotify(); + } + } + + public DateTime dataTimeShoreBaseStationCur; + + public DateTime DataTimeShoreBaseStationCur + { + get { return dataTimeShoreBaseStationCur; } + set + { + dataTimeShoreBaseStationCur = value; + this.DoNotify(); + } + } + #endregion + + + #region AngleBackground + public Brush angleBackgroundX; + + public Brush AngleBackgroundX + { + get { return angleBackgroundX; } + set + { + angleBackgroundX = value; + this.DoNotify(); + } + } + + public Brush angleBackgroundY; + + public Brush AngleBackgroundY + { + get { return angleBackgroundY; } + set + { + angleBackgroundY = value; + this.DoNotify(); + } + } + + public Brush angleBackgroundZ; + + public Brush AngleBackgroundZ + { + get { return angleBackgroundZ; } + set + { + angleBackgroundZ = value; + this.DoNotify(); + } + } + #endregion + + + private ImageSource leakageImage; + + public ImageSource LeakageImage + { + get { return leakageImage; } + set { leakageImage = value; } + } + + + /// + /// 环境状态列表数据 + /// + private List _baseStationStatus = new List + { + new KeypaiValueModel { Header = "主地震仪电压(V) / 电流(A)" }, + new KeypaiValueModel { Header = "海底基站温度(℃)" }, + new KeypaiValueModel { Header = "岸基站输出电压(V)" }, + new KeypaiValueModel { Header = "备地震仪电压(V) / 电流(A)" }, + new KeypaiValueModel { Header = "海底基站湿度(%)" }, + new KeypaiValueModel { Header = "岸基站输出电流(A)" }, + //new KeypaiValueModel { Header = "基站姿态X轴(°)" }, + //new KeypaiValueModel { Header = "基站姿态Y轴(°)" }, + //new KeypaiValueModel { Header = "基站姿态Z轴(°)" }, + //new KeypaiValueModel { Header = "基站漏水状态" }, + }; + + public List BaseStationStatus + { + get { return _baseStationStatus; } + set { _baseStationStatus = value; this.DoNotify(); } + } + + + /// + /// 告警信息 + /// + private List alarmList = new List(); + + public List AlarmList + { + get { return alarmList; } + set { alarmList = value; this.DoNotify(); } + } + + + public CommandBase ResetAngleCommand { get; set; } + + int station_id = 1; + + public RealTimeDataView realTimeDataView = new RealTimeDataView(); + + public BaseStationModelViewModel baseStationModelViewModel { get; set; } = new BaseStationModelViewModel(); + + + public RealTimeDataViewModel(int id) + { + //DoFresh(); + + station_id = id; + + this.ResetAngleCommand = new CommandBase(); + this.ResetAngleCommand.DoExcute = new Action(ResetAngle); + this.ResetAngleCommand.DoCanExcute = new Func((o) => true); + } + + public void ResetAngle(object o) + { + string sql = String.Format("select * from juncbox_env where StationID = {0} ORDER by id desc limit 1", station_id); + MySqlDataReader dataReader = DBHelper.ExecuteReader(sql, 1); + while (dataReader.Read()) + { + BaseStationGesture.RollAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeX"].ToString()) ? "0.00" : dataReader["AttitudeX"].ToString()); + BaseStationGesture.PitchAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeY"].ToString()) ? "0.00" : dataReader["AttitudeY"].ToString()); + BaseStationGesture.HeadingAngle = Convert.ToSingle(string.IsNullOrEmpty(dataReader["AttitudeZ"].ToString()) ? "0.00" : dataReader["AttitudeZ"].ToString()); + } + dataReader.Dispose(); + + baseStationModelViewModel.BaseStationGesture.RollAngle = BaseStationGesture.RollAngle; + baseStationModelViewModel.BaseStationGesture.PitchAngle = BaseStationGesture.PitchAngle; + baseStationModelViewModel.BaseStationGesture.HeadingAngle = BaseStationGesture.HeadingAngle; + + //baseStationModelView.angleX.Content = BaseStationGesture.RollAngle; + //baseStationModelView.angleY.Content = BaseStationGesture.PitchAngle; + //baseStationModelView.angleZ.Content = BaseStationGesture.HeadingAngle; + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml b/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml new file mode 100644 index 0000000..5b97cfa --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml.cs new file mode 100644 index 0000000..fba35df --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/AlarmRecordView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// AlarmRecordView.xaml 的交互逻辑 + /// + public partial class AlarmRecordView : Page + { + public AlarmRecordView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml b/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml new file mode 100644 index 0000000..16c1df7 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml.cs new file mode 100644 index 0000000..b12a593 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/BaseStationModelView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// BaseStationModelView.xaml 的交互逻辑 + /// + public partial class BaseStationModelView : UserControl + { + public BaseStationModelView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml new file mode 100644 index 0000000..3a24539 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml.cs new file mode 100644 index 0000000..749016c --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxEnvironDataView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// JunctionBoxEnvironDataView.xaml 的交互逻辑 + /// + public partial class JunctionBoxEnvironDataView : UserControl + { + public JunctionBoxEnvironDataView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml new file mode 100644 index 0000000..158dfeb --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml.cs new file mode 100644 index 0000000..a4d69fb --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/JunctionBoxStatusDataView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// JunctionBoxStatusDataView.xaml 的交互逻辑 + /// + public partial class JunctionBoxStatusDataView : UserControl + { + public JunctionBoxStatusDataView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml b/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml new file mode 100644 index 0000000..4f1de86 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml.cs new file mode 100644 index 0000000..a4ea2ed --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/LogRecordView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// LogRecordView.xaml 的交互逻辑 + /// + public partial class LogRecordView : UserControl + { + public LogRecordView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml b/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml new file mode 100644 index 0000000..4caddb6 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml @@ -0,0 +1,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml.cs new file mode 100644 index 0000000..9a597c5 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/RealTimeDataView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// RealTimeDataView.xaml 的交互逻辑 + /// + public partial class RealTimeDataView : UserControl + { + public RealTimeDataView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml b/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml new file mode 100644 index 0000000..5fa2a1a --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml.cs new file mode 100644 index 0000000..402cebc --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/ShoreBaseStationStatusDataView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// ShoreBaseStationStatusDataView.xaml 的交互逻辑 + /// + public partial class ShoreBaseStationStatusDataView : Page + { + public ShoreBaseStationStatusDataView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml b/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml new file mode 100644 index 0000000..b337338 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml.cs b/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml.cs new file mode 100644 index 0000000..db59680 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/SystemControlView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace FujianEarthquake.Views +{ + /// + /// SystemControlView.xaml 的交互逻辑 + /// + public partial class SystemControlView : Page + { + public SystemControlView() + { + InitializeComponent(); + } + } +} diff --git a/FujianEarthquake/FujianEarthquake/Views/UserControls/TextDialog.xaml b/FujianEarthquake/FujianEarthquake/Views/UserControls/TextDialog.xaml new file mode 100644 index 0000000..bd796d3 --- /dev/null +++ b/FujianEarthquake/FujianEarthquake/Views/UserControls/TextDialog.xaml @@ -0,0 +1,21 @@ + + + +