예제 #1
0
        public async Task <bool> AddOrModifyAutoreply(Autoreply reply)
        {
            var existing = GetExactAutoreply(reply.ChannelId, reply.GuildId, reply.Trigger);

            if (existing == null)
            {
                _autoreplies.Add(reply);

                using (var db = new WbContext())
                {
                    db.Autoreplies.Add(reply);
                    await db.SaveChangesAsync();
                }

                return(true);
            }

            existing.Reply     = reply.Reply;
            existing.AddedById = reply.AddedById;
            existing.AddedAt   = reply.AddedAt;

            using (var db = new WbContext())
            {
                db.Autoreplies.Update(existing);
                await db.SaveChangesAsync();
            }

            return(false);
        }
예제 #2
0
 public async Task InitAsync()
 {
     using (var db = new WbContext())
     {
         _sheets = await db.SheetsToSearch.ToListAsync();
     }
 }
        public ModelPropertiesForm(WbContext WbContext)
        {
            wbContext = WbContext;

              InitializeComponent();
              CreateValueNodeControl();
        }
예제 #4
0
        /// <summary>
        /// Removes a keyword from a user.
        /// </summary>
        /// <param name="userId">ID of the user to remove the keyword from</param>
        /// <param name="keyword">Keyword to remove</param>
        /// <returns>true if the keyword existed and was removed, or false if the user was not subscribed</returns>
        public async Task <bool> RemoveKeywordAsync(ulong userId, string keyword)
        {
            if (!IsKeywordRegex(keyword))
            {
                keyword = keyword.ToLowerInvariant();
            }

            var record = GetRecord(userId, keyword);

            if (record == null)
            {
                return(false);
            }

            _keywords.Remove(record);

            using (var db = new WbContext())
            {
                var dbRecord = await db.Keywords.FirstOrDefaultAsync(k => k.UserId == userId && k.Keyword == keyword);

                if (dbRecord == null)
                {
                    return(true);
                }

                db.Keywords.Remove(dbRecord);
                await db.SaveChangesAsync();
            }

            return(true);
        }
예제 #5
0
 public static void Show(String message, String info, WbContext wbcontext)
 {
     singleton.messageLabel.Text = message;
       singleton.errorInfo = info;
       singleton.wbContext = wbcontext;
       singleton.ShowDialog();
 }
예제 #6
0
        /// <summary>
        /// Mutes a channel for the given user.
        /// </summary>
        /// <param name="userId">User's ID</param>
        /// <param name="channelId">Channel's ID</param>
        public async Task MuteChannelAsync(ulong userId, ulong channelId)
        {
            var userRecord = _mutedChannels.Find(c => c.UserId == userId);

            if (userRecord?.ChannelIds.Contains(channelId) == true)
            {
                return;
            }

            if (userRecord == null)
            {
                userRecord = new UserMutedChannels
                {
                    UserId     = userId,
                    ChannelIds = new List <ulong>()
                }
            }
            ;

            userRecord.ChannelIds.Add(channelId);
            _mutedChannels.Add(userRecord);

            using (var db = new WbContext())
            {
                db.MutedChannels.Add(new DbUserMutedChannel
                {
                    UserId    = userId,
                    ChannelId = channelId
                });

                await db.SaveChangesAsync();
            }
        }
예제 #7
0
 public static void Show(String message, String info, WbContext wbcontext)
 {
     singleton.messageLabel.Text = message;
     singleton.errorInfo         = info;
     singleton.wbContext         = wbcontext;
     singleton.ShowDialog();
 }
예제 #8
0
        /// <summary>
        /// Mutes a guild for the given user.
        /// </summary>
        /// <param name="userId">User's ID</param>
        /// <param name="guildId">Guild's ID</param>
        public async Task MuteGuildAsync(ulong userId, ulong guildId)
        {
            var userRecord = _mutedGuilds.Find(c => c.UserId == userId);

            if (userRecord?.GuildIds.Contains(guildId) == true)
            {
                return;
            }

            if (userRecord == null)
            {
                userRecord = new UserMutedGuilds
                {
                    UserId   = userId,
                    GuildIds = new List <ulong>()
                }
            }
            ;

            userRecord.GuildIds.Add(guildId);
            _mutedGuilds.Add(userRecord);

            using (var db = new WbContext())
            {
                db.MutedGuilds.Add(new DbUserMutedGuild
                {
                    UserId  = userId,
                    GuildId = guildId
                });

                await db.SaveChangesAsync();
            }
        }
예제 #9
0
        /// <summary>
        /// Unmutes a guild for the given user.
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="guildId"></param>
        /// <returns></returns>
        public async Task UnmuteGuildAsync(ulong userId, ulong guildId)
        {
            var userRecord = _mutedGuilds.Find(c => c.UserId == userId);

            if (userRecord == null || !userRecord.GuildIds.Contains(guildId))
            {
                return;
            }

            userRecord.GuildIds.Remove(guildId);

            using (var db = new WbContext())
            {
                var record = await db.MutedGuilds
                             .FirstOrDefaultAsync(c => c.UserId == userId && c.GuildId == guildId);

                if (record == null)
                {
                    return;
                }

                db.MutedGuilds.Remove(record);
                await db.SaveChangesAsync();
            }
        }
        public ModelPropertiesForm(WbContext WbContext)
        {
            wbContext = WbContext;

            InitializeComponent();
            CreateValueNodeControl();
        }
예제 #11
0
 public async Task InitAutoreplyServiceAsync()
 {
     using (var db = new WbContext())
     {
         _autoreplies = await db.Autoreplies.ToListAsync();
     }
 }
예제 #12
0
 public UndoHistoryForm(WbContext context)
     : this()
 {
     historyTreeView             = context.get_history_tree();
     historyTreeView.BorderStyle = BorderStyle.None;
     headerPanel1.Controls.Add(historyTreeView);
     historyTreeView.Dock = DockStyle.Fill;
 }
예제 #13
0
 public SqlIdeForm(WbContext wbContext, UIForm uiForm)
     : base((uiForm as SqlEditorFormWrapper).grt_manager())
 {
     this.wbContext = wbContext;
     dbSqlEditorBE  = uiForm as SqlEditorFormWrapper;
     Initialize();
     UpdateColors();
 }
