コード例 #1
0
        private void AddNewInput(InputGroup inGroup, Input input)
        {
            Input i = new Input(input);

            i.Calculators = new List <Calculator1>();
            if (input.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, input.Calculators, i.Calculators);
            }
            i.Inputs = new List <Extensions.Input>();
            if (input.Inputs != null)
            {
                foreach (Input inputseries in input.Inputs)
                {
                    Input inputseries2 = new Input(inputseries);
                    inputseries2.Calculators = new List <Calculator1>();
                    if (inputseries.Calculators != null)
                    {
                        ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, inputseries.Calculators, inputseries2.Calculators);
                    }
                    i.Inputs.Add(inputseries2);
                }
            }
            inGroup.Inputs.Add(i);
        }
コード例 #2
0
        private void AddNewOutput(OutputGroup outGroup, Output output)
        {
            Output o = new Output(output);

            o.Calculators = new List <Calculator1>();
            if (output.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, output.Calculators, o.Calculators);
            }
            o.Outputs = new List <Extensions.Output>();
            if (output.Outputs != null)
            {
                foreach (Output outputseries in output.Outputs)
                {
                    Output outputseries2 = new Output(outputseries);
                    outputseries2.Calculators = new List <Calculator1>();
                    if (outputseries.Calculators != null)
                    {
                        ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, outputseries.Calculators, outputseries2.Calculators);
                    }
                    o.Outputs.Add(outputseries2);
                }
            }
            outGroup.Outputs.Add(o);
        }
コード例 #3
0
        private void AddNewOCToCollection(OperationComponent opComp, List <OperationComponent> ocs)
        {
            OperationComponent oc = new OperationComponent(this.GCCalculatorParams, opComp);

            oc.Calculators = new List <Calculator1>();
            if (opComp.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, opComp.Calculators, oc.Calculators);
            }
            oc.Inputs = new List <Extensions.Input>();
            if (opComp.Inputs != null)
            {
                foreach (Input input in opComp.Inputs)
                {
                    Input i = new Input(input);
                    i.Calculators = new List <Calculator1>();
                    if (input.Calculators != null)
                    {
                        ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, input.Calculators, i.Calculators);
                    }
                    oc.Inputs.Add(i);
                }
            }
            ocs.Add(oc);
        }
コード例 #4
0
        private void AddNewOutcomeToCollection(Outcome oc, List <Outcome> outcomes)
        {
            Outcome outcome = new Outcome(this.GCCalculatorParams, oc);

            outcome.Calculators = new List <Calculator1>();
            if (oc.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, oc.Calculators, outcome.Calculators);
            }
            outcome.Outputs = new List <Extensions.Output>();
            if (oc.Outputs != null)
            {
                foreach (Output output in oc.Outputs)
                {
                    Output o = new Output(output);
                    o.Calculators = new List <Calculator1>();
                    if (output.Calculators != null)
                    {
                        ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, output.Calculators, o.Calculators);
                    }
                    outcome.Outputs.Add(o);
                }
            }
            outcomes.Add(outcome);
        }
コード例 #5
0
        private void AddNewTPToCollection(TimePeriod timeP, List <TimePeriod> tps)
        {
            TimePeriod tp = new TimePeriod(timeP);

            tp.Calculators = new List <Calculator1>();
            if (timeP.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, timeP.Calculators, tp.Calculators);
            }
            //calculators start with inputs and outputs
            tp.OperationComponents = new List <Extensions.OperationComponent>();
            if (timeP.OperationComponents != null)
            {
                foreach (OperationComponent oc in timeP.OperationComponents)
                {
                    AddNewOCToCollection(oc, tp.OperationComponents);
                }
            }
            tp.Outcomes = new List <Extensions.Outcome>();
            if (timeP.Outcomes != null)
            {
                foreach (Outcome outcome in timeP.Outcomes)
                {
                    AddNewOutcomeToCollection(outcome, tp.Outcomes);
                }
            }
            tps.Add(tp);
        }
コード例 #6
0
ファイル: ME2.cs プロジェクト: kpboyle1/devtreks.3.1
 private static void SetAnalyzerParameters(
     ME2AnalyzerHelper me2AnalyzerHelper, CalculatorParameters me2CalcParams)
 {
     me2AnalyzerHelper.SetAnalysisParameters();
     me2CalcParams.FileExtensionType
         = me2AnalyzerHelper.ME2CalculatorParams.FileExtensionType;
     me2CalcParams.Stylesheet2Name
         = me2AnalyzerHelper.ME2CalculatorParams.Stylesheet2Name;
     me2CalcParams.Stylesheet2ObjectNS
         = me2AnalyzerHelper.ME2CalculatorParams.Stylesheet2ObjectNS;
 }
