コード例 #1
0
ファイル: ClientGate.cs プロジェクト: S031/MetaStack
        public static bool Logon(ConnectorOptions connectorOptions)
        {
            if (_connector != null && _connector.Connected)
            {
                return(true);
            }

            string userName      = $@"{Environment.UserDomainName}\{Environment.UserName}";
            bool   isPrompt      = false;
            var    sInfo         = CredentialManager.ReadCredential(_appName);
            bool   forcePassword = connectorOptions.ForcePassword || sInfo == null || sInfo.Password.IsEmpty() || !connectorOptions.SavePassword;
            string password;

            if (forcePassword)
            {
                password = connectorOptions.SecureRequest(userName);
                if (password.IsEmpty())
                {
                    return(false);
                }
                isPrompt = true;
            }
            else
            {
                password = sInfo.Password;
            }

            _connector = TCPConnector.Create(connectorOptions);
            _connector.Connect(userName, password);
            if (isPrompt && connectorOptions.SavePassword)
            {
                CredentialManager.WriteCredential(_appName, userName, password);
            }
            return(true);
        }
コード例 #2
0
 private void TCPConnectorConnectTest()
 {
     using (FileLog l = new FileLog("TCPConnectorConnectTest", new FileLogSettings()
     {
         DateFolderMask = "yyyy-MM-dd"
     }))
         using (TCPConnector connector = TCPConnector.Create())
         {
             connector.Connect("Test", "@TestPassword");
             l.Debug("Start performance test for logins");
             int i = 0;
             for (i = 0; i < 1000; i++)
             {
                 var dr = connector.Execute("Sys.Select", new DataPackage(new string[] { "ParamName", "ParamValue" },
                                                                          new object[] { "_connectionName", "banklocal" }));
                 //string s = (string)dr["ObjectSchema"];
             }
             l.Debug($"End performance test for {i} logins");
         }
 }