Beispiel #1
0
 //constructor sets class properties
 public ARSTextSubscriber(CalculatorParameters calcParameters,
                          ARSAnalyzerHelper.ANALYZER_TYPES analyzerType)
     : base(calcParameters)
 {
     //the base class holds the parameters
     this.AnalyzerType = analyzerType;
 }
Beispiel #2
0
 private static void CheckForLastStepAnalyzer(
     ARSAnalyzerHelper.ANALYZER_TYPES analyzerType,
     ContractHelpers.EXTENSION_STEPS stepNumber,
     ExtensionContentURI extDocToCalcURI)
 {
     //this release only includes three step analyzers
 }
Beispiel #3
0
        //define the actions to take when the event is raised
        public void SetLinkedView(object sender, CustomEventArgs e)
        {
            //pass a byref xelement from the publisher's data
            XElement          obsElement     = new XElement(e.CurrentElement);
            ARSAnalyzerHelper analyzerHelper = new ARSAnalyzerHelper();

            this.AnalyzerType = analyzerHelper.GetAnalyzerType(e.CalculatorParams.AnalyzerParms.AnalyzerType);
            //if observation documents need to differ depending on the analysis
            //use a switch (this.AnalyzerType) here
            SetLinkedViewAttributes(e.CalculatorParams,
                                    ref obsElement);
            //pass the new statelement back to the publisher
            //by setting the CalculatedElement property of CustomEventArgs
            e.CurrentElement = new XElement(obsElement);
        }
 //constructor sets class properties
 public OCAnalyzerSubscriber(CalculatorParameters calcParameters,
                             ARSAnalyzerHelper.ANALYZER_TYPES analyzerType)
     : base(calcParameters)
 {
     this.AnalyzerType = analyzerType;
 }
