private void ExecuteOtherCommand(OutputWindow ow, string stmt) { if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: Before Executing in R.", LogLevelEnum.Info); #region Check open close brackets before executing string unbalmsg; if (!AreBracketsBalanced(stmt, out unbalmsg))//if unbalanced brackets { CommandRequest errmsg = new CommandRequest(); string fullmsg = "Error : " + unbalmsg; errmsg.CommandSyntax = "write(\"" + fullmsg.Replace("<", "<").Replace('"', '\'') + "\",fp)";// analytics.ExecuteR(errmsg, false, false); //for printing command in file return; } #endregion ///if command is for loading dataset // if (stmt.Contains("UAloadDataset")) { int indexofopening = stmt.IndexOf('('); int indexofclosing = stmt.IndexOf(')'); string[] parameters = stmt.Substring(indexofopening + 1, indexofclosing - indexofopening - 2).Split(','); string filename = string.Empty; foreach (string s in parameters) { if (s.Contains('/') || s.Contains('\\')) filename = s.Replace('\"', ' ').Replace('\'', ' '); } if (filename.Contains("=")) { filename = filename.Substring(filename.IndexOf("=") + 1); } FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(filename.Trim()); return; } object o = null; CommandRequest cmd = new CommandRequest(); if (stmt.Contains("BSkySortDataframe(") || stmt.Contains("BSkyComputeExpression(") || stmt.Contains("BSkyRecode(")) { CommandExecutionHelper auacb = new CommandExecutionHelper(); UAMenuCommand uamc = new UAMenuCommand(); uamc.bskycommand = stmt; uamc.commandtype = stmt; auacb.ExeuteSingleCommandWithtoutXML(stmt);//auacb.ExecuteSynEdtrNonAnalysis(uamc); auacb.Refresh_Statusbar(); //auacb = null; } else { if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: Executing in R.", LogLevelEnum.Info); isVariable(ref stmt);///for checking if its variable then it must be enclosed within print(); //27May2015 check if command is graphic and get its height width and then reopen graphic device with new dimensions if (lastcommandwasgraphic)//listed graphic { if (imgDim!=null && imgDim.overrideImgDim) { CloseGraphicsDevice(); OpenGraphicsDevice(imgDim.imagewidth, imgDim.imageheight); // get image dimenstion from external source for this particular graphic. } } cmd.CommandSyntax = stmt;// command o = analytics.ExecuteR(cmd, false, false); //// get Direct Result and write in sink file CommandRequest cmdprn = new CommandRequest(); if (o != null && o.ToString().Contains("Error"))//for writing some of the errors those are not taken care by sink. { cmdprn.CommandSyntax = "write(\"" + o.ToString() + "\",fp)";// http://www.w3schools.com/xml/xml_syntax.asp o = analytics.ExecuteR(cmdprn, false, false); /// for printing command in file ///if there is error in assignment, like RHS caused error and LHS var is never updated ///Better make LHS var null. string lhvar = string.Empty; GetLeftHandVar(stmt, out lhvar); if (lhvar != null) { cmd.CommandSyntax = lhvar+" <- NULL";// assign null o = analytics.ExecuteR(cmd, false, false); } } } if (AdvancedLogging) logService.WriteToLogLevel("ExtraLogs: After Executing in R.", LogLevelEnum.Info); }