Example #1
0
        /***********************************************************************************************************/


        #region ----- Constructor ------


        public TicketManager(ComaToolCredentials credentials, ComaToolSession session)
        {
            if (credentials == null || session == null)
            {
                throw new Exception("Could not initialize TicketManager");
            }

            _ticketUri   = new ComaToolUri();
            _credentials = credentials;
            _session     = session;

            if (!_session.isNullOrEmpty())
            {
                _session.Status = (int)Enums.SESSION_STATUS.UNKNOWN;
                _httpClient     = new ComaToolWebClient(_credentials.WebClientUsername, _credentials.WebClientPassword, _session.Cookies);
            }
            else
            {
                _httpClient = new ComaToolWebClient(_credentials.WebClientUsername, _credentials.WebClientPassword);
            }

            _httpClient.WebClientCredentialsModified += new ComaToolWebClient.WebClientCredentialsEventHandler(_httpClient_WebClientCredentialsModified);
            _httpClient.LogWebClientException        += new ComaToolWebClient.LogWebClientExceptionEventHandler(_httpClient_LogWebClientException);
            _httpClient.ErrorOccurred       += new ComaToolWebClient.ErrorOccurredEventHandler(httpClient_ErrorOccurred);
            _httpClient.SessionStatusChange += new ComaToolWebClient.SessionStatusHandler(OnSessionStatusChange);
            _httpClient.BytesDownloaded     += new ComaToolWebClient.BytesDownloadedHandler(_httpClient_BytesDownloaded);
        }
Example #2
0
        /***********************************************************************************************************/


        #region ----- Private Methods ------


        /// <summary>
        /// Checks whether the session has been set to a value.
        /// It does not check whether the session is valid or invalid.
        /// </summary>
        /// <param name="fireEvent"></param>
        /// <returns></returns>
        internal bool IsSessionSet(bool fireEvent)
        {
            if (_session == null || _session.isNullOrEmpty())
            {
                if (fireEvent)
                {
                    OnSessionInvalid();
                }
                return(false);
            }
            else
            {
                return(true);
            }
        }