예제 #1
0
        public Task <DokmeeLoginResult> Login(string username, string password, ConnectorType type)
        {
            DokmeeLoginResult result = new DokmeeLoginResult();

            try
            {
                ConnectorVm.IsProgressVisible = Visibility.Visible;
                // initialize connector
                DokmeeApplication dApp = DokmeeApplication.DokmeeDMS;
                if (type == ConnectorType.DMS)
                {
                    ConnectionInfo connInfo = new ConnectionInfo();
                    connInfo.ServerName = ConnectorVm.Server;
                    connInfo.UserID     = "sa";
                    connInfo.Password   = "******";

                    // register connection
                    dApp          = DokmeeApplication.DokmeeDMS;
                    _dmsConnector = new DmsConnector(dApp);
                    _dmsConnector.RegisterConnection <ConnectionInfo>(connInfo);
                }
                else if (type == ConnectorType.WEB)
                {
                    // register connection
                    dApp          = DokmeeApplication.DokmeeWeb;
                    _dmsConnector = new DmsConnector(dApp);
                    _dmsConnector.RegisterConnection <string>(ConnectorVm.HostUrl);
                }
                else if (type == ConnectorType.CLOUD)
                {
                    // register connection
                    dApp          = DokmeeApplication.DokmeeCloud;
                    _dmsConnector = new DmsConnector(dApp);
                    _dmsConnector.RegisterConnection <string>("https://www.dokmeecloud.com");
                }

                var loginResult = _dmsConnector.Login(new LogonInfo {
                    Username = username, Password = password
                });

                result.Cabinets      = loginResult.DokmeeCabinets;
                result.UserInfo      = loginResult.CurrentUser;
                result.CabinetResult = loginResult;
                //_webCache.SetUserDokmeeCabinets(loginResult.CurrentUser.UserName, loginResult.DokmeeCabinets);
                //_webCache.UserInfo = loginResult.CurrentUser;
            }
            catch (Exception ex)
            {
                result.Result  = SignInResult.Fail;
                result.Message = ex.Message;
            }


            return(Task.FromResult(result));
        }
예제 #2
0
        private DokmeeCabinetResult CreateConnector(string username, string password, ConnectorType type)
        {
            username = username ?? _sessionHelperService.Username;
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new InvalideUsernameException("Username is null");
            }
            password = password ?? _sessionHelperService.Password;
            if (string.IsNullOrWhiteSpace(password))
            {
                throw new InvalidePasswordException("Password is null");
            }
            //// initialize connector
            DokmeeApplication dApp = DokmeeApplication.DokmeeDMS;

            if (type == ConnectorType.DMS)
            {
                ConnectionInfo connInfo = new ConnectionInfo
                {
                    ServerName = ConnectorVm.Server,
                    UserID     = "sa",
                    Password   = "******"
                };

                // register connection
                dApp          = DokmeeApplication.DokmeeDMS;
                _dmsConnector = new DmsConnector(dApp);
                _dmsConnector.RegisterConnection <ConnectionInfo>(connInfo);                // =>> this code cause lost session. Why???
            }
            else if (type == ConnectorType.WEB)
            {
                // register connection
                dApp          = DokmeeApplication.DokmeeWeb;
                _dmsConnector = new DmsConnector(dApp);
                _dmsConnector.RegisterConnection <string>(ConnectorVm.HostUrl);
            }
            else if (type == ConnectorType.CLOUD)
            {
                // register connection
                dApp          = DokmeeApplication.DokmeeCloud;
                _dmsConnector = new DmsConnector(dApp);
                _dmsConnector.RegisterConnection <string>("https://www.dokmeecloud.com");
            }

            var loginResult = _dmsConnector.Login(new LogonInfo
            {
                Username = username,
                Password = password
            });

            return(loginResult);
        }