예제 #14
0
 public UndoHistoryForm(WbContext context)
     : this()
 {
     historyTreeView = context.get_history_tree();
       historyTreeView.BorderStyle = BorderStyle.None;
       headerPanel1.Controls.Add(historyTreeView);
       historyTreeView.Dock = DockStyle.Fill;
 }
        /// <summary>
        /// Public constrcutor taking WbContext, calling core constructor
        /// </summary>
        /// <param name="WbContext">A WbContext</param>
        public ModelObjectDescriptionForm(WbContext WbContext) : this()
        {
            wbContext = WbContext;

            changeTimer          = new Timer();
            changeTimer.Interval = 700;
            changeTimer.Tick    += new EventHandler(changeTimer_Tick);

            ObjectDescriptionEnabled = false;
        }
        /// <summary>
        /// Public constrcutor taking WbContext, calling core constructor
        /// </summary>
        /// <param name="WbContext">A WbContext</param>
        public ModelObjectDescriptionForm(WbContext WbContext)
            : this()
        {
            wbContext = WbContext;

              changeTimer = new Timer();
              changeTimer.Interval = 700;
              changeTimer.Tick += new EventHandler(changeTimer_Tick);

              ObjectDescriptionEnabled = false;
        }
예제 #17
0
        public UserDatatypesForm(WbContext context)
            : this()
        {
            TabText = "User Types";
              Text = "User Types";

              userTypesList = context.get_usertypes_tree();
              userTypesList.BorderStyle = BorderStyle.None;
              headerPanel1.Controls.Add(userTypesList);
              userTypesList.Dock = DockStyle.Fill;
        }
        public UserDatatypesForm(WbContext context)
            : this()
        {
            TabText = "User Types";
            Text    = "User Types";

            userTypesList             = context.get_usertypes_tree();
            userTypesList.BorderStyle = BorderStyle.None;
            headerPanel1.Controls.Add(userTypesList);
            userTypesList.Dock = DockStyle.Fill;
        }
예제 #19
0
        /// <summary>
        /// Initializes the keyword service from the database.
        /// </summary>
        public async Task InitKeywordServiceAsync()
        {
            List <DbKeyword>          keywords;
            List <DbUserMutedChannel> mutedChannels;
            List <DbUserMutedGuild>   mutedGuilds;

            using (var db = new WbContext())
            {
                keywords = await db.Keywords
                           .Include(k => k.IgnoredChannels)
                           .Include(k => k.IgnoredGuilds)
                           .ToListAsync();

                mutedChannels = await db.MutedChannels.ToListAsync();

                mutedGuilds = await db.MutedGuilds.ToListAsync();
            }

            foreach (var k in keywords)
            {
                Regex regexKeyword = null;
                if (IsKeywordRegex(k.Keyword))
                {
                    regexKeyword = CreateRegex(k.Keyword);
                }

                _keywords.Add(new KeywordRecord
                {
                    Id              = k.Id,
                    UserId          = k.UserId,
                    Keyword         = k.Keyword,
                    RegexKeyword    = regexKeyword,
                    IgnoredChannels = k.IgnoredChannels.Select(c => c.ChannelId).ToList(),
                    IgnoredGuilds   = k.IgnoredGuilds.Select(g => g.GuildId).ToList()
                });
            }

            var mcUserIds = mutedChannels.Select(c => c.UserId).Distinct();

            _mutedChannels = mcUserIds.Select(i => new UserMutedChannels
            {
                UserId     = i,
                ChannelIds = mutedChannels.Where(c => c.UserId == i).Select(c => c.ChannelId).ToList()
            }).ToList();

            var mgUserIds = mutedGuilds.Select(g => g.UserId).Distinct();

            _mutedGuilds = mgUserIds.Select(i => new UserMutedGuilds
            {
                UserId   = i,
                GuildIds = mutedGuilds.Where(g => g.UserId == i).Select(g => g.GuildId).ToList()
            }).ToList();
        }
예제 #20
0
        /// <summary>
        /// Ignores guilds for a given user keyword.
        /// </summary>
        /// <param name="userId">ID of the user to add the ignores to</param>
        /// <param name="keyword">Keyword that is being ignored</param>
        /// <param name="guildIds">Guild IDs that are being ignored</param>
        /// <returns>True if success, false if the user isn't subscribed to the provided keyword or
        /// it is already being ignored</returns>
        public async Task <IgnoreResult> IgnoreGuildsAsync(ulong userId, string keyword, params ulong[] guildIds)
        {
            if (!IsKeywordRegex(keyword))
            {
                keyword = keyword.ToLowerInvariant();
            }

            var record = GetRecord(userId, keyword);

            if (record == null)
            {
                return(IgnoreResult.NotSubscribed);
            }
            if (guildIds.All(g => record.IgnoredGuilds.Contains(g)))
            {
                return(IgnoreResult.AlreadyIgnored);
            }

            var guilds   = guildIds.Distinct().Except(record.IgnoredGuilds);
            var dbGuilds = guilds.Select(c => new DbKeywordIgnoredGuild
            {
                KeywordId = record.Id,
                GuildId   = c
            });

            using (var db = new WbContext())
            {
                var dbRecord = await db.Keywords
                               .Include(k => k.IgnoredGuilds)
                               .FirstOrDefaultAsync(k => k.Id == record.Id);

                if (dbRecord == null)
                {
                    return(IgnoreResult.NotSubscribed);
                }

                foreach (var c in dbGuilds)
                {
                    dbRecord.IgnoredGuilds.Add(c);
                }

                await db.SaveChangesAsync();
            }

            record.IgnoredGuilds.AddRange(guilds);

            return(IgnoreResult.Success);
        }
