Escaping underscore in SSIS - oracle

I have an SSIS expression.as per below:
I am sending the results of this package as an sms,however the sms does not show the underscores,I have therefore opted to using dashes for now.
The sms is showing at as OLEGALINITTEST
I there a way i can escape the underscore so that it shows on the sms?
REPLACE(#[System::PackageName], "_", "-") = O-LEGAL-INIT-TEST
Desired output is O_LEGAL_INIT_TEST
I am replacing the underscore's in the string with "-" dashes .I am sending the variable to an Oracle package that send the actual sms.

#[System::PackageName] is generally the same as the file name without the file extension so given a package named This-Is-Fun.dtsx we would expect to see the PackageName property as This-Is-Fun.
But, there are cases where this not the case. If we named our package A=B.C_D.dtsx, the resulting object name for our package is A B C_D. Each offending character is replaced with spaces.
If you attempt to name an SSIS object with "something weird" it will throw an error on the operation like
The name cannot contain any of the following characters: / \ : [ ] . =
The restrictions are similar, but different, for the package name itself as Windows/Visual Studio will balk with
contain any of the following characters: / ? : & \ * " < > | # %
contain Unicode control characters contain invalid surrogate
characters be system reserved names, including 'CON', 'AUX', 'PRN', 'COM1'
or 'LPT2' be '.' or '..'
As always with expressions in SSIS, check what you're building. Create an SSIS Variable where you specify an expression.
Assuming you create an SSIS variable called SMS_CONTENT data type of string and then I'm going to replace spaces with underscores. The expression is
REPLACE(#[System::PackageName], " ", "_")
Given a starting package name of
a=b.SO_61618859_This_Is_Fun.dtsx
System::PackageName becomes a b SO_61618859_This_Is_Fun
SMS_CONTENT becomes a_b_SO_61618859_This_Is_Fun
If it works fine during development but goes awry in production, log the value via a script task's information event so you can review logs after the run. https://billfellows.blogspot.com/2016/04/biml-script-task-test-for-echo.html You don't need to Biml it, just mark the variable as part of the Read only variable collection and the following script will record the values in the log. In your case, I'd add System::PackageName and then my SSIS variable, User::SMS_CONTENT
bool fireAgain = false;
string message = "{0}::{1} : {2}";
foreach (var item in Dts.Variables)
{
Dts.Events.FireInformation(0, "SCR Echo Back", string.Format(message, item.Namespace, item.Name, item.Value), string.Empty, 0, ref fireAgain);
}

Related

Passing variable as a parameter for Set-MpPreference

I'm trying to configure Windows Defender via Set-MpPreference.
This is my code:
$ASRIds = "01443614-cd74-433a-b99e-2ecdc07bfc25,92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B"
$ASRValues = "1,1"
Set-MpPreference -AttackSurfaceReductionRules_Ids $ASRIds -AttackSurfaceReductionRules_Actions $ASRValues
however, I am getting error
Set-MpPreference : Cannot process argument transformation on parameter 'AttackSurfaceReductionRules_Actions'. Cannot
convert value "1,1" to type "Microsoft.PowerShell.Cmdletization.GeneratedTypes.MpPreference.ASRRuleActionType[]".
Error: "Cannot convert value "1,1" to type
"Microsoft.PowerShell.Cmdletization.GeneratedTypes.MpPreference.ASRRuleActionType". Error: "Unable to match the
identifier name 1,1 to a valid enumerator name. Specify one of the following enumerator names and try again:
Disabled, Enabled, AuditMode""
At line:1 char:96
+ ... tionRules_Ids $ASRIds -AttackSurfaceReductionRules_Actions $ASRValues
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-MpPreference], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-MpPreference
I know that this can be done directly like this:
Set-MpPreference -AttackSurfaceReductionRules_Ids 1443614-cd74-433a-b99e-2ecdc07bfc25,92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B -AttackSurfaceReductionRules_Actions 1,1
but passing it as variable is a necessary part of my project. Is there anything I can do to make the variables work?
One by one (working with only one attack surface reduction rule at the time) works, but Windows Defender disabled the other rules if you enable just one. So I need to have multiple IDs in the variable at the same time.
Thanks
I'm guessing this is not liking the fact that you're passing a string - try passing an array arrays:
$ASRIds = #("01443614-cd74-433a-b99e-2ecdc07bfc25","92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B")
$ASRValues = #(1,1)
Troubleshooting Notes
The [] in your error is telling us it is expecting an array
...Microsoft.PowerShell.Cmdletization.GeneratedTypes.MpPreference.ASRRuleActionType[]...
This part is telling us it's trying to match the whole string 1,1 to an enumerator - it should be matching one at a time.
Unable to match the identifier name 1,1 to a valid enumerator name
I'm guessing you want to specify Enabled? Consider this, to make your code more readable: $ASRValues = #('Enabled','Enabled')
Specify one of the following enumerator names and try again:
Disabled, Enabled, AuditMode
As for the error in the comments, well...

Search Query Parameter

I want to search email which contains '+' in it. for example
something like this myemail.subdomain+1#domain.com.
URL - https://example.com?searchKey=myemail.subdomain+1#
I am using Laravel, this parameter is fetched from route using
$request->get('searchKey');
but it's converting '+' to ' ' ,
as a result i am getting
searchKey as myemail.subdomain 1#
which leads to improper result.
Any help?
PHP assumes that + from GET request is a space. Right encoded plus symbol is %2B.
You have to just prepare string from request to save plus symbol:
$searchKey= urlencode(request()->get('searchKey'));
In your case you'll get # as %40. Then you can replace plus with correct code and decode it. But then be careful with usual spaces!
$searchKey = urlencode(request()->get('searchKey'));
$searchKey = urldecode(str_replace('+', '%2B', $searchKey));
https://www.php.net/manual/en/function.urlencode.php
https://www.php.net/manual/en/function.urldecode.php
P.S. I suppose it is not the best soulution, but it should work.
P.P.S. Or, if you can prepare plus as a %2B before it will be at search parameter, do it

Validation fails when passing a file path as Input Argument to Orchestrator API StartJobs

I am trying to use file name path (Ex: C:\Document\Report.txt) as a parameter through uipath orchastrator api. I tried different approach and In each approach I am getting Bad request error "{"message":"Argument Values validation failed.","errorCode":2003,"resourceIds":null}"
Below is my Example code
FileListUploaded ="C\\Documents\\report.txt";
string parameter1 = "{\"startInfo\": {\"ReleaseKey\": \"xxxxx-xxx-xxx-xxx-xxxxxx\"," +
"\"RobotIds\": [xxxxx]," +
"\"JobsCount\": 0," +
"\"InputArguments\": \"{ "+
"\\\"reports_or_other_files\\\": \\\" + FileListUploaded + \\\"}\"}}";
request_startRobot.AddParameter("application/json; charset=utf-16", parameter, ParameterType.RequestBody);
IRestResponse response_startRobot = client_startRobot.Execute(request_startRobot);
That's a bit messy to look at, but it appears you are not quoting and escaping your JSON correctly.
I might suggest building an array and serializing it into JSON to make it easier to read, or using a HEREDOC or string formatting. If you do continue to concatenate your JSON body string together, dump out the results to see how it is coming together.
The final results of the JSON should look something like
{
"startInfo": {
"ReleaseKey":"{{uipath_releaseKey}}",
"Strategy":"JobsCount",
"JobsCount":1,
"InputArguments":"{\"reports_or_other_files\":\"C:\\\\Documents\\\\report.txt\"}"
}
}
With the InputArguments:
Looks like you are missing some quotes
Might need to double escape your backslashes in the FileListUploaded variable
Missing a colon after the C in the path

Lua strings won't concatenate

I am trying to concatenate a variable to make my output "prettier", however it seems to output as an empty string when concatenated with other string values.
The output code excerpt looks like this:
local name = ""
local SendMessage = alien.User32.SendMessageA
SendMessage:types{ret = "int", abi = "stdcall", "pointer", "int", "int", "string"}
SendMessage(handle, LB_GETTEXT, index, name)
print(type(name)) --To verify that it is a string type
print(name) --Prints the name "Sample 1" perfectly fine
print("Title: " .. name .. "\n") --Doesn't print the name variable "Sample 1"
Output:
The name variable is set via Alien for Lua call to the WINAPI SendMessage function from User32.dll. I think this might be part of the issue, however as you can see above, the variable is set to type (Lua) "string" and prints fine when called by itself. However whenever you concatenate it with anything, it acts like the empty string (or something similar).
EDIT: I have also tried tostring(name) and alien.tostring(name). Neither of which fix the issue.
After a lot of trial and error as well as reading the Lua Alien documentation, I discovered that using an Alien Buffer solves the issue of converting between the hybrid C-Lua string and a native Lua string:
local name = alien.buffer()
print("Title: " .. name:tostring() .. "\n")
You can then use the tostring() method on the variable at any time to get the native Lua string.
NOTE: The buffer variable will be of type userdata. If you try to print it out by itself, it will show its contents, but if you try to concatenate it like a string (without the :tostring()) Lua will throw an error because you cannot concatenate a string with userdata.

VB6 / Crystal Report 8.5 error: A string is required here

I recently inherited an old visual basic 6/ crystal reports project which connects to a sql server database. The error message I get (Error# -2147191803 A String is required here) when I attempt to run the project seems to be narrowed down to the .Printout command in the following code:
'Login to database
Set Tables = Report.Database.Tables
Set Table = Tables.Item(1)
Table.SetLogOnInfo ConnName, DBName, user, pass
DomainName = CStr(selected)
'Set parameter Fields
'Declare parameter holders
Set ParamDefs = Report.ParameterFields
'Store parameter objects
For Each ParamDef In ParamDefs
With ParamDef
MsgBox("DomainName : " + DomainName)
Select Case .ParameterFieldName
Case "Company Name"
.SetCurrentValue DomainName
End Select
Select Case .Name
Case "{?Company Name}"
.SetCurrentValue DomainName
End Select
'Flag to see what is assigned to Current value
MsgBox("paramdef: " + ParamDef.Value)
End With
Next
Report.EnableParameterPrompting = False
Screen.MousePointer = vbHourglass
'CRViewer1.ReportSource = Report
'CRViewer1.ViewReport
test = 1
**Report.PrintOut**
test = test + 3
currenttime = Str(Now)
currenttime = Replace(currenttime, "/", "-")
currenttime = Replace(currenttime, ":", "-")
DomainName = Replace(DomainName, ".", "")
startName = mPath + "\crysta~1.pdf"
endName = mPath + "\" + DomainName + "\" + DomainName + " " + currenttime + ".pdf"
rc = MsgBox("Wait for PDF job to finish", vbInformation, "H/W Report")
Name startName As endName
Screen.MousePointer = vbDefault
End If
During the run, the form shows up, the ParamDef variable sets the "company name" and when it gets to the Report.PrintOut line which prompts to print, it throws the error. I'm guessing the crystal report isn't receiving the "Company Name" to properly run the crystal report. Does any one know how to diagnose this...either on the vb6 or crystal reports side to determine what I'm missing here?
UPDATE:
inserted CStr(selected) to force DomainName to be a string
inserted msgboxes into the for loop above and below the .setcurrentvalue line
inserted Case "{?Company Name}" statement to see if that helps setting the value
tried .AddCurrentValue and .SetCurrentValue functions as suggested by other forum websites
ruled out that it was my development environement..loaded it on another machine with the exact same vb6 crystal reports 8.5 running on winxp prof sp2 and the same errors come up.
and when I run the MsgBox(ParamDef.Value) and it also turns up blank with the same missing string error. I also can't find any documentation on the craxdrt.ParameterFieldDefinition class to see what other hidden functions are available. When I see the list of methods and property variables, it doesn't list SetCurrentValue as one of the functions.
Any ideas on this?
What is the value of your selected variable?
Table.SetLogOnInfo ConnName, DBName, user, pass
DomainName = selected
'Set parameter Fields
If it is not a string, then that might be the problem. Crystal expects a string variable and when it doesn't receive what it expects, it throws errors.
selected is a string variable input taken from a form with a drop down select box. I previously put a message box there to ensure there the variable is passing through right before the Report.Printout and it does come up. DomainName variable is also declared as a string type.
Here's how I set my parameters in Crystal (that came with .NET -- don't know if it helps you).
Dim dv As New ParameterDiscreteValue
dv.Value = showphone
rpt.ParameterFields("showphone").CurrentValues.Add(dv)
This can happen in crystal reports 8.5 if you changed the length of a string column you use in your report so that it exceeds 255 bytes. This can also happen if you change the column type from varchar to nvarchar (double byte string!)
The reason for this is that crystal reports 8.5 treats all strings longer than 255 bytes as memo fields.
I would suggest youe upgrade to crystal reports XI - the API has not changed that much.
From my point of view you should get the same error message if you open the report in the Crystal Reports Designer and switch to preview mode. The Designer should also show you a message with the exact location of the problem, e.g. the field which can not be treated as a string.
The problem is not that a field longer than 255 bytes cannot be printed. The problem is that a field longer than 255 bytes cannot be used in a formula, as a sort criteria ...
Here is a live example of setting the parameters that we use:
For Each CRXParamDef In CrystalReport.ParameterFields
Select Case CRXParamDef.ParameterFieldName
Case "#start"
CRXParamDef.AddCurrentValue CDate("1/18/2002 12:00:00AM")
Case "#end"
CRXParamDef.AddCurrentValue Now
End Select
Next
This is actually a sample written in VBScript for printing Crystal 8.5 reports, but the syntax is the same for VB6

Resources