鹿和sa0ChunLuyu 2 weeks ago
parent 5c04d9f3a0
commit 300a79559d

@ -0,0 +1,30 @@
## 编译输出
bin/
obj/
## Visual Studio
.vs/
*.user
*.suo
*.sln.docstates
*.userprefs
## NuGet
packages/
## 临时文件
*.cache
*.tmp
*.log
*.tlog
*.ilk
*.pdb
## 设计时
DesignTimeResolveAssemblyReferences*
_dependencies/
## 其他
*.opensdf
*.sdf
ipch/

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<appSettings>
<!-- 配置清屏的行数 -->
<add key="MaxLines" value="20" />
</appSettings>
<connectionStrings>
<add name="ConnStr" connectionString="Database=yiji;Data Source=127.0.0.1;Port=3306;User Id=root;Password=root;Charset=utf8;Allow User Variables=True;" />
<add name="LogConnStr" connectionString="Database=yjplog;Data Source=127.0.0.1;Port=3306;User Id=root;Password=root;Charset=utf8;Allow User Variables=True;" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.6" newVersion="9.0.0.6" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.6" newVersion="9.0.0.6" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,9 @@
<Application x:Class="MyHosListener.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyHosListener"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,35 @@
using log4net;
using log4net.Config;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MyHosListener
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var logDirectory = Path.GetDirectoryName("logs\\");
if (!Directory.Exists(logDirectory))
{
Directory.CreateDirectory(logDirectory);
}
// 初始化 log4net
var logCfg = new FileInfo("log4net.config");
XmlConfigurator.Configure(logCfg);
}
}
}

@ -0,0 +1,117 @@
<Window x:Class="MyHosListener.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyHosListener"
mc:Ignorable="d"
Title="队列监听" Height="640" Width="960" SnapsToDevicePixels="True"
Loaded="Window_Loaded" FontFamily="Microsoft YaHei" Closed="Window_Closed"
ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="130"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" x:Name="bt_clearlog" Content="清空日志" FontFamily="Microsoft YaHei" Width="90" BorderThickness="0" Background="#02a2f8"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Margin="0,0,0,0" Height="38" Foreground="#212121" Click="ClearLog_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bg" BorderThickness="1" CornerRadius="4" Background="#eeeeee" BorderBrush="#aaaaaa">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#aaaaaa" TargetName="bg"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Button Grid.Column="2" x:Name="bt_save2log" Content="保存日志到文件" FontFamily="Microsoft YaHei" Width="120" BorderThickness="0" Background="#02a2f8"
HorizontalAlignment="Right" VerticalAlignment="Center" FontSize="14" Margin="0,0,5,0" Height="38" Foreground="#212121" Click="Save2Log_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bg" BorderThickness="1" CornerRadius="4" Background="#eeeeee" BorderBrush="#aaaaaa">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#aaaaaa" TargetName="bg"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
<Grid Grid.Column="3" Margin="10,0,0,0">
<Image x:Name="iv_scrTag1" Margin="4,0,0,0" Width="14" Height="14" VerticalAlignment="Center" HorizontalAlignment="Left" Source="/images/pwd_uncheck.png"/>
<Label Content="停止滚动" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="19,0,0,0"
Visibility="Visible" FontFamily="Microsoft YaHei" FontSize="12" Foreground="#002944"/>
<Button BorderThickness="0" Width="75" Height="24" Background="Transparent" HorizontalAlignment="Left" Foreground="#009cff"
VerticalAlignment="Center" Margin="0,0,0,0" Click="ToggleScroll_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bg" BorderThickness="0" CornerRadius="0" Background="{TemplateBinding Background}" BorderBrush="Transparent">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
</Trigger>
<Trigger Property="IsEnabled" Value="False">
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
<Grid Grid.Column="4">
<Image x:Name="iv_scrTag2" Margin="4,0,0,0" Width="14" Height="14" VerticalAlignment="Center" HorizontalAlignment="Left" Source="/images/pwd_checked.png"/>
<Label Content="自动清理日志" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="19,0,0,0"
Visibility="Visible" FontFamily="Microsoft YaHei" FontSize="12" Foreground="#002944"/>
<Button BorderThickness="0" Width="100" Height="24" Background="Transparent" HorizontalAlignment="Left" Foreground="#009cff"
VerticalAlignment="Center" Margin="0,0,0,0" Click="ToggleAutoClearLog_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bg" BorderThickness="0" CornerRadius="0" Background="{TemplateBinding Background}" BorderBrush="Transparent">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
</Trigger>
<Trigger Property="IsEnabled" Value="False">
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Grid>
<Grid Grid.Row="1">
<TextBox Name="logBox"
VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
IsReadOnly="True" FontFamily="Consolas" FontSize="14" TextWrapping="NoWrap"
AcceptsReturn="True" Background="Black" Foreground="LightGreen"
Margin="10,0,10,10" />
</Grid>
</Grid>
</Window>

File diff suppressed because one or more lines are too long

