gov.va.medora.mdws.AccountLib.connectAndLogin C# (CSharp) Method

connectAndLogin() public method

Connect to and log onto a data source.
Combines connecting, authentication and authorization into a single function. It will create a new set of session credentials and a primary permission. These credentials can then be used for subsequent visits. Calls login.
public connectAndLogin ( string sourceId, string accountId, string accountPwd, string permissionString ) : UserTO
sourceId string Station number
accountId string Access code
accountPwd string Verify code
permissionString string If blank defaults to CPRS context
return gov.va.medora.mdws.dto.UserTO
        public UserTO connectAndLogin(string sourceId, string accountId, string accountPwd, string permissionString)
        {
            UserTO result = new UserTO();
            if (sourceId == "")
            {
                result.fault = new FaultTO("Missing source ID");
            }
            else if (accountId == "")
            {
                result.fault = new FaultTO("Missing account ID");
            }
            else if (accountPwd == "")
            {
                result.fault = new FaultTO("Missing account password");
            }
            if (result.fault != null)
            {
                return result;
            }

            try
            {
                ConnectionLib cxnLib = new ConnectionLib(mySession);
                DataSourceArray da = cxnLib.connectToLoginSite(sourceId);
                if (da.fault != null)
                {
                    result.fault = da.fault;
                    return result;
                }
                result = login(accountId, accountPwd, permissionString);
            }
            catch (Exception e)
            {
                result.fault = new FaultTO(e.Message);
            }
            return result;
        }