private void PrintDialogTitle(string title)
        {
            CommandOutput batch = new CommandOutput();

            batch.NameOfAnalysis     = "Open R package dataset";
            batch.IsFromSyntaxEditor = false;
            batch.Insert(0, new BSkyOutputOptionsToolbar());

            string      rcommcol = confService.GetConfigValueForKey("dctitlecol");//23nov2012 //before was syntitlecol
            byte        red      = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber);
            byte        green    = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber);
            byte        blue     = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber);
            Color       c        = Color.FromArgb(255, red, green, blue);
            AUParagraph aup      = new AUParagraph();

            aup.Text        = title;                                    // dialogTitle;
            aup.FontSize    = BSkyStyler.BSkyConstants.HEADER_FONTSIZE; //16;// before it was 16
            aup.FontWeight  = FontWeights.DemiBold;
            aup.textcolor   = new SolidColorBrush(c);                   //Colors.Blue);//SlateBlue //DogerBlue
            aup.ControlType = "Title";
            batch.Add(aup);
            SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>();

            sewindow.AddToSession(batch);
        }
コード例 #2
0
        private void CreateDynamicClassFlexGrid(string header, string[] colheaders, string[] rowheaders, string[,] data, CommandOutput lst)
        {
            IList list;
            AUXGrid xgrid = new AUXGrid();
            AUGrid c1FlexGrid1 = xgrid.Grid;// new C1flexgrid.
            xgrid.Header.Text = header;//FlexGrid header as well as Tree leaf node text(ControlType)

            ///////////// merge and sizing /////
            c1FlexGrid1.AllowMerging = AllowMerging.ColumnHeaders | AllowMerging.RowHeaders;
            c1FlexGrid1.AllowSorting = false;

            //trying to fix the size of the grid so that rendering does not take much time calculating these
            c1FlexGrid1.MaxHeight = 800;// NoOfRows* EachRowHeight;
            c1FlexGrid1.MaxWidth = 1000;

            int nrows = data.GetLength(0);
            int ncols = data.GetLength(1);

            //// Dynamic class logic
            FGDataSource ds = new FGDataSource();
            ds.RowCount = nrows;
            ds.Data = data;
            foreach (string s in colheaders)
            {
                ds.Variables.Add(s.Trim());
            }
            list = new DynamicList(ds);
            if (list != null)
            {
                c1FlexGrid1.ItemsSource = list;
            }
            FillColHeaders(colheaders, c1FlexGrid1);
            FillRowHeaders(rowheaders, c1FlexGrid1);
            lst.Add(xgrid);
        }
コード例 #3
0
        private void createFlexGrid(XmlDocument xd, CommandOutput lst, string header)
        {
            AUXGrid xgrid = new AUXGrid();
            AUGrid c1FlexGrid1 = xgrid.Grid;// new C1flexgrid.
            xgrid.Header.Text = header;//FlexGrid header as well as Tree leaf node text(ControlType)
            //XmlDocument xd = new XmlDocument(); xd.LoadXml(xdoc);

            BSkyOutputGenerator bsog = new BSkyOutputGenerator();
            bsog.html2flex(xd, c1FlexGrid1);
            lst.Add(xgrid);
        }
コード例 #4
0
 private void createBSkyGraphic(Image img, CommandOutput lst)//30Aug2012
 {
     lst.NameOfAnalysis = "R-Graphics";
     BSkyGraphicControl bsgc = new BSkyGraphicControl();
     bsgc.BSkyImageSource = img.Source;
     bsgc.ControlType = "Graphic";
     lst.Add(bsgc);
 }
コード例 #5
0
        private void createAUPara(string auparas, CommandOutput lst)
        {
            string startdatetime = string.Empty;
            if (lst.NameOfAnalysis == null || lst.NameOfAnalysis.Trim().Length < 1)
            {
                lst.NameOfAnalysis = "R-Output";//Parent Node name. 02Aug2012
            }
            if (auparas == null || auparas.Trim().Length < 1)
                return;
            string selectnode = "bskyoutput/bskyanalysis/aup";
            string AUPara = "<aup>" + auparas.Replace("&", "&amp;").Replace("<", "&lt;").Replace(">", "&gt;") + "</aup>";//single AUPara for all lines
            XmlDocument xd = null;

            ///// Creating DOM for generation output ///////
            string fulldom = "<bskyoutput> <bskyanalysis>" + AUPara + "</bskyanalysis> </bskyoutput>";
            xd = new XmlDocument(); xd.LoadXml(fulldom);

            //// for creating AUPara //////////////
            BSkyOutputGenerator bsog = new BSkyOutputGenerator();
            int noofaup = xd.SelectNodes(selectnode).Count;// should be 3

            for (int k = 1; k <= noofaup; k++)
            {
                if (lst.NameOfAnalysis.Equals("R-Output") || lst.NameOfAnalysis.Contains("Command Editor Execution"))
                {
                    lst.Add(bsog.createAUPara(xd, selectnode + "[" + (1) + "]", ""));
                }
                else if (lst.NameOfAnalysis.Equals("Datasets"))
                {
                    lst.Add(bsog.createAUPara(xd, selectnode + "[" + (1) + "]", "Open Datasets"));
                }
                else
                {
                    lst.Add(bsog.createAUPara(xd, selectnode + "[" + k + "]", startdatetime));
                }
            }
        }
