SSIS VB.Net Script to download a file using a proxy - vb.net

I am trying to write a VB.Net script to download a file from the web in a SSIS dtsx package.
I started from this, but I am having only proxy authentication errors (error 407).
I double checked the proxy, the port and the URL an they are right!
Can anyone help me please? I can't understand where the problem could be.
' Microsoft SQL Server Integration Services Script Task
' Write scripts using Microsoft Visual Basic
' The ScriptMain class is the entry point of the Script Task.
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net
Public Class ScriptMain
Public Sub Main()
Dim objWebClient As WebClient = New WebClient()
Dim objCache As New CredentialCache()
Dim strDownloadURL As String = "http://www.example.com/data.xlsx"
Dim strProxyURL As String = "myproxy.mycompany.local"
Dim intProxyPort As Integer = 1234
'Set Proxy & Credentials as a Network Domain User acc to get through the Proxy
Dim wp As WebProxy = New WebProxy(strProxyURL, intProxyPort)
objWebClient.Proxy = wp
'Download file, use Flat File Connectionstring to save the file
objWebClient.DownloadFile(strDownloadURL, "E:\MyFile.xlsx")
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
The file of strDownloadURL is accessible by browser and doesn't need any form of authentication. Anyone can access it by a web browser.

Related

Cannot get CefSharp Chromium web brower to work on target PC

I have a Windows VB application developed in Visual Studio 2013 that incorporates a CefSharp Chromium web browser (version 86.0.241 using the NuGet packages). Target CPU is set to x86, the build output path is set to bin\x86\debug, Configuration is set to Active (debug) and the Platform is set to Active (x86). The web browser works great on the development machine, but when I deploy the app to the target machine (which is a server), the browser displays a blank screen and freezes.
The CefSharp support files are included in the deployment package (InnoSetup), but I'm confused on which version of VC++ redistributables I need to deploy.The CefSharp FAQ's state that with versions 65.0.0 and above, the minimum of VC++2015 needs to be deployed. I had the client install this version on the target machine (when I originally deployed this app, I did not include the VC++ redistributables), but the browser still does not work. Do I need to deploy a different version?
Any other ideas on what I'm doing wrong? Please help!
Larry
Here is a link to the .zip file containing the CEF debug.log files from the client's three servers (the three servers rotate based on demand):
https://www.dropbox.com/s/b3zjxxk79v9xl9b/DataMinerDebugLogs.zip?dl=0
Please let me know if any of these provides the reason why the Chromium browser is displaying only a blank page.
Thanks.
Details of the log entry mentioned in my last comment:
[1228/093028.760:INFO:CONSOLE(32)] "Refused to connect to 'https://collection.decibelinsight.net/i/13878/265573/c.json' because it violates the following Content Security Policy directive: "connect-src https://qbonline.api.intuit.net https://cdn.decibelinsight.net https://api.segment.io 'self' https://.intuit.com https://.intuit.com:* https://.intuitcdn.net: https://hosted-shell-assets-us-west-2.s3.us-west-2.amazonaws.com wss://plugin-localhost.intuitcdn.net:* wss://plugin.intuitcdn.net:* https://.intuit.net wss://.msg.liveperson.net/ws_api/account/ https://*.objectstorage.liveperson.net/ https://scripts.neuro-id.com https://api.neuro-id.com https://logs.neuro-id.com".
", source: https://cdn.decibelinsight.net/i/13878/265573/di.js (32)
Code from Auth Class (the form that opens and displays the Chromium browser):
Imports Intuit.Ipp.OAuth2PlatformClient
Imports System.Net
Imports System.IO
Imports System.Web
Imports CefSharp
Imports CefSharp.WinForms
Public Class Auth
Public WithEvents Browser As ChromiumWebBrowser
Dim Settings As New CefSettings
Private Sub Auth_Load(sender As Object, e As EventArgs) Handles MyBase.Load
oauthClient = New OAuth2Client(ClientID, ClientSecret, RedirectURL, "production")
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
Dim scopes As List(Of OidcScopes) = New List(Of OidcScopes)()
scopes.Add(OidcScopes.Accounting)
authorizeURL = oauthClient.GetAuthorizationURL(scopes)
Settings.CefCommandLineArgs.Add("disable-gpu")
Browser = New ChromiumWebBrowser(authorizeURL)
Me.Controls.Add(Browser)
Browser.Dock = DockStyle.Fill
End Sub
Private Sub Browser_AddressChanged(sender As Object, e As AddressChangedEventArgs) Handles Browser.AddressChanged
Dim Str As String = Browser.Address
If InStr(Str, "&realmID", CompareMethod.Text) Then
Dim q = HttpUtility.ParseQueryString(Browser.Address)
Dim Code As String = ""
Dim RealmID As String = ""
For Each key In q.Keys
If InStr(key, "code") Then
Code = q.Item(key)
ElseIf InStr(key, "realmId", CompareMethod.Text) Then
RealmID = q.Item(key)
End If
Next
Call GetAuthTokens(Code, RealmID)
End If
End Sub
End Class
The "Address_Changed" event can be ignored and the first 5 lines of the "Load" event all relate to another SDK used in the app, none of which is related to the Chromium browser.
Startup code added:
Shared Sub Main()
'This sub executes first.
Dim Settings As New CefSettings
Settings.CefCommandLineArgs.Add("disable-gpu")
cef.initialize(Settings)
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New MainMenu)
End Sub

