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(); }
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; 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); } }
private void ExecuteBSkyRemoveRefreshDataframe(string stmt)//20Feb2014 { int start = stmt.IndexOf('('); int end = stmt.IndexOf(')'); string dataframename = stmt.Substring(start + 1, end - start - 1); FileCloseCommand fcc = new FileCloseCommand(); fcc.CloseDatasetFromSyntax(dataframename); }
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(); }
"|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(); }
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(); }