@ -0,0 +1,217 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>MyHosListener</RootNamespace>
<AssemblyName>MyHosListener</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Com.Neusoft.Nhip.MqProxy">
<HintPath>..\MQ SDK\MQ监听代码\bin\MqDebug\Com.Neusoft.Nhip.MqProxy.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=3.1.0.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.3.1.0\lib\net462\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=9.0.0.6, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Bcl.AsyncInterfaces.9.0.6\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=9.0.0.6, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.9.0.6\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=9.0.0.6, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.Extensions.Logging.Abstractions.9.0.6\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="MySqlConnector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d33d3e53aa5f8c92, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\MQ SDK\MySqlConnector.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.13.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=9.0.0.6, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Diagnostics.DiagnosticSource.9.0.6\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="common\listener\MI0164Listener.cs" />
<Compile Include="common\listener\MU0165Listener.cs" />
<Compile Include="TestCode.xaml.cs">
<DependentUpon>TestCode.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="common\DBTools.cs" />
<Compile Include="common\listener\BaseListener.cs" />
<Compile Include="common\listener\CD0050Listener.cs" />
<Compile Include="common\listener\CI0047Listener.cs" />
<Compile Include="common\listener\CI0054Listener.cs" />
<Compile Include="common\listener\CI0055Listener.cs" />
<Compile Include="common\listener\MI0150Listener.cs" />
<Compile Include="common\listener\MU0151Listener.cs" />
<Compile Include="common\listener\OD0084Listener.cs" />
<Compile Include="common\listener\OI0083Listener.cs" />
<Compile Include="common\MyLog.cs" />
<Compile Include="common\Tools.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="TestCode.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Content Include="log4net.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Resource Include="images\pwd_checked.png" />
<Resource Include="images\pwd_uncheck.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36203.30 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyHosListener", "MyHosListener.csproj", "{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Debug|x86.ActiveCfg = Debug|x86
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Debug|x86.Build.0 = Debug|x86
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Release|Any CPU.Build.0 = Release|Any CPU
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Release|x86.ActiveCfg = Release|x86
{E0024F00-0A93-4306-8B4A-431FEAF6D4E8}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A614A8E8-9B14-4801-8D74-AFBAAE2A9E9B}
EndGlobalSection
EndGlobal

@ -0,0 +1,52 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("MyHosListener")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyHosListener")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请设置
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
//在 <PropertyGroup> 中。例如,如果你使用的是美国英语。
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(未在页面中找到资源时使用,
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(未在页面中找到资源时使用,
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyHosListener.Properties
{
/// <summary>
/// 强类型资源类,用于查找本地化字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// 返回此类使用的缓存 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MyHosListener.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyHosListener.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

@ -0,0 +1,45 @@
<Window x:Class="MyHosListener.TestCode"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MyHosListener"
mc:Ignorable="d"
Title="队列监听" Height="640" Width="960" SnapsToDevicePixels="True"
FontFamily="Microsoft YaHei"
ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="130"/>
<ColumnDefinition Width="120"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" x:Name="bt_test" Content="测试代码" FontFamily="Microsoft YaHei" Width="90" BorderThickness="0" Background="#02a2f8"
HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" Margin="0,0,0,0" Height="38" Foreground="#212121" Click="bt_test_Click" >
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Border Name="bg" BorderThickness="1" CornerRadius="4" Background="#eeeeee" BorderBrush="#aaaaaa">
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#aaaaaa" TargetName="bg"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>
</Grid>
</Grid>
</Window>

File diff suppressed because one or more lines are too long

@ -0,0 +1,299 @@
using MyHosListener;
using MySqlConnector;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyHosListener.common
{
public class DBtools
{
private readonly string ConnString = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
private readonly string LogConnStr = ConfigurationManager.ConnectionStrings["LogConnStr"].ConnectionString;
/// <summary>
/// 0-9a-z,A-Z生成指定位数的随机数,没有I和i
/// </summary>
/// <param name="len">长度</param>
/// <returns></returns>
public string GetRandomStr(int len)
{
const string chars = "0123456789";
var random = new Random();
var result = new StringBuilder(len);
for (int i = 0; i < len; i++)
{
result.Append(chars[random.Next(chars.Length)]);
}
return result.ToString();
}
/// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="sql">SQL语句</param>
/// <param parameters="sql">SQL语句所带的参数</param>
/// <param name="parameters"></param>
/// <returns>受影响的行数</returns>
public int ExecSQL(string sql, MySqlParameter[] parameters)
{
using (var connection = new MySqlConnection(ConnString))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
command.Parameters.AddRange(parameters);
int result = command.ExecuteNonQuery();
command.Parameters.Clear();
connection.Close();
return result;
}
}
}
/// <summary>
///记录日志
/// </summary>
/// <param name="sql"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public int ExecSQLLog(string sql, MySqlParameter[] parameters)
{
using (var connection = new MySqlConnection(LogConnStr))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
command.Parameters.AddRange(parameters);
int result = command.ExecuteNonQuery();
command.Parameters.Clear();
connection.Close();
return result;
}
}
}
/// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="sql">SQL语句</param>
/// <param parameters="sql">SQL语句所带的参数</param>
/// <param name="parameters"></param>
/// <returns>受影响的行数</returns>
public int ExecSQL(string sql, Dictionary<string, string> dc)
{
using (var connection = new MySqlConnection(ConnString))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
command.Parameters.AddRange(sqlparameter_append(dc));
int result = command.ExecuteNonQuery();
command.Parameters.Clear();
connection.Close();
return result;
}
}
}
public int ExecSQL(string sql, Dictionary<string, object> dc)
{
using (var connection = new MySqlConnection(ConnString))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
command.Parameters.AddRange(sqlparameter_append(dc));
int result = command.ExecuteNonQuery();
command.Parameters.Clear();
connection.Close();
return result;
}
}
}
/// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="sql">SQL语句</param>
/// <returns>受影响的行数</returns>
public int ExecSQL(string sql)
{
return ExecSQL(sql, new MySqlParameter[0]);
}
/// <summary>
/// 记录日志
/// </summary>
/// <param name="logtext"></param>
/// <returns></returns>
public int Log(string logtext)
{
string sql = "INSERT INTO log(log) VALUES (@log)";
using (var connection = new MySqlConnection(LogConnStr))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
MySqlParameter mySqlParameter = new MySqlParameter();
mySqlParameter.ParameterName = "@log";
mySqlParameter.Value = logtext;
command.Connection = connection;
command.CommandText = sql;
command.Parameters.Add(mySqlParameter);
int result = command.ExecuteNonQuery();
command.Parameters.Clear();
connection.Close();
return result;
}
}
}
/// <summary>
/// 执行查询
/// </summary>
/// <param name="sql">查询语句</param>
/// <returns>查询结果表</returns>
public DataTable ExecQuery(string sql)
{
using (MySqlConnection connection = new MySqlConnection(ConnString))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
using (DataTable dt = new DataTable())
{
using (MySqlDataAdapter adapter = new MySqlDataAdapter())
{
adapter.SelectCommand = command;
adapter.Fill(dt);
command.Parameters.Clear();
connection.Close();
return dt;
}
}
}
}
}
// <summary>
/// 执行查询
/// </summary>
/// <param name="sql">查询语句</param>
/// <returns>查询结果表</returns>
public DataTable ExecQuery(string sql, MySqlParameter[] parameters)
{
using (MySqlConnection connection = new MySqlConnection(ConnString))
{
connection.Open();
using (MySqlCommand command = new MySqlCommand())
{
command.Connection = connection;
command.CommandText = sql;
using (DataTable dt = new DataTable())
{
using (MySqlDataAdapter adapter = new MySqlDataAdapter())
{
adapter.SelectCommand = command;
command.Parameters.AddRange(parameters);
adapter.Fill(dt);
command.Parameters.Clear();
connection.Close();
return dt;
}
}
}
}
}
/// <summary>
///执行sql语句返回databable
/// </summary>
/// <param name="sql">sql语句</param>
/// <param name="dc">参数</param>
/// <returns>datatable</returns>
public DataTable ExecQuery(string sql, Dictionary<string, string> dc)
{
return ExecQuery(sql, sqlparameter_append(dc));
}
/// <summary>
///执行sql语句返回databable
/// </summary>
/// <param name="sql">sql语句</param>
/// <param name="dc">参数</param>
/// <returns>datatable</returns>
public DataTable ExecQuery(string sql, Dictionary<string, object> dc)
{
return ExecQuery(sql, sqlparameter_append(dc));
}
/// <summary>
/// 根据Dictionary生成sqlparameter数组
/// </summary>
/// <param name="dc">Dictionary</param>
/// <returns>sqlparameter数组</returns>
public MySqlParameter[] sqlparameter_append(Dictionary<string, string> dc)
{
int count = dc.Count;
MySqlParameter[] paralist;
if (count == 0)
paralist = new MySqlParameter[0];
else
{
paralist = new MySqlParameter[dc.Count];
int i = 0;
foreach (KeyValuePair<string, string> kvp in dc)
{
paralist[i] = new MySqlParameter("@" + kvp.Key, kvp.Value);
i++;
}
}
return paralist;
}
public MySqlParameter[] sqlparameter_append(Dictionary<string, object> dc)
{
int count = dc.Count;
MySqlParameter[] paralist;
if (count == 0)
paralist = new MySqlParameter[0];
else
{
paralist = new MySqlParameter[dc.Count];
int i = 0;
foreach (KeyValuePair<string, object> kvp in dc)
{
paralist[i] = new MySqlParameter("@" + kvp.Key, kvp.Value);
i++;
}
}
return paralist;
}
}
}

