コード例 #1
0
        public CommandOutput Decode(AnalyticsData analysisdata)
        {
            CommandOutput op = new CommandOutput();

            Paragraph Title = new Paragraph();

            OutputHelper.AnalyticsData = analysisdata;
            OutputReader reader = new OutputReader();
            if (analysisdata.Result.CommandString != null && analysisdata.Result.CommandString.Contains("UAloadDataset"))
            {
                reader.Hdr = "Open Dataset"; //21Oct2013
            }
            else
            {
                reader.Hdr = analysisdata.Result.CommandString;
            }
            List<DependencyObject> objs = reader.GetOutput(analysisdata.OutputTemplate);
            op.AddRange(objs);
            return op;
        }
コード例 #2
0
 //selectedForDump is only for SyntaxEditor. (if we want to dump command executed from Syntax Editor or not)
 private void ExecuteAnalysisCommands()
 {
     //UAReturn retval = new UAReturn();
     retval.Success = true;
     AnalyticsData data = new AnalyticsData();
     data.SelectedForDump = selectedForDump;//10Jan2013
     data.PreparedCommand = cmd.CommandSyntax;//storing command
     data.Result = retval;
     //18Nov2013 replared by following data.AnalysisType = cmd.CommandSyntax;
     data.AnalysisType = cmd.CommandSyntax.Equals("bskyfrmtobj") ? ((UAMenuCommand)parameter).commandtype : cmd.CommandSyntax; //"T-Test"; For Parent Node name 02Aug2012
     data.InputElement = element;
     data.DataSource = ds;
     data.OutputTemplate = ((UAMenuCommand)parameter).commandoutputformat;
     UIController.AnalysisComplete(data);
 }
コード例 #3
0
 public void ExecuteXMLDefinedDialog(string command)
 {
     if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: templated dialog execution.", LogLevelEnum.Info);
     //UAReturn retval = new UAReturn();
     retval.Success = true;
     AnalyticsData data = new AnalyticsData();
     data.SelectedForDump = selectedForDump;//10Jan2013
     data.PreparedCommand = command;// cmd.CommandSyntax;//storing command
     data.Result = retval;
     //18Nov2013 replared by following data.AnalysisType = cmd.CommandSyntax;
     //data.AnalysisType = cmd.CommandSyntax.Equals("bskyfrmtobj") ? ((UAMenuCommand)parameter).commandtype : cmd.CommandSyntax; //"T-Test"; For Parent Node name 02Aug2012
     data.AnalysisType = command.Equals("bskyfrmtobj") ? ((UAMenuCommand)parameter).commandtype : command; //"T-Test"; For Parent Node name 02Aug2012
     data.InputElement = element;
     data.DataSource = ds;
     data.OutputTemplate = ((UAMenuCommand)parameter).commandoutputformat;
     if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: AnalysisComplete() function called:", LogLevelEnum.Info);
     UIController.AnalysisComplete(data);
 }