コード例 #6
0
        //18Dec2013 Sending command to output to make them appear different than command-output
        private void SendCommandToOutput(string command, string NameOfAnalysis)
        {
            string rcommcol = confService.GetConfigValueForKey("rcommcol");//23nov2012
            byte red = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber);
            byte green = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber);
            byte blue = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber);
            Color c = Color.FromArgb(255, red, green, blue);

            CommandOutput lst = new CommandOutput();
            lst.NameOfAnalysis = NameOfAnalysis; // left tree Parent
            AUParagraph Title = new AUParagraph();
            Title.Text = command; //right side contents
            Title.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014 //12; //right side content size
            Title.textcolor = new SolidColorBrush(c);//new SolidColorBrush(Colors.DeepSkyBlue);
            Title.ControlType = "Command"; // left tree child
            lst.Add(Title);

            AddToSession(lst);
        }
コード例 #7
0
        public void ExecuteSplit(string command = null, FrameworkElement fe = null)
        {
            CommandRequest cr = new CommandRequest();
            cr.CommandSyntax = command;
            string stmt = command; //cmd.CommandSyntax;
            if (stmt.Contains("BSkySetDataFrameSplit("))///executes when SPLIT is fired from menu
            {
                bool setsplit = false;
                int startind = 0; int endind = 0;
                if (stmt.Contains("col.names"))
                {
                    startind = stmt.IndexOf("c(", stmt.IndexOf("col.names"));// index of c(
                }
                else
                {
                    startind = stmt.IndexOf("c(");// index of c(
                }
                if (startind > 0)
                    endind = stmt.IndexOf(")", startind);
                if (startind > 0 && endind > startind)
                {
                    int len = endind - startind + 1; // finding the length of  c(......)
                    string str = stmt.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;
                        }
                    }
                }
                //Executing the command in R///
                analytics.ExecuteR(cr,false,false);

                ////Creating a command output////11Jul2014

                CommandOutput splitCo = new CommandOutput();
                splitCo.NameOfAnalysis = "Split:#" + setsplit;
                splitCo.IsFromSyntaxEditor = false;

                AUParagraph aup = new AUParagraph();
                aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.HEADER_FONTSIZE;
                aup.Text = stmt;
                aup.ControlType = "Header";// treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen);
                splitCo.Add(aup);

                //////////  Setting/Unsetting Macro  for SPLIT //////////
                if (setsplit)
                {
                    OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), fe);
                    //window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();// RefreshGrids();
                    return;// no need to do any thing further
                }
                else // unset split
                {
                    OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                    //if (window != null && window.Template != null)
                    //    window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo);//11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();// RefreshGrids();
                    return;// no need to do any thing further
                }
            }

        }
