コード例 #1
0
ファイル: XUserMethod.cs プロジェクト: wiciok/MultiNotes
        /// <exception cref="WebApiClientException"></exception>
        public void Login(string username, string password)
        {
            ILoginApi loginEngine = new LoginApi();

            loginEngine.Login(username, password);
            LoginMessage = loginEngine.Message;
            UserSigned   = loginEngine.User;
            if (IsLoginSuccessful)
            {
                try
                {
                    System.IO.File.WriteAllLines(
                        Constants.AuthenticationRecordFile,
                        new string[]
                    {
                        UserSigned.Id,
                        UserSigned.EmailAddress,
                        UserSigned.PasswordHash,
                        UserSigned.RegistrationTimestamp.ToString()
                    }
                        );
                }
                catch (Exception e)
                {
                    string a = e.Message;
                }
            }
        }
コード例 #2
0
ファイル: XUserMethod.cs プロジェクト: wiciok/MultiNotes
        /// <exception cref="WebApiClientException"></exception>
        public bool Verify(string username, string password)
        {
            ILoginApi loginEngine = new LoginApi();

            loginEngine.Login(username, password, true);
            return(loginEngine.User != null);
        }
コード例 #3
0
        public void LoginViaApi(User user)
        {
            var token = new Token(Driver.Manage().Cookies.GetCookieNamed("PHPSESSID").Value);

            LoginApi.Login(user, token);
            MyDriver.SetCookies(Driver);
            Driver.Url = "https://s2.demo.opensourcecms.com/orangehrm/index.php";
        }
コード例 #4
0
ファイル: XUserMethod.cs プロジェクト: wiciok/MultiNotes
        /// <exception cref="WebApiClientException"></exception>
        private string RegisterAutologin(string username, string password)
        {
            ILoginApi loginEngine = new LoginApi();

            loginEngine.Login(username, password);
            LoginMessage = loginEngine.Message;
            UserSigned   = loginEngine.User;
            return(loginEngine.Token);
        }
コード例 #5
0
        public void Login2(User user)
        {
            var token = LoginApi.Login(user);

            Driver.Manage().Cookies.AddCookie(new Cookie("PHPSESSID", token.PHPSESSID));
            Driver.Manage().Cookies.AddCookie(new Cookie("Loggedin", "True"));
            Driver.Url = "https://s2.demo.opensourcecms.com/orangehrm/index.php";
            MyDriver.WriteAllCookies(Driver);
        }
コード例 #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var user            = this.user.Text;
            var employeeAccount = this.employeeAccount.Text;
            var pwd             = this.pwd.Text;
            var code            = this.code.Text;

            LoginApi.Login(user, employeeAccount, pwd, code);

            Thread.Sleep(1000);

            ViewModels.ViewModelLoctor.CallNumberViewModel.AddTableModels(TableStatusApi.TableQuery <ObservableCollection <TableModel> >());
        }
コード例 #7
0
 void InitializeApi(LoginApi api)
 {
     api.Login(string.Empty, string.Empty).Then(loginResult => {
         if (loginResult)
         {
             Promise.All(
                 Database.Init().Then(DatabaseApiInitialized),
                 NetworkBroadcast.Init().Then(NetworkBroadcastApiInitialized),
                 History.Init().Then(HistoryApiInitialized),
                 Crypto.Init().Then(CryptoApiInitialized)
                 ).Then(( Action )InitializeDone);
         }
         else
         {
             Unity.Console.DebugLog("RequestManager class", Unity.Console.SetRedColor("Login Failed!"), "Login()");
         }
     });
 }
コード例 #8
0
 private void InitializeApi(LoginApi api)
 {
     api.Login(string.Empty, string.Empty).Then(loginResult =>
     {
         if (loginResult)
         {
             Promise.All(
                 Database.Init().Then(DatabaseApiInitialized),
                 NetworkBroadcast.Init().Then(NetworkBroadcastApiInitialized),
                 History.Init().Then(HistoryApiInitialized),
                 Registration.Init().Then(RegistrationApiInitialized)
                 ).Then(InitializeDone).Catch(ex =>
             {
                 CustomTools.Console.DebugError("EchoApiManager class", CustomTools.Console.LogRedColor(ex.Message), "Initialize all api");
             });
         }
         else
         {
             CustomTools.Console.DebugLog("EchoApiManager class", CustomTools.Console.LogRedColor("Login Failed!"), "Login()");
         }
     });
 }