コード例 #4
0
        ////// For Analysis Command Execution from Syntax Editor ///// 
        public void ExecuteSyntaxEditor3(object param, bool selectedForDump)
        {
            parameter = param;
            OnPreExecute(parameter);
            if (!canExecute) return;
            object obj = null;
            string dialogcommandstr = null;
            try
            {
                //here TemplateFileName xaml will have same name as the analysis command function name
                // say- function called frm SynEdtr was 'bsky.my.func()' then in bin\Config\ 
                // dialog xaml, 'bsky.my.func.xaml' and
                // output template file 'bsky.my.func.xml' must exist
                // ie.. func name = xaml name = xml name
                XmlReader xmlr = XmlReader.Create(TemplateFileName);
                xmlr.ReadToFollowing("BSkyCanvas");
                xmlr.MoveToAttribute("CommandString");
                dialogcommandstr = xmlr.Value.Replace(" ", string.Empty).Replace('\"', '\'');
                xmlr.Close();
                obj = System.Windows.Markup.XamlReader.Load(XmlReader.Create(TemplateFileName));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Could not create template from " + TemplateFileName);
                logService.WriteToLogLevel("SynEdtr:Could not create template from " + TemplateFileName, LogLevelEnum.Error, ex);
                return;
            }
            element = obj as FrameworkElement;
            window = new BaseOptionWindow();
            window.Template = element;
            element.DataContext = this; // loading vars in left listbox(source)
            ///window.ShowDialog();
            commandwindow = element;
            ////////////test///////
            //// take two strings and then try to make merged dictionary. remove extra spaces. replace " with '
            //string bksytemplate="bsky.CrossTable(x=c({Rows}),y=c({columns}),layers=c({layers}),datasetname='{%DATASET%}',chisq={chisq})";
            //string bskycommand="bsky.CrossTable(x=c('store','contact'),y='regular',layers=c('gender'),datasetname='Dataset1',chisq=FALSE)";
            //string dialogcommandstr = "bsky.one.sm.t.test(vars=c({SelectedVars}),mu={testValue},conf.level=0.89,datasetname='{%DATASET%}',missing=0)";
            string bskycommand = ((UAMenuCommand)parameter).bskycommand.Replace(" ", string.Empty);//"bsky.one.sm.t.test(vars=c('tg0','tg2','tg3'),mu=30,conf.level=0.89,datasetname='Dataset1',missing=0)";

            Dictionary<string, string> dialogkeyvalpair = new Dictionary<string, string>();//like: key=mu, val= {testValue}
            Dictionary<string, string> bskycommandkeyvalpair = new Dictionary<string, string>();//like: key=mu, val= 30
            Dictionary<string, string> merged = new Dictionary<string, string>();//like: key=testValue, val = 30

            OutputHelper.getArgumentSetDictionary(dialogcommandstr, dialogkeyvalpair);
            OutputHelper.getArgumentSetDictionary(bskycommand, bskycommandkeyvalpair);
            OutputHelper.MergeTemplateCommandDictionary(dialogkeyvalpair, bskycommandkeyvalpair, merged);

            foreach (KeyValuePair<string, string> pair in merged)
            {
                if (!pair.Key.Contains("%"))
                {
                    OutputHelper.SetValueFromSynEdt(element, pair.Key, pair.Value);
                }
            }
            //foreach (Match m in mc)
            //{
            //    //Console.WriteLine(s.Index + " : " + s.ToString());// {SelectedVars} {testValue} {%DATASET%}
            //    if (!m.ToString().Contains("%"))
            //    {
            //        args = OutputHelper.getArgument(bskycommand, m.Index);
            //        uiElementName = m.ToString().Replace('{', ' ').Replace('}', ' ').Trim();
            //        OutputHelper.SetValueFromSynEdt(element, uiElementName, args);
            //    }
            //}
            //OutputHelper.SetValueFromSynEdt(element, "SelectedVars");
            //OutputHelper.SetValueFromSynEdt(element, "testValue");

            //For Chisq check box only
            //FrameworkElement chkElement = element.FindName("chisq") as FrameworkElement;
            if (true)//window.DialogResult.HasValue && window.DialogResult.Value)
            {
                //analytics can be sent from parent function(in SyntaxEditorWindow)
                //IAnalyticsService analytics = LifetimeService.Instance.Container.Resolve<IAnalyticsService>();
                //IConfigService confService = LifetimeService.Instance.Container.Resolve<IConfigService>();//23nov2012
                cmd = new CommandRequest();

                OutputHelper.Reset();
                OutputHelper.UpdateMacro("%DATASET%", UIController.GetActiveDocument().Name);

                ///////////for chisq //// 29Mar2012 ///
                //if ((chkElement != null) && (bool)((chkElement as CheckBox).IsChecked))
                //    OutputHelper.UpdateMacro("%CHISQ%", "chisq");
                /////////////for chisq //// 29Mar2012 ///

                BSkyCanvas canvas = element as BSkyCanvas;
                if (canvas != null && !string.IsNullOrEmpty(canvas.CommandString))
                {
                    UAMenuCommand command = (UAMenuCommand)parameter;
                    cmd.CommandSyntax = command.commandformat;//OutputHelper.GetCommand(canvas.CommandString, element);// can be used for "Paste" for syntax editor
                    UAReturn retval = null; //retval = new UAReturn(); retval.Data = LoadAnalysisBinary();
                    #region Execute BSky command
                    try
                    {
                        retval = analytics.Execute(cmd); // RService called and DOM returned for Analysis commands
                        cmd.CommandSyntax = command.commandtype;////for header area ie NOTES
                        //SaveAnalysisBinary(retval.Data);
                        ///Added by Anil///07Mar2012
                        bool myrun = false;
                        if (cmd.CommandSyntax.Contains("BSkySetDataFrameSplit("))///executes when SPLIT is fired from menu
                        {
                            bool setsplit = false;
                            int startind = 0;
                            if (cmd.CommandSyntax.Contains("col.names"))
                            {
                                startind = cmd.CommandSyntax.IndexOf("c(", cmd.CommandSyntax.IndexOf("col.names"));// index of c(
                            }
                            else
                            {
                                startind = cmd.CommandSyntax.IndexOf("c(");// index of c(
                            }

                            int endind = cmd.CommandSyntax.IndexOf(")", startind);
                            int len = endind - startind + 1; // finding the length of  c(......)
                            string str = cmd.CommandSyntax.Substring(startind, len); // this will contain c('tg0','tg1') or just c()
                            string ch = null;
                            if (str.Contains("'")) ch = "'";
                            if (str.Contains('"')) ch = "\"";
                            if (ch != null && ch.Length > 0)
                            {
                                int i = str.IndexOf(ch);
                                int j = -1;
                                if (i >= 0) j = str.IndexOf(ch, i + 1);
                                if (j < 0) j = i + 1;
                                string sub = str.Substring(i + 1, (j - i - 1)).Trim();
                                if (i < 0)
                                    i = str.IndexOf("'");
                                if (i >= 0)
                                {
                                    if (sub.Length > 0)
                                        setsplit = true;
                                }
                            }

                            //////////  Setting/Unsetting Macro  for SPLIT //////////
                            if (setsplit)
                            {
                                OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), element);
                                return;// no need to do any thing further
                            }
                            else // unset split
                            {
                                OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                                return;// no need to do any thing further
                            }
                        }
                        ////////////////////////////
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Couldn't Execute the command");
                        logService.WriteToLogLevel("Couldn't Execute the command", LogLevelEnum.Error, ex);
                        return;
                    }
                    #endregion
                    //UAReturn retval = new UAReturn();
                    retval.Success = true;
                    AnalyticsData data = new AnalyticsData();
                    data.SelectedForDump = selectedForDump;//10Jan2013
                    data.PreparedCommand = cmd.CommandSyntax;//storing command
                    data.Result = retval;
                    data.AnalysisType = cmd.CommandSyntax; //"T-Test"; For Parent Node name 02Aug2012
                    data.InputElement = element;
                    data.DataSource = ds;
                    data.OutputTemplate = ((UAMenuCommand)parameter).commandoutputformat;
                    UIController.AnalysisComplete(data);
                }
            }

            //OnPostExecute(parameter);
        }