Beispiel #5
0
        public async Task <bool> RunAnalyzerStep(
            ExtensionContentURI extDocToCalcURI, ExtensionContentURI extCalcDocURI,
            string stepNumber, IList <string> urisToAnalyze,
            IDictionary <string, string> updates, CancellationToken cancellationToken)
        {
            bool bHasAnalysis = false;
            CalculatorParameters arsCalcParams
                = CalculatorHelpers.SetCalculatorParameters(
                      extDocToCalcURI, extCalcDocURI, stepNumber, urisToAnalyze,
                      updates);
            ARSAnalyzerHelper arsAnalyzerHelper = new ARSAnalyzerHelper(arsCalcParams);

            //check to make sure the analyzer can be run
            arsAnalyzerHelper.SetOptions();
            if (arsAnalyzerHelper.ARSCalculatorParams.ErrorMessage != string.Empty)
            {
                extDocToCalcURI.ErrorMessage += arsAnalyzerHelper.ARSCalculatorParams.ErrorMessage;
                return(false);
            }
            ContractHelpers.EXTENSION_STEPS eStepNumber
                = ContractHelpers.GetEnumStepNumber(stepNumber);
            bool bHasUpdates = false;

            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.RefreshUpdatesUsingDocToCalc(arsCalcParams,
                                                                                   stepNumber, updates);

                if (arsAnalyzerHelper.AnalyzerType
                    == ARSAnalyzerHelper.ANALYZER_TYPES.resources01 ||
                    arsAnalyzerHelper.AnalyzerType.ToString().StartsWith(ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString()))
                {
                    //linked view insertions needs some analysis parameters
                    SetAnalyzerParameters(arsAnalyzerHelper, arsCalcParams);
                    //the calculator pattern handles children linked view insertions
                    //better than the analyzer pattern
                    ARSCalculatorHelper arsCalculatorHelper
                        = new ARSCalculatorHelper(arsCalcParams);
                    if (arsCalcParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.devpacks)
                    {
                        bHasAnalysis = await arsCalculatorHelper.RunAnalysis(arsCalcParams.UrisToAnalyze);
                    }
                    else
                    {
                        bHasAnalysis = await arsCalculatorHelper.RunCalculations();
                    }
                }
                extDocToCalcURI.ErrorMessage = arsAnalyzerHelper.ARSCalculatorParams.ErrorMessage;
                if (!bHasAnalysis)
                {
                    extDocToCalcURI.ErrorMessage = (extDocToCalcURI.ErrorMessage == string.Empty) ?
                                                   Errors.MakeStandardErrorMsg("ANALYSES_URI_MISMATCH")
                            : extDocToCalcURI.ErrorMessage;
                    return(bHasAnalysis);
                }
                if (string.IsNullOrEmpty(extDocToCalcURI.ErrorMessage))
                {
                    //two step analyzers need to be saved now
                    ARSAnalyzerHelper.ANALYZER_TYPES eAnalyzerType
                        = arsAnalyzerHelper.GetAnalyzerType(
                              arsAnalyzerHelper.ARSCalculatorParams.AnalyzerParms.AnalyzerType);
                    //when 3+ step analyzers start being used
                    CheckForLastStepAnalyzer(eAnalyzerType,
                                             eStepNumber, extDocToCalcURI);
                    if (!CalculatorHelpers.IsSaveAction(extCalcDocURI))
                    {
                        //replace the old calculator with the new one
                        //and save the new calculations document
                        bool bHasReplacedCalcDoc
                            = await CalculatorHelpers.SaveNewCalculationsDocument(
                                  arsAnalyzerHelper.ARSCalculatorParams);

                        if (bHasReplacedCalcDoc)
                        {
                            //the resource01 app uses the calculator, rather
                            //than analyzer, pattern (i.e. children linked views
                            //can be inserted)
                            if (arsAnalyzerHelper.AnalyzerType
                                != ARSAnalyzerHelper.ANALYZER_TYPES.resources01 &&
                                (!arsAnalyzerHelper.AnalyzerType.ToString().StartsWith(ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString())))
                            {
                                //and add xmldoc params to update collection
                                //only doctocalc gets updated
                                CalculatorHelpers.AddXmlDocAndXmlDocIdsToUpdates(
                                    arsAnalyzerHelper.ARSCalculatorParams);
                            }
                            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 (arsAnalyzerHelper.AnalyzerType
                    == ARSAnalyzerHelper.ANALYZER_TYPES.resources01)
                {
                    extDocToCalcURI.URIDataManager.NeedsFullView    = true;
                    extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                    extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(arsCalcParams.LinkedViewElement,
                                                                                        Calculator1.cFileExtensionType);
                }
                else if (arsAnalyzerHelper.AnalyzerType
                         == ARSAnalyzerHelper.ANALYZER_TYPES.resources02a ||
                         arsAnalyzerHelper.AnalyzerType
                         == ARSAnalyzerHelper.ANALYZER_TYPES.resources02)
                {
                    extDocToCalcURI.URIDataManager.NeedsFullView    = true;
                    extDocToCalcURI.URIDataManager.NeedsSummaryView = false;
                    extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(arsCalcParams.LinkedViewElement,
                                                                                        Calculator1.cFileExtensionType);
                }
                if (extDocToCalcURI.URIDataManager.TempDocSaveMethod
                    == Constants.SAVECALCS_METHOD.saveastext.ToString())
                {
                    //text files can be filtered by subscribers
                    ARSAnalyzerHelper.ANALYZER_TYPES eAnalyzerType
                        = arsAnalyzerHelper.GetAnalyzerType(
                              arsAnalyzerHelper.ARSCalculatorParams.AnalyzerParms.AnalyzerType);
                    ARSTextSubscriber npvTextSubscriber
                                 = new ARSTextSubscriber(arsCalcParams, eAnalyzerType);
                    bHasAnalysis = await npvTextSubscriber.BuildObservations(urisToAnalyze);

                    if (!bHasAnalysis ||
                        (!string.IsNullOrEmpty(npvTextSubscriber.ObsCalculatorParams.ErrorMessage)))
                    {
                        extDocToCalcURI.ErrorMessage = npvTextSubscriber.ObsCalculatorParams.ErrorMessage;
                        CalculatorHelpers.SetTempDocSaveNoneProperty(extDocToCalcURI);
                    }
                    else
                    {
                        //tells addinhelper to save calcs
                        CalculatorHelpers.SetTempDocSaveAnalysesProperty(extDocToCalcURI);
                    }
                }
                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 += arsCalcParams.ErrorMessage;
            extDocToCalcURI.ErrorMessage += arsAnalyzerHelper.ARSCalculatorParams.ErrorMessage;
            return(bHasAnalysis);
        }
Beispiel #6
0
 //constructor sets class properties
 public ARSObservationsSubscriber(CalculatorParameters calcParameters,
                                  ARSAnalyzerHelper.ANALYZER_TYPES analyzerType)
     : base(calcParameters)
 {
     //the base class holds the parameters
 }