Getting swf boolean parameters - actionscript-3

I have a swf that I call as
/SWFUploader/upload.swf?single=true
Then in ActionScript 3 I read in the value. But it's not working. Here's my test code (the first block is taken from http://blogs.adobe.com/pdehaan/2006/07/using_flashvars_with_actionscr.html ):
var keyStr:String;
var valueStr:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (keyStr in paramObj) {
valueStr = String(paramObj[keyStr]);
trace(keyStr + " = " + valueStr);
}
var isSingle:Boolean = this.loaderInfo.parameters.single as Boolean;
var isSingle1:Boolean = this.loaderInfo.parameters['single'] as Boolean;
var isSingle2:Boolean = LoaderInfo(this.root.loaderInfo).parameters['single'] as Boolean;
var isSingle3:Boolean = LoaderInfo(this.root.loaderInfo).parameters.single as Boolean;
trace(isSingle + ", " + isSingle1 + ", " + isSingle2 + ", " + isSingle3);
And frustratingly this is the resulting two lines that are traced:
single = true
false, false, false, false
What am I doing wrong?

In ActionScript not empty and not null String is casted to Boolean true.
var singleStr:String = this.loaderInfo.parameters.single;
var singleBool:Boolean = singleStr == "true";

Related

How much faster could I make this script?

I have noticed that the script is significantly faster when I comment out the line that calls setValues(). Not that it's a super big issue, but I am interested in the different ways (if any) that I could speed the process up. If anyone has some insight, I would greatly appreciate it! It would also help me see where I could make similar optimizations in other parts of my script.
Here is the code in question:
// import new value(s)
if ((numRaw - numDk) > 0) {
var iDate;
var lastRow = getLastDataRow(earSheet, columnToLetter(earSheet.getRange("EAR_DATES_RNG").getColumn()));
var distName = impSheet.getRange("A1").getValue().toString();
var defaultDept = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("All Lists").getRange("A2").getValue().toString();
impData.forEach(function (entry) {
iDate = new Date(entry[0]);
var newEar = earSheet.getRange("A" + lastRow + ":G" + lastRow).getValues(); // init copy
if (currData.get(iDate.getTime()) == null) {
newEar[0][0] = entry[0];
newEar[0][1] = distName;
newEar[0][6] = entry[1];
newEar[0][3] = "Royalties";
newEar[0][4] = defaultDept;
newEar[0][5] = "NOT SPECIFIED";
earSheet.getRange("A" + lastRow + ":G" + lastRow).setValues(newEar);
Logger.log("ADDED: " + entry[1] + " to row: " + lastRow);
addedNewData++;
lastRow++;
}
else {
Logger.log("EXISTING DATA FOUND: " + currData.get(iDate.getTime()));
}
});
}
Using Matt and Cooper's suggestions, I came up with this revised code which is significantly faster:
if ((numRaw - numDk) > 0) {
var iDate;
var prevLastRow = getLastDataRow(earSheet, columnToLetter(earSheet.getRange("EAR_DATES_RNG").getColumn()));
var currLastRow = getLastDataRow(earSheet, columnToLetter(earSheet.getRange("EAR_DATES_RNG").getColumn()));
var rangeSize = numRaw;
var distName = impSheet.getRange("A1").getValue().toString();
var defaultDept = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("All Lists").getRange("A2").getValue().toString();
var newEar = earSheet.getRange("A" + prevLastRow + ":G" + (prevLastRow + rangeSize - 1)).getValues(); // init copy
impData.forEach(function (entry) {
iDate = new Date(entry[0]);
if (currData.get(iDate.getTime()) == null) {
newEar[currLastRow-2][0] = entry[0];
newEar[currLastRow-2][1] = distName;
newEar[currLastRow-2][6] = entry[1];
newEar[currLastRow-2][3] = "Royalties";
newEar[currLastRow-2][4] = defaultDept;
newEar[currLastRow-2][5] = "NOT SPECIFIED";
Logger.log("ADDED: " + entry[1] + " to row: " + currLastRow);
addedNewData++;
currLastRow++;
}
else {
Logger.log("EXISTING DATA FOUND: " + currData.get(iDate.getTime()));
}
});
earSheet.getRange("A" + prevLastRow + ":G" + (prevLastRow + rangeSize - 1)).setValues(newEar);
}```

How can I display a variable in a dynamic text field?

I have an input textfield on the screen and I have it set to the text that a user enters is saved as a variable and is later called upon o be displayed in a dynamic text box. It's kinda like a high score kind of system, but with multiple variables.
Here is the frame actions where the variables are being set (at least I think they are)
button.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
var data:String = username.text + " " + date.text + " " + company.text;
var file:FileReference = new FileReference();
file.save(data, username.text + " " + date.text + " " + company.text + ".txt");
}
button.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame_8);
function fl_ClickToGoToNextFrame_8(event:MouseEvent):void
{
nextFrame();
}
var nameperson = username.text;
var dateperson = date.text;
var companyperson = company.text;
And are the actions where I'm trying to display the variables in another frame:
var nScore:Number = 0;
for(var i:Number = 0; i < aQuestions.length; i++)
{
if(aUserAnswers[i].toUpperCase() == aCorrectAnswers[i].toUpperCase())
{
nScore++;
}
if(i == aQuestions.length - 1)
{
score_txt.text = nScore.toString();
}
}
endresult_name.text = nameperson;
endresult_date.text = dateperson;
I believe the problem is that you set these variables straight when you get to your 1st frame (the text inputs are empty at that point). You need to set them after the user have filled them out and clicked on the button:
var nameperson:String;
var dateperson:String;
var companyperson:String;
function fl_MouseClickHandler(event:MouseEvent):void
{
var data:String = username.text + " " + date.text + " " + company.text;
var file:FileReference = new FileReference();
file.save(data, username.text + " " + date.text + " " + company.text + ".txt");
nameperson = username.text;
dateperson = date.text;
companyperson = company.text;
}

Programmatically add transformation script component to ssis package

Can any one help me please...How do I programmatically add a transformation script component to a dataflow task in an ssis package?
I am crating an ssis package programmatically using the API via C#. It consists of a flat file source and a sql table (oledb destination). I have to add a script component to generate autoincrementing numbers to fill up the rownum column of the table. The rownum column is not an identity column.
CODE GIVEN...
public Microsoft.SqlServer.Dts.Runtime.DTSExecResult CreatePackage(Dictionary<int, int> LenMap)
{
Package package;
try
{
package = new Package();
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
package.MaximumErrorCount = 4;
package.Name = this.PackageName;
/* Add the Data Flow Task */
package.Executables.Add("STOCK:PipelineTask");
package.DelayValidation = false;
/* Get the task host wrapper, and the Data Flow task*/
TaskHost taskHost = package.Executables[0] as TaskHost;
MainPipe dataFlowTask = (MainPipe)taskHost.InnerObject;
/*===================================================================================
===============================ERROR LOGGING=======================================
===================================================================================*/
package.LoggingMode = DTSLoggingMode.Enabled;
//For package logging connection manager (flat file)
ConnectionManager LogConMgr = package.Connections.Add("FILE");
LogConMgr.ConnectionString = this.LogFilePath;
LogConMgr.Name = "SSISLog.txt";
LogProvider packagelogprovider = package.LogProviders.Add("DTS.LogProviderTextFile.2");
packagelogprovider.ConfigString = LogConMgr.Name;
packagelogprovider.Name = "Text File Log Provider";
packagelogprovider.Description = "Writes log entries for events to a CSV file";
package.LoggingOptions.SelectedLogProviders.Add(packagelogprovider);
LoggingOptions packageLogging = package.LoggingOptions;
packageLogging.EventFilterKind = DTSEventFilterKind.Inclusion;
packageLogging.EventFilter.Initialize();
packageLogging.EventFilter = new string[] { "OnError", "OnWarning", "OnInformation", "OnPreExecute", "OnExecute", "Diagnostic", "PipelineComponentTime", "OnExecStatusChanged", "OnPostExecute", "OnProgress", "OnPreValidate", "OnPostValidate" };
//OnError Event
DTSEventColumnFilter OnErrorColumnFilter = new DTSEventColumnFilter();
OnErrorColumnFilter.Computer = true;
OnErrorColumnFilter.SourceName = true;
OnErrorColumnFilter.MessageText = true;
OnErrorColumnFilter.SourceName = true;
OnErrorColumnFilter.SourceID = true;
OnErrorColumnFilter.DataBytes = true;
packageLogging.SetColumnFilter("OnError", OnErrorColumnFilter);
//OnWarning Event
DTSEventColumnFilter OnWarningColumnFilter = new DTSEventColumnFilter();
OnWarningColumnFilter.Computer = true;
OnWarningColumnFilter.SourceName = true;
OnWarningColumnFilter.MessageText = true;
packageLogging.SetColumnFilter("OnWarning", OnWarningColumnFilter);
/*==================================================================================
================END ERROR LOGGING=================================================
==================================================================================*/
/*=================================================================================
=========================== FOR SOURCE CONNECTION ===============================
=================================================================================*/
/* Add the Flat File connection*/
ConnectionManager connectionManagerFlatFile = package.Connections.Add("FLATFILE");
connectionManagerFlatFile.ConnectionString = this.FlatFileConnString;
connectionManagerFlatFile.Name = "FlatFile";
connectionManagerFlatFile.Properties["Format"].SetValue(connectionManagerFlatFile, this.FlatFileColFormat);
connectionManagerFlatFile.Properties["ColumnNamesInFirstDataRow"].SetValue(connectionManagerFlatFile, this.FirstRowAsCol);
/* Get native flat file connection */
RuntimeWrapper.IDTSConnectionManagerFlatFile100 connectionFlatFile =
connectionManagerFlatFile.InnerObject as RuntimeWrapper.IDTSConnectionManagerFlatFile100;
/* Specify Column delimeter*/
connectionFlatFile.HeaderRowDelimiter = Environment.NewLine;
connectionFlatFile.RowDelimiter = Environment.NewLine;
connectionFlatFile.DataRowsToSkip = 0;
connectionFlatFile.HeaderRowsToSkip = RowsToSkip;
//connectionFlatFile.ColumnNamesInFirstDataRow = this.firstRowAsCol;
/*Determine the number of columns by reading Mapping Information.*/
foreach (DictionaryEntry de in (IDictionary)MapInfo)
{
if (Int32.Parse(de.Key.ToString()) != 0)
{
RuntimeWrapper.IDTSConnectionManagerFlatFileColumn100 flatFileCol =
connectionFlatFile.Columns.Add() as RuntimeWrapper.IDTSConnectionManagerFlatFileColumn100;
//sS_AssignColumnProperties(flatFileCol, parts[col], new string(delimit));
sS_AssignColumnProperties(flatFileCol, de.Value.ToString(), LenMap[Int32.Parse(de.Key.ToString())]);
}
}
//Correct the last Flat File column delimiter, needs to be NewLine not Comma
connectionFlatFile.Columns[connectionFlatFile.Columns.Count - 1].ColumnDelimiter = Environment.NewLine;
// Check if columns generated
if (connectionFlatFile.Columns.Count == 0)
{
throw new ArgumentException(string.Format("No flat file columns have been created. "));
}
// Add Flat File source component
IDTSComponentMetaData100 componentSource = dataFlowTask.ComponentMetaDataCollection.New();
componentSource.Name = "FlatFileSource";
componentSource.ComponentClassID = "DTSAdapter.FlatFileSource.2";
// componentSource.UsesDispositions = true;
// Get source design-time instance, and initialise component
CManagedComponentWrapper instanceSource = componentSource.Instantiate();
instanceSource.ProvideComponentProperties();
// Set source connection
componentSource.RuntimeConnectionCollection[0].ConnectionManagerID = connectionManagerFlatFile.ID;
componentSource.RuntimeConnectionCollection[0].ConnectionManager =
DtsConvert.GetExtendedInterface(connectionManagerFlatFile);
// Reinitialize the metadata,
instanceSource.AcquireConnections(null);
instanceSource.ReinitializeMetaData();
instanceSource.ReleaseConnections();
IDTSOutput100 output = componentSource.OutputCollection[0];
Stack<int> ColumnsToRemove = new Stack<int>();
for (int outCol = 0; outCol < output.OutputColumnCollection.Count; outCol++)
{
IDTSOutputColumn100 column = output.OutputColumnCollection[outCol];
column.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
column.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
}
/*===================================================================================
* ===================================Add Row Number Transformation==================
* ===================================================================================*/
// Create a package variable to store the row count value
package.Variables.Add("RowCountVar", false, "User", 0);
IDTSComponentMetaData100 componentRowNumber = dataFlowTask.ComponentMetaDataCollection.New();
componentRowNumber.Name = "RowNumberTransformation";
componentRowNumber.ComponentClassID = "DTSTransform.RowCount";
CManagedComponentWrapper instanceRowNumber = componentRowNumber.Instantiate();
instanceRowNumber.ProvideComponentProperties();
// Set the variable name property
instanceRowNumber.SetComponentProperty("VariableName", "User::RowCountVar");
// Connect the two components together
IDTSPath100 path = dataFlowTask.PathCollection.New();
path.AttachPathAndPropagateNotifications(componentSource.OutputCollection[0], componentRowNumber.InputCollection[0]);
/*End Row Number Transformation*/
/*=================================================================================
======================== FOR DESTINATION CONNECTION =============================
=================================================================================*/
/* Add the SQL OLE-DB connection*/
ConnectionManager connectionManagerOleDb = package.Connections.Add("OLEDB");
//connectionManagerOleDb.ConnectionString = this.OleDbConnString;
connectionManagerOleDb.ConnectionString = string.Format(
"Provider=SQLOLEDB;Data Source={0};Initial Catalog={1};User ID=truser;Password=truser", this.DBServerName, this.DBName);
connectionManagerOleDb.Name = "OLEDB";
/*=================================================================================
============================Derived Columns======================================
=================================================================================*/
//Derived Column
IDTSComponentMetaData100 derived = dataFlowTask.ComponentMetaDataCollection.New();
derived.Name = "Derived Column Component";
derived.ComponentClassID = "DTSTransform.DerivedColumn";
CManagedComponentWrapper DesignDerivedColumns = derived.Instantiate();
DesignDerivedColumns.ProvideComponentProperties(); //design time
derived.InputCollection[0].ExternalMetadataColumnCollection.IsUsed = false;
derived.InputCollection[0].HasSideEffects = true;
//update the metadata for the derived columns
DesignDerivedColumns.AcquireConnections(null);
DesignDerivedColumns.ReinitializeMetaData();
DesignDerivedColumns.ReleaseConnections();
//Create the path from source to derived component
IDTSPath100 SourceToDerivedPath = dataFlowTask.PathCollection.New();
SourceToDerivedPath.AttachPathAndPropagateNotifications(componentRowNumber.OutputCollection[0], derived.InputCollection[0]);
/*Replace Values of Input to null for empty string*/
// Get the derived's default input and virtual input.
IDTSInput100 input = derived.InputCollection[0];
IDTSVirtualInput100 derivedInputVirtual = input.GetVirtualInput();
IDTSCustomProperty100 property = null;
// Iterate through the virtual input column collection.
foreach (IDTSVirtualInputColumn100 vColumn in derivedInputVirtual.VirtualInputColumnCollection)
{
DesignDerivedColumns.SetUsageType(input.ID, derivedInputVirtual, vColumn.LineageID, DTSUsageType.UT_READWRITE);
}
foreach (IDTSInputColumn100 inputColumn in derived.InputCollection[0].InputColumnCollection)
{
inputColumn.Description = string.Format("Override the orginal column {0} with a null value if the string is empty.", inputColumn.Name);
property = inputColumn.CustomPropertyCollection["Expression"];
property.Name = "Expression";
property.Value = string.Format("(DT_STR,{0},1252)(LEN(TRIM([{1}])) == 0 ? (DT_STR,{0},1252)(NULL(DT_STR,{0},1252)) : TRIM([{1}]))", inputColumn.Length, inputColumn.Name);
property = inputColumn.CustomPropertyCollection["FriendlyExpression"];
property.Name = "FriendlyExpression";
property.Value = string.Format("(DT_STR,{0},1252)(LEN(TRIM([{1}])) == 0 ? (DT_STR,{0},1252)(NULL(DT_STR,{0},1252)) : TRIM([{1}]))", inputColumn.Length, inputColumn.Name);
inputColumn.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
inputColumn.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
}
/*End Replace Values of Input to null for empty string*/
//For Batch Id
IDTSOutputColumn100 myCol = derived.OutputCollection[0].OutputColumnCollection.New();
myCol.Name = "BtchId";
myCol.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_I4, 0, 0, 0, 0);
myCol.ExternalMetadataColumnID = 0;
myCol.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
myCol.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
IDTSCustomProperty100 myProp = myCol.CustomPropertyCollection.New();
myProp.Name = "Expression";
myProp.Value = "\"" + this.BatchId.ToString() + "\"";
myProp = myCol.CustomPropertyCollection.New();
myProp.Name = "FriendlyExpression";
myProp.Value = "\"" + this.BatchId.ToString() + "\"";
// For FileNm
IDTSOutputColumn100 fleNmCol = derived.OutputCollection[0].OutputColumnCollection.New();
fleNmCol.Name = "CSVFileNm";
fleNmCol.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR, 1100, 0, 0, 1252);
fleNmCol.ExternalMetadataColumnID = 0;
fleNmCol.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
fleNmCol.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
IDTSCustomProperty100 fleNmProp = fleNmCol.CustomPropertyCollection.New();
fleNmProp.Name = "Expression";
fleNmProp.Value = " \" " + this.FileName.Replace("\\", "\\\\") + " \"";
fleNmProp = fleNmCol.CustomPropertyCollection.New();
fleNmProp.Name = "FriendlyExpression";
fleNmProp.Value = " \" " + "csvFile.csv" + " \"";
// For FileDate
IDTSOutputColumn100 fleDtCol = derived.OutputCollection[0].OutputColumnCollection.New();
fleDtCol.Name = "FileDt";
fleDtCol.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR, 50, 0, 0, 1252);
fleDtCol.ExternalMetadataColumnID = 0;
fleDtCol.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
fleDtCol.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
IDTSCustomProperty100 fleDtProp = fleDtCol.CustomPropertyCollection.New();
fleDtProp.Name = "Expression";
fleDtProp.Value = "\"" + this.FileDate + "\"";
fleDtProp = fleDtCol.CustomPropertyCollection.New();
fleDtProp.Name = "FriendlyExpression";
fleDtProp.Value = "\"" + this.FileDate + "\"";
package.Variables.Add("RowNumber", false, "User", 1);
// For RowNum
IDTSOutputColumn100 RowNumCol = derived.OutputCollection[0].OutputColumnCollection.New();
RowNumCol.Name = "RowNum";
RowNumCol.SetDataTypeProperties(Microsoft.SqlServer.Dts.Runtime.Wrapper.DataType.DT_STR, 3, 0, 0, 1252);
RowNumCol.ExternalMetadataColumnID = 0;
RowNumCol.ErrorRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
RowNumCol.TruncationRowDisposition = DTSRowDisposition.RD_IgnoreFailure;
IDTSCustomProperty100 RowNumColProp = RowNumCol.CustomPropertyCollection.New();
RowNumColProp.Name = "Expression";
RowNumColProp.Value = "DATEPART(\"Ms\",GetDate())";
RowNumColProp = RowNumCol.CustomPropertyCollection.New();
RowNumColProp.Name = "FriendlyExpression";
RowNumColProp.Value = "DATEPART(\"Ms\",GetDate())";
/*Script Component*/
IDTSComponentMetaData100 scriptPropType = dataFlowTask.ComponentMetaDataCollection.New();
scriptPropType.Name = "Transform Property Type";
scriptPropType.ComponentClassID = "DTSTransform.ScriptComponent";
scriptPropType.Description = "Transform Property Type";
CManagedComponentWrapper instance2 = scriptPropType.Instantiate();
instance2.ProvideComponentProperties();
string[] scriptValue = new String[4];
scriptValue[0] = "dts://Scripts/" + "ScriptComponent_9ddf9eba6f5b488f9710b95e4d7e7c74" + "/" + "ScriptComponent_9ddf9eba6f5b488f9710b95e4d7e7c74" + ".vsaproj";
scriptValue[1] = Resources.ProjectFile;//????????
scriptValue[2] = "dts://Scripts/" + "ScriptComponent_9ddf9eba6f5b488f9710b95e4d7e7c74" + "/ScriptMain.vsaitem";
scriptValue[3] = "/* Microsoft SQL Server Integration Services user script component\r\n"
+ "* This is your new script component in Microsoft Visual Basic .NET \r\n"
+ "* ScriptMain is the entrypoint class for script components*/\r\n"
+ "\r\n"
+ "using System \r\n"
+ "using System.Data \r\n"
+ "using System.Math \r\n"
+ "using Microsoft.SqlServer.Dts.Pipeline.Wrapper \r\n"
+ "using Microsoft.SqlServer.Dts.Runtime.Wrapper \r\n"
+ " \r\n"
+ "public class ScriptMain:UserComponent \r\n"
+ "{ \r\n"
+ " int i;\r\n"
+ "public override void PreExecute(){\r\n"
+ "base.PreExecute();\r\n"
+ " i=0;\r\n"
+ "}\r\n"
+ "public override void postExecute(){\r\n"
+ "base.postExecute();\r\n"
+ "}\r\n"
+ " public override void Input0_ProcessInputRow(Input0Buffer Row){ \r\n"
+ " ++i;\r\n"
+ " Row.RowNum = i.ToString(); \r\n"
+ " } \r\n"
+ "} \r\n";
IDTSDesigntimeComponent100 scriptComponentDesignTime = instance2 as IDTSDesigntimeComponent100;
scriptComponentDesignTime.SetComponentProperty("SourceCode", scriptValue);
scriptComponentDesignTime.SetComponentProperty("PreCompile", false);
/*End Script Component
/*=================================================================================
======================== FOR DESTINATION ========================================
=================================================================================*/
/*Add OLE-DB destination*/
IDTSComponentMetaData100 componentDestination = dataFlowTask.ComponentMetaDataCollection.New();
componentDestination.Name = "OLEDBDestination";
componentDestination.ComponentClassID = "DTSAdapter.OLEDBDestination.2";
/* Get destination design-time instance, and initialise component*/
CManagedComponentWrapper instanceDestination = componentDestination.Instantiate();
instanceDestination.ProvideComponentProperties();
/* Set destination connection*/
componentDestination.RuntimeConnectionCollection[0].ConnectionManagerID = connectionManagerOleDb.ID;
componentDestination.RuntimeConnectionCollection[0].ConnectionManager =
DtsConvert.GetExtendedInterface(connectionManagerOleDb);
/* Set destination table name*/
instanceDestination.SetComponentProperty("OpenRowset", this.TargetTable);
instanceDestination.SetComponentProperty("AccessMode", 0);
//instanceDestination.SetComponentProperty("ProtectionLevel", "SaveSensitive");
instanceDestination.SetComponentProperty("DefaultCodePage", 1252);
/* Set Data Flow direction*/
//Create the path from derived to desitination
IDTSPath100 DerivedToDestinationPath = dataFlowTask.PathCollection.New();
DerivedToDestinationPath.AttachPathAndPropagateNotifications(derived.OutputCollection[0], componentDestination.InputCollection[0]);
/* Get input and virtual input for destination to select and map columns*/
IDTSInput100 destinationInput = componentDestination.InputCollection[0];
IDTSVirtualInput100 destinationVirtualInput = destinationInput.GetVirtualInput();
IDTSVirtualInputColumnCollection100 destinationVirtualInputColumns = destinationVirtualInput.VirtualInputColumnCollection;
//componentDestination.ValidateExternalMetadata = false;
/* Reinitialize the metadata, generating exernal columns from flat file columns
If errors are raised here, it is most likely because the flat file connection columns
are wrong, which itself is probably because the template table does not match the file.*/
instanceDestination.AcquireConnections(null);
instanceDestination.ReinitializeMetaData();
instanceDestination.ReleaseConnections();
/*=================================================================================
======================== MAP DESTINATION ========================================
=================================================================================*/
/*Select and map destination columns*/
foreach (IDTSVirtualInputColumn100 virtualInputColumn in destinationVirtualInputColumns)
{
// Select column, and retain new input column
IDTSInputColumn100 inputColumn = instanceDestination.SetUsageType(destinationInput.ID,
destinationVirtualInput, virtualInputColumn.LineageID, DTSUsageType.UT_READWRITE);
// Find external column by name
IDTSExternalMetadataColumn100 externalColumn =
destinationInput.ExternalMetadataColumnCollection[inputColumn.Name];
// Map input column to external column
instanceDestination.MapInputColumn(destinationInput.ID, inputColumn.ID, externalColumn.ID);
}
new Application().SaveToXml("E:\\TrustPortal-All\\SourceCode\\TrustSolution\\Web\\TrustSolution\\TrustRite\\OtherActivity\\Import\\Temp\\test.dtsx", package, null);
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
this.RowCount = GetRowCount(package);
string message = "";
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
{
message += local_DtsError.Description.ToString();
}
}
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success)
{
message = "Package Executed Successfully....";
}
package.Dispose();
return results;
}
}
private void sS_AssignColumnProperties(RuntimeWrapper.IDTSConnectionManagerFlatFileColumn100 flatFileCol, string getColName, int colLength)
{
//Assign delimiter:
flatFileCol.ColumnType = this.FlatFileColFormat;
//Indicate column data type – in this case, all the source columns will be set to String Data Type:
flatFileCol.DataType = RuntimeWrapper.DataType.DT_STR;
flatFileCol.MaximumWidth = colLength;
//Indicate column width – in this case, width of all source columns will be set to a length of 50:
flatFileCol.ColumnWidth = colLength; //flatFileColWidth;
flatFileCol.DataPrecision = 0;
flatFileCol.DataScale = 0;
//Assign column name:
RuntimeWrapper.IDTSName100 columnName = flatFileCol as RuntimeWrapper.IDTSName100;
columnName.Name = getColName;
}

Edit JSON Response in AngularJS and bind to the list

Hi I know how to read form json and bind the output to the view however I would like to add some logic into the output and bid converted data. How do I output my forEach to the array and than do ng-repeat based on it or combine my ajax data binding with my amendments?
At the moment if I change
$scope.fleet = newData; => $scope.fleet = data;
and view.html eg. {{item.name}} everything works but I would like to add some changes to the name before binding.
My code:
controler.js
function LoadFleetControler($scope){
$.ajax({
url: 'https://someapi/list',
type: 'GET',
dataType: 'json',
success: function (data) {
var newData = [];
angular.forEach(data, function(value, key){
/* ############################ Options ############################ */
var d = new Date();
var month = d.getMonth() + 1;
var thisDate = d.getDate() + '/' + padLeft(month,2) + '/' + d.getFullYear();
var thisCycle = dateToDays(thisDate, value.end_bill_date) + 1; // Include last 24H
/* ############################ Scope ############################ */
$scope.fleetUser = value.name;
$scope.fleetCycle = 'Cycle: ' + thisCycle + ' days left (' + value.end_bill_date + ')';
$scope.fleetPercentageUsed = value.percentage_used;
$scope.fleetCycleColor = highlighSwitch(value.percentage_used);
}, newData);
console.log(newData);
$scope.fleet = newData;
$scope.$apply();
},
error: function(data) {
$scope.error = true;
$scope.$apply();
}
});
}
view.html
<div ng-controller="LoadFleetControler">
<ons-list>
<ons-list-item ng-show="error">Server Connection Error</ons-list-item>
<ons-list-item class="topcoat-list__item__line-height" ng-repeat="item in fleet">
{{fleetUser}}
<small>{{fleetCycle}}</small>
</ons-list-item>
</ons-list>
</div>
Inside angular.forEach(), you are assigning items to the scope, when you probably meant to create new objects and add them to the newData array...
angular.forEach(data, function(value, key){
// ...
var newItem = {};
newItem.fleetUser = value.name;
newItem.fleetCycle = 'Cycle: ' + thisCycle + ' days left (' + value.end_bill_date + ')';
newItem.fleetPercentageUsed = value.percentage_used;
newItem.fleetCycleColor = highlighSwitch(value.percentage_used);
newData.push(newItem);
}
);

AS3 Error: 1078: Label must be a simple identifier

I have some code not written by me that I'm trying to compile.
public static function getUserInfoObject(info:Array) : Object {
var lastBattleTime:Number = info[7];
var listLength:Number = info[8];
var list:Array = info.slice(9,9 + listLength);
var achievesLength:Number = info[9 + listLength];
var achievements:Array = info.slice(10 + listLength,10 + listLength + achievesLength);
var statsLength:Number = info[10 + listLength + achievesLength];
var stats:Array = info.slice(11 + listLength + achievesLength,11 + listLength + achievesLength + statsLength);
var commonInfo:Array = info.slice(11 + listLength + achievesLength + statsLength,11 + listLength + achievesLength + statsLength + 8);
return
{
"uid":info[0],
"name":info[1],
"chatRoster":info[2],
"status":info[3],
"displayName":info[5],
"list":list,
"achievements":achievements,
"stats":stats,
"commonInfo":commonInfo,
"creationTime":App.utils.locale.longDate(info[6]),
"lastBattleTime":(lastBattleTime == 0?"":App.utils.locale.longDate(lastBattleTime) + " " + App.utils.locale.longTime(lastBattleTime))
};
}
It gives me this error: 1078: Label must be a simple identifier. in every line in return.
Am I blind or dumb or this code is bad?
You should start your return statement with the curly brace, not with new line:
public static function getUserInfoObject(info:Array) : Object {
return { // <-Here
};
}