CmisSync.Lib.Queueing.ConnectionScheduler.Connect C# (CSharp) Method

Connect() protected method

Connect this instance.
protected Connect ( ) : bool
return bool
        protected bool Connect() {
            lock(this.repoInfoLock) {
                try {
                    if (this.isForbiddenUntil > DateTime.UtcNow) {
                        return false;
                    }

                    // Create session.
                    var session = this.SessionFactory.CreateSession(this.RepoInfo, authenticationProvider: this.AuthProvider);
                    Logger.Debug(session.RepositoryInfo.ToLogString());
                    this.cancelToken.ThrowIfCancellationRequested();
                    session.DefaultContext = OperationContextFactory.CreateDefaultContext(session);
                    this.cancelToken.ThrowIfCancellationRequested();
                    this.Queue.AddEvent(new SuccessfulLoginEvent(this.RepoInfo.Address, session));
                    this.lastSuccessfulLogin = DateTime.Now;
                    return true;
                } catch (DotCMIS.Exceptions.CmisPermissionDeniedException e) {
                    Logger.Info(string.Format("Failed to connect to server {0}", this.RepoInfo.Address.ToString()), e);
                    var permissionDeniedEvent = new PermissionDeniedEvent(e);
                    this.Queue.AddEvent(permissionDeniedEvent);
                    this.isForbiddenUntil = permissionDeniedEvent.IsBlockedUntil ?? DateTime.MaxValue;
                } catch (CmisRuntimeException e) {
                    if (e.Message == "Proxy Authentication Required") {
                        this.Queue.AddEvent(new ProxyAuthRequiredEvent(e));
                        Logger.Warn("Proxy Settings Problem", e);
                        this.isForbiddenUntil = DateTime.MaxValue;
                    } else {
                        Logger.Error("Connection to repository failed: ", e);
                        this.Queue.AddEvent(new ExceptionEvent(e));
                    }
                } catch (DotCMIS.Exceptions.CmisInvalidArgumentException e) {
                    Logger.Warn(string.Format("Failed to connect to server {0}", this.RepoInfo.Address.ToString()), e);
                    this.Queue.AddEvent(new ConfigurationNeededEvent(e));
                    this.isForbiddenUntil = DateTime.MaxValue;
                } catch (CmisObjectNotFoundException e) {
                    Logger.Error("Failed to find cmis object: ", e);
                } catch (CmisConnectionException e) {
                    Logger.Info(string.Format("Failed to create connection to \"{0}\". Will try again in {1} ms", this.RepoInfo.Address.ToString(), this.Interval));
                    Logger.Debug(string.Empty, e);
                } catch (CmisBaseException e) {
                    Logger.Error("Failed to create session to remote " + this.RepoInfo.Address.ToString() + ": ", e);
                }

                return false;
            }
        }
    }