新增UserLoginTester项目用于测试用户登录逻辑。
This commit is contained in:
parent
56bbd2e440
commit
600d1bc5a1
|
@ -26,6 +26,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SicUI", "UIDebug\SicUI\SicU
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MECF.Framework.Common.Test", "UnitTest\MECF.Framework.Common.Test\MECF.Framework.Common.Test.csproj", "{25E5D56D-461A-43A0-BEA8-CF5057356C80}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UserLoginTester", "UIDebug\UserLoginTester\UserLoginTester.csproj", "{F52B2BFA-D142-4F23-BD3F-190F4A553B57}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -112,6 +114,14 @@ Global
|
|||
{25E5D56D-461A-43A0-BEA8-CF5057356C80}.DebugWithoutCopyFiles|Any CPU.Build.0 = Debug|Any CPU
|
||||
{25E5D56D-461A-43A0-BEA8-CF5057356C80}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{25E5D56D-461A-43A0-BEA8-CF5057356C80}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.DebugWithoutCopy|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.DebugWithoutCopy|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.DebugWithoutCopyFiles|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.DebugWithoutCopyFiles|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -120,6 +130,7 @@ Global
|
|||
{F619C5AD-D0D9-4758-A85E-D747156709E6} = {A9774FAC-A372-4CFE-9E84-8CEF067A0442}
|
||||
{290FE38F-45F9-408C-B25B-C899B467E3F8} = {137A5FA1-1B36-4635-81EA-91A74853B86D}
|
||||
{25E5D56D-461A-43A0-BEA8-CF5057356C80} = {A9774FAC-A372-4CFE-9E84-8CEF067A0442}
|
||||
{F52B2BFA-D142-4F23-BD3F-190F4A553B57} = {137A5FA1-1B36-4635-81EA-91A74853B86D}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {BF012408-B30F-40C6-B6F6-B78688F4E4ED}
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" />
|
||||
</configSections>
|
||||
|
||||
<system.diagnostics>
|
||||
<sources>
|
||||
<source name="System.ServiceModel"
|
||||
switchValue="Information, ActivityTracing"
|
||||
propagateActivity="true" >
|
||||
<listeners>
|
||||
<add name="xml"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.ServiceModel.MessageLogging">
|
||||
<listeners>
|
||||
<add name="xml"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="myUserTraceSource"
|
||||
switchValue="Information, ActivityTracing">
|
||||
<listeners>
|
||||
<add name="xml"/>
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<sharedListeners>
|
||||
<add name="xml"
|
||||
type="System.Diagnostics.XmlWriterTraceListener"
|
||||
initializeData="Error.svclog" />
|
||||
</sharedListeners>
|
||||
</system.diagnostics>
|
||||
<system.serviceModel>
|
||||
<bindings>
|
||||
<netTcpBinding>
|
||||
|
||||
<binding name="Aitex_netTcpBinding" maxReceivedMessageSize="2147483647" openTimeout="00:00:05" closeTimeout="00:03:00" receiveTimeout="00:30:00" sendTimeout="00:30:00">
|
||||
<readerQuotas maxDepth="132" maxStringContentLength="1048576" maxArrayLength="163840000" maxBytesPerRead="14096" maxNameTableCharCount="116384" />
|
||||
<security mode="None" />
|
||||
</binding>
|
||||
</netTcpBinding>
|
||||
</bindings>
|
||||
<behaviors>
|
||||
<endpointBehaviors>
|
||||
<behavior name="EndpointBehavior">
|
||||
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
|
||||
</behavior>
|
||||
</endpointBehaviors>
|
||||
</behaviors>
|
||||
<client>
|
||||
<endpoint address="net.tcp://localhost:8751/InvokeService" behaviorConfiguration="EndpointBehavior" binding="netTcpBinding" bindingConfiguration="Aitex_netTcpBinding" contract="MECF.Framework.Common.OperationCenter.IInvokeService" name="Client_IInvokeService" />
|
||||
<endpoint address="net.tcp://localhost:8752/EventService" behaviorConfiguration="EndpointBehavior" binding="netTcpBinding" bindingConfiguration="Aitex_netTcpBinding" contract="Aitex.Core.WCF.Interface.IEventService" name="Client_IEventService" />
|
||||
|
||||
<endpoint address="net.tcp://localhost:8771/QueryDataService" behaviorConfiguration="EndpointBehavior" binding="netTcpBinding" bindingConfiguration="Aitex_netTcpBinding" contract="MECF.Framework.Common.DataCenter.IQueryDataService" name="Client_IQueryDataService" />
|
||||
<endpoint address="net.tcp://localhost:8773/RecipeService" behaviorConfiguration="EndpointBehavior" binding="netTcpBinding" bindingConfiguration="Aitex_netTcpBinding" contract="MECF.Framework.Common.RecipeCenter.IRecipeService" name="Client_IRecipeService" />
|
||||
<endpoint address="net.tcp://localhost:8775/AccountService" behaviorConfiguration="EndpointBehavior" binding="netTcpBinding" bindingConfiguration="Aitex_netTcpBinding" contract="Aitex.Core.Account.IAccountService" name="Client_IAccountService" />
|
||||
|
||||
</client>
|
||||
</system.serviceModel>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
|
||||
</startup>
|
||||
|
||||
|
||||
<log4net>
|
||||
<appender name="xmlFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||
<param name="File" value="Logs\log" />
|
||||
<param name="AppendToFile" value="true" />
|
||||
<param name="RollingStyle" value="Date" />
|
||||
<maxSizeRollBackups value="300" />
|
||||
<param name="StaticLogFileName" value="false" />
|
||||
<datePattern value="yyyyMMdd'.xlog'" />
|
||||
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
|
||||
<locationInfo value="true" />
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="txtFileAppender" type="log4net.Appender.RollingFileAppender">
|
||||
<param name="File" value="Logs\log" />
|
||||
<param name="AppendToFile" value="true" />
|
||||
<param name="RollingStyle" value="Date" />
|
||||
<param name="StaticLogFileName" value="false" />
|
||||
<datePattern value="yyyyMMdd'.log'" />
|
||||
<encoding value="utf-8" />
|
||||
<maxSizeRollBackups value="120" />
|
||||
<layout type="log4net.Layout.PatternLayout,log4net">
|
||||
<param name="ConversionPattern" value="%m%n" />
|
||||
<param name="Header" value=" <=====Sic Begin=====> " />
|
||||
<param name="Footer" value=" <=====Sic End=====> " />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<level value="ALL" />
|
||||
<appender-ref ref="txtFileAppender" />
|
||||
</root>
|
||||
</log4net>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="SciChart.Charting" publicKeyToken="b55dd9efe817e823" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.12982" newVersion="6.0.1.12982" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="SciChart.Core" publicKeyToken="b55dd9efe817e823" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.12982" newVersion="6.0.1.12982" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="SciChart.Data" publicKeyToken="b55dd9efe817e823" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.1.12982" newVersion="6.0.1.12982" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Aitex.Core.Account;
|
||||
using Aitex.Core.RT.Event;
|
||||
using Aitex.Core.WCF;
|
||||
using MECF.Framework.UI.Core.Accounts;
|
||||
|
||||
namespace UserLoginTester
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
private static Credential _loginCred;
|
||||
|
||||
public static async Task Main(string[] args)
|
||||
{
|
||||
EventClient.Instance.OnEvent += Instance_OnEvent;
|
||||
EventClient.Instance.OnDisconnectedWithRT += Instance_OnDisconnectedWithRT;
|
||||
EventClient.Instance.Start();
|
||||
|
||||
var accounts = AccountClient.Instance.Service.GetAccounts();
|
||||
foreach (var acc in accounts)
|
||||
{
|
||||
Console.WriteLine(acc.LoginName);
|
||||
}
|
||||
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine(@"Login by 'admin'...");
|
||||
var retLogin = await AccountClient.Instance.Service.LoginEx("admin", "admin", "0", null);
|
||||
_loginCred = retLogin.Credential;
|
||||
Console.ResetColor();
|
||||
Console.WriteLine($@"Login Result: {retLogin.Result}");
|
||||
|
||||
Console.WriteLine(@"Press any key to exit...");
|
||||
Console.ReadKey();
|
||||
|
||||
AccountClient.Instance.Service.LogoutEx(retLogin.Credential.Token);
|
||||
}
|
||||
|
||||
private static void Instance_OnDisconnectedWithRT()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private static void Instance_OnEvent(EventItem evt)
|
||||
{
|
||||
switch (evt.Type)
|
||||
{
|
||||
case EventType.EventUI_Notify:
|
||||
break;
|
||||
case EventType.Dialog_Nofity:
|
||||
break;
|
||||
case EventType.KickOut_Notify:
|
||||
break;
|
||||
|
||||
case EventType.LoginBySameUser_Notify:
|
||||
if (Guid.TryParse(evt.Description, out var token) && evt.Tag is Credential requestingCred)
|
||||
{
|
||||
if (token == _loginCred.Token)
|
||||
{
|
||||
Console.WriteLine(
|
||||
@"Some users is requesting to login the system, you will be forced to switch to read-only mode, do you agree?");
|
||||
|
||||
__prompt:
|
||||
Console.Write("[Y]es/[N]o: ");
|
||||
var ack = Console.ReadLine();
|
||||
switch (ack)
|
||||
{
|
||||
case "Y":
|
||||
AccountClient.Instance.Service.ConfirmLoginRequest(requestingCred);
|
||||
AccountClient.Instance.Service.LogoutEx(_loginCred.Token);
|
||||
break;
|
||||
case "N":
|
||||
AccountClient.Instance.Service.RejectLoginRequest(requestingCred);
|
||||
break;
|
||||
default:
|
||||
goto __prompt;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case EventType.Sound_Notify:
|
||||
break;
|
||||
case EventType.UIMessage_Notify:
|
||||
//PopUIMessage(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("UserLoginTester")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("UserLoginTester")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("F52B2BFA-D142-4F23-BD3F-190F4A553B57")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,64 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{F52B2BFA-D142-4F23-BD3F-190F4A553B57}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>UserLoginTester</RootNamespace>
|
||||
<AssemblyName>UserLoginTester</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</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>
|
||||
<ItemGroup>
|
||||
<Reference Include="System"/>
|
||||
<Reference Include="System.Core"/>
|
||||
<Reference Include="System.Data"/>
|
||||
<Reference Include="System.Xml"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs"/>
|
||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MECF.Framework.Common\MECF.Framework.Common.csproj">
|
||||
<Project>{efad063f-fa97-42b7-87f8-8279eba30d34}</Project>
|
||||
<Name>MECF.Framework.Common</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue