Example #1
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            // Object Container: Use objectContainer.Get<T>() to retrieve objects from the scope
            var objectContainer = context.GetFromContext <IObjectContainer>(TextApplicationScope.ParentContainerPropertyTag);

            // Inputs
            string inputText = objectContainer.Get <string>();

            // Inputs
            var  begWordsCol        = BegWords.Get(context);
            var  endWordsCol        = EndWords.Get(context);
            var  regexParameterText = RegexParameter.Get(context);
            bool displayLog         = DisplayLog;
            bool displayRegex       = DisplatyRegex;

            //Convert Collection to Array
            string[] begWords = Utils.ConvertCollectionToArray(begWordsCol);

            string[] endWords = null;
            if (endWordsCol != null)
            {
                endWords = Utils.ConvertCollectionToArray(endWordsCol);
            }

            //Output Data Row
            bool bUpdateDataRow  = BUpdateDataRow;
            var  myDataRow       = MyDataRow.Get(context);
            var  myDataRowColumn = MyDataRowColumn.Get(context);
            var  myIndex         = MyIndex.Get(context);

            string OutputString = null;

            ///////////////////////////
            // Add execution logic HERE
            string[] OutputResults = CallExtractions.CallExtractTextBetweenTwoAnchorWords(inputText, begWords, endWords, regexParameterText, displayLog, displayRegex);


ExitLoop:

            #region Update Data Row (optional)
            //Check if functionality is Activated
            if (bUpdateDataRow == true)
            {
                //Check it there is an item to the Output Variable
                if (OutputResults.Length > 0)
                {
                    if (myIndex == -1)
                    {
                        //Upper Bound
                        OutputString = OutputResults[OutputResults.Length - 1];
                    }
                    else
                    {
                        OutputString = OutputResults[myIndex];
                    }

                    //Update Data Row
                    Utils.CallUpdateDataRow2(myDataRow, myDataRowColumn, OutputString);
                }
            }
            #endregion

            ///////////////////////////
            // Outputs
            return((ctx) =>
            {
                Results.Set(ctx, OutputResults);
            });
        }