コード例 #8
0
        //For commands : Dialog may or may not be shown but surely XML template is not present.
        public void ExeuteSingleCommandWithtoutXML(string command = "")
        {
            if (command != null && command.Length > 0)
            {
                cmd = new CommandRequest();
                cmd.CommandSyntax = command;
            }
            if (cmd.CommandSyntax == null || cmd.CommandSyntax.Length < 1)
            {
                cmd = new CommandRequest();
                cmd.CommandSyntax = "print('No command to execute')";
            }

            if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))// if its relaod dataset commmand then prepare some parameter before executing the command
            {
                DataSource tempds = UIController.GetActiveDocument();
                string filename = tempds.FileName.Replace("\\", "/");
                string filetype = tempds.FileType;
                string temp = new string(cmd.CommandSyntax.ToCharArray());

                cmd.CommandSyntax = temp.Replace("fullpathfilename", "fullpathfilename='" + filename + "'").Replace("filetype", "filetype='" + filetype + "'"); ;

                //Restting split if all data and attributes are loaded 
                int idx = temp.IndexOf("=", temp.IndexOf("loaddataonly")); // index of  '=' after 'loaddataonly'
                int idxcomma = temp.IndexOf(",", temp.IndexOf("loaddataonly")); // index of  ',' after 'loaddataonly'
                string boolvalue = temp.Substring(idx + 1, idxcomma - idx - 1).Trim();
                if (boolvalue.Equals("FALSE"))//loaddataonly = false then we need to reset SPLIT in C# also
                {
                    OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                }
            }
            //retval = analytics.Execute(cmd);
            if (bdt != null)
                if (!bdt.IsBatchCommand && bdt.IsCommandOnly && !bdt.IsXMLDefined && !cmd.CommandSyntax.Contains("BSkySetDataFrameSplit("))
                {
                    SendToOutputWindow(dialogTitle, cmd.CommandSyntax);
                    ExecuteInSyntaxEditor(true, dialogTitle);//GenerateOutputTablesForNonXAML(null);// ExecuteXMLDefinedDialog();
                }

            if (cmd.CommandSyntax.Contains("BSkySortDataframe(") || cmd.CommandSyntax.Contains("BSkyComputeExpression(") ||
                         cmd.CommandSyntax.Contains("BSkyRecode("))
            {
                retval = analytics.Execute(cmd);
                OutputHelper.AnalyticsData.Result = retval;//putting latest DOM
                string[,] ew = OutputHelper.GetBSkyErrorsWarning(1, "normal");//08Nov2014

                if (cmd.CommandSyntax.Contains("BSkySortDataframe")) //11Apr2014 putting sort icon
                {
                    //single column logic
                    //int startidx = cmd.CommandSyntax.IndexOf("'");
                    //int endidx= cmd.CommandSyntax.IndexOf("'", startidx+1);
                    //int leng = endidx - startidx-1;
                    //string colname = cmd.CommandSyntax.Substring(startidx+1, leng);

                    //sort order 14Apr2014
                    string srtodr = string.Empty;
                    // descending=TRUE in command. There is just 1 boolean in sort so this 'if' will work
                    if (cmd.CommandSyntax.Contains("TRUE"))
                        srtodr = "desc";
                    else
                        srtodr = "asc";

                    //mulitiple col logic
                    List<string> collst = new List<string>();
                    int startidx = cmd.CommandSyntax.IndexOf("c(");
                    if (startidx == -1) //no items in target listbox. No need of this if sort dialog has OK disabled when no items in target
                    {
                        return;
                    }
                    int endidx = cmd.CommandSyntax.IndexOf(")", startidx + 1);
                    int leng = endidx - startidx - 1;
                    string selcols = cmd.CommandSyntax.Substring(startidx + 2, leng - 1).Replace("'", "");// +2 is the length of "c(", -1 for )
                    string[] cols = selcols.Split(',');
                    for (int j = 0; j < cols.Length; j++) //string s in cols)
                    {
                        collst.Add(cols[j]);
                    }
                    RefreshGrids(collst, srtodr);
                }
                else
                {
                    //testing something. If success, we dont need this. RefreshGrids();
                }

                //16Apr2014
                //must be excuted at the end after data is reloaded otherwise split is not refresh in statusbar. 
                if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))
                {
                    Refresh_Statusbar();
                }

                ////Finally show messages in output
                //SendToOutputWindow(dialogTitle, cmd.CommandSyntax);
                //Show errors if any 08Nov2014
                if (ew != null && ew[0, 0] != null)
                {
                    //SendToOutputWindow("", ew[0, 2]);
                    CommandOutput ewmsg = new CommandOutput();
                    ewmsg.NameOfAnalysis = "Errors/Warnings";
                    ewmsg.IsFromSyntaxEditor = false;

                    AUParagraph ewtypeaup = new AUParagraph();
                    ewtypeaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    ewtypeaup.Text = (ew[0, 0] != null)?ew[0, 0]:"no type info";
                    ewtypeaup.ControlType = "Type:";
                    ewmsg.Add(ewtypeaup);

                    AUParagraph usrmsgaup = new AUParagraph();
                    usrmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    usrmsgaup.Text = (ew[0, 1] != null) ? ew[0, 1] : "no user message info";
                    usrmsgaup.ControlType = "User Message:";
                    ewmsg.Add(usrmsgaup);

                    AUParagraph rmsgaup = new AUParagraph();
                    rmsgaup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    rmsgaup.Text = (ew[0, 2] != null) ? ew[0, 2] : "no R message info";
                    rmsgaup.ControlType = "R Message:";
                    ewmsg.Add(rmsgaup);

                    AddToSyntaxSession(ewmsg);
                }
            }
        }