예제 #21
0
        public ModelDiagramForm(WbContext context, String id)
        {
            InitializeComponent();

              wbContext = context;

              CreateCanvas(id); // Sets formBE.

              canvasViewer.CanvasPanel.MouseMove += new MouseEventHandler(CanvasPanel_MouseMove);
              canvasViewer.CanvasPanel.MouseDown += new MouseEventHandler(CanvasPanel_MouseDown);
              canvasViewer.CanvasPanel.MouseUp += new MouseEventHandler(CanvasPanel_MouseUp);
              canvasViewer.CanvasPanel.MouseDoubleClick += new MouseEventHandler(CanvasPanel_MouseDoubleClick);
              canvasViewer.CanvasPanel.KeyDown += new KeyEventHandler(CanvasPanel_KeyDown);
              canvasViewer.CanvasPanel.KeyUp += new KeyEventHandler(CanvasPanel_KeyUp);
              canvasViewer.CanvasPanel.MouseLeave += new EventHandler(CanvasPanel_MouseLeave);

              // Sidebar windows.
              modelNavigator = new ModelNavigatorForm(this);
              userDatatypesForm = new UserDatatypesForm(wbContext);
              modelLayerForm = new ModelLayerForm(this);
              modelCatalogForm = new ModelCatalogForm(formBE);
              historyForm = new UndoHistoryForm(wbContext);
              modelPropertiesForm = new ModelPropertiesForm(wbContext);
              modelObjectDescriptionForm = new ModelObjectDescriptionForm(wbContext);

              SetupSideBars();

              toolsToolStrip = formBE.get_tools_toolbar();
              toolsToolStrip.Dock = DockStyle.Left;
              diagramPanel.Controls.Add(toolsToolStrip);

              optionsToolStrip = formBE.get_options_toolbar();
              optionsToolStrip.Padding = new Padding(2);
              optionsToolStrip.Dock = DockStyle.None;
              optionsToolStrip.AutoSize = false;
              diagramPanel.Controls.Add(optionsToolStrip);
              diagramPanel.Controls.SetChildIndex(optionsToolStrip, 0);
              optionsToolStrip.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
              optionsToolStrip.Hide();

              UpdateColors();

              ManagedNotificationCenter.AddObserver(this, "GNFormTitleDidChange");
        }
예제 #22
0
        public ModelDiagramForm(WbContext context, String id)
        {
            InitializeComponent();

            wbContext = context;

            CreateCanvas(id); // Sets formBE.

            canvasViewer.CanvasPanel.MouseMove        += new MouseEventHandler(CanvasPanel_MouseMove);
            canvasViewer.CanvasPanel.MouseDown        += new MouseEventHandler(CanvasPanel_MouseDown);
            canvasViewer.CanvasPanel.MouseUp          += new MouseEventHandler(CanvasPanel_MouseUp);
            canvasViewer.CanvasPanel.MouseDoubleClick += new MouseEventHandler(CanvasPanel_MouseDoubleClick);
            canvasViewer.CanvasPanel.KeyDown          += new KeyEventHandler(CanvasPanel_KeyDown);
            canvasViewer.CanvasPanel.KeyUp            += new KeyEventHandler(CanvasPanel_KeyUp);
            canvasViewer.CanvasPanel.MouseLeave       += new EventHandler(CanvasPanel_MouseLeave);

            // Sidebar windows.
            modelNavigator             = new ModelNavigatorForm(this);
            userDatatypesForm          = new UserDatatypesForm(wbContext);
            modelLayerForm             = new ModelLayerForm(this);
            modelCatalogForm           = new ModelCatalogForm(formBE);
            historyForm                = new UndoHistoryForm(wbContext);
            modelPropertiesForm        = new ModelPropertiesForm(wbContext);
            modelObjectDescriptionForm = new ModelObjectDescriptionForm(wbContext);

            SetupSideBars();

            toolsToolStrip      = formBE.get_tools_toolbar();
            toolsToolStrip.Dock = DockStyle.Left;
            diagramPanel.Controls.Add(toolsToolStrip);

            optionsToolStrip          = formBE.get_options_toolbar();
            optionsToolStrip.Padding  = new Padding(2);
            optionsToolStrip.Dock     = DockStyle.None;
            optionsToolStrip.AutoSize = false;
            diagramPanel.Controls.Add(optionsToolStrip);
            diagramPanel.Controls.SetChildIndex(optionsToolStrip, 0);
            optionsToolStrip.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
            optionsToolStrip.Hide();

            UpdateColors();

            ManagedNotificationCenter.AddObserver(this, "GNFormTitleDidChange");
        }
예제 #23
0
        /// <summary>
        /// Unignores guilds for a given user keyword.
        /// </summary>
        /// <param name="userId">ID of the user to remove the ignores from</param>
        /// <param name="keyword">Keyword that is being unignored</param>
        /// <param name="guildIds">Guild IDs that are being unignored</param>
        /// <returns>True if success, false if the user isn't subscribed to the provided keyword</returns>
        public async Task <UnignoreResult> UnignoreGuildsAsync(ulong userId, string keyword, params ulong[] guildIds)
        {
            if (!IsKeywordRegex(keyword))
            {
                keyword = keyword.ToLowerInvariant();
            }

            var record = GetRecord(userId, keyword);

            if (record == null)
            {
                return(UnignoreResult.NotSubscribed);
            }
            if (guildIds.All(g => !record.IgnoredGuilds.Contains(g)))
            {
                return(UnignoreResult.NotIgnored);
            }

            var guilds = guildIds.Distinct().Intersect(record.IgnoredGuilds);

            using (var db = new WbContext())
            {
                var dbRecord = await db.Keywords
                               .Include(k => k.IgnoredGuilds)
                               .FirstOrDefaultAsync(k => k.Id == record.Id);

                if (dbRecord == null)
                {
                    return(UnignoreResult.NotSubscribed);
                }

                foreach (var g in dbRecord.IgnoredGuilds.Where(g => guilds.Contains(g.GuildId)).ToList())
                {
                    dbRecord.IgnoredGuilds.Remove(g);
                }

                await db.SaveChangesAsync();
            }

            record.IgnoredGuilds.RemoveAll(g => guilds.Contains(g));

            return(UnignoreResult.Success);
        }
예제 #24
0
        public async Task <bool> RemoveAutoreply(ulong channelId, ulong guildId, string trigger)
        {
            var autoreply = GetExactAutoreply(channelId, guildId, trigger);

            if (autoreply == null)
            {
                return(false);
            }

            _autoreplies.Remove(autoreply);

            using (var db = new WbContext())
            {
                db.Autoreplies.Remove(autoreply);
                await db.SaveChangesAsync();
            }

            return(true);
        }
