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);
}
}
}