コード例 #1
0
ファイル: DoStepsHost.cs プロジェクト: kpboyle1/devtreks
        private async Task <bool> RunStepAsync(ContentURI docToCalcURI, ContentURI calcDocURI,
                                               string step, DoStepsHostView hostview, IList <string> urisToAnalyze,
                                               IDictionary <string, string> updates, CancellationToken cancellationToken)
        {
            bool bIsStepDone = false;
            //convert DevTreks' base model to the Extensions base model
            ExtensionContentURI extDocToCalcURI
                = new ExtensionContentURI(docToCalcURI);

            //extensions sets html view needed for each step
            extDocToCalcURI.URIDataManager.NeedsFullView    = false;
            extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
            ExtensionContentURI extCalcDocURI
                = new ExtensionContentURI(calcDocURI);

            //always display calculator
            extCalcDocURI.URIDataManager.NeedsFullView = true;
            //return Task.Run(() =>
            //{
            //    cancellationToken.ThrowIfCancellationRequested();
            //}, cancellationToken);

            if (calcDocURI.URIDataManager.HostName.ToLower() ==
                DataHelpers.AddInHelper.HOSTS.extensioncalculatorsteps.ToString())
            {
                //compute bound and mostly run synchronously
                bIsStepDone = await hostview.RunCalculatorStep(
                    extDocToCalcURI, extCalcDocURI, step,
                    urisToAnalyze, updates, cancellationToken);

                //set any new general display parameters
                docToCalcURI.URIDataManager.NeedsFullView
                    = extDocToCalcURI.URIDataManager.NeedsFullView;
                docToCalcURI.URIDataManager.NeedsSummaryView
                    = extDocToCalcURI.URIDataManager.NeedsSummaryView;
                docToCalcURI.URIDataManager.TempDocSaveMethod
                    = extDocToCalcURI.URIDataManager.TempDocSaveMethod;
                docToCalcURI.ErrorMessage += extDocToCalcURI.ErrorMessage;
            }
            else if (calcDocURI.URIDataManager.HostName.ToLower() ==
                     DataHelpers.AddInHelper.HOSTS.extensionanalyzersteps.ToString())
            {
                //compute bound and mostly run synchronously
                bIsStepDone = await hostview.RunAnalyzerStep(
                    extDocToCalcURI, extCalcDocURI, step,
                    urisToAnalyze, updates, cancellationToken);

                //set any new general display parameters
                docToCalcURI.URIDataManager.NeedsFullView
                    = extDocToCalcURI.URIDataManager.NeedsFullView;
                docToCalcURI.URIDataManager.NeedsSummaryView
                    = extDocToCalcURI.URIDataManager.NeedsSummaryView;
                docToCalcURI.URIDataManager.TempDocSaveMethod
                    = extDocToCalcURI.URIDataManager.TempDocSaveMethod;
                docToCalcURI.ErrorMessage += extDocToCalcURI.ErrorMessage;
            }
            //newly inserted calculators usually set new fileextensiontypes
            if (extCalcDocURI.URIFileExtensionType
                != calcDocURI.URIFileExtensionType &&
                (!string.IsNullOrEmpty(extCalcDocURI.URIFileExtensionType)) &&
                extCalcDocURI.URIFileExtensionType != Constants.NONE)
            {
                //note: nothing more should be done with this parameter
                //linked view authors must manually set this property on
                //the LinkedView html form (previously ran unnecessary db updates)
                calcDocURI.URIFileExtensionType
                    = extCalcDocURI.URIFileExtensionType;
            }
            if (docToCalcURI.ErrorMessage == string.Empty)
            {
                //set new stylesheet parameters
                //note that the sshelper looks for ssname2, which could be passed to it here
                IContentRepositoryEF contentRepository
                    = new DevTreks.Data.SqlRepositories.ContentRepository(docToCalcURI);
                //i/o bound and run async
                await contentRepository.SetLinkedViewStateAsync(docToCalcURI, docToCalcURI);

                contentRepository.Dispose();
            }

            return(bIsStepDone);
        }