03-09-2015 03:34 AM
I am creating an EG custom task with more than one input data and [InputRequired] attribute being set to [InputResourceType.None].
In task’s [Show] override method I use the [Consumer.ShowInputDataSelector] to require all input data before showing task form.
There is a [TaskSelectedDataControl] control on the task form that user can use it to filter the dataset.
Here is the problem:
An error occurred say “Can not select a data source. Reason: Index out of range.”.
If I ignore the above error and save the task, (the selected input data comes out to the project flow at this time) and open it again and do same processes as above, no error occurs.
Is there any way that I can resolve this problem?
Is there any must thing that I missed after calling ShowInputDataSelector?
You can reproduce this by making a few changes on SASPress.Examples.RunningTotals:
var cookie = string.Empty;
var selectedDatasets = Consumer.ShowInputDataSelector(
null, DataSelectionMode.ReadOnlySingleInput, ServerAccessMode.AnyServer,
"", "SASHELP", string.Empty, ref cookie) as ISASTaskData2;
Thanks in advance.
03-11-2015 05:22 PM
Be sure to check for null on the selectedDatasets variable before you try to reference it. If you click Cancel on the data selector, the return will be null. You should then call ClearInputData and AddInputData only if the selectedDatasets != null.
Also, ShowInputDataSelector returns an array of ISASTaskData, not ISASTaskData2. You should probably not try to cast this to ISASTaskData2 The returned object in the array will support ISASTaskData and ISASTaskData2, but the way the interfaces are designed, I would not cast those to other types unless you need the specific ISASTaskData2 methods/properties.
03-11-2015 11:48 PM
Thanks for you answer, but it still not make my problem solved.
Sorry for the incomplete sample code I posted.
Yes, I do confirm the selectedDatasets variable being not null before doing anything further in my real code.
The reason that I cast the return type of ShowInputDataSelector methods to ISASTaskData2 is for convenience that I will need this later:
1. Get columns of the dataset by using GetColumns() methods of SasData class whose constructor needs a SASTaskData2 type parameter.
2. Set the TaskData property of TaskSelectedDataControl.
I can change both of them to do cast right at it is being used , if it helps, just like the SASPress.Examples.RunningTotals sample shows.
My prolem is, I call Consumer.ShowInputDataSelector to select a data and set it to TaskSelectedDataControl's TaskData property, then in the TaskSelectedDataControl I do nothing but click the OK button, the error message box pops up.
This only occures when I create the task on a new project.