예제 #25
0
        public ModelOverviewForm(WbContext WbContext, Overview be)
        {
            InitializeComponent();

              wbContext = WbContext;
              wbOverview = be;

              UpdateTabText();
              workbenchMenuManager = new WorkbenchMenuManager(wbContext);
              userDatatypesForm = new UserDatatypesForm(wbContext);
              historyForm = new UndoHistoryForm(wbContext);
              modelObjectDescriptionForm = new ModelObjectDescriptionForm(wbContext);

              wheelMessageFilter = new WheelMessageFilter(this);
              Application.AddMessageFilter(wheelMessageFilter);

              SetupSideBar();
              UpdateColors();
        }
예제 #26
0
        /// <summary>
        /// Adds a new keyword to a user.
        /// </summary>
        /// <param name="userId">ID of the user to add the keyword to</param>
        /// <param name="keyword">Keyword to add</param>
        /// <returns>Tuple of the keyword and whether user was already subscribed</returns>
        public async Task <(KeywordRecord Keyword, bool AlreadyExisted)> AddKeywordAsync(ulong userId, string keyword)
        {
            var isKeywordRegex = IsKeywordRegex(keyword);

            if (!isKeywordRegex)
            {
                keyword = keyword.ToLowerInvariant();
            }

            var record = GetRecord(userId, keyword);

            if (record != null)
            {
                return(record, true);
            }

            if (isKeywordRegex)
            {
                record = new KeywordRecord(userId, keyword, CreateRegex(keyword));
            }
            else
            {
                record = new KeywordRecord(userId, keyword);
            }

            var dbKeyword = new DbKeyword
            {
                UserId  = userId,
                Keyword = keyword
            };

            using (var db = new WbContext())
            {
                db.Keywords.Add(dbKeyword);
                await db.SaveChangesAsync();
            }

            record.Id = dbKeyword.Id;
            _keywords.Add(record);

            return(record, false);
        }
예제 #27
0
        public async Task InitTwitterServiceAsync()
        {
            var consumerKey       = Environment.GetEnvironmentVariable("TWITTER_CONSUMER_KEY");
            var consumerSecret    = Environment.GetEnvironmentVariable("TWITTER_CONSUMER_SECRET");
            var accessToken       = Environment.GetEnvironmentVariable("TWITTER_ACCESS_TOKEN");
            var accessTokenSecret = Environment.GetEnvironmentVariable("TWITTER_ACCESS_TOKEN_SECRET");

            Auth.SetUserCredentials(consumerKey, consumerSecret, accessToken, accessTokenSecret);

            List <TwitterToCheck> twittersToCheck;

            using (var db = new WbContext())
            {
                twittersToCheck = await db.TwittersToCheck.ToListAsync();
            }

            foreach (var toCheck in twittersToCheck)
            {
                StartStream(toCheck);
            }
        }
        public DiagramOptionsForm(WbContext wbContext)
        {
            InitializeComponent();

            contentPanel.CustomBackground = true;

            this.wbContext = wbContext;

            canvas = new MySQL.GUI.Mdc.WindowsGDICanvasView(contentPanel.Handle,
                                                            contentPanel.Width, contentPanel.Height);

            canvas.set_on_queue_repaint(canvasNeedsRepaint);

            canvas.initialize();

            optionsBE = new DiagramOptionsBE(canvas, wbContext, PropertyChanged);

            optionsBE.update_size();

            diagramNameEdit.Text = optionsBE.get_name();
            PropertyChanged();
        }
예제 #29
0
        public DiagramOptionsForm(WbContext wbContext)
        {
            InitializeComponent();

              contentPanel.CustomBackground = true;

              this.wbContext = wbContext;

              canvas = new MySQL.GUI.Mdc.WindowsGDICanvasView(contentPanel.Handle,
            contentPanel.Width, contentPanel.Height);

              canvas.set_on_queue_repaint(canvasNeedsRepaint);

              canvas.initialize();

              optionsBE = new DiagramOptionsBE(canvas, wbContext, PropertyChanged);

              optionsBE.update_size();

              diagramNameEdit.Text = optionsBE.get_name();
              PropertyChanged();
        }
예제 #30
0
        public PageSettingsForm(WbContext wbcontext)
        {
            InitializeComponent();

            WbContext = wbcontext;
        }