コード例 #7
0
        private void AddNewBudgetToCollection(BudgetInvestment budI, List <BudgetInvestment> bis)
        {
            BudgetInvestment bi = new BudgetInvestment(this.GCCalculatorParams, budI);

            bi.Calculators = new List <Calculator1>();
            if (budI.Calculators != null)
            {
                ME2AnalyzerHelper.CopyStockCalculator(this.GCCalculatorParams, budI.Calculators, bi.Calculators);
            }
            //calculators start with inputs and outputs
            bi.TimePeriods = new List <Extensions.TimePeriod>();
            if (budI.TimePeriods != null)
            {
                foreach (TimePeriod tp in budI.TimePeriods)
                {
                    AddNewTPToCollection(tp, bi.TimePeriods);
                }
            }
            bis.Add(bi);
        }
コード例 #8
0
        public static ME2Stock GetNewME2Stock(CalculatorParameters calcParams,
                                              Calculator1 baseElement, List <Calculator1> calcs, ME2Stock descendant)
        {
            ME2Stock newStock = new ME2Stock(calcParams, calcParams.AnalyzerParms.AnalyzerType);

            if (calcs == null)
            {
                calcs = new List <Calculator1>();
            }
            if (calcs.Count > 0)
            {
                ME2AnalyzerHelper.CopyandInitStockCalculator(calcs
                                                             .FirstOrDefault(), newStock);
            }
            else
            {
                //need the options
                newStock.CopyCalculatorProperties(descendant);
            }
            BIME2StockAnalyzer.CopyBaseElementProperties(baseElement, newStock);
            return(newStock);
        }
コード例 #9
0
ファイル: ME2.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 me2CalcParams
                = CalculatorHelpers.SetCalculatorParameters(
                      extDocToCalcURI, extCalcDocURI, stepNumber, urisToAnalyze,
                      updates);
            ME2AnalyzerHelper me2AnalyzerHelper = new ME2AnalyzerHelper(me2CalcParams);

            //check to make sure the analyzer can be run
            me2AnalyzerHelper.SetOptions();
            if (me2AnalyzerHelper.ME2CalculatorParams.ErrorMessage != string.Empty)
            {
                extDocToCalcURI.ErrorMessage += me2AnalyzerHelper.ME2CalculatorParams.ErrorMessage;
                return(false);
            }
            bool bHasUpdates = 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(me2CalcParams, stepNumber, updates);

                //linked view insertions needs some analysis parameters
                SetAnalyzerParameters(me2AnalyzerHelper, me2CalcParams);
                if (me2CalcParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.devpacks)
                {
                    bHasAnalysis = await me2AnalyzerHelper.RunAnalysis(me2CalcParams.UrisToAnalyze);
                }
                else
                {
                    bHasAnalysis = await me2AnalyzerHelper.RunAnalysis();
                }
                extDocToCalcURI.ErrorMessage  = me2CalcParams.ErrorMessage;
                extDocToCalcURI.ErrorMessage += me2AnalyzerHelper.ME2CalculatorParams.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
                    ME2AnalyzerHelper.ANALYZER_TYPES eAnalyzerType
                        = me2AnalyzerHelper.GetAnalyzerType(
                              me2AnalyzerHelper.ME2CalculatorParams.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(
                                  me2AnalyzerHelper.ME2CalculatorParams);

                        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 (me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.metotal1 ||
                    me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.mestat1 ||
                    me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.mechangeyr ||
                    me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.mechangeid ||
                    me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.mechangealt ||
                    me2AnalyzerHelper.AnalyzerType
                    == ME2AnalyzerHelper.ANALYZER_TYPES.meprogress1)
                {
                    if (me2CalcParams.NeedsFullView)
                    {
                        extDocToCalcURI.URIDataManager.NeedsFullView    = true;
                        extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                    }
                    else
                    {
                        extDocToCalcURI.URIDataManager.NeedsFullView    = false;
                        extDocToCalcURI.URIDataManager.NeedsSummaryView = true;
                    }
                    extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(me2CalcParams.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 += me2AnalyzerHelper.ME2CalculatorParams.ErrorMessage;
            return(bHasAnalysis);
        }