示例#1
0
        private void InitialiseApi()
        {
            InitialiseWithIdResult initialiseResult = _emisInterface.InitializeWithId(_configuration.EmisWebIPAddress, (int)_configuration.EmisWebCdb, _configuration.PartnerApiKey);

            if (_stopping)
            {
                return;
            }

            LogonResult logonResult = _emisInterface.Logon(initialiseResult.LoginId, _configuration.PartnerApiUserName, _configuration.PartnerApiPassword);

            _sessionId = logonResult.SessionId;
        }
示例#2
0
        public LogonResult Logon(string loginId, string userName, string password)
        {
            const string MethodName = "Logon";

            object sessionId = null;
            object error     = null;
            object outcome   = null;

            const int outParameterStartIndex = 3;

            object[] parameters = new object[]
            {
                // in
                loginId,
                userName,
                password,

                // out
                sessionId,
                error,
                outcome
            };

            ParameterModifier[] modifiers = CreateParameterModifiers(parameters.Length, outParameterStartIndex);

            InvokeMethod(MethodName, parameters, modifiers);

            int index = outParameterStartIndex;

            LogonResult result = new LogonResult()
            {
                SessionId = parameters.GetAs <string>(index++),
                Error     = parameters.GetAs <string>(index++),
                Outcome   = parameters.GetAs <object>(index++).WhenNotNull(t => t.ToString()) // type varies!
            };

            if (result.IsError)
            {
                throw CreatePartnerApiException(MethodName, result);
            }

            return(result);
        }