コード例 #1
0
ファイル: DoStepsHost.cs プロジェクト: kpboyle1/devtreks
        public async Task <bool> DoStepAsync(ContentURI docToCalcURI, ContentURI calcDocURI,
                                             string extensionTypeName, IList <string> urisToAnalyze, IDictionary <string, string> updates,
                                             CancellationToken cancellationToken)
        {
            bool bIsStepDone = false;

            try
            {
                //extensiontypename (a parameter stored in db) determines
                //extension to run
                DoStepsHostView hostview = GetDoStepsView(calcDocURI,
                                                          extensionTypeName);
                if (hostview != null)
                {
                    //these extensions define their own number of steps internally
                    string sStepNumber = DataHelpers.AddInHelper.GetStepNumber(docToCalcURI);
                    //use the view to carry out the current step
                    bIsStepDone = await RunStepAsync(docToCalcURI, calcDocURI, sStepNumber,
                                                     hostview, urisToAnalyze, updates, cancellationToken);
                }
                else
                {
                    docToCalcURI.ErrorMessage = Errors.MakeStandardErrorMsg("CALCULATORS_MISSING_HOST");
                }
            }
            catch (CompositionException x)
            {
                docToCalcURI.ErrorMessage = x.ToString();
            }
            return(bIsStepDone);
        }
コード例 #2
0
ファイル: DoStepsHost.cs プロジェクト: kpboyle1/devtreks
        private DoStepsHostView GetDoStepsView(ContentURI uri,
                                               string extensionTypeName)
        {
            DoStepsHostView hostview = null;

            try
            {
                //directory storing extensions (webproject apppath (c:\Devtreks)
                //extension projects use the project's post build event to copy their dlls there
                string sExtensionRoot = DataHelpers.AppSettings.GetExtensionsRelPath(uri);
                CompositionContainer container
                    = GetCompositionContainerFromDirectory(sExtensionRoot);
                container.ComposeParts(this);
                foreach (var calculatorView in calculatorViews)
                {
                    //the export attributes will change in future upgrades
                    //extensiontypename (a parameter stored in db) determines extension to run
                    if (calculatorView.Metadata.CONTRACT_TYPE
                        == CALULATOR_CONTRACT_TYPES.defaultcalculatormanager &&
                        calculatorView.Metadata.CalculatorsExtensionName.ToLower()
                        == extensionTypeName.ToLower())
                    {
                        hostview = calculatorView.Value;
                        container.ReleaseExport(calculatorView);
                        break;
                    }
                }
            }
            catch (CompositionException cex)
            {
                uri.ErrorMessage = cex.ToString();
            }
            return(hostview);
        }
コード例 #3
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);
        }