Overwriting zip file in expression with user variable in ssis - sql-server

I want to overwrite a zip file in a folder but when i tried the below expression, it is giving an error as:
The expression is not valid and could not be parsed. it might contain invalid elements.
Expression:
#[User::Command_Syntax] = " /c copy " + "\"" + #[User::Output_File_Path_Var] + substring(#[User::Output_Zip_Name_Var], 1, len(#[User::Output_Zip_Name_Var]) - 4) + REPLACE(right(#[User::Output_Zip_Name_Var], 4) , ".zip", "") + ".zip" + "\"" + " " + "\"" + #[User::Archive_File_Path_Var] + substring(#[User::Output_Zip_Name_Var], 1, len(#[User::Output_Zip_Name_Var]) - 4) + REPLACE(right(#[User::Output_Zip_Name_Var], 4) , ".zip", "") + ".zip" + "\""
Can any one please let me know why i'm getting error. Thanks in advance!

I use a tool, which is outside of Visual Studio, which helps troubleshoot expression building. The tool information is here: SQLIS | SSIS Expression Editor & Tester and the github is here: SSIS Expression GitHub
That being said, I copy/pasted your expression above into the editor, added in the # user variables with made-up values in the "Add Variable" ability of the tool, and I get this as my output when evaluating.
So it does seem to evaluate for me, could you verify your user variables are spelled correctly and they are the correct type (string)?
You could also verify the variable assignments during debugging. Here is a good article on how to debug, if needed: Debugging Control Flow in SSIS

Related

SSIS Custom Column Property

I have a general question I'm hoping someone can answer about creating custom properties for use in a Data Flow Component.
Is it possible to create custom properties for use at the column level? I can create custom properties at the component level, no problem, but that does me no good.
I want to add two properties (Encrypt and Decrypt) to the Input Column metadata.
Say I have a collection of Input columns col1, col2, col3. As a developer, I would like to set col3's Encrypt value to true so, at run time, col3 gets encrypted before being loaded into a database.
I have successfully encrypted and decrypted using a custom component. Still, I used the values "e" and "d" in the column Description and then evaluated that Description during PreExecute. I set a state object based on the value of Description and add it to a collection that is processed during ProcessInput. I don't think using the Description is a good thing to do, and that is the need for the custom properties.
Do SSIS columns have custom properties?
The answer is yes. SSIS columns are objects that inherit the IDTSColumn130 interface. As mentioned in the SSIS documentation, this interface contains a property called CustomPropertyCollection that contains the collection of IDTSCustomProperty100 objects added to the input by the component.
Some components add some custom property to the SSIS columns such as the Derived Column Transformation. As I know, a custom component called FriendlyExpression is used to store the expression in plain text form. But, there is no way to add custom properties in the Integration Services package designer (Visual Studio).
How to add Custom Properties?
I think the only way is to create packages programmatically and edit those values or develop a custom SSIS component that adds these properties at runtime.
This is an example of reading the custom properties of a Derived Column transformation using C#. (Reference)
foreach (IDTSInputColumn localIColumn in localInput.InputColumnCollection)
{
if (localIColumn.CustomPropertyCollection.Count == 2)
{
repository.AddAttribute(componentRepositoryID, localInput.Name + " [" + localIColumn.Name + "] [ID: " + localIColumn.ID.ToString() + "]", "From [" + localIColumn.UpstreamComponentName + "] " + FormatColumnDescription(localIColumn.Name, localIColumn.DataType, localIColumn.Length, localIColumn.Precision, localIColumn.Scale) + " Expression " +
localIColumn.CustomPropertyCollection["FriendlyExpression"].Value != null ? localIColumn.CustomPropertyCollection["FriendlyExpression"].Value.ToString() : "Not Available"
);
}
else
{
repository.AddAttribute(componentRepositoryID, localInput.Name + " [" + localIColumn.Name + "] [ID: " + localIColumn.ID.ToString() + "]", "From [" + localIColumn.UpstreamComponentName + "] " + FormatColumnDescription(localIColumn.Name, localIColumn.DataType, localIColumn.Length, localIColumn.Precision, localIColumn.Scale) + " Expression (See Ouput Column)");
}
//repository.AddObject(localIColumn.Name, "", ColumnEnumerator.ObjectTypes.Column, componentRepositoryID);
}
Alternatives
You can store the columns metadata within an external data source (SQL, XML, ...) and load it at runtime. Or you can use the Description property as you mentioned in your question.

