FileOpen() public method

public FileOpen ( string filename ) : void
filename string
return void
コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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("<", "&lt;").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);

            
        }
コード例 #4
0
        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();
        }
        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();
                    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();
        }
コード例 #6
0
                                             "|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();
        }