コード例 #9
0
        //AUGrid c1fg = null;
        /// Read .bso file and create all the displayable objects in allanalysis
        public List <SessionOutput> html2xml(string fullpathfilename)
        {
            #region read html and
            if (!File.Exists(fullpathfilename))
            {
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileNotFound);
                return(null);
            }
            string fulltext = File.ReadAllText(fullpathfilename);
            string s        = Regex.Replace(fulltext, @"\0", "");
            //////////////Put <BSKYOUTPUT> check here //////////////
            if (Regex.Matches(s, "<bskyoutput>").Count < 1 || Regex.Matches(s, "</bskyoutput>").Count < 1)
            {
                MessageBox.Show(BSky.GlobalResources.Properties.Resources.BSkyOutFileBadFormat);
                return(null);
            }

            string r = Regex.Replace(s, @"<head>", "");
            string t = r;

            /// fixing class attribute with quotes
            string patternh = @"\bclass=h[0-9]+";
            string u        = Regex.Replace(t, patternh, " class='h'");
            string patternc = @"\bclass=c[0-9]+";
            string v        = Regex.Replace(u, patternc, " class='c'");

            List <SessionOutput> allSessions = new List <SessionOutput>();
            XmlDocument          sessXd      = new XmlDocument();
            //New Session tag which is parent of bskyanalysis tag
            ////// No of sessions/// ana is abbrivation for analysis
            MatchCollection sessmc  = Regex.Matches(v, "<sessoutput");
            MatchCollection sessmc2 = Regex.Matches(v, "</sessoutput>");
            for (int ss = 0; ss < sessmc.Count; ss++) ///loop on number of sessions
            {                                         ///
                int    sessStart  = sessmc[ss].Index;
                int    sessEnd    = sessmc2[ss].Index;
                string onesession = v.Substring(sessStart, sessEnd - sessStart + 14);
                ////// No of Analysis/// ana is abbrivation for analysis
                MatchCollection anamc  = Regex.Matches(onesession, "<bskyanalysis>");
                MatchCollection anamc2 = Regex.Matches(onesession, "</bskyanalysis>");

                sessXd.LoadXml(onesession);
                string sessionheader = sessXd.SelectSingleNode("sessoutput").Attributes["Header"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["Header"].Value : string.Empty;

                string isRsession = sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"] != null?sessXd.SelectSingleNode("sessoutput").Attributes["isRsession"].Value : "false";

                bool isrsessionoutput = false;
                if (isRsession.ToLower().Trim().Equals("true"))
                {
                    isrsessionoutput = true;
                }
                int           anaStart = 0; int anaEnd = 0;
                XmlDocument   anaXd       = new XmlDocument();
                CommandOutput lst         = null;
                SessionOutput allanalysis = new SessionOutput();
                allanalysis.NameOfSession    = sessionheader;
                allanalysis.isRSessionOutput = isrsessionoutput;

                AUParagraph AUP;                      //09Jul2013
                for (int j = 0; j < anamc.Count; j++) ///loop on number of analysis
                {
                    lst      = new CommandOutput();   ///for treeview. New analysis
                    anaStart = anamc[j].Index;
                    anaEnd   = anamc2[j].Index;
                    string oneAnalysis = onesession.Substring(anaStart, anaEnd - anaStart + 15);
                    anaXd.LoadXml(oneAnalysis);

                    lst.NameOfAnalysis = anaXd.SelectSingleNode("bskyanalysis/analysisname").InnerText.Trim(); //For Parent Node name 02Aug2012

                    int      noofaup   = anaXd.SelectNodes("bskyanalysis/aup").Count;                          // should be 2
                    int      leafcount = anaXd.ChildNodes.Item(0).ChildNodes.Count;                            //29Oct2013 no. of leaves in an analysis
                    string[] contTyp   = { "Header", "Dataset" };                                              // should be 2
                    int      noofnotes = anaXd.SelectNodes("bskyanalysis/bskynotes").Count;                    //06nov2012

                    foreach (XmlNode ln in anaXd.ChildNodes.Item(0).ChildNodes)
                    {
                        if (ln.Name.Trim().Equals("analysisname"))
                        {
                            continue;
                        }
                        XmlNode xn = null;
                        switch (ln.Name.Trim())
                        {
                        case "aup":
                            #region AUPara
                            AUP = createAUPara(ln, "", "");
                            if (AUP != null)
                            {
                                lst.Add(AUP);
                            }

                            #endregion
                            break;

                        case "bskynotes":
                            #region BSkyNotes
                            if (noofnotes >= 1)
                            {
                                BSkyNotes bsnotes = createBSkyNotes(ln, "", "Notes");
                                if (bsnotes != null)
                                {
                                    lst.Add(bsnotes);
                                }
                            }
                            #endregion
                            break;

                        case "graphic":
                            #region Graphic
                            string  tempDir             = System.IO.Path.GetDirectoryName(fullpathfilename);
                            string  fullpathimgfilename = string.Empty;
                            XmlNode imgxn           = ln;//anaXd.SelectSingleNode("bskyanalysis/graphic");
                            string  pathimgfilename = (imgxn != null) ? imgxn.InnerText.Trim() : "";

                            string imgfileNamewithExt = System.IO.Path.GetFileName(pathimgfilename);
                            string outputDir          = tempDir + "\\";// @"\temp2\";
                            fullpathimgfilename = System.IO.Path.Combine(outputDir + imgfileNamewithExt);

                            if (fullpathimgfilename.Trim().Length > 0)
                            {
                                lst.Add(CreateBSkyGraphicControl(fullpathimgfilename));
                            }
                            #endregion
                            break;

                        case "auxgrid":
                            #region FlexGrid

                            oneAnalysis = ln.OuterXml;
                            ////// No. of Grids in one analysis: for C1FlexGrid header/footer err/warning generation //////
                            MatchCollection aux1    = Regex.Matches(oneAnalysis, "<auxgrid>");
                            MatchCollection aux2    = Regex.Matches(oneAnalysis, "</auxgrid>");
                            XmlDocument     anagrid = new XmlDocument();//this will be used to get contents of auxgrid(excluding flexgrid)

                            ////// No. of FlexGrids in one analysis: for C1FlexGrid generation //////
                            MatchCollection mc = Regex.Matches(oneAnalysis, "<html>");
                            MatchCollection mc2 = Regex.Matches(oneAnalysis, "</html>");
                            int             start = 0; int end = 0;
                            XmlDocument     xd = new XmlDocument();
                            for (int k = 0; k < mc.Count; k++) /// loop till all C1FlexGrid in current Analysis get generated
                            {
                                AUXGrid xgrid = new AUXGrid();
                                AUGrid  c1fg  = xgrid.Grid;// new C1flexgrid.

                                anagrid.LoadXml(oneAnalysis.Substring(aux1[k].Index, aux2[k].Index - aux1[k].Index + 10));
                                //flexgrid header
                                xn = anagrid.SelectSingleNode("auxgrid/fgheader[1]");
                                xgrid.Header.Text = (xn != null) ? xn.InnerText : "";
                                ///AUXGrid  error/warning
                                Dictionary <char, string> Metadata = new Dictionary <char, string>();
                                char   ch = ' '; int erri = 2;
                                string mesg = "", fullmsg = "";
                                xn = anagrid.SelectSingleNode("auxgrid/errm[1]");
                                while (xn != null)
                                {
                                    /// err msg is like :-   "a:. Warning: ....
                                    fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                    ch      = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char.
                                    mesg    = fullmsg.Substring(fullmsg.IndexOf(':') + 1);
                                    Metadata.Add(ch, mesg);
                                    xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]");
                                    erri++; //error index. next line.
                                }
                                xgrid.Metadata = Metadata;
                                /////// AUXGrid Footer /////

                                bool templatedDialog = false;
                                if (templatedDialog)
                                {
                                    Dictionary <char, string> Footer = new Dictionary <char, string>();

                                    erri = 2;
                                    xn   = anagrid.SelectSingleNode("auxgrid/footermsg[1]");
                                    while (xn != null)
                                    {
                                        /// err msg is like :-   "a:. Warning: ....
                                        fullmsg = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                        ch      = fullmsg.Substring(0, xn.InnerText.ToString().IndexOf(':')).ToCharArray()[0];///extract key char.
                                        mesg    = fullmsg.Substring(fullmsg.IndexOf(':') + 1);
                                        Footer.Add(ch, mesg);
                                        xn = anagrid.SelectSingleNode("auxgrid/errm[" + erri + "]");
                                        erri++;     //error index. next line.
                                    }
                                    xgrid.FootNotes = Footer;
                                }
                                else
                                {
                                    //This works for non-templated dialogs
                                    xn = anagrid.SelectSingleNode("auxgrid/footermsg[1]");
                                    if (xn != null)
                                    {
                                        fullmsg             = xn.InnerText.ToString().Replace('"', ' ').Trim();
                                        xgrid.StarFootNotes = fullmsg;
                                    }
                                }



                                ////////////get index of <html> and </html> //////
                                start = mc[k].Index;
                                end   = mc2[k].Index;

                                //// create xmldoc loaind string from <html> to </html> ////
                                xd.LoadXml(oneAnalysis.Substring(start, end - start + 7));

                                html2flex(xd, c1fg);//create rows/cols/headers and populate
                                ///////////// find C1Flexgrid Generate it //////E/////
                                xgrid.Margin = new Thickness(10);
                                lst.Add(xgrid);
                            }
                            #endregion
                            break;
                        } //switch
                    }     //for each leave

                    allanalysis.Add(lst);
                }
                allSessions.Add(allanalysis);
            }//for session
            #endregion

            return(allSessions);
        }
