public void ConnectToQlikSense(string url, X509Certificate2 cert, string userId, string domain) { try { var uri = new Uri(url); _location = Qlik.Engine.Location.FromUri(uri); _location.IsVersionCheckActive = false; X509Certificate2Collection certificateCollection = new X509Certificate2Collection(cert); _location.AsDirectConnectionAsync(domain, userId, certificateValidation: false, certificateCollection: certificateCollection); } catch (CommunicationErrorException cex) { Debug.WriteLine("Can not connect to Qlik Sense instance, check that Qlik Sense is running." + Environment.NewLine + cex.Message); } catch (Exception ex) { Debug.WriteLine("General error. " + ex.Message); } }
public async Task <ILocation> GetLocation() { try { using var ctx = new RlvMailerContext(); ctx.Qs.Load(); var qs_settings = ctx.Qs.FirstOrDefault(); ILocation location = Location.FromUri(qs_settings.qs_servr_uri); string domain = qs_settings.qs_domain; string user = qs_settings.qs_user; SecureString securepass = new NetworkCredential("", qs_settings.qs_certificate_password).SecurePassword; var x509 = new X509Certificate2(File.ReadAllBytes(qs_settings.qs_certificate_path), securepass); var certificateCollection = new X509Certificate2Collection(x509); await location.AsDirectConnectionAsync(qs_settings.qs_domain, user, certificateValidation : false, certificateCollection : certificateCollection); return(location); } catch (Exception ex) { //Log.Fatal(ex.Message); throw ex; } }