Report Builder Expression with a '

I have this field called series that has this expression in it, what does the ' mean in this context?
=(Fields!PropertyID.Value)
'=IIF(Parameters!CombineProperties.Value = TRUE AND (Fields!Campus.Value<>""),Fields!Campus.Value,Fields!PropertyName.Value)
This is an SSRS expression for a label or variable that is parsed at runtime in an ssrs report. The gist here is :
The starting =(Fields!PropertyID.Value) does not make sense as you can't set variables that way, however, after the ' it goes like this:
var result=null;
if (CombineProperties && Campus.Length > 0)
result=Campus
else
result=PropertyName
After reading your post again, I think you are trying to Concatenate strings. Is this your end goal?
=CSTR(Fields!PropertyID.Value) + IIF((Parameters!CombineProperties.Value = True) AND (Fields!Campus.Value<>""), Fields!Campus.Value,Fields!PropertyName.Value)
Update
Doh!, I am rusty on VB. I believe apostrophe comments out a line. Everything after ' is ignored. DOH!

How to upload multiple files to the page

I am trying to upload multiple files to the page with
<input id="dropInput" type="file" multiple>
For one file it is as simple as:
driver.FindElement(By.Id("dropInput")).SendKeys(#"path-to-file");
As a user I can click Choose Files button and select number of files (with Ctrl) so in Open dialog I can see sth like: "file-1" "file-2"
From the script it does not work. I have tried different combinations of SendKeys argument:
#"file-1" + " " + #"file-2"
#"file-1" + ", " + #"file-2"
"\"path\\to\\file-1\" \"path\\to\\file-2\""
Path.GetFullPath(file-1) + " " + Path.GetFullPath(file-2)
"\"" + Path.GetFullPath(file-1) + "\" \"" + Path.GetFullPath(file-2) + "\""
The input accepts the last file only. The same with sending keys several times. For the last example I have got an exception:
unknown error: path is not absolute: "file-1" "file-2"
I am out of ideas.
I'd like to know if there is any simple solution for that before I'll start injecting jQuery scripts to the page under test.
Please advise.
Cheers,
Przemek

ssis variable not evaluating

I have a variable that concatenates a file path into a string , and i can't get it to evaluate the concatenation. when i display the value of the variable in a script task, i still see all the double quote marks (see below). I have set the evaluateasexpression for the variable to true.
When i try to use this variable as a sql command, the error is:
"invalid syntax near the +"
(i believe this is the plus sign below the redactedcol3 below)
BTW, is property expressions the only place where you can evaluate a variable's value as you are developing? (expression builder).
This is how the variable displays in the message box in the script component:
"SELECT redactedcol1,redactedcol2,rtrim(" + "'" + #user::LocalPath + " + "'" + "+[redactedcol3]) AS Path FROM dbo.SF_redacted where id=1"
Not entirely sure this is what you want, but I think it is:
"SELECT redactedcol1,redactedcol2,rtrim("
+ "'"
+ #user::LocalPath
+ "'"
+ " + [redactedcol3]) AS Path FROM dbo.SF_redacted where id=1"
Note the removed extraneous plus sign and double-quote. (I find it helps when concatenating in SSIS to put each part on its own line.)
And I also recommend BIDS Helper, a free tool that includes a better (IMO) expression building GUI, as well as Konesans' Expression Editor which is a like a mini-Intellisense workbench for expressions.
There's also a Variables window in SSIS Projects (View -> Other Windows -> Variables) where you can see the evaluated value of a variable expression.
For others wondering why their expression is not evaluating...
http://www.sqlchicken.com/2012/02/ssis-expressions-not-evaluating-correctly/
Click on the Variable. Make sure "EvaluateAsExpression" is True

Crystal Report issue.Net 4.0

There is a definite syntax of passing value to crystal-report Formula Field from .Net 4.0- Code
behind
E.g. (C# Code):
Following will NOT work
_rpt.DataDefinition.FormulaFields["fClient"].Text = Mr.Gates;
Following will work-
_rpt.DataDefinition.FormulaFields["fClient"].Text = "\"Mr.Gates\"";
I haven't understand the prominence and way of using following ..
"\" \""
What if "Mr. Gates:" is in some variable, I want to pass!?
plz reply with some code...
Thanks
\" sends a literal " through to the variable. For literal string values in Formulae to be seen as literal strings they must be quoted hence sending the quoted " through is necessary.

Resources