コード例 #10
0
        //30Apr2015 Output Dialog Title
        private void PrintDialogTitle(string title)
        {
            CommandOutput batch = new CommandOutput();
            batch.NameOfAnalysis = "Batch Command";
            batch.IsFromSyntaxEditor = false;

            string rcommcol = confService.GetConfigValueForKey("dctitlecol");//23nov2012 //before was syntitlecol
            byte red = byte.Parse(rcommcol.Substring(3, 2), NumberStyles.HexNumber);
            byte green = byte.Parse(rcommcol.Substring(5, 2), NumberStyles.HexNumber);
            byte blue = byte.Parse(rcommcol.Substring(7, 2), NumberStyles.HexNumber);
            Color c = Color.FromArgb(255, red, green, blue);
            AUParagraph aup = new AUParagraph();
            aup.Text = title; // dialogTitle;
            aup.FontSize = BSkyStyler.BSkyConstants.HEADER_FONTSIZE;//16;// before it was 16
            aup.FontWeight = FontWeights.DemiBold;
            aup.textcolor = new SolidColorBrush(c); //Colors.Blue);//SlateBlue //DogerBlue
            aup.ControlType = "Header";
            batch.Add(aup);
            SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve<SyntaxEditorWindow>();
            sewindow.AddToSession(batch); 
        }