@ -0,0 +1,18 @@
using log4net.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyHosListener.common
{
public class MyLog
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(MyLog));
public static void Info(string logStr)
{
log.Info(logStr);
}
}
}

@ -0,0 +1,144 @@
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace MyHosListener.common
{
public class Tools
{
private static System.Timers.Timer _timerNoPay;
private static readonly HttpClient client = new HttpClient();
/// <summary>
/// 通知医技取消
/// </summary>
public static async Task NoticeEntrustChange(string orderNo)
{
try
{
string url = $"http://192.168.80.76/api/PacsCancelApplyInfo?orderNo={orderNo}";
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info(responseBody);
}
catch (Exception e)
{
MyLog.Info($"请求错误 (NoticeEntrustChange): {e.Message}");
}
}
/// <summary>
/// 未支付自动取消每5分钟
/// </summary>
private static async void NoPayCancel(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
string url = "http://192.168.80.76/api/admin/NoPayCancel";
var response = await client.GetAsync(url);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info("[NoPayCancel] " + responseBody);
}
catch (Exception ex)
{
MyLog.Info($"请求错误 (NoPayCancel): {ex.Message}");
}
}
/// <summary>
/// 夜间任务核心逻辑每天22点执行
/// </summary>
private static async Task NightlyTaskCore()
{
MyLog.Info(">>> 夜间任务执行:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
DateTime targetDate = DateTime.Now.AddDays(15);
string dateStr = targetDate.ToString("yyyy-MM-dd");
var postData = new
{
dateRange = new[] { dateStr, dateStr },
HolidayEnable = 1
};
string jsonContent = JsonConvert.SerializeObject(postData);
var content = new StringContent(jsonContent, Encoding.UTF8, "application/json");
string url = "http://192.168.80.76/api/BatchGenerateByDateRange";
var response = await client.PostAsync(url, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
MyLog.Info("<<< 夜间任务成功:" + responseBody);
}
/// <summary>
/// 启动所有定时任务
/// </summary>
public static void StartRound()
{
MyLog.Info("正在初始化定时任务模块...");
// ===== 5分钟任务 =====
if (_timerNoPay == null)
{
_timerNoPay = new System.Timers.Timer(300000); // 5分钟
_timerNoPay.Elapsed += NoPayCancel;
_timerNoPay.AutoReset = true;
_timerNoPay.Start();
MyLog.Info("[OK] 定时任务 [NoPayCancel] 已启动 (每5分钟)");
}
// ===== 每天22点任务 =====
Task.Run(async () =>
{
MyLog.Info("[Nightly] 每日22点任务已启动");
while (true)
{
try
{
DateTime now = DateTime.Now;
// 今天22点
DateTime today22 = new DateTime(
now.Year, now.Month, now.Day, 22, 0, 0
);
// 如果已经过了22点就安排到明天
DateTime nextRun = now > today22 ? today22.AddDays(1) : today22;
TimeSpan delay = nextRun - now;
MyLog.Info($"[Nightly] 下次执行时间: {nextRun:yyyy-MM-dd HH:mm:ss}");
// 等待到指定时间
await Task.Delay(delay);
// 执行任务
await NightlyTaskCore();
}
catch (Exception ex)
{
MyLog.Info("夜间任务异常:" + ex.Message);
// 出错后延迟1分钟再重试
await Task.Delay(TimeSpan.FromMinutes(1));
}
}
});
MyLog.Info("所有定时任务初始化完成。");
}
}
}

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Xml;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class BaseListener
{
public MainWindow caller;
private string FormattedXml(string xmlString)
{
try
{
XDocument xdoc = XDocument.Parse(xmlString);
StringBuilder sb = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(sb))
using (XmlWriter xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings
{
Indent = true, // 设置缩进
IndentChars = " ", // 设置缩进字符
NewLineChars = "\r\n", // 设置换行字符
NewLineHandling = NewLineHandling.Replace, // 替换换行符
Encoding = Encoding.UTF8 // 设置编码
}))
{
xdoc.WriteTo(xmlWriter);
}
return sb.ToString();
}
catch (Exception ex)
{
return "xml消息格式化错误" + ex.Message;
}
}
public void Save2Log(string tag, string message)
{
string finalStr = FormattedXml(message);
MyLog.Info(tag + "消息:" + Environment.NewLine + finalStr);
System.Threading.Thread.Sleep(100);
if (caller != null)
{
caller.AppendMessage(tag + "消息↓:" + Environment.NewLine + finalStr);
}
}
}
}

