public void RunCommands(string commands, BSkyDialogProperties dlgprop = null) //30Apr2013
{
try
{
ShowMouseBusy();
AdvancedLogging = AdvancedLoggingService.AdvLog;//01May2015
logService.WriteToLogLevel("Adv Log Flag:" + AdvancedLogging.ToString(), LogLevelEnum.Info);
DlgProp = dlgprop;
#region Load registered graphic commands from GraphicCommandList.txt 18Sep2012
// loads each time run is clicked. Performance will be effected, as we read file each time.
string grplstfullfilepath = confService.GetConfigValueForKey("sinkregstrdgrph");//23nov2012
//if graphic file does not exists the n create one.
if (!IsValidFullPathFilename(grplstfullfilepath, true))//17Jan2014
{
string text = "plot";
System.IO.File.WriteAllText(@grplstfullfilepath, text);
}
// load default value if no path is set or invalid path is set
if (grplstfullfilepath.Trim().Length == 0 || !IsValidFullPathFilename(grplstfullfilepath, true))
{
//grplstfullfilepath = confService.DefaultSettings["sinkregstrdgrph"];
MessageBox.Show(this, "Key 'sinkregstrdgrph' not found in config file. You cannot run Graphics from Command Editor.");
//return;
}
else
{
LoadRegisteredGraphicsCommands(@grplstfullfilepath);
}
#endregion
#region Save to Disk
if (saveoutput.IsChecked == true)
{
if (fullpathfilename.Text != null && fullpathfilename.Text.Trim().Length > 0)
{
fullfilepathname = fullpathfilename.Text;///setting filename
bool fileExists = File.Exists(fullfilepathname); fileExists = false;
if (fullfilepathname.Contains('.') && !fileExists)
{
string extension = Path.GetExtension(fullfilepathname).ToLower();// fullfilepathname.Substring(fullfilepathname.LastIndexOf('.'));
if (extension.Equals(".csv"))
{ fileformat = C1.WPF.FlexGrid.FileFormat.Csv; extratags = false; }
else if (extension.Equals(".html"))
{ fileformat = C1.WPF.FlexGrid.FileFormat.Html; extratags = false; }
else if (extension.Equals(".bsoz"))
{ fileformat = C1.WPF.FlexGrid.FileFormat.Html; extratags = true; }
else
{ fileformat = C1.WPF.FlexGrid.FileFormat.Html; extratags = true; fullfilepathname = fullfilepathname + ".bsoz"; }
}
else
{
MessageBox.Show(this, "Output File Already Exists! Provide different name in Command Editor window.");
return;
}
}
else
{
MessageBox.Show(this, "Please provide new output filename and fileformat by clicking 'Browse' in Command Editor for saving the output.", "Save Output is checked...", MessageBoxButton.OK, MessageBoxImage.Asterisk);
return;
}
}
#endregion
#region Get Active output Window
//////// Active output window ///////
OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer;
ow = owc.ActiveOutputWindow as OutputWindow; //get currently active window
if (saveoutput.IsChecked == true)
{
ow.ToDiskFile = true;//save lst to disk. Dump
}
#endregion
#region Executing Syntax Editors Commands
///// Now statements from Syntax Editor will be executed ////
CommandOutput lst = new CommandOutput(); ////one analysis////////
lst.IsFromSyntaxEditor = true;
if (saveoutput.IsChecked == true)//10Jan2013
lst.SelectedForDump = true;
////03Oct2014 We should remove R comments right here, before proceeding with execution.
string nocommentscommands = RemoveCommentsFromCommands(commands);
ExecuteCommandsAndCreateSinkFile(ow, lst, nocommentscommands);
bool s = true;
if (s) CreateOuput(ow); /// for last remaining few non BSkyFormat commands, if any.
///
#endregion
#region Saving to Disk
//////Dumping results from Syntax Editor ////08Aug2012
if (saveoutput.IsChecked == true)
ow.DumpAllAnalyisOuput(fullfilepathname, fileformat, extratags);
#endregion
}
catch (Exception ex)
{
logService.WriteToLogLevel("Exeception:" + ex.Message, LogLevelEnum.Error);
}
finally
{
HideMouseBusy();
}
}