コード例 #11
0
        protected void ExecuteBatch(string[] commands)
        {
            commands = RemoveSplitCommandFromBatch(commands);
            bool IsSplitCommand= false;
            string allcommands = string.Join(";", commands);
            if(allcommands.Contains("BSkySetDataFrameSplit"))
            {
                IsSplitCommand = true;//current command is split/unsplit command and so we dont run split/unsplit in split loop.
            }
            string datasetname = UIController.GetActiveDocument().Name;//'Dataset1'
            string modifiedCommand = string.Empty;
            int splititrationcount = 1;
            try
            {

                if(AdvancedLogging)logService.WriteToLogLevel("ExtraLogs: BatchCommand begins.", LogLevelEnum.Info);

                #region R Batch Command invoker
                //11Jul2014 need dialog title for commands those are single lined. if (CommandCountInBatch > 1)
                {
                    //BSkyFunctionInit()  // Execute in R
                    cmd.CommandSyntax = "BSkyBatchCommand(1)"; // starting batch command
                    analytics.ExecuteR(cmd, false, false);

                    cmd.CommandSyntax = "BSkySetCurrentDatasetName('" + datasetname + "', setDatasetIndex = \"y\")";
                    analytics.ExecuteR(cmd, false, false);

                    cmd.CommandSyntax = "New.version.BSkyComputeSplitdataset('" + datasetname + "')";
                    object ocnt = analytics.ExecuteR(cmd, true, false);
                    if (ocnt != null)// && (ocnt is int))
                    {
                        splititrationcount = Convert.ToInt32(ocnt);
                    }

                    ///ADDing right side Title for batch commands and associate it with left side leaf node////
                    PrintDialogTitle(dialogTitle);
                }
                #endregion

                bool islastslice = false;
                bool isemptyslice = false;

                object slicename;
                string curslice;

                string treenocharscount = confService.GetConfigValueForKey("nooftreechars");//16Dec2013
                int treenodecharlen;
                bool result = Int32.TryParse(treenocharscount, out treenodecharlen);
                if (!result)
                    treenodecharlen = 15;


                if (splititrationcount > 1 && !IsSplitCommand) //dlgprop.HandleSplits)
                {
                    #region Split itrations
                    for (int i = 1; i <= splititrationcount; i++)
                    {
                        CommandOutput sliceco = null;//21Nov2013 Slicename, if any
                        isemptyslice = false;
                        slicename = null;
                        curslice = null;
                        //int uaGlobalDataSliceIndexToWorkOn = 1;
                        if (true)//04Jul2014 all dialogs get executed in Syntax   // !commands[0].Contains("bsky") && !commands[0].Contains("BSky")) // FOR NON-BSKY COMMANDS
                        {
                            cmd.CommandSyntax = "uaDatasetSliceIndex = New.version.BSkyGetNextDatasetSplitSlice('" + datasetname + "')";
                            analytics.ExecuteR(cmd, false, false);

                            //Current Slice
                            cmd.CommandSyntax = "paste(BSkyComputeCurrentVarNamesAndFactorValues('" + datasetname + "'))";
                            slicename = analytics.ExecuteR(cmd, true, false).ToString();
                            curslice = slicename.ToString();
                            //21Nov2013 SendToOutputWindow("<<-- " + curslice +" -->>", "Slice:" + i.ToString());
                            //following block in place of above commented line
                            // Set slicename for syn edt session list
                            if (!curslice.Contains("Split = N"))
                            {
                                int startindex = curslice.IndexOf(',');
                                startindex = curslice.IndexOf(',', startindex + 1) + 2;
                                string treenodename = curslice.Substring(startindex).Trim();

                                sliceco = new CommandOutput();
                                sliceco.NameOfAnalysis = "Split:" + i.ToString();
                                sliceco.IsFromSyntaxEditor = false;

                                AUParagraph aup = new AUParagraph();
                                aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014
                                aup.Text = "<<-- " + curslice + " -->>";
                                aup.ControlType = treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen);
                                sliceco.Add(aup);
                            }
                        }

                        #region /////// Checking if slice is empty or not /////// Do not process empty slice //////

                        //check uadatasets$lst[[index]] exists or not

                        cmd.CommandSyntax = "eval(parse(text=paste('nrow(bskyCurrentDatasetSplitSliceObj)', sep='')))";
                        object rcont = analytics.ExecuteR(cmd, true, false);
                        int rowcount = rcont != null ? Int32.Parse(rcont.ToString()) : -1;
                        if (rowcount < 2)//empty slice. There should be empty slice. If no slice error "subscript out of bounds" will occur
                        {
                            isemptyslice = true;
                        }
                        //}
                        #endregion

                        if (!isemptyslice)
                        {
                            cmd.CommandSyntax = GetSliceSubstitutedCommands(commands, splititrationcount);
                        }
                        else
                        {
                            if (sliceco != null) // There is no slice when slice==null.(No Split dataset)
                            {
                                cmd.CommandSyntax = null; // no command is to be executed for empty slice.

                                //adding one more AUPara to sliceco for empty slice
                                string treenodename = "Empty Slice : " + i.ToString();
                                AUParagraph aup = new AUParagraph();
                                aup.FontSize = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//10Nov2014
                                aup.Text = "!!!!!!! Empty Slice !!!!!!!";
                                aup.ControlType = treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen);
                                sliceco.Add(aup);
                            }
                        }
                        if (i == splititrationcount)//last slice under execution
                            islastslice = true;
                        ExecuteInSyntaxEditor(true, dialogTitle, sliceco, islastslice); //Execute command batch in syntax editor in one session.
                    }//split itration on command batch
                    #endregion
                }
                else//No Split
                {
                    cmd.CommandSyntax = GetSliceSubstitutedCommands(commands, splititrationcount);
                    ExecuteInSyntaxEditor(true, dialogTitle);
                }
                //till this point command has already been executed. So now we store this command for "History"
            }//Try
            finally
            {
                ////////  THIS MUST EXECUTE AT THE END OTHERWISE THIS WILL IMPACT BADLY ON R SIDE //////////
                //if (CommandCountInBatch > 1)
                {

                    if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: BatchCommand ends.", LogLevelEnum.Info);

                    cmd.CommandSyntax = "BSkyBatchCommand(0)"; // ending batch command
                    analytics.ExecuteR(cmd, false, false);
                }
            }
        }
