Exemplo n.º 1
0
        public InitialiseWithIdResult InitializeWithId(string ipAddress, int organisationId, string partnerApiKey)
        {
            const string MethodName = "InitializeWithID";

            object cdb         = null;
            object productName = null;
            object version     = null;
            object loginID     = null;
            object error       = null;
            object outcome     = null;
            object sessionId   = null;

            const int outParameterStartIndex = 6;

            object[] parameters = new object[]
            {
                // in
                2,
                ipAddress,
                string.Empty,
                string.Empty,
                organisationId,
                partnerApiKey,

                // out
                cdb,
                productName,
                version,
                loginID,
                error,
                outcome,
                sessionId
            };

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

            InvokeMethod(MethodName, parameters, modifiers);

            int index = outParameterStartIndex;

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

            if (result.IsError)
            {
                throw new PartnerApiException(string.Format("Partner API {0} call failed: {1} (Version = {2})", MethodName, result.ErrorMessage, result.Version));
            }

            return(result);
        }
Exemplo n.º 2
0
        private static void ActivatePartnerApi()
        {
            Configuration.Configuration configuration = ConfigurationManager.ReadConfiguration();

            EmisPartnerInterface emisInterface = new EmisPartnerInterface();

            InitialiseWithIdResult initializeResult = emisInterface.InitializeWithId(configuration.EmisWebIPAddress, configuration.EmisWebCdb, configuration.PartnerApiKey);

            emisInterface.Logon(initializeResult.LoginId, configuration.PartnerApiUserName, configuration.PartnerApiPassword);

            Log.WriteToConsoleAndLog(string.Empty);
            Log.WriteToConsoleAndLog("Partner API activation succeeded");
        }
Exemplo n.º 3
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;
        }