Exemple #1
0
        /// <summary>
        /// Resumed the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="bookmark">The bookmark.</param>
        /// <param name="value">The value.</param>
        /// <exception cref="System.Exception">
        /// Parent and Child DataList IDs are the same, aborting resumption!
        /// or
        /// Fatal Error : Cannot merge resumed data
        /// or
        /// Fatal Error : Cannot locate Root DataList for resumption!
        /// </exception>
        public virtual void Resumed(NativeActivityContext context, Bookmark bookmark, object value)
        {
            IDSFDataObject    myDO          = context.GetExtension <IDSFDataObject>();
            IDataListCompiler compiler      = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errorResultTO = new ErrorResultTO();
            Guid executionID = myDO.DataListID;

            if (value != null)
            {
                Guid rootID;
                Guid.TryParse(value.ToString(), out rootID);

                if (executionID == rootID)
                {
                    throw new Exception("Parent and Child DataList IDs are the same, aborting resumption!");
                }

                try
                {
                    /* Now perform the shape.... */

                    // First set the parentID on executionID to rootID.. so the shape happens correctly ;)
                    compiler.SetParentID(rootID, executionID);
                    // Next shape the execution result into the root datalist ;)
                    ErrorResultTO tmpErrors;
                    Guid          shapeID = compiler.Shape(rootID, enDev2ArgumentType.Output, OutputMapping, out tmpErrors);
                    errorResultTO.MergeErrors(tmpErrors);

                    // set parent instanceID
                    myDO.DataListID = executionID; // reset the DataListID accordingly

                    if (shapeID != executionID)
                    {
                        throw new Exception("Fatal Error : Cannot merge resumed data");
                    }


                    compiler.ConditionalMerge(DataListMergeFrequency.Always | DataListMergeFrequency.OnResumption,
                                              myDO.DatalistOutMergeID, myDO.DataListID, myDO.DatalistOutMergeFrequency, myDO.DatalistOutMergeType, myDO.DatalistOutMergeDepth);
                    ExecutionStatusCallbackDispatcher.Instance.Post(myDO.BookmarkExecutionCallbackID, ExecutionStatusCallbackMessageType.ResumedCallback);
                }
                finally
                {
                    // At resumption this is the root dl entry ;)

                    // Handle Errors
                    if (errorResultTO.HasErrors())
                    {
                        DisplayAndWriteError("Resumption", errorResultTO);
                        var errorString = errorResultTO.MakeDataListReady();
                        myDO.Environment.AddError(errorString);
                    }
                }
            }
            else
            {
                throw new Exception("Fatal Error : Cannot locate Root DataList for resumption!");
            }
        }