예제 #31
0
        static void Main(string[] Args)
        {
            // Connect the application to console to have proper output there if requested.
            bool consoleRedirectionWorked = Win32Api.RedirectConsole();

            // Start with command line parsing.
            string userDir = System.IO.Path.Combine(System.IO.Path.Combine(
                                                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                        "MySQL"), "Workbench");

            Logger.InitLogger(userDir);

            if (!consoleRedirectionWorked)
            {
                Logger.LogError("Workbench", "Console redirection failed.\n");
            }

            System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
            string    baseDir   = System.IO.Path.GetDirectoryName(asm.Location);
            WbOptions wbOptions = new WbOptions(baseDir, userDir, true);

            if (!wbOptions.parse_args(Args, asm.Location))
            {
                Logger.LogInfo("Workbench", "Command line params told us to shut down.\n");
                return;
            }

            wbOptions.analyzeCommandLineArguments();

            PrintInitialLogInfo();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Hook into the exception handling to establish our own handling.
            AppDomain currentDomain = AppDomain.CurrentDomain; // CLR

            currentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);

            Application.ThreadException += // Windows Forms
                                           new System.Threading.ThreadExceptionEventHandler(OnGuiUnhandledException);

            // Read some early values which cannot be stored in the preferences (since they are loaded
            // later) from registry.
            bool   singleInstance = true;
            string lastVersion    = "";
            string currentVersion = GetApplicationMetaInfo(ApplicationMetaInfo.Version);

            Logger.LogInfo("Workbench", "Current version given by meta info is: " + currentVersion + '\n');
            RegistryKey wbKey = Registry.CurrentUser;

            try
            {
                wbKey = wbKey.OpenSubKey(@"Software\Oracle\MySQL Workbench", false);
                if (wbKey != null)
                {
                    if (wbKey.GetValue("DisableSingleInstance", 0).ToString() == "1")
                    {
                        singleInstance = false;
                    }
                    lastVersion = wbKey.GetValue("LastStartedAs", "").ToString();
                }
                else
                {
                    Registry.CurrentUser.CreateSubKey(@"Software\Oracle\MySQL Workbench");
                }
            }
            catch (Exception e)
            {
                Logger.LogError("Workbench", "Error while checking single instance reg key: " + e.Message + '\n');
            }
            finally
            {
                if (wbKey != null)
                {
                    wbKey.Close();
                }
            }

            // First check if this is the first instance of Workbench (if enabled).
            // The setting for single-instance is stored in the registry as it is Windows-only
            // and loading of the application settings happens later.
            if (singleInstance)
            {
                if (!ApplicationInstanceManager.CreateSingleInstance(
                        Assembly.GetExecutingAssembly().GetName().Name, Args, SingleInstanceCallback))
                {
                    Logger.LogInfo("Workbench", "Exiting as another instance of WB is already running.\n");
                    return;
                }
            }

            // Give the main thread a proper name, so we can later check for it when needed.
            Thread.CurrentThread.Name = "mainthread";

            // Change the working dir to to application path.
            // This is necessary because all our internal data files etc. are located under the app dir
            // and WB could have been called from a different dir.
            string workdir = System.IO.Directory.GetCurrentDirectory();

            System.IO.Directory.SetCurrentDirectory(baseDir);

            // Next check if this is the first start of a new version of WB. In this case remove all
            // compiled python files. They will be automatically recreated and can produce problems
            // under certain circumstances.
            if (currentVersion != lastVersion)
            {
                Logger.LogInfo("Workbench", "This is the first start of a new version. Doing some clean up.\n");
                List <string> failed = new List <string>();
                RemoveCompiledPythonFiles(baseDir, failed);

                // TODO: decide if we wanna ask the user to remove those files manually or just ignore them.
            }

            // Some people don't have c:\windows\system32 in PATH, so we need to set it here
            // for WBA to find the needed commands
            String systemFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
            String cleanedPath  = Environment.GetEnvironmentVariable("PATH");

            String [] paths = cleanedPath.Split(new char[] { ';' });
            cleanedPath = "";

            // Strip all python related dirs from PATH to avoid conflicts with other Python installations.
            foreach (String path in paths)
            {
                if (!path.ToLower().Contains("python"))
                {
                    cleanedPath = cleanedPath + ";" + path;
                }
            }
            Environment.SetEnvironmentVariable("PATH", systemFolder + cleanedPath);
            Logger.LogInfo("Workbench", "Setting PATH to: " + systemFolder + cleanedPath + '\n');

            // Clear PYTHONPATH environment variable, as we do not need it but our python impl
            // seriously gets confused with it.
            Environment.SetEnvironmentVariable("PYTHONPATH", workdir + "\\python\\Lib;" + workdir + "\\python\\DLLs;" + workdir + "\\python");
            Environment.SetEnvironmentVariable("PYTHONHOME", workdir + "\\python");

            // Initialize forms stuff.
            MySQL.Forms.Manager formsManager = MySQL.Forms.Manager.get_instance(); // Creates the singleton.

            // init extra mforms things that are delegated to the frontend, indirectly through RecordsetWrapper in wbpublic
            MySQL.Grt.Db.RecordsetWrapper.init_mforms(MySQL.Grt.Db.RecordsetView.create);

            #region Runtime path check

            // Currently WB has trouble running from a path containing non-ASCII characters.
            // Actually, our third party libraries have (namely lua, python, ctemplate),
            // as they don't consider Unicode file names (encoded as UTF-8) which leads to file-not-found
            // errors. Refuse to work in such a path for now.
            foreach (Char c in baseDir)
            {
                if (c > 0x7f)
                {
                    MessageBox.Show("MySQL Workbench cannot be executed from a path that contains non-ASCII characters.\n" +
                                    "This problem is imposed by used third-party libraries.\n" +
                                    "Please run this application from the default installation path or at least a path which is all ASCII characters.",
                                    "MySQL Workbench Execution Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            #endregion

            #region Release check (outdated beta or rc version)

            // check the date of the executable and suggest to install a new version if this is a beta or rc
            if (GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("BETA") >= 0 ||
                GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("RC") >= 0)
            {
                DateTime fileDate = System.IO.File.GetCreationTime(Application.ExecutablePath);

                if (DateTime.Now.Subtract(fileDate).TotalDays > 45)
                {
                    Logger.LogInfo("Workbench", "Found an old WB pre release. Showing warning.\n");
                    if (MessageBox.Show("This version of MySQL Workbench is older than 45 days and most probably outdated. "
                                        + Environment.NewLine
                                        + "It is recommended to upgrade to a newer version if available. "
                                        + Environment.NewLine
                                        + "Press [OK] to check for a new version and exit the application. "
                                        + "Press [Cancel] to continue using this version.",
                                        "MySQL Workbench Version Outdated", MessageBoxButtons.OKCancel,
                                        MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK)
                    {
                        CheckForNewVersion();
                        return;
                    }
                }
            }

            #endregion

            #region Variables and Splashscreen

            #endregion

            #region Initialize GRT

            // Try to instantiate the Workbench context and the GRT Manager and catch exceptions
            try
            {
                // Create Workbench Context
                wbContext = new WbContext(wbOptions.Verbose);

                if (wbContext != null)
                {
                    // Create the GRT Manager instance
                    grtManager = wbContext.get_grt_manager();
                }
            }
            catch (Exception ex)
            {
                HandleException(ex);
            }

            #endregion

            // If the Workbench Context and GRT Manager were successfully created,
            // initialize the application
            if (wbContext != null && grtManager != null)
            {
                #region Initialize Callbacks and Mainform

                mainForm = new MainForm(wbContext);

                // Initialize the Workbench context
                ManagedApplication formsApplication = new ManagedApplication(
                    new AppCommandDelegate(mainForm.ApplicationCommand),
                    mainForm.dockDelegate);

                callbacks = new WbFrontendCallbacks(
                    new WbFrontendCallbacks.StrStrStrStrDelegate(mainForm.ShowFileDialog),
                    new WbFrontendCallbacks.VoidStrDelegate(mainForm.ShowStatusText),
                    new WbFrontendCallbacks.BoolStrStrFloatDelegate(mainForm.ShowProgress),
                    new WbFrontendCallbacks.CanvasViewStringStringDelegate(mainForm.CreateNewDiagram),
                    new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.DestroyView),
                    new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.SwitchedView),
                    new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.ToolChanged),
                    new WbFrontendCallbacks.IntPtrGRTManagerModuleStrStrGrtListFlagsDelegate(mainForm.OpenPlugin),
                    new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.ShowPlugin),
                    new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.HidePlugin),
                    new WbFrontendCallbacks.VoidRefreshTypeStringIntPtrDelegate(mainForm.RefreshGUI),
                    new WbFrontendCallbacks.VoidBoolDelegate(mainForm.LockGUI),
                    new WbFrontendCallbacks.VoidStrDelegate(mainForm.PerformCommand),
                    new WbFrontendCallbacks.BoolDelegate(mainForm.QuitApplication));

                // TODO: check return value and show error message.
                // Currently the return value is always true. In case of an error an exception is raised.
                // That should change.
                wbContext.init(callbacks, wbOptions,
                               new WbContext.VoidStrUIFormDelegate(mainForm.CreateMainFormView)
                               );

                // command registration must be done after WBContext init
                mainForm.PostInit();

                // Set the Application.Idle event handler
                Application.Idle += new EventHandler(OnApplicationIdle);

                // Don't call the idle handler too often.
                timer          = new System.Windows.Forms.Timer();
                timer.Interval = 100;
                timer.Tick    += new EventHandler(timer_Tick);
                timer.Start();

                // Trigger GRT idle tasks
                grtManager.perform_idle_tasks();

                // Setup Menus
                wbContext.validate_edit_menu();
                mainForm.Show();
                Logger.LogInfo("Workbench", "UI is up\n");

                // Tell the backend our main UI is ready. This will also load a model if it was given via command line
                // and opens the overview form for it.
                wbContext.finished_loading(wbOptions);

                // Right before we go to work and everything was loaded write the current version to registry
                // to allow us later to find out if we ran a new version the first time.
                try
                {
                    wbKey = Registry.CurrentUser.OpenSubKey(@"Software\Oracle\MySQL Workbench", true);
                    if (wbKey != null)
                    {
                        wbKey.SetValue("LastStartedAs", currentVersion);
                    }
                }
                catch (Exception e)
                {
                    Logger.LogError("Workbench", "Couldn't write regkey LastStartedAs: " + e.Message + '\n');
                }
                finally
                {
                    if (wbKey != null)
                    {
                        wbKey.Close();
                    }
                }

                // Start the Application if we are not already shutting down.
                if (!wbContext.is_quitting())
                {
                    try
                    {
                        Logger.LogInfo("Workbench", "Running the application\n");
                        Application.Run(new ApplicationContext(mainForm));
                    }
                    catch (Exception e)
                    {
                        HandleException(e);
                    }
                }

                #endregion

                Logger.LogInfo("Workbench", "Shutting down Workbench\n");

                timer.Stop();
                timer.Dispose();

                // shutdown wb context
                if (wbContext != null)
                {
                    while (wbContext.is_busy())
                    {
                        wbContext.flush_idle_tasks();
                    }

                    wbContext.finalize();
                    wbContext.Dispose();
                }
                formsApplication.Dispose();
                formsManager.Dispose();

                GC.Collect();
            }

            Win32Api.ReleaseConsole();

            Logger.LogInfo("Workbench", "Done\n");
        }