コード例 #5
0
        private void SendErrorWarningToOutput(UAReturn retval)//08jul2013
        {
            OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer;
            OutputWindow ow = owc.ActiveOutputWindow as OutputWindow; //get currently active window
            IUIController UIController = LifetimeService.Instance.Container.Resolve<IUIController>();

            OutputHelper.Reset();
            OutputHelper.UpdateMacro("%DATASET%", UIController.GetActiveDocument().Name);
            retval.Success = true;
            AnalyticsData data = new AnalyticsData();
            //data.SelectedForDump = selectedForDump;//10Jan2013
            //data.PreparedCommand = cmd.CommandSyntax;//storing command
            data.Result = retval;
            data.AnalysisType = retval.CommandString; //"T-Test"; For Parent Node name 02Aug2012
            //data.InputElement = element;
            //data.DataSource = ds;
            //data.OutputTemplate = ((UAMenuCommand)parameter).commandoutputformat;
            UIController.AnalysisComplete(data);
            //ow.AddAnalyis(data);

            //08Apr2015 bring main window in front after file open, instead of output window
            Window1 window = LifetimeService.Instance.Container.Resolve<Window1>();
            window.Activate();
        }
コード例 #6
0
 public void AnalysisComplete(AnalyticsData data)
 {
     if (data.Result.Success)
     {
         OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer;//new line
         _outputWindow = owc.ActiveOutputWindow;//To get active ouput window to populate analysis.AD.
         _outputWindow.Show();
         _outputWindow.AddAnalyis(data);
     }
 }
コード例 #7
0
        public void SendToOutput(UAReturn datasrc) // if possible move this function to global space so that it can be used by
        {                                           // open/close/ edit vargrid / edit datagrid etc.. you might want to add few more lines here.
            AnalyticsData data = new AnalyticsData();
            data.Result = datasrc;
            data.AnalysisType = datasrc.CommandString;//21Oct2013

            OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer;//new line
            IOutputWindow _outputWindow = owc.ActiveOutputWindow;//To get active ouput window to populate analysis.AD.
            _outputWindow.Show();
            OutputHelper.Reset();
            _outputWindow.AddAnalyis(data);
        }