@ -0,0 +1,118 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class CD0050Listener : BaseListener
{
public CD0050Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[CD0050]", message);
// 解析数据
ParseMessage(message);
}
private async void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var visitSqNo = xdoc
.Descendants(ns + "componentOf1")
.Descendants(ns + "encounter")
.Descendants(ns + "id")
.Descendants(ns + "item")
.FirstOrDefault()
?.Attribute("extension")?.Value;
var orderNo = xdoc
.Descendants(ns + "observationRequest")
.Descendants(ns + "id")
.Descendants(ns + "item")
.FirstOrDefault()
?.Attribute("extension")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
string sql_exits = "select id from s_list where entrust_id = @entrust_id and is_del=0 and is_nullify=0";
dc.Add("entrust_id", orderNo);
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count == 1)
{
// 存在,执行更新操作 is_nullify = 1
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_list SET is_nullify = 1 WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
MyLog.Info($"Mq050,医嘱已更新 is_nullify=1, OrderNO: {orderNo}");
await Tools.NoticeEntrustChange(orderNo);
}
else
{
MyLog.Info($"Mq050,医嘱更新失败, OrderNO: {orderNo}");
}
}
else
{
MyLog.Info($"Mq050,医嘱不存在,OrderNO:{orderNo}");
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[CD0050]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[CD0050]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,480 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class CI0047Listener : BaseListener
{
public CI0047Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[CI0047]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
// 1 获取 item[@root='2.16.156.10011.2.5.1.4']
var cardNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.2.5.1.4")
?.Attribute("extension")?.Value;
// 2 获取 patientPerson/name/item/part 的 value
var patientName = xdoc
.Descendants(ns + "patient")
.Descendants(ns + "patientPerson")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 3 获取 administrativeGenderCode/displayName 的 value
var patientGenderName = xdoc
.Descendants(ns + "administrativeGenderCode")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 4.循环component2获取termCode
var termCodes = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "observationRequest")
.Descendants(ns + "code")
.FirstOrDefault()
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("code"))
.ToList();
// 循环获取的termCode
foreach (var termCode in termCodes)
{
}
// 5 获取 controlActProcess/subject/observationRequest/component2/observationRequest/code/displayName
// 循环component2获取termNames
var termNames = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "observationRequest")
.Descendants(ns + "code")
.Descendants(ns + "displayName")
.FirstOrDefault()
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("value"))
.ToList();
// 循环获取的termName
foreach (var termName in termNames)
{
}
// 6 获取 code[@codeSystem='2.16.156.10011.0.9.2.3.2.95']/displayName
var chargeStatusName = xdoc
.Descendants(ns + "code")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.95")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 7 获取 representedOrganization/name/item/part
var orderDeptName = xdoc
.Descendants(ns + "representedOrganization")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 8 获取 observationRequest/author/time
var requestDate = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "author")
.Descendants(ns + "time")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 9 获取 componentOf1/encounter/subject/patient/patientPerson/birthTime
var patientBirthDate = xdoc
.Descendants(ns + "patientPerson")
.Descendants(ns + "birthTime")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 10 获取 controlActProcess/subject/observationRequest/author/assignedEntity/assignedPerson/name/item/part
var orderPersonName = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "author")
.Descendants(ns + "assignedEntity")
.Descendants(ns + "assignedPerson")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 11 获取 componentOf1/encounter/code[code]
var visitTypeCode = xdoc
.Descendants(ns + "componentOf1")
.Descendants(ns + "encounter")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("code")?.Value;
// 12 获取 patientPerson/telecom/item
var mobile = xdoc
.Descendants(ns + "patientPerson")
.Descendants(ns + "telecom")
.Descendants(ns + "item")
.FirstOrDefault()
?.Attribute("value")?.Value;
// controlActProcess/subject/observationRequest/
// component2/observationRequest/
// location/serviceDeliveryLocation/serviceProviderOrganization/name/item/part
// 13 循环获取 serviceProviderOrganization/name/item/part
//var execDeptName1 = xdoc
// .Descendants(ns + "item")
// .FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.28")
// ?.Ancestors(ns + "observationRequest")
// .Descendants(ns + "location")
// .Descendants(ns + "serviceDeliveryLocation")
// .Descendants(ns + "serviceProviderOrganization")
// .Descendants(ns + "name")
// .Descendants(ns + "item")
// .Descendants(ns + "part")
// .FirstOrDefault()
// ?.Attribute("value")?.Value;
var execDeptNames = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "observationRequest")
.Descendants(ns + "location")
.Descendants(ns + "serviceDeliveryLocation")
.Descendants(ns + "serviceProviderOrganization")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("value"))
.ToList();
// 循环获取的 execDeptName
foreach (var execDeptName in execDeptNames)
{
}
// 14 循环component2/observationRequest/id/item[@root='2.16.156.10011.1.28']
//var orderNo = xdoc
// .Descendants(ns + "item")
// .FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.28")
// ?.Attribute("extension")?.Value;
var orderNos = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.28")
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("extension"))
.ToList();
// 循环获取的orderNo
foreach (var orderNo in orderNos)
{
}
// 15 获取 item[@root='2.16.156.10011.2.5.1.9']
var visitSqNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.2.5.1.9")
?.Attribute("extension")?.Value;
// 16 获取 serviceDeliveryLocation/serviceProviderOrganization/id/item
// controlActProcess/subject/observationRequest/component2/
// observationRequest/location/serviceDeliveryLocation/serviceProviderOrganization/id/item
//var execDeptCode = xdoc
// .Descendants(ns + "item")
// .FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.26")
// ?.Attribute("extension")?.Value;
var execDeptCodes = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "observationRequest")
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "observationRequest")
.Descendants(ns + "location")
.Descendants(ns + "serviceDeliveryLocation")
.Descendants(ns + "serviceProviderOrganization")
.Descendants(ns + "id")
.Descendants(ns + "item")
.FirstOrDefault()
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("extension"))
.ToList();
// 循环获取的execDeptCode
foreach (var execDeptCode in execDeptCodes)
{
}
// 17 获取 item[@root='2.16.156.10011.0.9.1.64']../../name/item/part
var areaName = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.1.64")
?.Ancestors(ns + "location")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 18 获取 asOrganizationPartOf/wholeOrganization/id/item
var areaCode = xdoc
.Descendants(ns + "wholeOrganization")
.Descendants(ns + "id")
.Descendants(ns + "item")
.FirstOrDefault()
?.Attribute("extension")?.Value;
// 19 获取 serviceDeliveryLocation/location/name/item/part
var bedName = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.22")
?.Ancestors(ns + "location")
.Descendants(ns + "name")
.Descendants(ns + "item")
.Descendants(ns + "part")
.FirstOrDefault()
?.Attribute("value")?.Value;
// 20 获取 serviceDeliveryLocation/location/id/item
var bedNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.22")
?.Attribute("extension")?.Value;
// 21 获取 subject/observationRequest/id/item
var requestNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.24")
?.Attribute("extension")?.Value;
//22 获取身份证
var idCardNumber = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.3")
?.Attribute("extension")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
// 循环获取的orderNo分别入库
for (int i = 0; i < orderNos.Count; i++)
{
dc.Clear();
dc.Add("entrust_id", orderNos[i]);
//查询库里是否存在该检医嘱
string sql_exits = "select id from s_list where entrust_id = @entrust_id";
if (db.ExecQuery(sql_exits, dc).Rows.Count == 0)
{
//不存在则执行插入操作
DateTime dateTime;
bool success = DateTime.TryParseExact(
requestDate,
"yyyyMMddHHmmss",
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out dateTime);
var entrust_datePart = "";
var entrust_timePart = "";
if (success)
{
// 提取格式化后的日期和时间
entrust_datePart = dateTime.ToString("yyyy-MM-dd");
entrust_timePart = dateTime.ToString("HH:mm:ss");
}
//生日
DateTime birthdayDate;
bool birthdaySuccess = DateTime.TryParseExact(
patientBirthDate,
"yyyyMMdd",
CultureInfo.InvariantCulture,
DateTimeStyles.None,
out birthdayDate);
var birthday = "";
if (success)
{
birthday = birthdayDate.ToString("yyyy-MM-dd");
}
//患者类型
Dictionary<string, int> mapping = new Dictionary<string, int>
{
{ "03", 0 }, // 住院
{ "01", 1 }, // 门诊
{ "02", 2 }, // 急诊
{ "04", 3 } // 体检
};
int patientType = mapping.TryGetValue(visitTypeCode, out int value) ? value : 9;
string insertSql = @"
INSERT INTO s_list (
list_status,
reg_num,
user_name,
user_sex,
entrust_code,
entrust,
is_pay,
reservation_department,
entrust_date,
entrust_time,
user_brithday,
docotr,
patient_type,
user_phone,
implement_department,
entrust_id,
episodeid,
RISRAcceptDeptCode,
warddesc,
wardcode,
bedname,
bedno,
app_num,
idCardNumber
) VALUES (
@list_status,
@reg_num,
@user_name,
@user_sex,
@entrust_code,
@entrust,
@is_pay,
@reservation_department,
@entrust_date,
@entrust_time,
@user_brithday,
@docotr,
@patient_type,
@user_phone,
@implement_department,
@entrust_id,
@episodeid,
@RISRAcceptDeptCode,
@warddesc,
@wardcode,
@bedname,
@bedno,
@app_num,
@idCardNumber
)";
dc.Clear();
dc.Add("list_status", 0); // int
dc.Add("reg_num", cardNo);
dc.Add("user_name", patientName);
// dc.Add("user_sex", patientGenderName == "男" ? 1 : 2); // int
dc.Add("user_sex", patientGenderName?.Contains("男") == true ? 1 : 2);
dc.Add("entrust_code", termCodes[i]);
dc.Add("entrust", termNames[i]);
dc.Add("is_pay", chargeStatusName == "已收费" ? 1 : 0); // int
dc.Add("reservation_department", orderDeptName);
dc.Add("entrust_date", entrust_datePart);
dc.Add("entrust_time", entrust_timePart);
dc.Add("user_brithday", birthday);
dc.Add("docotr", orderPersonName);
dc.Add("patient_type", patientType);
dc.Add("user_phone", mobile);
dc.Add("implement_department", execDeptNames[i]);
dc.Add("entrust_id", orderNos[i]);
dc.Add("episodeid", visitSqNo);
dc.Add("RISRAcceptDeptCode", execDeptCodes[i]);
dc.Add("warddesc", areaName);
dc.Add("wardcode", areaCode);
dc.Add("bedname", bedName);
dc.Add("bedno", bedNo);
dc.Add("app_num", requestNo);
dc.Add("idCardNumber", idCardNumber);
int ins = db.ExecSQL(insertSql, dc);
if (ins > 0)
{
// 执行成功了,可以做其他业务处理
MyLog.Info($"0047消息已入库成功,orderNo:{orderNos[i]}");
}
else
{
MyLog.Info($"0047消息入库失败{ins},orderNo:{orderNos[i]}");
}
}
else
{
MyLog.Info("数据库已存在该检医嘱--" + orderNos[i]);
}
}
}
catch (Exception e)
{
MyLog.Info("解析[CI0047]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,151 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class CI0054Listener : BaseListener
{
public CI0054Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[CI0054]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private async void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var visitSqNo = xdoc
.Descendants(ns + "componentOf1")
.Descendants(ns + "encounter")
.Descendants(ns + "id")
.Descendants(ns + "item")
.FirstOrDefault()
?.Attribute("extension")?.Value;
// 循环component2
var extensions = xdoc
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "item")
.FirstOrDefault(item => (string)item.Attribute("root") == "2.16.156.10011.1.28")
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("extension"))
.ToList();
var codes = xdoc
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "code")
.FirstOrDefault(item => (string)item.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.88")
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("code"))
.ToList();
// 循环获取的itemCode
foreach (var itemCode in codes)
{
}
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
// 循环获取的orderNo
foreach (var orderNo in extensions)
{
dc.Clear();
dc.Add("entrust_id", orderNo);
string sql_exits = "select id from s_list where entrust_id = @entrust_id and is_del=0 and is_nullify=0";
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count == 1)
{
// 存在,执行更新操作 is_pay = 1
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_list SET is_pay = 1 WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
MyLog.Info($"Mq054申请单缴费,医嘱已更新 is_pay=1, OrderNO: {orderNo}");
await Tools.NoticeEntrustChange(orderNo);
}
else
{
MyLog.Info($"Mq054申请单缴费,医嘱更新失败, OrderNO: {orderNo}");
}
}
else
{
MyLog.Info($"Mq054申请单缴费,医嘱不存在,OrderNO:{orderNo}");
}
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[CI0054]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[CI0054]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,148 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class CI0055Listener : BaseListener
{
public CI0055Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[CI0055]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private async void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var requestNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.24")
?.Attribute("extension")?.Value;
// 循环component2
var extensions = xdoc
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "item")
.FirstOrDefault(item => (string)item.Attribute("root") == "2.16.156.10011.1.28")
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("extension"))
.ToList();
var codes = xdoc
.Descendants(ns + "component2")
.Select(component =>
component
.Descendants(ns + "code")
.FirstOrDefault(item => (string)item.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.88")
)
.Where(item => item != null)
.Select(item => (string)item.Attribute("code"))
.ToList();
// 循环获取的itemCode
foreach (var itemCode in codes)
{
}
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
// 循环获取的orderNo
foreach (var orderNo in extensions)
{
dc.Clear();
dc.Add("entrust_id", orderNo);
string sql_exits = "select id from s_list where entrust_id = @entrust_id and is_del=0 and is_nullify=0";
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count == 1)
{
// 存在,执行更新操作 is_pay = 0
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_list SET is_pay = 0 WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
MyLog.Info($"Mq055申请单退费,医嘱已更新 is_pay=0, OrderNO: {orderNo}");
await Tools.NoticeEntrustChange(orderNo);
}
else
{
MyLog.Info($"Mq055申请单退费,医嘱更新失败, OrderNO: {orderNo}");
}
}
else
{
MyLog.Info($"Mq055申请单退费,医嘱不存在,OrderNO:{orderNo}");
}
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[CI0055]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[CI0055]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,141 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class MI0150Listener : BaseListener
{
public MI0150Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[MI0150]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var itemTypeCode = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.144")
?.Attribute("code")?.Value;
var itemTypeName = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.144")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
var itemGrade = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.262")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
var itemCode = xdoc
.Descendants(ns + "billableClinicalService")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("code")?.Value;
var itemName = xdoc
.Descendants(ns + "billableClinicalService")
.Descendants(ns + "code")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
string sql_exits = "select id from s_check_item where item_code = @item_code";
dc.Add("item_code", itemCode);
if (db.ExecQuery(sql_exits, dc).Rows.Count == 0)
{
//不存在则执行插入操作
string insert = @"INSERT INTO s_check_item(sheetType,item_code, item_desc, item_name,reservation_method,limosis,check_time)
VALUES (@sheetType, @item_code, @item_desc, @item_name,@reservation_method,@limosis,@check_time)";
dc.Clear();
dc.Add("sheetType", itemGrade);
dc.Add("item_code", itemCode);
dc.Add("item_desc", itemName);
dc.Add("item_name", itemName);
dc.Add("reservation_method", "0,1,2,3,4");
dc.Add("limosis", 0);
dc.Add("check_time", 0);
int ins = db.ExecSQL(insert, dc);
if (ins > 0)
{
// 执行成功了,可以做其他业务处理
MyLog.Info("消息已入库成功");
}
else
{
MyLog.Info($"消息入库失败:{ins}");
}
MyLog.Info("itemCode:" + itemCode);
return;
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[MI0150]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[MI0150]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
internal class MI0164Listener : BaseListener
{
public MI0164Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[MI0164]", message);
ParseMessage(message);
}
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var termCode = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.2.3.2.101")
?.Attribute("extension")?.Value;
var termName = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.2.3.2.101")
?.Attribute("identifierName")?.Value;
var requestTypeCode = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("code") != null && (string)x.Attribute("codeSystemName") == "申请单类型代码表")
?.Attribute("code")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
string sql_exits = "select id from s_check_item where item_code = @item_code";
dc.Add("item_code", termCode);
if (db.ExecQuery(sql_exits, dc).Rows.Count == 0)
{
//不存在则执行插入操作
string insert = @"INSERT INTO s_check_item(sheetType,item_code, item_desc, item_name,reservation_method,limosis,check_time)
VALUES (@sheetType, @item_code, @item_desc, @item_name,@reservation_method,@limosis,@check_time)";
dc.Clear();
dc.Add("sheetType", requestTypeCode);
dc.Add("item_code", termCode);
dc.Add("item_desc", termName);
dc.Add("item_name", termName);
dc.Add("reservation_method", "0,1,2,3,4");
dc.Add("limosis", 0);
dc.Add("check_time", 0);
int ins = db.ExecSQL(insert, dc);
if (ins > 0)
{
// 执行成功了,可以做其他业务处理
MyLog.Info("消息已入库成功");
}
else
{
MyLog.Info($"消息入库失败:{ins}");
}
MyLog.Info("itemCode:" + termCode);
return;
}
else {
MyLog.Info($"Mq164项目已经存在无需入库, itemCode: {termCode}");
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[MI0150]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[MI0164]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,157 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class MU0151Listener : BaseListener
{
public MU0151Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[MU0151]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var itemTypCode = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.144")
?.Attribute("code")?.Value;
var itemTypeName = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.144")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
var itemGrade = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("codeSystem") == "2.16.156.10011.0.9.2.3.2.262")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
var itemCode = xdoc
.Descendants(ns + "billableClinicalService")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("code")?.Value;
var itemName = xdoc
.Descendants(ns + "billableClinicalService")
.Descendants(ns + "code")
.Descendants(ns + "displayName")
.FirstOrDefault()
?.Attribute("value")?.Value;
var isEffective = xdoc
.Descendants(ns + "billableClinicalService")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("validTimeLow")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
dc.Add("itemCode", itemCode);
string sql_exits = "select id from s_check_item where item_code = @itemCode";
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count >= 1)
{
var status = "1";
if (isEffective != "1")
{
status = "0";
}
// 存在,执行更新操作
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_check_item SET item_name = @itemName,item_desc = @itemName ,status=@status WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("itemName", itemName);
updateParams.Add("status", status);
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
// AppendMessage($"Mq151变更检查项目,项目已更新, itemCode: {itemCode}");
MyLog.Info($"Mq151变更检查项目,项目已更新, itemCode: {itemCode}");
}
else
{
// AppendMessage($"Mq151变更检查项目,项目更新失败, itemCode: {itemCode}");
MyLog.Info($"Mq151变更检查项目,项目更新失败, itemCode: {itemCode}");
}
}
else
{
// AppendMessage($"Mq151变更检查项目,项目不存在,itemCode:{itemCode}");
MyLog.Info($"Mq151变更检查项目,项目不存在,itemCode:{itemCode}");
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[MU0151]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[MU0151]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
internal class MU0165Listener : BaseListener
{
public MU0165Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[MU0165]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var termCode = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.2.3.2.101")
?.Attribute("extension")?.Value;
var termName = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.2.3.2.101")
?.Attribute("identifierName")?.Value;
var isEffective = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.0.9.2.3.2.101")
?.Attribute("validTimeLow")?.Value;
var requestTypeCode = xdoc
.Descendants(ns + "translation")
.FirstOrDefault(x => (string)x.Attribute("code") != null && (string)x.Attribute("codeSystemName") == "申请单类型代码表")
?.Attribute("code")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
dc.Add("itemCode", termCode);
string sql_exits = "select id from s_check_item where item_code = @itemCode";
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count >= 1)
{
var status = "1";
if (isEffective != "1")
{
status = "0";
}
// 存在,执行更新操作
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_check_item SET item_name = @itemName,item_desc = @itemName ,status=@status WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("itemName", termName);
updateParams.Add("status", status);
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
// AppendMessage($"Mq151变更检查项目,项目已更新, itemCode: {itemCode}");
MyLog.Info($"Mq165变更检查项目,项目已更新, itemCode: {termCode}");
}
else
{
// AppendMessage($"Mq151变更检查项目,项目更新失败, itemCode: {itemCode}");
MyLog.Info($"Mq165变更检查项目,项目更新失败, itemCode: {termCode}");
}
}
else
{
// AppendMessage($"Mq151变更检查项目,项目不存在,itemCode:{itemCode}");
MyLog.Info($"Mq165变更检查项目,项目不存在,进行添加,itemCode:{termCode}");
//不存在则执行插入操作
string insert = @"INSERT INTO s_check_item(sheetType,item_code, item_desc, item_name,reservation_method,limosis,check_time)
VALUES (@sheetType, @item_code, @item_desc, @item_name,@reservation_method,@limosis,@check_time)";
dc.Clear();
dc.Add("sheetType", requestTypeCode);
dc.Add("item_code", termCode);
dc.Add("item_desc", termName);
dc.Add("item_name", termName);
dc.Add("reservation_method", "0,1,2,3,4");
dc.Add("limosis", 0);
dc.Add("check_time", 0);
int ins = db.ExecSQL(insert, dc);
if (ins > 0)
{
// 执行成功了,可以做其他业务处理
MyLog.Info($"165不存在后新增检查项目消息已入库成功itemCode:{termCode}");
}
else
{
MyLog.Info($"165不存在后新增检查项目消息入库失败{ins}");
}
MyLog.Info("itemCode:" + termCode);
return;
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[MU0151]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[MU0165]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,121 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class OD0084Listener : BaseListener
{
public OD0084Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[OD0084]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
var orderNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.28")
?.Attribute("extension")?.Value;
var cardNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.2.5.1.4")
?.Attribute("extension")?.Value;
// controlActProcess/subject/placerGroup/code[code]
var itemCode = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "placerGroup")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("code")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
string sql_exits = "select id from s_list where entrust_id = @entrust_id and is_del=0 and is_nullify=0";
dc.Add("entrust_id", orderNo);
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count == 1)
{
// 存在,执行更新操作 is_pay = 0
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_list SET is_pay = 0 WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
MyLog.Info($"Mq0084,医嘱已更新 is_pay=0, OrderNO: {orderNo}");
}
else
{
MyLog.Info($"Mq0084,医嘱更新失败, OrderNO: {orderNo}");
}
}
else
{
MyLog.Info($"Mq0084,医嘱不存在,OrderNO:{orderNo}");
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[OD0084]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[OD0084]消息异常 : " + e.Message);
}
}
}
}

