コード例 #1
0
ファイル: NPV1.cs プロジェクト: kpboyle1/devtreks.3.1
 private static void CheckForLastStepAnalyzer(
     NPV1AnalyzerHelper.ANALYZER_TYPES analyzerType,
     ContractHelpers.EXTENSION_STEPS stepNumber,
     ExtensionContentURI extDocToCalcURI)
 {
     //this release only includes three step analyzers
 }
コード例 #2
0
ファイル: NPV1.cs プロジェクト: kpboyle1/devtreks.3.1
        public async Task <bool> RunAnalyzerStep(
            ExtensionContentURI extDocToCalcURI, ExtensionContentURI extCalcDocURI,
            string stepNumber, IList <string> urisToAnalyze,
            IDictionary <string, string> updates, CancellationToken cancellationToken)
        {
            bool bHasAnalysis = false;
            CalculatorParameters npv1CalcParams
                = CalculatorHelpers.SetCalculatorParameters(
                      extDocToCalcURI, extCalcDocURI, stepNumber, urisToAnalyze,
                      updates);
            NPV1AnalyzerHelper npv1AnalyzerHelper = new NPV1AnalyzerHelper(npv1CalcParams);

            //check to make sure the analyzer can be run
            npv1AnalyzerHelper.SetOptions();
            bool bHasUpdates = false;

            if (npv1AnalyzerHelper.NPV1CalculatorParams.ErrorMessage != string.Empty)
            {
                extDocToCalcURI.ErrorMessage += npv1AnalyzerHelper.NPV1CalculatorParams.ErrorMessage;
                return(false);
            }
            ContractHelpers.EXTENSION_STEPS eStepNumber
                = ContractHelpers.GetEnumStepNumber(stepNumber);
            switch (eStepNumber)
            {
            case ContractHelpers.EXTENSION_STEPS.stepzero:
                bHasAnalysis = true;
                break;

            case ContractHelpers.EXTENSION_STEPS.stepone:
                bHasAnalysis = true;
                break;

            case ContractHelpers.EXTENSION_STEPS.steptwo:
                //clear updates collection
                updates.Clear();
                //just need the html form edits in this step
                bHasAnalysis = true;
                extDocToCalcURI.URIDataManager.NeedsFullView    = false;
                extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                break;

            case ContractHelpers.EXTENSION_STEPS.stepthree:
                //get rid of any update member that was added after running the same step 2x
                bHasUpdates = await CalculatorHelpers.RefreshUpdates(npv1CalcParams, stepNumber, updates);

                //linked view insertions needs some analysis parameters
                SetAnalyzerParameters(npv1AnalyzerHelper, npv1CalcParams);
                if (npv1CalcParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.devpacks)
                {
                    bHasAnalysis = await npv1AnalyzerHelper.RunAnalysis(npv1CalcParams.UrisToAnalyze);
                }
                else
                {
                    bHasAnalysis = await npv1AnalyzerHelper.RunAnalysis();
                }
                extDocToCalcURI.ErrorMessage  = npv1CalcParams.ErrorMessage;
                extDocToCalcURI.ErrorMessage += npv1AnalyzerHelper.NPV1CalculatorParams.ErrorMessage;
                if (!bHasAnalysis)
                {
                    extDocToCalcURI.ErrorMessage = (extDocToCalcURI.ErrorMessage == string.Empty) ?
                                                   Errors.MakeStandardErrorMsg("CALCULATORS_URI_MISMATCH")
                            : extDocToCalcURI.ErrorMessage;
                    return(bHasAnalysis);
                }
                if (string.IsNullOrEmpty(extDocToCalcURI.ErrorMessage))
                {
                    //two step analyzers need to be saved now
                    NPV1AnalyzerHelper.ANALYZER_TYPES eAnalyzerType
                        = npv1AnalyzerHelper.GetAnalyzerType(
                              npv1AnalyzerHelper.NPV1CalculatorParams.AnalyzerParms.AnalyzerType);
                    //when 3+ step analyzers start being used
                    CheckForLastStepAnalyzer(eAnalyzerType,
                                             eStepNumber, extDocToCalcURI);
                    if (!CalculatorHelpers.IsSaveAction(extDocToCalcURI))
                    {
                        //replace the old calculator with the new one
                        //and save the new calculations document
                        bool bHasReplacedCalcDoc
                            = await CalculatorHelpers.SaveNewCalculationsDocument(
                                  npv1AnalyzerHelper.NPV1CalculatorParams);

                        if (bHasReplacedCalcDoc)
                        {
                            bHasAnalysis = true;
                        }
                        else
                        {
                            extDocToCalcURI.ErrorMessage = Errors.MakeStandardErrorMsg("ANALYSES_ID_MISMATCH");
                        }
                    }
                }
                else
                {
                    bHasAnalysis = false;
                }
                extDocToCalcURI.URIDataManager.NeedsFullView    = true;
                extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                break;

            case ContractHelpers.EXTENSION_STEPS.stepfour:
                bHasAnalysis = true;
                if (npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvtotal1 ||
                    npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvstat1 ||
                    npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeyr ||
                    npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeid ||
                    npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangealt ||
                    npv1AnalyzerHelper.AnalyzerType
                    == NPV1AnalyzerHelper.ANALYZER_TYPES.npvprogress1)
                {
                    if (npv1CalcParams.NeedsFullView)
                    {
                        extDocToCalcURI.URIDataManager.NeedsFullView    = true;
                        extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                    }
                    else
                    {
                        extDocToCalcURI.URIDataManager.NeedsFullView    = false;
                        extDocToCalcURI.URIDataManager.NeedsSummaryView = true;
                    }
                    extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(npv1CalcParams.LinkedViewElement,
                                                                                        Calculator1.cFileExtensionType);
                }
                if (extDocToCalcURI.URIDataManager.TempDocSaveMethod
                    == Constants.SAVECALCS_METHOD.saveastext.ToString())
                {
                    //analyzers aren't yet available
                }
                else
                {
                    //tells addinhelper to save calcs
                    CalculatorHelpers.SetTempDocSaveAnalysesProperty(extDocToCalcURI);
                }
                break;

            default:
                //as many steps as needed can be added to this addin
                break;
            }
            extDocToCalcURI.ErrorMessage += npv1AnalyzerHelper.NPV1CalculatorParams.ErrorMessage;
            return(bHasAnalysis);
        }