예제 #32
0
 public SqlIdeForm(WbContext wbContext, UIForm uiForm)
     : base((uiForm as SqlEditorFormWrapper).grt_manager())
 {
     this.wbContext = wbContext;
       dbSqlEditorBE = uiForm as SqlEditorFormWrapper;
       Initialize();
       UpdateColors();
 }
예제 #33
0
        /// <summary>
        /// Constructor that takes a WbContext and passes it to the sub-forms that get created
        /// </summary>
        /// <param name="WbContext">The WbContext Backend Wrapper</param>
        public MainForm(WbContext WbContext)
            : this()
        {
            wbContext = WbContext;
              grtManager = wbContext.get_grt_manager();

              dockDelegate = new MainPageDockDelegate(this, null);

              tabImageList = new ImageList();
              tabImageList.ColorDepth = ColorDepth.Depth32Bit;
              tabImageList.ImageSize = new Size(18, 16);
              ImageListHelper.Add(ApplicationCommand(AppCommand.AppGetResourcePath, "WB_Home.png"), tabImageList);
              contentTabControl.ImageList = tabImageList;

              // Create a timer to be triggered when the backend needs
              timer = new System.Windows.Forms.Timer();
              timer.Tick += new EventHandler(timer_Tick);

              // Prepare Statusbar
              PictureBox statusStripImg = new PictureBox();
              statusStripImg.SizeMode = PictureBoxSizeMode.CenterImage;
              statusStripImg.Image = Resources.statusbar_separator;
              statusStripImg.BackColor = Color.Transparent;
              ToolStripControlHost host = new ToolStripControlHost(statusStripImg);
              host.Alignment = ToolStripItemAlignment.Right;
              mainStatusStrip.Items.Add(host);

              // output img
              statusStripImg = new PictureBox();
              statusStripImg.Name = "grtShellStripButton";
              statusStripImg.SizeMode = PictureBoxSizeMode.CenterImage;
              statusStripImg.Image = Resources.statusbar_output;
              statusStripImg.BackColor = Color.Transparent;
              statusStripImg.Click += new System.EventHandler(grtOutputImg_Click);
              mainFormToolTip.SetToolTip(statusStripImg, "Display Output Window");
              host = new ToolStripControlHost(statusStripImg);
              host.Alignment = ToolStripItemAlignment.Right;
              mainStatusStrip.Items.Add(host);

              statusStripImg = new PictureBox();
              statusStripImg.SizeMode = PictureBoxSizeMode.CenterImage;
              statusStripImg.Image = Resources.statusbar_separator;
              statusStripImg.BackColor = Color.Transparent;
              host = new ToolStripControlHost(statusStripImg);
              host.Alignment = ToolStripItemAlignment.Right;
              mainStatusStrip.Items.Add(host);

              // Listen to system color changes.
              Microsoft.Win32.SystemEvents.UserPreferenceChanged += new Microsoft.Win32.UserPreferenceChangedEventHandler(PreferenceChangedHandler);

              ManagedNotificationCenter.AddObserver(this, "GNColorsChanged");
              ManagedNotificationCenter.AddObserver(this, "GNFocusChanged");
        }
