Пример #1
0
 /// <summary>
 /// Disconnect from the Perforce server
 /// </summary>
 public void Disconnect()
 {
     try
     {
         ConnectionStatus = EP4ConnectionStatus.P4CS_Disconnected;
         mP4Repository.Connection.Disconnect();
     }
     catch (NullReferenceException)
     {
         //Ignore null reference connection may not have been initialized when we are disposing.
     }
 }
Пример #2
0
		/// <summary>
		/// Disconnect from the Perforce server
		/// </summary>
		public void Disconnect()
		{
			try
			{
                ConnectionStatus = EP4ConnectionStatus.P4CS_Disconnected;
                mP4Repository.Connection.Disconnect();
            }
			catch (NullReferenceException)
			{
				//Ignore null reference connection may not have been initialized when we are disposing.
			}
		}
Пример #3
0
        /// <summary>
        /// Attempt to connect to the Perforce server
        /// </summary>
        /// <returns>Connection status after the connection attempt</returns>
        public EP4ConnectionStatus Connect()
        {
            // Only attempt to connect if not already successfully connected
            if (ConnectionStatus != EP4ConnectionStatus.P4CS_Connected)
            {
                // Assume disconnected state
                ConnectionStatus = EP4ConnectionStatus.P4CS_Disconnected;

                // Attempt to connect to the server
                try
                {
                    var P4Server = new Server(new ServerAddress(mServerName));

                    mP4Repository = new Repository(P4Server);

                    Connection P4Connection = mP4Repository.Connection;


                    P4Connection.UserName = mUserName;

                    P4Connection.Client = new Client();

                    P4Connection.Connect(null);

                    //Check user connection error, invalid login
                    if (P4Connection.ErrorList != null)
                    {
                        if (P4Connection.ErrorList[0].ErrorCode == 822483067)
                        {
                            Disconnect();
                            ConnectionStatus = EP4ConnectionStatus.P4CS_UserLoginError;
                        }
                        else
                        {
                            Disconnect();
                            ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                        }
                    }
                    else
                    {
                        Credential LoginCredential = P4Connection.Login(mUserPassword, null, null);
                        if (P4Connection.ErrorList != null)
                        {
                            if (P4Connection.ErrorList[0].ErrorCode == 839195695)
                            {
                                Disconnect();
                                ConnectionStatus = EP4ConnectionStatus.P4CS_UserPasswordLoginError;
                            }
                            else
                            {
                                Disconnect();
                                ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                            }
                        }
                        else
                        {
                            P4Connection.Credential = LoginCredential;
                            ConnectionStatus        = EP4ConnectionStatus.P4CS_Connected;
                        }
                    }
                }
                // Disconnect and return an error status if an exception was thrown
                catch (P4Exception ex)
                {
                    if (ex.ErrorCode == 841354277)
                    {
                        //Could not connect to the server
                        Disconnect();
                        ConnectionStatus = EP4ConnectionStatus.P4CS_ServerLoginError;
                    }
                    else
                    {
                        //unknown error
                        Disconnect();
                        ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                    }
                }
            }
            return(ConnectionStatus);
        }
Пример #4
0
		/// <summary>
		/// Attempt to connect to the Perforce server
		/// </summary>
		/// <returns>Connection status after the connection attempt</returns>
		public EP4ConnectionStatus Connect()
		{
			// Only attempt to connect if not already successfully connected
			if (ConnectionStatus != EP4ConnectionStatus.P4CS_Connected)
			{
				// Assume disconnected state
				ConnectionStatus = EP4ConnectionStatus.P4CS_Disconnected;

				// Attempt to connect to the server
				try
				{
                    var P4Server = new Server(new ServerAddress(mServerName));

                    mP4Repository = new Repository(P4Server);

                    Connection P4Connection = mP4Repository.Connection;


                    P4Connection.UserName = mUserName;

                    P4Connection.Client = new Client();

                    P4Connection.Connect(null);

                    //Check user connection error, invalid login
                    if (P4Connection.ErrorList!=null)
                    {
                        if (P4Connection.ErrorList[0].ErrorCode == 822483067)
                        {
                            Disconnect();
                            ConnectionStatus = EP4ConnectionStatus.P4CS_UserLoginError;
                        }
                        else
                        {
                            Disconnect();
                            ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                        }
                    }
                    else
                    {
                        Credential LoginCredential = P4Connection.Login(mUserPassword, null, null);
                        if (P4Connection.ErrorList != null)
                        {
                            if (P4Connection.ErrorList[0].ErrorCode == 839195695)
                            {
                                Disconnect();
                                ConnectionStatus = EP4ConnectionStatus.P4CS_UserPasswordLoginError;
                            }
                            else
                            {
                                Disconnect();
                                ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                            }
                        }
                        else
                        {
                            P4Connection.Credential = LoginCredential;
                            ConnectionStatus = EP4ConnectionStatus.P4CS_Connected;
                        }
                    }
                }
				// Disconnect and return an error status if an exception was thrown
                catch (P4Exception ex)
				{
                    if (ex.ErrorCode == 841354277)
                    {
                        //Could not connect to the server
                        Disconnect();
                        ConnectionStatus = EP4ConnectionStatus.P4CS_ServerLoginError;
                    }
                    else
                    {
                        //unknown error
                        Disconnect();
                        ConnectionStatus = EP4ConnectionStatus.P4CS_GeneralError;
                    }
                }
			}
			return ConnectionStatus;
		}