@ -0,0 +1,132 @@
using MyHosListener;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace MyHosListener.common.listener
{
public class OI0083Listener : BaseListener
{
public OI0083Listener(MainWindow caller)
{
this.caller = caller;
}
public void OnMessage(string message)
{
Save2Log("[OI0083]", message);
ParseMessage(message);
}
/// <summary>
/// 解析数据
/// </summary>
/// <param name="message"></param>
private void ParseMessage(string message)
{
try
{
XDocument xdoc = XDocument.Parse(message);
// 获取默认命名空间
XNamespace ns = "urn:hl7-org:v3";
// 消息ID
var messageId = xdoc.Descendants(ns + "id")
.FirstOrDefault() // 括号内可以加判定条件
?.Attribute("extension")?.Value;
// 提取医嘱相关 ID
var orderNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.1.28")
?.Attribute("extension")?.Value;
var cardNo = xdoc
.Descendants(ns + "item")
.FirstOrDefault(x => (string)x.Attribute("root") == "2.16.156.10011.2.5.1.4")
?.Attribute("extension")?.Value;
//componentOf1/encounter/id/item
var visitSqNo = xdoc
.Descendants(ns + "componentOf1")
.Descendants(ns + "encounter")
.Descendants(ns + "id")
.Descendants (ns + "item")
.FirstOrDefault()
?.Attribute("extension")?.Value;
// controlActProcess/subject/placerGroup/code[code]
var itemCode = xdoc
.Descendants(ns + "controlActProcess")
.Descendants(ns + "subject")
.Descendants(ns + "placerGroup")
.Descendants(ns + "code")
.FirstOrDefault()
?.Attribute("code")?.Value;
DBtools db = new DBtools();
Dictionary<string, object> dc = new Dictionary<string, object>();
string sql_exits = "select id from s_list where entrust_id = @entrust_id and is_del=0 and is_nullify=0";
dc.Add("entrust_id", orderNo);
DataTable result = db.ExecQuery(sql_exits, dc);
if (result.Rows.Count == 1)
{
// 存在,执行更新操作 is_pay = 1
string id = result.Rows[0]["id"].ToString(); // 获取要更新的记录ID
string sql_update = "UPDATE s_list SET is_pay = 1 WHERE id = @id";
Dictionary<string, object> updateParams = new Dictionary<string, object>();
updateParams.Add("id", id);
int rowsAffected = db.ExecSQL(sql_update, updateParams);
if (rowsAffected > 0)
{
MyLog.Info($"Mq0083,医嘱已更新 is_pay=1, OrderNO: {orderNo}");
}
else
{
MyLog.Info($"Mq0083,医嘱更新失败, OrderNO: {orderNo}");
}
}
else
{
MyLog.Info($"Mq0083,医嘱不存在,OrderNO:{orderNo}");
}
// 将解析出来的数据入库
//DBtools db = new DBtools();
//Dictionary<string, object> dc = new Dictionary<string, object>();
//// 自己构造SQL语句即可
//string sql_exits = "select id from user_info where user_num = @user_num and user_card_num=@user_card_num";
//dc.Add("user_num", "1111");
//dc.Add("user_card_num", "12345");
//if (db.ExecQuery(sql_exits, dc).Rows.Count == 1)
//{
// // 执行成功了,可以做其他业务处理
// return;
//}
//string sql_insert = @"INSERT INTO user_info(hosid, user_name, user_sex, addtime, unbind) VALUES (@hosid, @user_name, @user_sex, @addtime, @unbind)";
//dc.Clear();
//dc.Add("hosid", 1);
//dc.Add("user_name", "testname");
//dc.Add("user_sex", 1);
//dc.Add("addtime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//dc.Add("unbind", false);
//if (db.ExecSQL(sql_insert, dc) == 0)
//{
// // 执行成功了,可以做其他业务处理
// MyLog.Info("[OI0083]消息已入库成功--消息ID" + messageId);
//}
}
catch (Exception e)
{
MyLog.Info("解析[OI0083]消息异常 : " + e.Message);
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<appender name="InfoAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="logs\\log_" />
<param name="AppendToFile" value="true" />
<param name="MaximumFileSize" value="10MB" />
<param name="MaxSizeRollBackups" value="20" />
<param name="StaticLogFileName" value="false" />
<param name="DatePattern" value="yyyyMMdd&quot;.log&quot;" />
<param name="RollingStyle" value="Composite" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss} -- %message%newline" />
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="InfoAppender" />
</root>
</log4net>

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="3.1.0" targetFramework="net472" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="9.0.6" targetFramework="net472" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="9.0.6" targetFramework="net472" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="9.0.6" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.4" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.Diagnostics.DiagnosticSource" version="9.0.6" targetFramework="net472" />
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
</packages>
Loading…
Cancel
Save