コード例 #12
0
        //For commands : Dialog may or may not be shown but surely XML template is not present.
        public void ExeuteSingleCommandWithtoutXML(string command = "")
        {
            if (command != null && command.Length > 0)
            {
                cmd = new CommandRequest();
                cmd.CommandSyntax = command;
            }
            if (cmd.CommandSyntax == null || cmd.CommandSyntax.Length < 1)
            {
                cmd = new CommandRequest();
                cmd.CommandSyntax = "print('No command to execute')";
            }

            if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))// if its relaod dataset commmand then prepare some parameter before executing the command
            {
                DataSource tempds   = UIController.GetActiveDocument();
                string     filename = tempds.FileName.Replace("\\", "/");
                string     filetype = tempds.FileType;
                string     temp     = new string(cmd.CommandSyntax.ToCharArray());

                cmd.CommandSyntax = temp.Replace("fullpathfilename", "fullpathfilename='" + filename + "'").Replace("filetype", "filetype='" + filetype + "'");;

                //Restting split if all data and attributes are loaded
                int    idx       = temp.IndexOf("=", temp.IndexOf("loaddataonly")); // index of  '=' after 'loaddataonly'
                int    idxcomma  = temp.IndexOf(",", temp.IndexOf("loaddataonly")); // index of  ',' after 'loaddataonly'
                string boolvalue = temp.Substring(idx + 1, idxcomma - idx - 1).Trim();
                if (boolvalue.Equals("FALSE"))                                      //loaddataonly = false then we need to reset SPLIT in C# also
                {
                    OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                }
            }
            //retval = analytics.Execute(cmd);
            if (bdt != null)
            {
                if (!bdt.IsBatchCommand && bdt.IsCommandOnly && !bdt.IsXMLDefined && !cmd.CommandSyntax.Contains("BSkySetDataFrameSplit("))
                {
                    SendToOutputWindow(dialogTitle, cmd.CommandSyntax);
                    ExecuteInSyntaxEditor(true, dialogTitle);//GenerateOutputTablesForNonXAML(null);// ExecuteXMLDefinedDialog();
                }
            }

            if (cmd.CommandSyntax.Contains("BSkySortDataframe(") || cmd.CommandSyntax.Contains("BSkyComputeExpression(") ||
                cmd.CommandSyntax.Contains("BSkyRecode("))
            {
                retval = analytics.Execute(cmd);
                OutputHelper.AnalyticsData.Result = retval;                    //putting latest DOM
                string[,] ew = OutputHelper.GetBSkyErrorsWarning(1, "normal"); //08Nov2014

                if (cmd.CommandSyntax.Contains("BSkySortDataframe"))           //11Apr2014 putting sort icon
                {
                    //single column logic
                    //int startidx = cmd.CommandSyntax.IndexOf("'");
                    //int endidx= cmd.CommandSyntax.IndexOf("'", startidx+1);
                    //int leng = endidx - startidx-1;
                    //string colname = cmd.CommandSyntax.Substring(startidx+1, leng);

                    //sort order 14Apr2014
                    string srtodr = string.Empty;
                    // descending=TRUE in command. There is just 1 boolean in sort so this 'if' will work
                    if (cmd.CommandSyntax.Contains("TRUE"))
                    {
                        srtodr = "desc";
                    }
                    else
                    {
                        srtodr = "asc";
                    }

                    //mulitiple col logic
                    List <string> collst   = new List <string>();
                    int           startidx = cmd.CommandSyntax.IndexOf("c(");
                    if (startidx == -1) //no items in target listbox. No need of this if sort dialog has OK disabled when no items in target
                    {
                        return;
                    }
                    int      endidx  = cmd.CommandSyntax.IndexOf(")", startidx + 1);
                    int      leng    = endidx - startidx - 1;
                    string   selcols = cmd.CommandSyntax.Substring(startidx + 2, leng - 1).Replace("'", ""); // +2 is the length of "c(", -1 for )
                    string[] cols    = selcols.Split(',');
                    for (int j = 0; j < cols.Length; j++)                                                    //string s in cols)
                    {
                        collst.Add(cols[j]);
                    }
                    RefreshGrids(collst, srtodr);
                }
                else
                {
                    //testing something. If success, we dont need this. RefreshGrids();
                }

                //16Apr2014
                //must be excuted at the end after data is reloaded otherwise split is not refresh in statusbar.
                if (cmd.CommandSyntax.Contains("BSkyReloadDataset("))
                {
                    Refresh_Statusbar();
                }

                ////Finally show messages in output
                //SendToOutputWindow(dialogTitle, cmd.CommandSyntax);
                //Show errors if any 08Nov2014
                if (ew != null && ew[0, 0] != null)
                {
                    //SendToOutputWindow("", ew[0, 2]);
                    CommandOutput ewmsg = new CommandOutput();
                    ewmsg.NameOfAnalysis     = "Errors/Warnings";
                    ewmsg.IsFromSyntaxEditor = false;

                    AUParagraph ewtypeaup = new AUParagraph();
                    ewtypeaup.FontSize    = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    ewtypeaup.Text        = (ew[0, 0] != null)?ew[0, 0]:"no type info";
                    ewtypeaup.ControlType = "Type:";
                    ewmsg.Add(ewtypeaup);

                    AUParagraph usrmsgaup = new AUParagraph();
                    usrmsgaup.FontSize    = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    usrmsgaup.Text        = (ew[0, 1] != null) ? ew[0, 1] : "no user message info";
                    usrmsgaup.ControlType = "User Message:";
                    ewmsg.Add(usrmsgaup);

                    AUParagraph rmsgaup = new AUParagraph();
                    rmsgaup.FontSize    = BSkyStyler.BSkyConstants.TEXT_FONTSIZE;//App.TEXT_FONTSIZE;
                    rmsgaup.Text        = (ew[0, 2] != null) ? ew[0, 2] : "no R message info";
                    rmsgaup.ControlType = "R Message:";
                    ewmsg.Add(rmsgaup);

                    AddToSyntaxSession(ewmsg);
                }
            }
        }
