SSIS: HTML Encoding a URL in a Script Task - ssis

I would like to URL encode a URL in a C# SSIS script task. I have tried using System.Web.HttpServerUtility, but intellisense shows it doesn't seem to be aware of "Server". Here's an example of the code that's raising an error:
Import System.Web
...
...
...
Server.HtmlEncode(TestVariable);
I have worked around this issue by writing a function that finds and replaces characters in a string to mimic HTML encoding a string, but I honestly abhore the solution. I would really just like to find out what I need to differently to use what's baked into .NET instead of reinventing the HTML Encoder wheel.

You need to add a reference to the assembly System.Web

Related

How to enable "Go to declaration" from typescript to json (i18next)

Im working on a project that uses i18next with react and typescript, where translationkeys are defined in .json files.
One drawback of switching to json for the translation files, is that we can no longer use the intellij idea "Go to declaration" or ctrl + left-click feature, to quickly navigate from a key usage in typescript, to its declaration in the json file.
Is there any way to enable this without requiring all developers to download some third-party intellij plugin?
I've googled for hours for any information about this.
I've made a d.ts file to enable strong typing for where translationkeys are used. What strikes me as odd is that intellij/typescript is able to know when a key doesent exist and warns about it, but at the same time doesent know "where" that key exists whenever i type a correct key.
I also set resolveJsonModule:true in tsconfig, but to my limited understanding it doesent seem relevant.
This is not technically possible because commands like Go To Declaration will look for a declaration in a source code file (think .ts or .js or .d.ts) whereas you want to go ...to its declaration in the json file.
The resolveJsonModule flag won't help you either because as per the docs:
Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. This includes generating a type for the import based on the static JSON shape.
One possible solution is to create a build script to take your .json file and output a .js or .ts file containing the same content, then IDE commands like Go To Declaration will jump to that file.
In summary: you will need some kind of plugin, or a custom build script.
DISCLAIMER: I don't use i18next or react, this answer is based on my understanding of both TypeScript and the JetBrains Rider IDE (which is like IntelliJ).

web crawling using regex or xml libraries

I am trying to do webcrawler program using python. In this case, can we use regex to get the expected string or can we use the XML packages in python to get the string ?
I can see most of them are using regex. I like to know reason behind it.

How to debug JSON files

There are several errors in my JSON file. What is the best option for debugging JSON files? I used this editor - http://www.jsoneditoronline.org/, but it's a bit difficult to use for long files.
For instance, the error message says:
Error: Parse error on line 1:
...000.0}]}},"data": [{"id": 0,"fr
-----------------------^
Expecting 'EOF', '}', ',', ']', got ':'"
But the line looks fine.
Try putting your JSON file's content into a validator, like http://jsonlint.com/ or http://jsonformatter.curiousconcept.com/ and see what it says.
I suggest entering your JSON into a linter such as http://jsonlint.com/. Additionally, properly formatting your JSON will make it easier to debug. A site such as http://jsonformatter.curiousconcept.com/ can do this for you.
If you have access to NodeJS locally, there's a CLI tool that works well for linting JSON files: https://github.com/zaach/jsonlint
Otherwise, you can use JSONLint if you don't mind uploading your JSON to a "random" remote server.
If you have access to Visual Studio. They have a visualizer debugging tool, which as such, will traverse the structure and throw at the problematic lines.
JSON Debugger Visualizer in Visual Studio 2013
Why not try something like vim or Notepad++ and try matching the brackets and braces? You may need to use something to "pretty print" the JSON first. I believe you could do that from a Python console.
You may try something from here http://jsbeautifier.org/ to format in one-line JSON stuff.
You can use Codverter JSON Validator, its online but it`s highly secure and everything you do is interpreted on your local computer and never sent back to the server. the validation error messages are informative and accurate.
(Full Disclosure: I am one of the developers).

Pass an argument to the XSLT when using an SSIS XML Task?

Anyone know a way to pass an argument to the XSLT when using an SSIS XML Task?
There seems to be no obvious way to do this, but there may be some clever workaround/hack?
EDIT: I'm currently looking into running an xpath update to insert param values...
EDIT: I got this working in the end by using a script task to insert the parameter value into the XSLT file. Hacky, I know, but it works. (And I have to work with VB.net, ugh!)
A quick search indicates that sending XSLT params is not possible in SSIS.
But, it also indicates that you could work with a variable as the XSLT source: Using XML Task (XSLT) with variables on social.msdn.microsoft.com (scroll down to Wenyang Hu's answer).
However, this looks like it would be a real pain in the a** to use.
Another idea would be to create a small XML file with a fixed name first (as part of the whole process) and store your parameter/config values there.
In your XSLT you could then load the file through the document('fixedname.xml') function and pull out the values you've just put there.

Loading HTML from a .res file

Using VS2005/2008 as a resource editor, one of the options in the Add Resource dialog is HTML: it appears to allow me to embed HTML file(s) into a resource (res) file. Does anyone know how to grab the HTML (as a string) from VB6 code? The LoadResData appears to be close to what I'm looking for but the problem is there isn't a HTML format defined in the table of formats (in that documentation link).
In Win32 C headers a resource format constant is defined called RT_HTML, it has the value 23. It should be possible to load the HTML resource type. Additionally you can verify the resource type number by looking at the built exe file with Resource Hacker. It lists the resource format types and resource IDs embedded in the file.
here is a good tutorial in c++ http://www.rohitab.com/discuss/index.php?showtopic=15281
you can probably adapt the code(usually function names are the same for win32 routines search on msdn.microsoft.com for documentation) or search the website for a VB example