예제 #34
0
 public WorkbenchMenuManager(WbContext WbContext)
 {
     wbContext = WbContext;
 }
예제 #35
0
        public PageSettingsForm(WbContext wbcontext)
        {
            InitializeComponent();

              WbContext = wbcontext;
        }
 public WorkbenchMenuManager(WbContext WbContext)
 {
     wbContext = WbContext;
 }
예제 #37
0
        static void Main(string[] Args)
        {
            // Connect the application to console to have proper output there if requested.
              bool consoleRedirectionWorked = Win32Api.RedirectConsole();

              // Start with command line parsing.
              string userDir = System.IO.Path.Combine(System.IO.Path.Combine(
            Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
            "MySQL"), "Workbench");
              Logger.InitLogger(userDir);

              if (!consoleRedirectionWorked)
            Logger.LogError("Workbench", "Console redirection failed.\n");

              System.Reflection.Assembly asm = System.Reflection.Assembly.GetEntryAssembly();
              string baseDir = System.IO.Path.GetDirectoryName(asm.Location);
              WbOptions wbOptions = new WbOptions(baseDir, userDir, true);

              if (!wbOptions.parse_args(Args, asm.Location))
              {
            Logger.LogInfo("Workbench", "Command line params told us to shut down.\n");
            return;
              }

              PrintInitialLogInfo();

              Application.EnableVisualStyles();
              Application.SetCompatibleTextRenderingDefault(false);

              // Hook into the exception handling to establish our own handling.
              AppDomain currentDomain = AppDomain.CurrentDomain; // CLR
              currentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);

              Application.ThreadException += // Windows Forms
             new System.Threading.ThreadExceptionEventHandler(OnGuiUnhandledException);

              // Read some early values which cannot be stored in the preferences (since they are loaded
              // later) from registry.
              bool singleInstance = true;
              string lastVersion = "";
              string currentVersion = GetApplicationMetaInfo(ApplicationMetaInfo.Version);
              Logger.LogInfo("Workbench", "Current version given by meta info is: " + currentVersion + '\n');
              RegistryKey wbKey = Registry.CurrentUser;
              try
              {
            wbKey = wbKey.OpenSubKey(@"Software\Oracle\MySQL Workbench", false);
            if (wbKey != null)
            {
              if (wbKey.GetValue("DisableSingleInstance", 0).ToString() == "1")
            singleInstance = false;
              lastVersion = wbKey.GetValue("LastStartedAs", "").ToString();
            }
            else
              Registry.CurrentUser.CreateSubKey(@"Software\Oracle\MySQL Workbench");
              }
              catch (Exception e)
              {
            Logger.LogError("Workbench", "Error while checking single instance reg key: " + e.Message + '\n');
              }
              finally
              {
            if (wbKey != null)
              wbKey.Close();
              }

              // First check if this is the first instance of Workbench (if enabled).
              // The setting for single-instance is stored in the registry as it is Windows-only
              // and loading of the application settings happens later.
              if (singleInstance)
              {
            if (!ApplicationInstanceManager.CreateSingleInstance(
              Assembly.GetExecutingAssembly().GetName().Name, Args, SingleInstanceCallback))
            {
              Logger.LogInfo("Workbench", "Exiting as another instance of WB is already running.\n");
              return;
            }
              }

              // Give the main thread a proper name, so we can later check for it when needed.
              Thread.CurrentThread.Name = "mainthread";

              // Change the working dir to to application path.
              // This is necessary because all our internal data files etc. are located under the app dir
              // and WB could have been called from a different dir.
              string workdir = System.IO.Directory.GetCurrentDirectory();
              System.IO.Directory.SetCurrentDirectory(baseDir);

              // Next check if this is the first start of a new version of WB. In this case remove all
              // compiled python files. They will be automatically recreated and can produce problems
              // under certain circumstances.
              if (currentVersion != lastVersion)
              {
            Logger.LogInfo("Workbench", "This is the first start of a new version. Doing some clean up.\n");
            List<string> failed = new List<string>();
            RemoveCompiledPythonFiles(baseDir, failed);

            // TODO: decide if we wanna ask the user to remove those files manually or just ignore them.
              }

              // Some people don't have c:\windows\system32 in PATH, so we need to set it here
              // for WBA to find the needed commands
              String systemFolder = Environment.GetFolderPath(Environment.SpecialFolder.System);
              String cleanedPath = Environment.GetEnvironmentVariable("PATH");

              String []paths= cleanedPath.Split(new char[]{';'});
              cleanedPath = "";

              // Strip all python related dirs from PATH to avoid conflicts with other Python installations.
              foreach (String path in paths)
              {
            if (!path.ToLower().Contains("python"))
              cleanedPath = cleanedPath + ";" + path;
              }
              Environment.SetEnvironmentVariable("PATH", systemFolder + cleanedPath);
              Logger.LogInfo("Workbench", "Setting PATH to: " + systemFolder + cleanedPath + '\n');

              // Clear PYTHONPATH environment variable, as we do not need it but our python impl
              // seriously gets confused with it.
              Environment.SetEnvironmentVariable("PYTHONPATH", workdir + "\\python\\Lib;" + workdir + "\\python\\DLLs;" + workdir + "\\python");
              Environment.SetEnvironmentVariable("PYTHONHOME", workdir + "\\python");

              // Initialize forms stuff.
              MySQL.Forms.Manager formsManager = MySQL.Forms.Manager.get_instance(); // Creates the singleton.

              // init extra mforms things that are delegated to the frontend, indirectly through RecordsetWrapper in wbpublic
              MySQL.Grt.Db.RecordsetWrapper.init_mforms(MySQL.Grt.Db.RecordsetView.create);

              #region Runtime path check

              // Currently WB has trouble running from a path containing non-ASCII characters.
              // Actually, our third party libraries have (namely lua, python, ctemplate),
              // as they don't consider Unicode file names (encoded as UTF-8) which leads to file-not-found
              // errors. Refuse to work in such a path for now.
              foreach (Char c in baseDir)
            if (c > 0x7f)
            {
              MessageBox.Show("MySQL Workbench cannot be executed from a path that contains non-ASCII characters.\n"+
            "This problem is imposed by used third-party libraries.\n" +
            "Please run this application from the default installation path or at least a path which is all ASCII characters.",
            "MySQL Workbench Execution Problem", MessageBoxButtons.OK, MessageBoxIcon.Error);
              return;
            }

              #endregion

              #region Release check (outdated beta or rc version)

              // check the date of the executable and suggest to install a new version if this is a beta or rc
              if (GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("BETA") >= 0 ||
            GetApplicationMetaInfo(ApplicationMetaInfo.Configuration).ToUpper().IndexOf("RC") >= 0)
              {
            DateTime fileDate = System.IO.File.GetCreationTime(Application.ExecutablePath);

            if (DateTime.Now.Subtract(fileDate).TotalDays > 45)
            {
              Logger.LogInfo("Workbench", "Found an old WB pre release. Showing warning.\n");
              if (MessageBox.Show("This version of MySQL Workbench is older than 45 days and most probably outdated. "
            + Environment.NewLine
            + "It is recommended to upgrade to a newer version if available. "
            + Environment.NewLine
            + "Press [OK] to check for a new version and exit the application. "
            + "Press [Cancel] to continue using this version.",
            "MySQL Workbench Version Outdated", MessageBoxButtons.OKCancel,
            MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.OK)
              {
            CheckForNewVersion();
            return;
              }
            }
              }

              #endregion

              #region Variables and Splashscreen

              #endregion

              #region Initialize GRT

              // Try to instantiate the Workbench context and the GRT Manager and catch exceptions
              try
              {
            // Create Workbench Context
            wbContext = new WbContext(wbOptions.Verbose);

            if (wbContext != null)
            {
              // Create the GRT Manager instance
              grtManager = wbContext.get_grt_manager();
            }
              }
              catch (Exception ex)
              {
            HandleException(ex);
              }

              #endregion

              // If the Workbench Context and GRT Manager were successfully created,
              // initialize the application
              if (wbContext != null && grtManager != null)
              {
            #region Initialize Callbacks and Mainform

            mainForm = new MainForm(wbContext);

            // Initialize the Workbench context
            ManagedApplication formsApplication = new ManagedApplication(
              new AppCommandDelegate(mainForm.ApplicationCommand),
              mainForm.dockDelegate);

            callbacks = new WbFrontendCallbacks(
              new WbFrontendCallbacks.StrStrStrStrDelegate(mainForm.ShowFileDialog),
              new WbFrontendCallbacks.VoidStrDelegate(mainForm.ShowStatusText),
              new WbFrontendCallbacks.BoolStrStrFloatDelegate(mainForm.ShowProgress),
              new WbFrontendCallbacks.CanvasViewStringStringDelegate(mainForm.CreateNewDiagram),
              new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.DestroyView),
              new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.SwitchedView),
              new WbFrontendCallbacks.VoidCanvasViewDelegate(mainForm.ToolChanged),
              new WbFrontendCallbacks.IntPtrGRTManagerModuleStrStrGrtListFlagsDelegate(mainForm.OpenPlugin),
              new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.ShowPlugin),
              new WbFrontendCallbacks.VoidIntPtrDelegate(mainForm.HidePlugin),
              new WbFrontendCallbacks.VoidRefreshTypeStringIntPtrDelegate(mainForm.RefreshGUI),
              new WbFrontendCallbacks.VoidBoolDelegate(mainForm.LockGUI),
              new WbFrontendCallbacks.VoidStrDelegate(mainForm.PerformCommand),
              new WbFrontendCallbacks.BoolDelegate(mainForm.QuitApplication));

            // TODO: check return value and show error message.
            // Currently the return value is always true. In case of an error an exception is raised.
            // That should change.
            wbContext.init(callbacks, wbOptions,
              new WbContext.VoidStrUIFormDelegate(mainForm.CreateMainFormView)
            );

            // command registration must be done after WBContext init
            mainForm.PostInit();

            // Set the Application.Idle event handler
            Application.Idle += new EventHandler(OnApplicationIdle);

            // Don't call the idle handler too often.
            timer = new System.Windows.Forms.Timer();
            timer.Interval = 100;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();

            // Trigger GRT idle tasks
            grtManager.perform_idle_tasks();

            // Setup Menus
            wbContext.validate_edit_menu();
            mainForm.Show();
            Logger.LogInfo("Workbench", "UI is up\n");

            // Tell the backend our main UI is ready. This will also load a model if it was given via command line
            // and opens the overview form for it.
            wbContext.finished_loading(wbOptions);

            // Right before we go to work and everything was loaded write the current version to registry
            // to allow us later to find out if we ran a new version the first time.
            try
            {
              wbKey = Registry.CurrentUser.OpenSubKey(@"Software\Oracle\MySQL Workbench", true);
              if (wbKey != null)
            wbKey.SetValue("LastStartedAs", currentVersion);
            }
            catch (Exception e)
            {
              Logger.LogError("Workbench", "Couldn't write regkey LastStartedAs: " + e.Message + '\n');
            }
            finally
            {
              if (wbKey != null)
            wbKey.Close();
            }

            // Start the Application if we are not already shutting down.
            if (!wbContext.is_quitting())
            {
              try
              {
            Logger.LogInfo("Workbench", "Running the application\n");
            Application.Run(new ApplicationContext(mainForm));
              }
              catch (Exception e)
              {
            HandleException(e);
              }
            }

            #endregion

            Logger.LogInfo("Workbench", "Shutting down Workbench\n");

            timer.Stop();
            timer.Dispose();

            // shutdown wb context
            if (wbContext != null)
            {
              while (wbContext.is_busy())
            wbContext.flush_idle_tasks();

              wbContext.finalize();
              wbContext.Dispose();
            }
            formsApplication.Dispose();
            formsManager.Dispose();

            GC.Collect();
              }

              Win32Api.ReleaseConsole();

              Logger.LogInfo("Workbench", "Done\n");
        }