コード例 #13
0
        public void ExecuteSplit(string command = null, FrameworkElement fe = null)
        {
            CommandRequest cr = new CommandRequest();

            cr.CommandSyntax = command;
            string stmt = command;                       //cmd.CommandSyntax;

            if (stmt.Contains("BSkySetDataFrameSplit(")) ///executes when SPLIT is fired from menu
            {
                bool setsplit = false;
                int  startind = 0; int endind = 0;
                if (stmt.Contains("col.names"))
                {
                    startind = stmt.IndexOf("c(", stmt.IndexOf("col.names"));// index of c(
                }
                else
                {
                    startind = stmt.IndexOf("c(");// index of c(
                }
                if (startind > 0)
                {
                    endind = stmt.IndexOf(")", startind);
                }
                if (startind > 0 && endind > startind)
                {
                    int    len = endind - startind + 1;         // finding the length of  c(......)
                    string str = stmt.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;
                            }
                        }
                    }
                }
                //Executing the command in R///
                analytics.ExecuteR(cr, false, false);

                ////Creating a command output////11Jul2014

                CommandOutput splitCo = new CommandOutput();
                splitCo.NameOfAnalysis     = "Split:#" + setsplit;
                splitCo.IsFromSyntaxEditor = false;

                AUParagraph aup = new AUParagraph();
                aup.FontSize    = BSkyStyler.BSkyConstants.TEXT_FONTSIZE; //App.HEADER_FONTSIZE;
                aup.Text        = stmt;
                aup.ControlType = "Header";                               // treenodename.Length < treenodecharlen ? treenodename : treenodename.Substring(0, treenodecharlen);
                splitCo.Add(aup);

                //////////  Setting/Unsetting Macro  for SPLIT //////////
                if (setsplit)
                {
                    OutputHelper.AddGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name), fe);
                    //window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo); //11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();         // RefreshGrids();
                    return;                      // no need to do any thing further
                }
                else // unset split
                {
                    OutputHelper.DeleteGlobalObject(string.Format("GLOBAL.{0}.SPLIT", UIController.GetActiveDocument().Name));
                    //if (window != null && window.Template != null)
                    //    window.Template = null; //11Mar2013 release the XAML object. ie obj is no more child of window.
                    AddToSyntaxSession(splitCo); //11Jul2014 SendToOutputWindow(dialogTitle, stmt);
                    Refresh_Statusbar();         // RefreshGrids();
                    return;                      // no need to do any thing further
                }
            }
        }