Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public bool SaveCredentialsPassword(string password)
        {
            if (_credentials == null)
            {
                _credentials = new ComaToolCredentials();
            }

            _credentials.Password = password;
            return(true);
        }
Exemplo n.º 3
0
        public bool SaveCredentialsUserName(string userName)
        {
            if (_credentials == null)
            {
                _credentials = new ComaToolCredentials();
            }

            _credentials.UserName = userName;
            return(true);
        }
Exemplo n.º 4
0
        public void LoadControl(bool firstLoad)
        {
            // Load text box if credentials
            if (_ticketManager.IsCredentialsExist())
            {
                ComaToolCredentials credentials = _ticketManager.GetCredentials();
                txtboxUserName.Text = credentials.UserName;
                txtboxPassword.Text = credentials.Password;
            }

            if (firstLoad)
            {
                CheckSessionValidityOnFirstLoad();
            }
        }
Exemplo n.º 5
0
        public bool SaveCredentials(string userName, string password)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                OnErrorOccurred("Credentials could not be saved. Username or password is empty.");
                return(false);
            }

            if (_credentials == null)
            {
                _credentials = new ComaToolCredentials();
            }

            _credentials.UserName = userName;
            _credentials.Password = password;
            return(true);
        }