protected override void OnExecute(object param) { BSkyMouseBusyHandler.ShowMouseBusy();//ShowProgressbar_old(); IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$" + controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; //CheckBox cbox = new CheckBox(); //saveasFileDialog.FileName = filename;////// Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving if (saveasFileDialog.FileName.ToLower().EndsWith("sav")) //12Feb2018 we dont want to open SaveAs-ed SAV files. { MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsSucces + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.Saved, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else if (System.IO.File.Exists(saveasFileDialog.FileName)) { //Close current Dataset on whic Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed. FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName, true); } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsFailed + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.InternalError, MessageBoxButton.OK, MessageBoxImage.Asterisk); } } BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); }
void fillVars() { UIController = LifetimeService.Instance.Container.Resolve<IUIController>(); ds = UIController.GetActiveDocument(); if (ds == null) { canExecute = false; return; } Variables = new ObservableCollection<DataSourceVariable>(ds.Variables); source.ItemsSource = ds.Variables; //source.Items.Add("AA"); //source.Items.Add("BB"); //source.Items.Add("CC"); //source.Items.Add("DD"); //source.Items.Add("EE"); //source.Items.Add("FF"); //source.Items.Add("GG"); //source.Items.Add("HH"); //source.Items.Add("II"); //source.Items.Add("JJ"); //source.Items.Add("KK"); //source.Items.Add("LL"); //source.Items.Add("MM"); //source.Items.Add("NN"); //source.Items.Add("OO"); ////////////// Function catagory ///////// funcat.Items.Add("All"); funcat.Items.Add("Arithmetic"); funcat.Items.Add("CDF & Noncentral CDF"); funcat.Items.Add("Conversion"); funcat.Items.Add("Current Date/Time"); funcat.Items.Add("Date Arithmetic"); funcat.Items.Add("Date Creation"); }
void fillVars() { UIController = LifetimeService.Instance.Container.Resolve <IUIController>(); ds = UIController.GetActiveDocument(); if (ds == null) { canExecute = false; return; } Variables = new ObservableCollection <DataSourceVariable>(ds.Variables); source.ItemsSource = ds.Variables; //source.Items.Add("AA"); //source.Items.Add("BB"); //source.Items.Add("CC"); //source.Items.Add("DD"); //source.Items.Add("EE"); //source.Items.Add("FF"); //source.Items.Add("GG"); //source.Items.Add("HH"); //source.Items.Add("II"); //source.Items.Add("JJ"); //source.Items.Add("KK"); //source.Items.Add("LL"); //source.Items.Add("MM"); //source.Items.Add("NN"); //source.Items.Add("OO"); ////////////// Function catagory ///////// funcat.Items.Add("All"); funcat.Items.Add("Arithmetic"); funcat.Items.Add("CDF & Noncentral CDF"); funcat.Items.Add("Conversion"); funcat.Items.Add("Current Date/Time"); funcat.Items.Add("Date Arithmetic"); funcat.Items.Add("Date Creation"); }
protected override void OnExecute(object param) { IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$" + controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; //CheckBox cbox = new CheckBox(); //saveasFileDialog.FileName = filename;////// Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving //Close current Dataset on whic Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName); } }
protected override void OnExecute(object param) { IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$"+controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension.ToLower(); string filename = controller.GetActiveDocument().FileName; string filter = null; switch (extension) { case "csv": filter = "Comma Seperated (*.csv)|*.csv"; break; case "xls": filter = "Excel 2003 (*.xls)|*.xls"; break; case "xlsx": filter = "Excel 2007-2010 (*.xlsx)|*.xlsx"; break; case "dbf": filter = "DBF (*.dbf)|*.dbf"; break; case "rdata": filter = "R Obj (*.RData)|*.RData"; break; default: filter = "All Files(*.*)|*.*"; break; } if (extension.Equals("sav"))//show save-as dialog if current loaded file is SPSS file. { SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving } } else { service.SaveAs(filename, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving } }
public FindVargridWindow() { InitializeComponent(); container = LifetimeService.Instance.Container; controller = container.Resolve <IUIController>(); ds = controller.GetActiveDocument(); TabItem ti = controller.GetTabItem(ds); dp = ti.Content as DataPanel; //dp.datavartabs.SelectedIndex = 1;//switch to DATA tab appWin = LifetimeService.Instance.Container.Resolve <Window1>(); this.Owner = appWin; searchtext.Focus(); }
public FindDatagridWindow() { InitializeComponent(); container = LifetimeService.Instance.Container; controller = container.Resolve <IUIController>(); ds = controller.GetActiveDocument(); TabItem ti = controller.GetTabItem(ds); dp = ti.Content as DataPanel; appWin = LifetimeService.Instance.Container.Resolve <Window1>(); this.Owner = appWin; //fill listbox with colnames of currently active dataset FillColnames(); searchtext.Focus(); }
public FindVargridWindow(Window1 appwin) { InitializeComponent(); container = LifetimeService.Instance.Container; controller = container.Resolve <IUIController>(); ds = controller.GetActiveDocument(); if (ds == null || ds.Variables == null || ds.Variables.Count < 1)//12Sep2016 For NULL dataset we can disable the textfield and the Next button { DisableDialog(); } TabItem ti = controller.GetTabItem(ds); dp = ti.Content as DataPanel; //dp.datavartabs.SelectedIndex = 1;//switch to DATA tab appWin = appwin; this.Owner = appWin; searchtext.Focus(); }
public bool ProcessNewDataset(string dfName = null, bool loadDFinGrid = true) { container = LifetimeService.Instance.Container; service = container.Resolve <IDataService>(); UIController = LifetimeService.Instance.Container.Resolve <IUIController>(); string CurrentDatasetName = UIController.GetActiveDocument().Name; OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve <IOutputWindowContainer>()) as OutputWindowContainer; SyntaxEditorWindow sewindow = LifetimeService.Instance.Container.Resolve <SyntaxEditorWindow>(); string DSName = CurrentDatasetName; //string.IsNullOrEmpty(dfName) ? service.GetUniqueNewDatasetname() : dfName.Trim(); string sheetname = string.Empty; //no sheetname for empty dataset(new dataset) string isEmpty = sewindow.ExecuteBoolCommand("BSkyIsEmptyDataset('" + DSName + "')"); bool isProcessed = false;//false:dataset not processed may be it was empty. if (!isEmpty.Equals("TRUE")) { BSkyMouseBusyHandler.ShowMouseBusy(); string strAsFactor = confService.GetConfigValueForKey("NewDatasetStrToFactor"); strAsFactor = strAsFactor.ToUpper().Equals("TRUE") ? "TRUE" : "FALSE"; string createCommand = "BsKyTeM<-BSkyProcessNewDataset('" + DSName + "', stringAsFactor=" + strAsFactor + "); "; string loadInGridCommand = string.Empty; if (loadDFinGrid) { loadInGridCommand = "BSkyLoadRefreshDataframe(" + DSName + ")"; } string commands = createCommand + loadInGridCommand; //PrintDialogTitle("Dataset loaded from the clipboard."); sewindow.RunCommands(commands, null); sewindow.DisplayAllSessionOutput("Dataset loaded.", (owc.ActiveOutputWindow as OutputWindow)); BSkyMouseBusyHandler.HideMouseBusy(); isProcessed = true; //dataset was processed } //bring main window in front Window1 window = LifetimeService.Instance.Container.Resolve <Window1>(); window.Activate(); return(isProcessed); }
private void PreExecuteSub()//16May2013 { UIController = LifetimeService.Instance.Container.Resolve <IUIController>(); ds = UIController.GetActiveDocument(); ////24Apr2014 If no dataset is open, we still need to run some commands from Syntax, those do not require Dataset //so following 'if' is commented out //if (ds == null) //{ // canExecute = false; // return; //} if (ds != null) //24Apr2014 { Variables = new ObservableCollection <DataSourceVariable>(ds.Variables); } }
private string GetActiveTabOfActiveDataset() { container = LifetimeService.Instance.Container; controller = container.Resolve <IUIController>(); ds = controller.GetActiveDocument(); TabItem ti = controller.GetTabItem(ds); dp = ti.Content as DataPanel; if (dp.datavartabs.SelectedIndex == 0)//datagrid is active { return("datagrid"); } else if (dp.datavartabs.SelectedIndex == 1) //vargrid is active { return("vargrid"); } else //something strange { return(string.Empty); } }
////Send executed command to output window. So, user will know what he executed //protected override void SendToOutputWindow(string command, string title)//13Dec2013 //{ // #region Get Active output Window // //////// Active output window /////// // OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer; // OutputWindow ow = owc.ActiveOutputWindow as OutputWindow; //get currently active window // #endregion // ow.AddMessage(command, title); //} public bool OpenDataframe(string dframename) { ShowProgressbar();//ShowStatusProgressbar();//29Oct2014 bool isSuccess = false; IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); Window1 appwindow = LifetimeService.Instance.Container.Resolve <Window1>();//for refeshing recent files list string filename = controller.GetActiveDocument().FileName; //For Excel string sheetname = controller.GetActiveDocument().SheetName; if (sheetname == null) { sheetname = string.Empty; } // if dataset was already loaded last time then this time we want to refresh it bool isDatasetNew = service.isDatasetNew(dframename + sheetname); try { DataSource ds = service.OpenDataframe(dframename, sheetname); string errormsg = string.Empty; if (ds != null && ds.Message != null && ds.Message.Length > 0) //message that is related to error { errormsg = "\n" + ds.Message; ds = null; //making it null so that we do execute further } if (ds != null) //03Dec2012 { logService.WriteToLogLevel("Start Loading Dataframe: " + ds.Name, LogLevelEnum.Info); if (isDatasetNew) { controller.Load_Dataframe(ds); } else { controller.RefreshBothGrids(ds); //23Jul2015 .RefreshGrids(ds);//.RefreshDataSet(ds); } ds.Changed = true; // keep track of change made, so that it can prompt for saving while closing dataset tab. logService.WriteToLogLevel("Finished Loading Dataframe: " + ds.Name, LogLevelEnum.Info); //recentfiles.AddXMLItem(dframename);//adding to XML file for recent docs isSuccess = true; } else { HideProgressbar(); MessageBox.Show(appwindow, "Unable to open '" + dframename + "'..." + "\nReasons could be one or more of the following:" + "\n1. Not a data frame object." + "\n2. File format not supported (or corrupt file or duplicate column names)." + "\n3. R.Net server from the old session still running (use task manager to kill it)." + "\n4. Some issue on R side (like: required library not loaded, incorrect syntax).", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); SendToOutputWindow("Error Opening Dataset.(probably not a data frame)", dframename + errormsg); } } catch (Exception ex) { logService.WriteToLogLevel("Error:" + ex.Message, LogLevelEnum.Error); } finally { //18OCt2013 move up for using in msg box Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();//for refeshing recent files list //appwindow.RefreshRecent(); HideProgressbar();//HideStatusProgressbar();//29Oct2014 } //if (isSuccess) //{ //08Apr2015 bring main window in front after file open, instead of output window //Window1 window = LifetimeService.Instance.Container.Resolve<Window1>(); //window.Activate(); //} return(isSuccess); }
protected override void OnExecute(object param) { BSkyMouseBusyHandler.ShowMouseBusy();//ShowProgressbar_old(); IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); if (controller.GetActiveDocument().isUnprocessed) { NewDatasetProcessor procDS = new NewDatasetProcessor(); bool isProcessed = procDS.ProcessNewDataset("", true); if (isProcessed)//true:empty rows cols removed successfully. False: whole dataset was empty and nothing was removed. { controller.GetActiveDocument().isUnprocessed = false; } else { BSkyMouseBusyHandler.HideMouseBusy(); MessageBox.Show("The dataset is empty. Please populate the dataset and save the file.", "Empty Dataset", MessageBoxButton.OK, MessageBoxImage.Information); return; } } //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$" + controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; //CheckBox cbox = new CheckBox(); //saveasFileDialog.FileName = filename;////// Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving if (System.IO.File.Exists(saveasFileDialog.FileName)) { //Close current Dataset on whic Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed. FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName); } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsFailed + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.InternalError, MessageBoxButton.OK, MessageBoxImage.Asterisk); } } BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); }
////// For Analysis Command Execution from Syntax Editor /////28Mar2013 Using this one and not the other one below this method public void ExecuteSyntaxEditor(object param, bool SelectedForDump) { parameter = param; //set Global var. selectedForDump = SelectedForDump; //set Global var OnPreExecute(param); if (!canExecute) { return; } object obj = null; string dialogcommandstr = null; string HistMenuText = string.Empty;//29Mar2013 try { if (AdvancedLogging) { logService.WriteToLogLevel("ExtraLogs: dialog xaml:" + TemplateFileName, LogLevelEnum.Info); } //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"); //Following commented code can be used to Add command to "History" menu when executed from Syntax Editor //But "Title" from XAML may not same as "text" attr from menu.xml //So the same command executed from Syntax Editor and Main App's menu will show duplicate ////xmlr.MoveToAttribute("Title");//29Mar2013 For "History" Text ////HistMenuText = xmlr.Value;//29Mar2013 For "History" Text ////UAMenuCommand uam = (UAMenuCommand)param; ////uam.text = HistMenuText; ////parameter = uam;//set Global var xmlr.MoveToAttribute("CommandString"); dialogcommandstr = xmlr.Value.Replace(" ", string.Empty).Replace('\"', '\''); if (AdvancedLogging) { logService.WriteToLogLevel("ExtraLogs: dialog command string:" + dialogcommandstr, LogLevelEnum.Info); } xmlr.Close(); obj = System.Windows.Markup.XamlReader.Load(XmlReader.Create(TemplateFileName)); } catch (Exception ex) { //18Aug2014 Supressing this message box as we dont need it. But we still pass message in log. //MessageBox.Show("XAML missing or has improper format! Could not create template from " + TemplateFileName); logService.WriteToLogLevel("SynEdtr:Could not create template from " + TemplateFileName, LogLevelEnum.Error, ex); GenerateOutputTablesForNonXAML(param); return; } //obj = GetSessionDialog(); // same dialog cant be used as its child of the another parent in AUAnalysisCommandBase element = obj as FrameworkElement; window = new BaseOptionWindow(); window.Template = element; element.DataContext = this; // loading vars in left listbox(source) ///window.ShowDialog(); commandwindow = element; { if (AdvancedLogging) { logService.WriteToLogLevel("ExtraLogs: Dialog controls value mapping.", LogLevelEnum.Info); } ////////////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)"; if (AdvancedLogging) { logService.WriteToLogLevel("ExtraLogs: Command:" + bskycommand, LogLevelEnum.Info); } 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 (AdvancedLogging) { string mapping = "Element:" + element.Name + ". Key:" + pair.Key + ". Value:" + pair.Value; logService.WriteToLogLevel("ExtraLogs:\n" + mapping, LogLevelEnum.Info); } if (!pair.Key.Contains("%")) // This should only skip macros(words enclosed within %) and not other formats. { OutputHelper.SetValueFromSynEdt(element, pair.Key, pair.Value); //Filling dialog with values } } } //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) 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 if (AdvancedLogging) { logService.WriteToLogLevel("ExtraLogs: Getting DOM", LogLevelEnum.Info); } retval = analytics.Execute(cmd); //ExecuteBSkyCommand(true); ExecuteXMLDefinedDialog(cmd.CommandSyntax); //no need to pass parameters here. Just to match func signature } //16Apr2013 till this point command has already been executed. So now we store this command for "History" // moved here from common function ExecuteBSkyCommand b'coz for command batch dialog SaveHistory should execute once. //SaveInHistory(); // not sure if needed to be commented } //OnPostExecute(parameter); //Cleanup. Remove Canvas children and make it null. then make Window.templace null BSkyCanvas canv = element as BSkyCanvas; int count = canv.Children.Count; canv.Children.RemoveRange(0, count); window.Template = null; }
//closes tab-dataset from 'X' icon void b_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { FrameworkElement fe = sender as FrameworkElement; FrameworkElement tag = fe.Tag as FrameworkElement; TabItem panel = tag as TabItem; string fullpathdatasetname = (panel.Tag as DataSource).FileName; if (System.Windows.MessageBox.Show("Do you want to close " + fullpathdatasetname + " Dataset?", "Do you want to close Dataset?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { //Close Dataset in R first IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } /////Save Prompt////13Mar2014 bool cancel = false; string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; if (controller.GetActiveDocument().Changed)//Changes has been done. Do you want to save or Discard { System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Do you want to save changes?", "Save Changes?", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes)//save { //If filetype=SPSS then save in RDATA format //For other filetypes data grid can be saved but not the variable grid. // For saving data grid and var grid only save in RDATA format if (extension.Trim().Length < 1 || extension.Equals("sav")) //if no extension or if sav file. no extension in case of new dataset created. { Microsoft.Win32.SaveFileDialog saveasFileDialog = new Microsoft.Win32.SaveFileDialog(); saveasFileDialog.Filter = "R Obj (*.RData)|*.RData"; bool?output = saveasFileDialog.ShowDialog(System.Windows.Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument());// #0 } } else { service.SaveAs(filename, controller.GetActiveDocument());// #0 } } else if (result == System.Windows.Forms.DialogResult.No)//Dont save { //Do nothing } else // Dont close the dataset/tab { cancel = true; } //Sort icon fix controller.sortasccolnames = null; //These 2 lines will make sure this is reset. Fix for issue with sort icon controller.sortdesccolnames = null; // Sort dataset col. Close it. Reopen it and you still see sort icons. } if (!cancel) { //// Dataset Closing in UI ////// service.Close(controller.GetActiveDocument()); // Close the Tab docGroup.Items.Remove(tag);//OR//closeTab(panel); ////13Feb2013 Also remove related dialogs from sessiondialog list RemoveSessionDialogs(panel); } } }
private void PreExecuteSub()//16May2013 { UIController = LifetimeService.Instance.Container.Resolve<IUIController>(); ds = UIController.GetActiveDocument(); if (ds != null) //24Apr2014 { List<string> datasetnames = new List<string>(); int i = 0; Variables = new ObservableCollection<DataSourceVariable>(ds.Variables); datasetnames = UIController.GetDatasetNames(); int count = datasetnames.Count; Datasets = new List<DatasetDisplay>(); for (i = 0; i < count; i++) { DatasetDisplay temp = new DatasetDisplay(); temp.Name = datasetnames[i]; temp.ImgURL = "../Resources/ordinal.png"; Datasets.Add(temp); } } }
//close from menu or clicking on cross icon 'X' public void CloseDataset(bool confirm = true) { IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; bool cancel = false; if (confirm) //confirm from use about closing and about saving the modified dataset { if (System.Windows.MessageBox.Show("Do you want to close " + filename + " Dataset?", "Do you want to close Dataset?", MessageBoxButton.YesNo) == MessageBoxResult.No) { // Dont Close the window return; } if (controller.GetActiveDocument().Changed)//Changes has been done. Do you want to save or Discard { DialogResult result = System.Windows.Forms.MessageBox.Show("Do you want to save changes?", "Save Changes?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (result == DialogResult.Yes)//save { //If filetype=SPSS then save in RDATA format //For other filetypes data grid can be saved but not the variable grid. // For saving data grid and var grid only save in RDATA format if (extension.Trim().Length < 1 || extension.Equals("sav")) //if no extension or if sav file. no extension in case of new dataset created. { Microsoft.Win32.SaveFileDialog saveasFileDialog = new Microsoft.Win32.SaveFileDialog(); saveasFileDialog.Filter = "R Obj (*.RData)|*.RData"; bool?output = saveasFileDialog.ShowDialog(System.Windows.Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument());// #0 } } else { service.SaveAs(filename, controller.GetActiveDocument());// #0 } } else if (result == DialogResult.No)//Dont save { //Do nothing } else // Dont close the dataset/tab { cancel = true; } } } if (!cancel) { service.Close(controller.GetActiveDocument()); controller.closeTab(); //container.Dispose();//added to cleanup. } }
protected override void OnExecute(object param) { BSkyMouseBusyHandler.ShowMouseBusy();//ShowProgressbar_old(); IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); if (controller.GetActiveDocument().isUnprocessed) { NewDatasetProcessor procDS = new NewDatasetProcessor(); bool isProcessed = procDS.ProcessNewDataset("", true); if (isProcessed)//true:empty rows cols removed successfully. False: whole dataset was empty and nothing was removed. { controller.GetActiveDocument().isUnprocessed = false; } else { BSkyMouseBusyHandler.HideMouseBusy(); MessageBox.Show("The dataset is empty. Please populate the dataset and save the file.", "Empty Dataset", MessageBoxButton.OK, MessageBoxImage.Information); return; } } //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$" + controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension; string filename = controller.GetActiveDocument().FileName; SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; //CheckBox cbox = new CheckBox(); //saveasFileDialog.FileName = filename;////// Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { //If the filename provided by user matches to any of the dataset's disk filename, currently open // in the grid then we must not let user overwrite // and inform him/her to first close the dataset whose filename matches and then try Save-As again. // //Only thing that may confuse users is, in the first Microsoft-SaveAs dialog they already decided //to overwrite an existing file (which happens to be loaded in the grid also) but we prompt them //again telling that the file is open in the grid and skip the SaveAs operation with message. // List <string> dsfnames = controller.GetAllOpenDatasetsInGrid(); if (dsfnames.Contains(saveasFileDialog.FileName)) { BSkyMouseBusyHandler.HideMouseBusy(); string fullpathfilename = saveasFileDialog.FileName; string filenameonly = Path.GetFileName(saveasFileDialog.FileName); //The filenameonly dataset (fullpathfilename) is already open in the datagrid. Close the dataset first and then try Save-As again. MessageBox.Show(BSky.GlobalResources.Properties.Resources.The + " \'" + filenameonly + "\' " + BSky.GlobalResources.Properties.Resources.Dtaset + " (" + fullpathfilename + ") " + BSky.GlobalResources.Properties.Resources.OverwritingOpenDatasetNotallowed, BSky.GlobalResources.Properties.Resources.SaveAsFailed, MessageBoxButton.OK, MessageBoxImage.Asterisk); return; } service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving if (saveasFileDialog.FileName.ToLower().EndsWith("sav")) //12Feb2018 we dont want to open SaveAs-ed SAV files. { MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsSucces + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.Saved, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else if (System.IO.File.Exists(saveasFileDialog.FileName)) { //Close current Dataset on whic Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed. FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName, true); } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsFailed + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.InternalError, MessageBoxButton.OK, MessageBoxImage.Asterisk); } } BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); }
////Send executed command to output window. So, user will know what he executed //protected override void SendToOutputWindow(string command, string title)//13Dec2013 //{ // #region Get Active output Window // //////// Active output window /////// // OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer; // OutputWindow ow = owc.ActiveOutputWindow as OutputWindow; //get currently active window // #endregion // ow.AddMessage(command, title); //} public bool OpenDataframe(string dframename, string fname) { initGlobalObjects(); AdvancedLogging = AdvancedLoggingService.AdvLog;//08Aug2016 Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew(); if (!AreDefaultRPackagesLoaded()) { stopwatch.Stop(); return(false); } stopwatch.Stop(); long elapsed = stopwatch.ElapsedMilliseconds; if (AdvancedLogging) { logService.WriteToLogLevel("PERFORMANCE:Are Req Package loaded: Time taken: " + elapsed, LogLevelEnum.Info); } BSkyMouseBusyHandler.ShowMouseBusy();// ShowProgressbar_old();//ShowStatusProgressbar();//29Oct2014 bool isSuccess = false; string filename = null, sheetname = null; DataSource tempds = controller.GetActiveDocument(); if (tempds != null) { filename = tempds.FileName; //For Excel sheetname = UtilFunctions.GetSheetname(tempds); } if (filename == null) { filename = string.Empty; } if (sheetname == null) { sheetname = string.Empty; } // if dataset was already loaded last time then this time we want to refresh it bool isDatasetNew = service.isDatasetNew(dframename /*+ sheetname*/); try { stopwatch.Restart(); if (fname.Length == 0) { /// It is difficult to diffeneretiate between ///(1) BSkyLoadRefreshDataframe(housing) which is a part of 'Compute' analysis on housing dataset and ///(2) BSkyLoadRefreshDataframe(housing) which is a part of 'Aggregate to dataset' on iris dataset. /// Ideally, first one should keep the Housing.Rdata filename in DataSource as well as on TabItem /// TabItem should be "Housing.RData(housing)" /// And the second on should replace the Housing.Rdata filename in Datasource and TabItem with /// 'housing'. TabItem should be "housing(housing)" /// ///Since we do not have a way to differentiate the two loadRefresh so A.R. and A.D. decided to ///leave the filename in DataSource as well as on TabItem in both cases. if (isDatasetNew)//new dataset may not have filename so R dataset obj name(DatasetX or mydf) is used. { fname = dframename; } else { fname = service.FindDataSourceFromDatasetname(dframename).FileName;//filename;//existing dataframe should retain original filename. } } if (!(fname.ToLower().EndsWith(".xls") || fname.ToLower().EndsWith(".xlsx"))) { sheetname = string.Empty; } DataSource ds = service.OpenDataframe(dframename, sheetname, fname); //ds.FileName = fname; stopwatch.Stop(); elapsed = stopwatch.ElapsedMilliseconds; if (AdvancedLogging) { logService.WriteToLogLevel("PERFORMANCE:Open Dataset in R: Time taken: " + elapsed, LogLevelEnum.Info); } string errormsg = string.Empty; if (ds != null && ds.Message != null && ds.Message.Length > 0) //message that is related to error { errormsg = "\n" + ds.Message; ds = null; //making it null so that we do execute further } if (ds != null && ds.Variables.Count > 0) //07Aug2016 added count condition to not open dataset if there are no variables //03Dec2012 { logService.WriteToLogLevel("Start Loading Dataframe: " + ds.Name, LogLevelEnum.Info); if (isDatasetNew) { stopwatch.Restart(); controller.Load_Dataframe(ds); stopwatch.Stop(); elapsed = stopwatch.ElapsedMilliseconds; if (AdvancedLogging) { logService.WriteToLogLevel("PERFORMANCE:Grid loading: Time taken: " + elapsed, LogLevelEnum.Info); } } else { stopwatch.Restart(); controller.RefreshBothGrids(ds);//23Jul2015 .RefreshGrids(ds);//.RefreshDataSet(ds); stopwatch.Stop(); elapsed = stopwatch.ElapsedMilliseconds; if (AdvancedLogging) { logService.WriteToLogLevel("PERFORMANCE:Grid loading: Time taken: " + elapsed, LogLevelEnum.Info); } ActivateDatagrid(ds); } //ds.Changed = true; // keep track of change made, so that it can prompt for saving while closing dataset tab. logService.WriteToLogLevel("Finished Loading Dataframe: " + ds.Name, LogLevelEnum.Info); //recentfiles.AddXMLItem(dframename);//adding to XML file for recent docs isSuccess = true; } else { BSkyMouseBusyHandler.HideMouseBusy();// HideProgressbar_old(); //MessageBox.Show(appwindow, "Unable to open '" + dframename + "'..." + // "\nReasons could be one or more of the following:" + // "\n1. Not a data frame object." + // "\n2. File format not supported (or corrupt file or duplicate column names)." + // "\n3. Dataframe does not have row(s) or column(s)." + // "\n4. R.Net server from the old session still running (use task manager to kill it)." + // "\n5. Some issue on R side (like: required library not loaded, incorrect syntax).", // "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); //SendToOutputWindow("Error Opening Dataset.(probably not a data frame)", dframename + errormsg); MessageBox.Show(appwindow, BSky.GlobalResources.Properties.Resources.cantopen + " '" + dframename + "'" + "\n" + BSky.GlobalResources.Properties.Resources.reasonsAre + "\n" + BSky.GlobalResources.Properties.Resources.NotDataframe2 + "\n" + BSky.GlobalResources.Properties.Resources.FormatNotSupported2 + "\n" + BSky.GlobalResources.Properties.Resources.NoRowsColsPresent + "\n" + BSky.GlobalResources.Properties.Resources.OldSessionRunning2 + "\n" + BSky.GlobalResources.Properties.Resources.RSideIssue2, BSky.GlobalResources.Properties.Resources.warning, MessageBoxButton.OK, MessageBoxImage.Warning); SendToOutputWindow(BSky.GlobalResources.Properties.Resources.ErrOpeningDataset2, dframename + errormsg); } } catch (Exception ex) { logService.WriteToLogLevel("Error:" + ex.Message, LogLevelEnum.Error); } finally { //18OCt2013 move up for using in msg box Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();//for refeshing recent files list //appwindow.RefreshRecent(); BSkyMouseBusyHandler.HideMouseBusy();// HideProgressbar_old();//HideStatusProgressbar();//29Oct2014 } //if (isSuccess) //{ //08Apr2015 bring main window in front after file open, instead of output window //Window1 window = LifetimeService.Instance.Container.Resolve<Window1>(); //window.Activate(); //} return(isSuccess); }
//Added by Aaron 07/20/2014 //this function looks at all the objects on the canvas recursively (for subdialogs) that contain the Overwrite settings property //The overwrite setting value controls whether the user should be prompted when creating a new variable or dataset and that variable or dataset already exists. public Boolean CheckForOverwrittenVars(BSkyCanvas cs) { System.Windows.Forms.DialogResult result; Boolean stopexecution = false; string message; foreach (object obj in cs.Children) { if (obj.GetType().Name == "BSkyTextBox") { BSkyTextBox tb = obj as BSkyTextBox; if (tb.OverwriteSettings == "PromptBeforeOverwritingVariables") { List <DataSourceVariable> varlst = UIController.GetActiveDocument().Variables; // UIController. //as=UIController.Re // List<DataSourceVariable> varlst = UIController. foreach (DataSourceVariable dsv in varlst) { // varnames = varnames + ", " + dsv.Name; if (dsv.Name == tb.Text) { message = "Do you want to overwrite variable " + tb.Text; result = System.Windows.Forms.MessageBox.Show(message, "Save Changes", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes)//save { } if (result == System.Windows.Forms.DialogResult.Cancel)//save { return(stopexecution = true); } if (result == System.Windows.Forms.DialogResult.No)//save { return(stopexecution = true); } } } } if (tb.OverwriteSettings == "PromptBeforeOverwritingDatasets") { // List<DataSourceVariable> varlst = UIController.GetActiveDocument().Variables; // UIController. //as=UIController.Re // List<DataSourceVariable> varlst = UIController. List <string> datasetnames; datasetnames = UIController.GetDatasetNames(); foreach (string dataset in datasetnames) { if (dataset == tb.Text) { message = "Do you want to overwrite dataset " + tb.Text; result = System.Windows.Forms.MessageBox.Show(message, "Save Changes", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes)//save { } if (result == System.Windows.Forms.DialogResult.Cancel)//save { return(stopexecution = true); } if (result == System.Windows.Forms.DialogResult.No)//save { return(stopexecution = true); } } } } } else if (obj.GetType().Name == "BSkyButton") { BSkyButton btn = obj as BSkyButton; FrameworkElement fe = obj as FrameworkElement; BSkyCanvas cnvs = fe.Resources["dlg"] as BSkyCanvas; // if (cs != null) ls.AddRange(gethelpfilenames(cs)); stopexecution = CheckForOverwrittenVars(cnvs); } } return(stopexecution); }
private void PreExecuteSub()//16May2013 { UIController = LifetimeService.Instance.Container.Resolve<IUIController>(); ds = UIController.GetActiveDocument(); ////24Apr2014 If no dataset is open, we still need to run some commands from Syntax, those do not require Dataset //so following 'if' is commented out //if (ds == null) //{ // canExecute = false; // return; //} if (ds != null) //24Apr2014 Variables = new ObservableCollection<DataSourceVariable>(ds.Variables); }
"|R Object (*.RData)|*.RData";//"Excel 2003 (*.xls)|*.xls " + protected override void OnExecute(object param) { BSkyMouseBusyHandler.ShowMouseBusy();//ShowProgressbar_old(); IUnityContainer container = LifetimeService.Instance.Container; IDataService service = container.Resolve <IDataService>(); IUIController controller = container.Resolve <IUIController>(); //Get current filetype from loaded dataset. This is file extension and Filter DataSource actds = controller.GetActiveDocument();//06Nov2012 if (actds == null) { return; } string datasetName = "" + actds.Name;//uadatasets$lst$ //string datasetName = "uadatasets$lst$"+controller.GetActiveDocument().Name; //Also try to get the filename of currently loaded file. This is FileName. string extension = controller.GetActiveDocument().Extension.ToLower(); string filename = controller.GetActiveDocument().FileName; string filter = null; switch (extension) { case "csv": filter = "Comma Seperated (*.csv)|*.csv"; break; case "xls": filter = "Excel 2003 (*.xls)|*.xls"; break; case "xlsx": filter = "Excel 2007-2010 (*.xlsx)|*.xlsx"; break; case "dbf": filter = "DBF (*.dbf)|*.dbf"; break; case "rdata": filter = "R Object (*.RData)|*.RData"; break; default: filter = "All Files(*.*)|*.*"; break; } if (extension.Equals("sav") || extension.Trim().Length == 0)//show save-as dialog if current loaded file is SPSS file or memory dataframe(RData file) { SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving if (saveasFileDialog.FileName.ToLower().EndsWith("sav")) //12Feb2018 we dont want to open SaveAs-ed SAV files. { MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsSucces + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.Saved, MessageBoxButton.OK, MessageBoxImage.Asterisk); } else if (System.IO.File.Exists(saveasFileDialog.FileName)) { //Close current Dataset on whic Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed. FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName, true); } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsFailed + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.InternalError, MessageBoxButton.OK, MessageBoxImage.Asterisk); } } } else if (extension.Equals("xls"))//we are using write.xlsx() from openxlsx package so we can save to XLSX format only and not to XLS. { MessageBoxResult mbr = MessageBox.Show(BSky.GlobalResources.Properties.Resources.CantSaveAsExcel, BSky.GlobalResources.Properties.Resources.SaveToOtherFormat, MessageBoxButton.OKCancel, MessageBoxImage.Asterisk); if (mbr == MessageBoxResult.OK) { SaveFileDialog saveasFileDialog = new SaveFileDialog(); saveasFileDialog.Filter = FileNameFilter; Window1 appwin = LifetimeService.Instance.Container.Resolve <Window1>(); bool? output = saveasFileDialog.ShowDialog(appwin);//Application.Current.MainWindow); if (output.HasValue && output.Value) { service.SaveAs(saveasFileDialog.FileName, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving if (System.IO.File.Exists(saveasFileDialog.FileName)) { //Close current Dataset on which Save As was run FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDataset(false); //Open Dataset that was SaveAs-ed. FileOpenCommand fo = new FileOpenCommand(); fo.FileOpen(saveasFileDialog.FileName); } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(BSky.GlobalResources.Properties.Resources.SaveAsFailed + saveasFileDialog.FileName, BSky.GlobalResources.Properties.Resources.InternalError, MessageBoxButton.OK, MessageBoxImage.Asterisk); } } } else { return; } } else { service.SaveAs(filename, controller.GetActiveDocument()); // #0 controller.GetActiveDocument().Changed = false; //21Mar2014 during close it should not prompt again for saving } BSkyMouseBusyHandler.HideMouseBusy(); //HideProgressbar_old(); }
////Send executed command to output window. So, user will know what he executed //protected override void SendToOutputWindow(string command, string title)//13Dec2013 //{ // #region Get Active output Window // //////// Active output window /////// // OutputWindowContainer owc = (LifetimeService.Instance.Container.Resolve<IOutputWindowContainer>()) as OutputWindowContainer; // OutputWindow ow = owc.ActiveOutputWindow as OutputWindow; //get currently active window // #endregion // ow.AddMessage(command, title); //} public bool OpenDataframe(string dframename) { initGlobalObjects(); if (!AreDefaultRPackagesLoaded()) { return(false); } BSkyMouseBusyHandler.ShowMouseBusy();//ShowProgressbar_old();//ShowStatusProgressbar();//29Oct2014 bool isSuccess = false; string filename = controller.GetActiveDocument().FileName; //For Excel string sheetname = controller.GetActiveDocument().SheetName; if (sheetname == null) { sheetname = string.Empty; } // if dataset was already loaded last time then this time we want to refresh it bool isDatasetNew = service.isDatasetNew(dframename + sheetname); try { DataSource ds = service.OpenDataframe(dframename, sheetname); string errormsg = string.Empty; if (ds != null && ds.Message != null && ds.Message.Length > 0) //message that is related to error { errormsg = "\n" + ds.Message; ds = null; //making it null so that we do execute further } if (ds != null) //03Dec2012 { logService.WriteToLogLevel("Start Loading Dataframe: " + ds.Name, LogLevelEnum.Info); if (isDatasetNew) { controller.Load_Dataframe(ds); } else { controller.RefreshBothGrids(ds); //23Jul2015 .RefreshGrids(ds);//.RefreshDataSet(ds); } ds.Changed = true; // keep track of change made, so that it can prompt for saving while closing dataset tab. logService.WriteToLogLevel("Finished Loading Dataframe: " + ds.Name, LogLevelEnum.Info); //recentfiles.AddXMLItem(dframename);//adding to XML file for recent docs isSuccess = true; } else { BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old(); MessageBox.Show(appwindow, BSky.GlobalResources.Properties.Resources.cantopen + " '" + dframename + "'" + "\n" + BSky.GlobalResources.Properties.Resources.reasonsAre + "\n" + BSky.GlobalResources.Properties.Resources.NotDataframe2 + "\n" + BSky.GlobalResources.Properties.Resources.FormatNotSupported2 + "\n" + BSky.GlobalResources.Properties.Resources.NoRowsColsPresent + "\n" + BSky.GlobalResources.Properties.Resources.OldSessionRunning2 + "\n" + BSky.GlobalResources.Properties.Resources.RSideIssue2, BSky.GlobalResources.Properties.Resources.warning, MessageBoxButton.OK, MessageBoxImage.Warning); SendToOutputWindow(BSky.GlobalResources.Properties.Resources.ErrOpeningDataset2, dframename + errormsg); } } catch (Exception ex) { logService.WriteToLogLevel("Error:" + ex.Message, LogLevelEnum.Error); } finally { //18OCt2013 move up for using in msg box Window1 appwindow = LifetimeService.Instance.Container.Resolve<Window1>();//for refeshing recent files list //appwindow.RefreshRecent(); BSkyMouseBusyHandler.HideMouseBusy();//HideProgressbar_old();//HideStatusProgressbar();//29Oct2014 } //if (isSuccess) //{ //08Apr2015 bring main window in front after file open, instead of output window //Window1 window = LifetimeService.Instance.Container.Resolve<Window1>(); //window.Activate(); //} return(isSuccess); }