Beispiel #1
0
        private static bool LoginToApi()
        {
            serviceProxy = new PvxApi.IntegrationServiceV4();
            try
            {
                //Connect to PVX API
                serviceProxy.Url = Properties.Settings.Default.PvxApiUrl;
                var response = serviceProxy.Authenticate(
                    Properties.Settings.Default.PvxClientId,
                    Properties.Settings.Default.PvxUsername,
                    Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Properties.Settings.Default.PvxPassword)));

                //Set SessionId
                if (response.ResponseId != 0)
                {
                    serviceProxy = null;
                }
                else
                {
                    //Split the response and get ClientId and Session string
                    var csvValues = response.Detail.Split(",".ToCharArray());
                    serviceProxy.UserSessionCredentialsValue = new PvxApi.UserSessionCredentials()
                    {
                        ClientId  = csvValues[0], //Client Id
                        SessionId = csvValues[1]  //Session
                    };
                }
            }
            catch (Exception)
            {
                serviceProxy = null;
            }
            return(serviceProxy != null);
        }
        private static bool LoginToApi()
        {
            serviceProxy = new PvxApi.IntegrationServiceV4();
            try
            {
                //Connect to PVX API
                serviceProxy.Url = Properties.Settings.Default.PvxApiUrl;
                var response = serviceProxy.Authenticate(
                    Properties.Settings.Default.PvxClientId,
                    Properties.Settings.Default.PvxUsername,
                    Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(Properties.Settings.Default.PvxPassword)));

                //Set SessionId
                if (response.ResponseId != 0)
                {
                    serviceProxy = null;
                }
                else
                {
                    //Split the response and get ClientId and Session string
                    var csvValues = response.Detail.Split(",".ToCharArray());
                    serviceProxy.UserSessionCredentialsValue = new PvxApi.UserSessionCredentials()
                    {
                        ClientId = csvValues[0], //Client Id
                        SessionId = csvValues[1] //Session
                    };
                }
            }
            catch (Exception)
            {
                serviceProxy = null;
            }
            return serviceProxy != null;
        }