diff --git a/Sic.Framework.sln b/Sic.Framework.sln index 0071ae5..397c9a1 100644 --- a/Sic.Framework.sln +++ b/Sic.Framework.sln @@ -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} diff --git a/UIDebug/UserLoginTester/App.config b/UIDebug/UserLoginTester/App.config new file mode 100644 index 0000000..66bdf0e --- /dev/null +++ b/UIDebug/UserLoginTester/App.config @@ -0,0 +1,113 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UIDebug/UserLoginTester/Program.cs b/UIDebug/UserLoginTester/Program.cs new file mode 100644 index 0000000..974cbf1 --- /dev/null +++ b/UIDebug/UserLoginTester/Program.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/UIDebug/UserLoginTester/Properties/AssemblyInfo.cs b/UIDebug/UserLoginTester/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..75138c8 --- /dev/null +++ b/UIDebug/UserLoginTester/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/UIDebug/UserLoginTester/UserLoginTester.csproj b/UIDebug/UserLoginTester/UserLoginTester.csproj new file mode 100644 index 0000000..5374377 --- /dev/null +++ b/UIDebug/UserLoginTester/UserLoginTester.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + {F52B2BFA-D142-4F23-BD3F-190F4A553B57} + Exe + Properties + UserLoginTester + UserLoginTester + v4.8 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + {efad063f-fa97-42b7-87f8-8279eba30d34} + MECF.Framework.Common + + + + + +