Ejemplo n.º 1
0
        static void Main()
        {
            ConsoleHandler.RedirectToParent();
            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            var args = Environment.GetCommandLineArgs();

            if (RunWithArgs(args))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FormMain());
            }
            TabularModelHandler.Cleanup();
        }
Ejemplo n.º 2
0
        static void Main()
        {
            ConsoleHandler.RedirectToParent();
            AppDomain.CurrentDomain.AssemblyResolve          += CurrentDomain_AssemblyResolve;
            System.Net.WebRequest.DefaultWebProxy.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

            var args = Environment.GetCommandLineArgs();

            if (RunWithArgs(args))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new FormMain());
            }
            TabularModelHandler.Cleanup();
        }
Ejemplo n.º 3
0
        public void File_New()
        {
            var newModelDialog = new NewModelDialog();

            if (newModelDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            TabularModelHandler.Cleanup();
            if (Handler != null && File_SaveMode == ModelSourceType.Database)
            {
                Handler.OnExternalChange -= Handler_OnExternalChange;
            }
            Handler        = new TabularModelHandler(newModelDialog.CompatibilityLevel, Preferences.Current.GetSettings(), newModelDialog.PbiDatasetModel);
            File_Current   = null;
            File_Directory = null;
            File_SaveMode  = Handler.SourceType;

            LoadTabularModelToUI();
        }
Ejemplo n.º 4
0
        static void Main()
        {
            ConsoleHandler.RedirectToParent();

            var args = Environment.GetCommandLineArgs();

            if (args.Length > 1)
            {
                Console.WriteLine("");
                Console.WriteLine($"{ Application.ProductName } { Application.ProductVersion } (build { UpdateService.CurrentBuild })");
                Console.WriteLine("--------------------------------");
            }

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            var plugins = LoadPlugins();

            SetupLibraries(plugins);

            CommandLineMode = true;
            if (args.Length > 1 && HandleCommandLine(args))
            {
                if (enableVSTS)
                {
                    Console.WriteLine("##vso[task.complete result={0};]Done.", errorCount > 0 ? "Failed" : ((warningCount > 0) ? "SucceededWithIssues" : "Succeeded"));
                }
                Environment.Exit(errorCount > 0 ? 1 : 0);
                return;
            }
            CommandLineMode = false;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormMain());
            TabularModelHandler.Cleanup();
        }
Ejemplo n.º 5
0
        public void File_Open(string fileName)
        {
            var oldFile      = File_Current;
            var oldDirectory = File_Directory;
            var oldLastWrite = File_LastWrite;
            var oldSaveMode  = File_SaveMode;
            var oldHandler   = Handler;

            var cancel = false;

            using (new Hourglass())
            {
                try
                {
                    Handler = new TabularModelHandler(fileName, Preferences.Current.GetSettings());

                    if (Handler.SourceType == ModelSourceType.Pbit)
                    {
                        switch (Handler.PowerBIGovernance.GovernanceMode)
                        {
                        case TOMWrapper.PowerBI.PowerBIGovernanceMode.ReadOnly:
                            MessageBox.Show("Editing a Power BI Template (.pbit) file that does not use the Enhanced Model Metadata (V3) format is not allowed, unless you enable Experimental Power BI Features under File > Preferences.\n\nTabular Editor will still load the file in read-only mode.", "Power BI Template Read-only", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            break;

                        case TOMWrapper.PowerBI.PowerBIGovernanceMode.V3Restricted:
                            break;

                        case TOMWrapper.PowerBI.PowerBIGovernanceMode.Unrestricted:
                            if (MessageBox.Show("Experimental Power BI features is enabled. You can edit any object and property of this Power BI Template file but be aware that many types of changes ARE NOT CURRENTLY SUPPORTED by Microsoft.\n\nKeep a backup of your .pbit file and proceed at your own risk.", "Power BI Template Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.Cancel)
                            {
                                cancel = true;
                            }
                            break;
                        }
                    }

                    if (!cancel)
                    {
                        TabularModelHandler.Cleanup();
                        if (oldHandler != null && File_SaveMode == ModelSourceType.Database)
                        {
                            oldHandler.OnExternalChange -= Handler_OnExternalChange;
                        }
                        File_Current   = Handler.Source;
                        File_Directory = FileSystemHelper.DirectoryFromPath(Handler.Source);
                        File_SaveMode  = Handler.SourceType;

                        // TODO: Use a FileSystemWatcher to watch for changes to the currently loaded file(s)
                        // and handle them appropriately. For now, we just store the LastWriteDate of the loaded
                        // file, to ensure that we don't accidentally overwrite newer changes when saving.
                        File_LastWrite = File_SaveMode == ModelSourceType.Folder ? GetLastDirChange(File_Current) : File.GetLastWriteTime(File_Current);

                        LoadTabularModelToUI();
                        RecentFiles.Add(fileName);
                        RecentFiles.Save();
                        UI.FormMain.PopulateRecentFilesList();
                    }
                }
                catch (Exception ex)
                {
                    cancel = true;
                    MessageBox.Show(ex.Message, "Error loading Model from disk", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (cancel)
            {
                Handler        = oldHandler;
                File_Current   = oldFile;
                File_Directory = oldDirectory;
                File_SaveMode  = oldSaveMode;
                File_LastWrite = oldLastWrite;
            }
        }