How to get template list from docusing account?

How to retrieve all template from Docusign api using vb.net.I manage to create multiple template through docusing website, and need to retrieve list of template from account.
Regards,
Aravind
You will need to add the nuget package from https://www.nuget.org/packages/DocuSign.eSign.dll/ but this code is not for latest version.
Imports System
Imports System.Collections.Generic
Imports DocuSign.eSign.Api
Imports DocuSign.eSign.Client
Imports DocuSign.eSign.Model
Imports Microsoft.AspNetCore.MvcPrivate Sub SurroundingSub()
Dim config = New Configuration(New ApiClient(basePath))
config.AddDefaultHeader("Authorization", "Bearer " & accessToken)
Dim templatesApi As TemplatesApi = New TemplatesApi(config)
Dim options As TemplatesApi.ListTemplatesOptions = New TemplatesApi.ListTemplatesOptions()
options.searchText = "Example Signer and CC template"
Dim results As EnvelopeTemplateResults = templatesApi.ListTemplates(accountId, options)
End Sub

How to create global obects in vb.net

I'm using visual studio 2015.
I'm clearly missing some things...
I want to create a global filestream and stream writer.
Dim wFile As System.IO.FileStream = New FileStream _
("C:\inetpub\wwwroot\SummitMap1Local\Labels\BufferedData.txt", FileMode.Append)
Dim sw As New StreamWriter(wFile)
This works fine. BUT I need to access it globally. Ideally the code would be in its own .aspx file and the wFile and sw objects could be used in a different .aspx file.
Thanks
(odd that I need to edit my original post to add new info)
I am now trying to add a class based on info from MSDN. It's not working. Code -
Imports System
Imports System.IO
Imports System.Text
Public Class test
Public Shared Sub CreateFileStream()
Dim fs As FileStream = New FileStream("C:\inetpub\wwwroot\SummitMap1Local\Labels\BufferedData.txt", FileMode.Append
End Sub
End Class
Then trying to use the class in a function -
Protected Function bufferList(ByVal testData As String) As String
Try
Dim sw As New StreamWriter(fs)
sw.WriteLine(testData)
End Try
End Function
I get an error on 'Dim sw As New StreamWriter(fs)' fs is not declared. It may be inaccessible due to it's protection level
I've tried calling it with test.fs, but test does not have an fs property.

Debugging SSIS vb.net Script

I am debugging a SSIS vb.net script in a Visual Studio 2005 SSIS project.
Is there a way to execute just the script without having to start in my control flow? Otherwise I have to work through my other steps and drill down through my Script Task into the Editor into the actual script.
As a side not my script is pretty simple, it just creates a directory if a directory with today's date is not found.
Imports System
Imports System.IO
Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
' Checks to see if todays folder exists on sqlzdocs -> if it doesnt it creates it. Else it errors
Public Sub Main()
Dim todaysdate As String = String.Format("{0:yyyyMMdd}", DateTime.Now)
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo("\\MyServer\Path\Current\" + todaysdate )
If di.Exists = True Then
Dts.Variables("User::FolderExists").Value = True
Else
Try
Dim createdirectory As IO.DirectoryInfo = Directory.CreateDirectory(di.ToString)
Catch ex As Exception
Dts.Variables("User::Errors").Value = "Could not create the directory:" + di.ToString
Dts.Variables("User::FolderExists").Value = False
End Try
End If
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
When i was developing ETL modules that had Script tasks, i followed couple of things to help in testing
Logging the Script task execution points - I wrote simple custom module to handle that
Seperated the functions in the script task and created a seperate Vb.net console project. I executed that project and once it was working successfully, i then included the same in the SSIS project.

FilePath as a URL, Visual Basic Desktop App

I am using the code below to bind data from a XML file in my PC. It works fine when using a local PC filePath, but when I change the location of the XML filePath to an URL which is listed below. it simply doesn't work. I made this xml file public in my onedrive but still doen´t work. Do I need to download the file and then readXML?
Many Thanks,
Imports System
Imports System.IO
Imports System.Net
Imports System.Xml
Public Class NasgoLive
Private Sub RefreshButton_Click(sender As Object, e As EventArgs) Handles RefreshButton.Click, RefreshButton.Click
MessageBox.Show("Done")
Me.BackColor = Color.FloralWhite
Dim filePath As String = "Complete path where you saved the XML"
AuthorsDataSet.ReadXml("https://onedrive.live.com/? cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE%21674")
alliancehorizonvalue.DataSource = AuthorsDataSet
alliancehorizonvalue.DataMember = "alliancehorizon"
arcticovalue.DataSource = AuthorsDataSet
arcticovalue.DataMember = "arctico"
You need to download the file first. DataSet.ReadXml supports just a file name, not url.
You could download the file with a WebClient (not tested):
byte[] data;
using (WebClient client = new WebClient()) {
data = client.DownloadData("https://onedrive.live.com/?cid=42FE4354E1EDA2AE&id=42FE4354E1EDA2AE!674");
}
File.WriteAllBytes(#"c:\myfile.xml", data);
EDIT:
For downloading you need to use OneDrive API