コード例 #9
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            lbErrorMessages.Visible = false;
            if (string.IsNullOrEmpty(txtAccount.Text))
            {
                lbAccountNullError.Visible = true;
                return;
            }
            lbAccountNullError.Visible = false;
            if (string.IsNullOrEmpty(txtPassword.Text))
            {
                lbPasswordNullError.Visible = true;
                return;
            }
            lbPasswordNullError.Visible = false;
            LoginModelSend loginModelSend = new LoginModelSend();

            loginModelSend.AccountId     = txtAccount.Text;
            loginModelSend.LoginPassword = txtPassword.Text;
            LoginModelGet loginModelGet = _loginApi.Login(loginModelSend);

            if (loginModelGet != null)
            {
                LoginedUserInfo.AccountId = loginModelGet.AccountId;
                LoginedUserInfo.Name      = loginModelGet.Nickname;
                LoginedUserInfo.Token     = loginModelGet.Token;
                LoginedUserInfo.Id        = loginModelGet.Id;
                MainForm mainForm = new MainForm();
                mainForm.Show();
                this.Hide();
            }
            else
            {
                lbErrorMessages.Visible = true;
            }
        }
コード例 #10
0
 public void test()
 {
     LoginApi.Login(User.DefaultUser);
 }
コード例 #11
0
        static void Main(string[] args)
        {
            #region 禁止手动关闭窗体
            string fullPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            //根据控制台标题找控制台
            int WINDOW_HANDLER = FindWindow(null, fullPath);
            //找关闭按钮
            IntPtr CLOSE_MENU = GetSystemMenu((IntPtr)WINDOW_HANDLER, IntPtr.Zero);
            int    SC_CLOSE   = 0xF060;
            //关闭按钮禁用
            RemoveMenu(CLOSE_MENU, SC_CLOSE, 0x0);
            #endregion

            #region 连接服务中显示
            Console.CursorVisible = false;
            Thread thread = new Thread(() =>
            {
                while (true)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        Console.SetCursorPosition(0, 0);
                        switch (i)
                        {
                        case 0:
                            Console.Write("Connect Server .  ");
                            break;

                        case 1:
                            Console.Write("Connect Server .. ");
                            break;

                        case 2:
                            Console.Write("Connect Server ...");
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                }
            });
            thread.Start();
            #endregion

            #region 登录服务
            LoginModelSend loginModelSend = new LoginModelSend();
            loginModelSend.AccountId     = "windowsserver";
            loginModelSend.LoginPassword = "******";
            string        messages;
            LoginModelGet loginModelGet = LoginApi.Login(loginModelSend, out messages);
            thread.Abort();
            Console.SetCursorPosition(0, 0);
            Console.CursorVisible = true;
            if (loginModelGet == null)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Connect server failure");
                Console.WriteLine("Error for server :" + messages);
                Console.Write("Enter any key to exit");
                Console.ReadKey();
                return;
            }
            LoginedUserInfo.AccountId = loginModelGet.AccountId;
            LoginedUserInfo.Name      = loginModelGet.Nickname;
            LoginedUserInfo.Token     = loginModelGet.Token;
            LoginedUserInfo.Id        = loginModelGet.Id;
            #endregion
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Connect server successful");
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Start console server");
            LogHelper.info("Start console server");
            ConsoleServer consoleServer = new ConsoleServer();
            consoleServer.RunServer();

            #region 关闭服务
            while (true)
            {
                if (Console.ReadLine().ToLower() == "exit")
                {
                    Console.WriteLine("Sure close server?[Y/N]");
                    if (Console.ReadLine().ToLower() == "y")
                    {
                        LogHelper.info("Close console server");
                        return;
                    }
                }
            }
            #endregion
        }
コード例 #12
0
 public ActionResult <LoginToken> Get([FromQuery] string userName, [FromQuery] string password)
 {
     return(controller.Login(userName, password));
 }