提交 e7e3cd0b 编写于 作者: cdy816's avatar cdy816

Proxy 服务端口可配置

上级 775d260e
<Application x:Class="DBGrpcApiDemo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DBGrpcApiDemo"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace DBGrpcApiDemo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
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)
)]
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Proxy\DBGrpcApi.Client\DBGrpcApi.Client.csproj" />
</ItemGroup>
</Project>
\ No newline at end of file
<Window x:Class="DBGrpcApiDemo.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:DBGrpcApiDemo"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
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 DBGrpcApiDemo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
......@@ -83,7 +83,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBRuntimeTests", "RunTime\D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBGrpcApi", "Proxy\DBGrpcApi\DBGrpcApi.csproj", "{A0FF67D7-D874-4CD5-A6B2-ADC3DC6E09C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBGrpcApi.Client", "Proxy\DBGrpcApi.Client\DBGrpcApi.Client.csproj", "{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DBGrpcApi.Client", "Proxy\DBGrpcApi.Client\DBGrpcApi.Client.csproj", "{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DBGrpcApiDemo", "Example\Consumer\DBGrpcApiDemo\DBGrpcApiDemo.csproj", "{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......@@ -215,6 +217,10 @@ Global
{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE}.Release|Any CPU.Build.0 = Release|Any CPU
{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......@@ -253,6 +259,7 @@ Global
{8E64B132-719D-4DBF-925C-F33B42A0B29E} = {1A69E6A7-33B3-4DAF-9D9D-FD7CD474FFD3}
{A0FF67D7-D874-4CD5-A6B2-ADC3DC6E09C1} = {15D0D528-DC48-4E43-A8E8-3EFEC938951B}
{F9A34AAF-C915-45D4-82A0-C85FE8E77BBE} = {15D0D528-DC48-4E43-A8E8-3EFEC938951B}
{A8D3561D-EEEE-47DD-A47F-0F37BDA7350D} = {723CADA9-2D52-4F05-9661-1655F8182084}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {577CCEC3-4CDB-458A-B93D-F8579C2C3D8F}
......
<?xml version="1.0" encoding="utf-8" ?>
<Config>
<Config ServerPort="14333">
<ProxyClient Ip="192.168.0.33" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" IsUseStandardHisDataServer="false"/>
</Config>
\ No newline at end of file
......@@ -2,6 +2,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon>mrdbg.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
......@@ -29,4 +30,8 @@
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).exe&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).runtimeconfig.json&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)zh-CN&quot; copy &quot;$(TargetDir)zh-CN\*.dll&quot; &quot;$(SolutionDir)\Output\zh-CN&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)Config\*.cfg&quot; &quot;$(SolutionDir)\Output\Config&quot; /y" />
</Target>
</Project>
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
......@@ -10,17 +11,40 @@ namespace DBGrpcApi
{
public class Program
{
static int Port = 14333;
private static int ReadServerPort()
{
try
{
string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(Program).Assembly.Location), "Config", "DBGrpcApi.cfg");
if (System.IO.File.Exists(spath))
{
XElement xx = XElement.Load(spath);
return int.Parse(xx.Attribute("ServerPort")?.Value);
}
}
catch
{
}
return 14333;
}
public static void Main(string[] args)
{
Port = ReadServerPort();
CreateHostBuilder(args).Build().Run();
}
// Additional configuration is required to successfully run gRPC on macOS.
// For instructions on how to configure Kestrel and gRPC clients on macOS, visit https://go.microsoft.com/fwlink/?linkid=2099682
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("https://0.0.0.0:"+ Port);
webBuilder.UseStartup<Startup>();
});
}
......
{
{
"profiles": {
"DBGrpcApi": {
"commandName": "Project",
"launchBrowser": false,
"applicationUrl": "https://localhost:5001",
"commandName": "Executable",
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBGrpcApi.exe",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "https://localhost:5001"
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<Config>
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" IsUseStandardHisDataServer="false" ServerPort="14332"/>
<Config ServerPort="14332">
<ProxyClient Ip="127.0.0.1" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" IsUseStandardHisDataServer="false" />
</Config>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
......@@ -35,8 +35,14 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Config\DBHighApi.cfg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).exe&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).runtimeconfig.json&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)zh-CN&quot; copy &quot;$(TargetDir)zh-CN\*.dll&quot; &quot;$(SolutionDir)\Output\zh-CN&quot; /y" />
<Exec Command="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).exe&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)$(TargetName).runtimeconfig.json&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).XML&quot; copy &quot;$(TargetDir)$(TargetName).XML&quot; &quot;$(SolutionDir)\Output\Xml&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)$(TargetName).pdb&quot; copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)\Output&quot; /y&#xD;&#xA;if exist &quot;$(TargetDir)zh-CN&quot; copy &quot;$(TargetDir)zh-CN\*.dll&quot; &quot;$(SolutionDir)\Output\zh-CN&quot; /y&#xD;&#xA;copy &quot;$(TargetDir)Config\*.cfg&quot; &quot;$(SolutionDir)\Output\Config&quot; /y" />
</Target>
</Project>
......@@ -2,12 +2,33 @@
using DBHighApi.Api;
using DBRuntime.Proxy;
using System;
using System.Xml.Linq;
namespace DBHighApi
{
class Program
{
private static bool mIsClosed = false;
private static int ReadServerPort()
{
try
{
string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(Program).Assembly.Location), "Config", "DBHighApi.cfg");
if (System.IO.File.Exists(spath))
{
XElement xx = XElement.Load(spath);
return int.Parse(xx.Attribute("ServerPort")?.Value);
}
}
catch
{
}
return 14332;
}
static void Main(string[] args)
{
Console.CancelKeyPress += Console_CancelKeyPress;
......@@ -39,7 +60,6 @@ namespace DBHighApi
DatabaseRunner.Manager.Load();
DatabaseRunner.Manager.Start();
DatabaseRunner.Manager.IsReadyEvent += Manager_IsReadyEvent;
}
......@@ -52,8 +72,11 @@ namespace DBHighApi
{
if (value)
{
Cdy.Tag.LoggerService.Service.Info("DBHighAPI", string.Format(Res.Get("serverstartmsg"), 14332));
DataService.Service.Start("127.0.0.1", 14332);
int port = ReadServerPort();
Cdy.Tag.LoggerService.Service.Info("DBHighAPI", string.Format(Res.Get("serverstartmsg"), port));
DataService.Service.Start("127.0.0.1", port);
}
else
{
......
......@@ -2,7 +2,7 @@
"profiles": {
"DBHighApi": {
"commandName": "Executable",
"executablePath": "D:\\Project\\Galaxy\\Output\\DBHighApi.exe"
"executablePath": "C:\\Users\\cdy81\\source\\repos\\mars\\Output\\DBHighApi.exe"
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<Config>
<Config ServerPort="14331">
<ProxyClient Ip="192.168.0.33" Port="14330" LoginUser="Admin" LoginPassword="Admin" WorkMode="0" PollCircle="1000" IsUseStandardHisDataServer="false"/>
</Config>
\ No newline at end of file
......@@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using Cdy.Tag;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
......@@ -12,8 +13,29 @@ namespace DbInRunWebApi
{
public class Program
{
static int Port = 14331;
private static int ReadServerPort()
{
try
{
string spath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(Program).Assembly.Location), "Config", "DbWebApi.cfg");
if (System.IO.File.Exists(spath))
{
XElement xx = XElement.Load(spath);
return int.Parse(xx.Attribute("ServerPort")?.Value);
}
}
catch
{
}
return 14331;
}
public static void Main(string[] args)
{
Port = ReadServerPort();
WindowConsolHelper.DisbleQuickEditMode();
CreateHostBuilder(args).Build().Run();
}
......@@ -22,6 +44,7 @@ namespace DbInRunWebApi
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("https://0.0.0.0:"+Port);
webBuilder.UseStartup<WebAPIStartup>();
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册