public void analyze(long max_duration_in_ms, ExceLint.FeatureConf config, Boolean forceDAGBuild, ProgBar pb) { var sw = new System.Diagnostics.Stopwatch(); sw.Start(); // disable screen updating during analysis to speed things up var initial_state = _app.ScreenUpdating; _app.ScreenUpdating = false; // Also disable alerts; e.g., Excel thinks that compute-bound plugins // are deadlocked and alerts the user. ExceLint really is just compute-bound. _app.DisplayAlerts = false; // build data dependence graph try { // test Graph g = new Graph(_app, (Worksheet)_app.ActiveSheet); _analysis = inProcessAnalysis(max_duration_in_ms, config, g, Progress.NOPProgress()); if (!_analysis.ranOK) { System.Windows.Forms.MessageBox.Show("This spreadsheet contains no formulas."); return; } //else //{ // var output = String.Join("\n", _analysis.model.ranking()); // System.Windows.Forms.Clipboard.SetText(output); // System.Windows.Forms.MessageBox.Show("look in clipboard"); //} } catch (AST.ParseException e) { // UI cleanup repeated here since the throw // below will cause the finally clause to be skipped _app.DisplayAlerts = true; _app.ScreenUpdating = initial_state; throw e; } finally { // Re-enable alerts _app.DisplayAlerts = true; // Enable screen updating when we're done _app.ScreenUpdating = initial_state; } sw.Stop(); }
public Analysis inProcessAnalysis(long max_duration_in_ms, ExceLint.FeatureConf config, Graph g, Progress p) { // sanity check if (g.NumFormulas == 0) { return(new Analysis { scores = null, ranOK = false, cutoff = 0 }); } else { // run analysis FSharpOption <ExceLint.ErrorModel> mopt; try { mopt = ExceLint.ModelBuilder.analyze(_app, config, g, 0, p); } catch (ExceLint.CommonTypes.NoFormulasException e) { System.Windows.Forms.MessageBox.Show(e.Message); throw new AnalysisCancelled(); } if (FSharpOption <ExceLint.ErrorModel> .get_IsNone(mopt)) { throw new AnalysisCancelled(); } else { var model = mopt.Value; Score[] scores = model.ranking(); int cutoff = model.Cutoff; return(new Analysis { scores = scores, ranOK = true, cutoff = cutoff, model = model, hasRun = true, dag = g }); } } }
public ExceLint.EntropyModelBuilder2.EntropyModel2 NewEntropyModelForWorksheet2(Worksheet w, ExceLint.FeatureConf conf, Graph g, ProgBar pb) { // create return(ExceLint.ModelBuilder.initEntropyModel2(_app, conf, g, Progress.NOPProgress())); }