Ejemplo n.º 1
0
        public void PanelSetup(IPanelHost host, Dictionary<string, object> arguments)
        {
            // Grab the panel manager
            m_panelHost = host;

            // Make a new collector
            m_collector = new MessageCollector(App.BaconMan);

            // Sub to the collector callbacks
            m_collector.OnCollectionUpdated += Collector_OnCollectionUpdated;
            m_collector.OnCollectorStateChange += Collector_OnCollectorStateChange;

            // Ask the collector to update
            m_collector.Update();
        }
        /// <summary>
        /// Checks if we should update and if so does so.
        /// </summary>
        /// <param name="refDeferral"></param>
        /// <param name="force"></param>
        public void RunUpdate(RefCountedDeferral refDeferral, bool force = false)
        {
            if (IsEnabled && m_baconMan.UserMan.IsUserSignedIn)
            {
                TimeSpan timeSinceLastRun = DateTime.Now - LastUpdateTime;
                if (timeSinceLastRun.TotalMinutes > 10 || force)
                {
                    // We should update. Grab the deferral
                    m_refDeferral = refDeferral;
                    m_refDeferral.AddRef();

                    // Make the collector
                    m_collector = new MessageCollector(m_baconMan);

                    // We don't need to sub to the collection update because we will get
                    // called automatically when it updates
                    m_collector.OnCollectorStateChange += Collector_OnCollectorStateChange;

                    // Tell it to update!
                    m_collector.Update(true);
                }
            }
        }
Ejemplo n.º 3
0
 public Worker(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <InformationGathered, WorkScheduled>(OnMessagesCollected);
 }
 public ModelIdUpdater(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <TreeViewModelCreated, ModificationResult>(OnMessagesCollected);
 }
Ejemplo n.º 5
0
        public static void SaveSettings()
        {
            try
            {
                var with1           = frmMain.Default;
                var windowPlacement = new WindowPlacement(frmMain.Default);
                if (with1.WindowState == FormWindowState.Minimized & windowPlacement.RestoreToMaximized)
                {
                    with1.Opacity     = 0;
                    with1.WindowState = FormWindowState.Maximized;
                }

                mRemoteNG.Settings.Default.MainFormLocation = with1.Location;
                mRemoteNG.Settings.Default.MainFormSize     = with1.Size;

                if (with1.WindowState != FormWindowState.Normal)
                {
                    mRemoteNG.Settings.Default.MainFormRestoreLocation = with1.RestoreBounds.Location;
                    mRemoteNG.Settings.Default.MainFormRestoreSize     = with1.RestoreBounds.Size;
                }

                mRemoteNG.Settings.Default.MainFormState = with1.WindowState;

                if (with1.Fullscreen != null)
                {
                    mRemoteNG.Settings.Default.MainFormKiosk = with1.Fullscreen.Value;
                }

                mRemoteNG.Settings.Default.FirstStart    = false;
                mRemoteNG.Settings.Default.ResetPanels   = false;
                mRemoteNG.Settings.Default.ResetToolbars = false;
                mRemoteNG.Settings.Default.NoReconnect   = false;

                mRemoteNG.Settings.Default.ExtAppsTBLocation = with1.tsExternalTools.Location;
                if (with1.tsExternalTools.Parent != null)
                {
                    mRemoteNG.Settings.Default.ExtAppsTBParentDock = with1.tsExternalTools.Parent.Dock.ToString();
                }
                mRemoteNG.Settings.Default.ExtAppsTBVisible  = with1.tsExternalTools.Visible;
                mRemoteNG.Settings.Default.ExtAppsTBShowText = with1.cMenToolbarShowText.Checked;

                mRemoteNG.Settings.Default.QuickyTBLocation = with1.tsQuickConnect.Location;
                if (with1.tsQuickConnect.Parent != null)
                {
                    mRemoteNG.Settings.Default.QuickyTBParentDock = with1.tsQuickConnect.Parent.Dock.ToString();
                }
                mRemoteNG.Settings.Default.QuickyTBVisible = with1.tsQuickConnect.Visible;

                var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                mRemoteNG.Settings.Default.ConDefaultPassword =
                    cryptographyProvider.Encrypt(Convert.ToString(mRemoteNG.Settings.Default.ConDefaultPassword), EncryptionKey);

                mRemoteNG.Settings.Default.Save();

                SavePanelsToXML();
                SaveExternalAppsToXML();
            }
            catch (Exception ex)
            {
                MessageCollector.AddExceptionStackTrace("Saving settings failed", ex);
            }
        }
Ejemplo n.º 6
0
        private void ChannelGraph(SocketGuild guild, string filename, SocketUser user = null)
        {
            PlotModel plot = new PlotModel();

            //List<DateTimeOffset> messages = new List<DateTimeOffset>();//MessageCollector.collectMessages(guild);
            int total = 0;

            if (user == null)
            {
                Task <List <DateTimeOffset> > t = MessageCollector.collectMessages(guild);
                t.Wait();
                total = t.Result.Count;
            }
            else
            {
                Task <List <DateTimeOffset> > t = MessageCollector.collectMessages(user, guild);
                t.Wait();
                total = t.Result.Count;
            }

            //int total = messages.Count;


            Dictionary <IMessageChannel, int> organized = new Dictionary <IMessageChannel, int>();

            foreach (SocketTextChannel channel in guild.TextChannels)
            {
                Task <List <DateTimeOffset> > t = MessageCollector.collectMessages(channel);
                t.Wait();
                organized.Add(channel, t.Result.Count);
            }

            var pieSeries = new OxyPlot.Series.PieSeries {
                Title = "ChannelGraph: " + filename + "\n Messages referenced: " + total
            };

            pieSeries.AreInsideLabelsAngled = true;
            for (int i = 0; i < organized.Count; i++)
            {
                var     l       = organized.ToList();
                decimal percent = decimal.Divide(l[i].Value, total) * 100;
                if (l[i].Value == 0 || percent < 1)
                {
                    continue;
                }
                if (percent < 2)
                {
                    pieSeries.Slices.Add(new PieSlice(null, l[i].Value));
                }
                else
                {
                    pieSeries.Slices.Add(new PieSlice(l[i].Key.Name, l[i].Value));
                }
            }
            plot.Series.Add(pieSeries);
            plot.TitleFontSize = 40;

            var pngExporter = new PngExporter {
                Width = 1200, Height = 1000
            };

            pngExporter.ExportToFile(plot, filename + ".png");
        }
 public PackageUsingStatePattern(MessageCollector messageCollector)
 {
     _messageCollector = messageCollector;
     _state            = PackageState.State1(this);
 }
Ejemplo n.º 8
0
 public GeneratorSettingsModifier(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <ModifyModel, ModelVersionCreated>(OnMessagesCollected);
 }
Ejemplo n.º 9
0
        public static void SaveConnectionsAs()
        {
            ConnectionsSaver connectionsSave = new ConnectionsSaver();

            try
            {
                if (SQLConnProvider != null)
                {
                    SQLConnProvider.Disable();
                }

                using (SaveFileDialog saveFileDialog = new SaveFileDialog())
                {
                    saveFileDialog.CheckPathExists  = true;
                    saveFileDialog.InitialDirectory = ConnectionsFileInfo.DefaultConnectionsPath;
                    saveFileDialog.FileName         = ConnectionsFileInfo.DefaultConnectionsFile;
                    saveFileDialog.OverwritePrompt  = true;

                    List <string> fileTypes = new List <string>();
                    fileTypes.AddRange(new[] { Language.strFiltermRemoteXML, "*.xml" });
                    fileTypes.AddRange(new[] { Language.strFilterAll, "*.*" });

                    saveFileDialog.Filter = string.Join("|", fileTypes.ToArray());

                    if (!(saveFileDialog.ShowDialog(frmMain.Default) == DialogResult.OK))
                    {
                        return;
                    }

                    connectionsSave.SaveFormat         = ConnectionsSaver.Format.mRXML;
                    connectionsSave.ConnectionFileName = saveFileDialog.FileName;
                    connectionsSave.Export             = false;
                    connectionsSave.SaveSecurity       = new Security.Save();
                    connectionsSave.ConnectionList     = ConnectionList;
                    connectionsSave.ContainerList      = ContainerList;
                    connectionsSave.RootTreeNode       = Windows.treeForm.tvConnections.Nodes[0];

                    connectionsSave.SaveConnections();

                    if (saveFileDialog.FileName == GetDefaultStartupConnectionFileName())
                    {
                        Settings.Default.LoadConsFromCustomLocation = false;
                    }
                    else
                    {
                        Settings.Default.LoadConsFromCustomLocation = true;
                        Settings.Default.CustomConsPath             = saveFileDialog.FileName;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotSaveAs, connectionsSave.ConnectionFileName), ex);
            }
            finally
            {
                if (SQLConnProvider != null)
                {
                    SQLConnProvider.Enable();
                }
            }
        }
Ejemplo n.º 10
0
 public Package(MessageCollector messageCollector)
 {
     _state1           = true;
     _messageCollector = messageCollector;
 }
Ejemplo n.º 11
0
        public static void SaveConnections(bool Update = false)
        {
            if (!IsConnectionsFileLoaded)
            {
                return;
            }

            try
            {
                if (Update && Settings.Default.UseSQLServer == false)
                {
                    return;
                }

                if (SQLConnProvider != null)
                {
                    SQLConnProvider.Disable();
                }

                ConnectionsSaver conS = new ConnectionsSaver();

                if (!Settings.Default.UseSQLServer)
                {
                    conS.ConnectionFileName = GetStartupConnectionFileName();
                }

                conS.ConnectionList = ConnectionList;
                conS.ContainerList  = ContainerList;
                conS.Export         = false;
                conS.SaveSecurity   = new Security.Save(false);
                conS.RootTreeNode   = Windows.treeForm.tvConnections.Nodes[0];

                if (Settings.Default.UseSQLServer)
                {
                    conS.SaveFormat      = ConnectionsSaver.Format.SQL;
                    conS.SQLHost         = Convert.ToString(Settings.Default.SQLHost);
                    conS.SQLDatabaseName = Convert.ToString(Settings.Default.SQLDatabaseName);
                    conS.SQLUsername     = Convert.ToString(Settings.Default.SQLUser);
                    var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                    conS.SQLPassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey);
                }

                conS.SaveConnections();

                if (Settings.Default.UseSQLServer)
                {
                    LastSqlUpdate = DateTime.Now;
                }
            }
            catch (Exception ex)
            {
                MessageCollector.AddMessage(MessageClass.ErrorMsg, Language.strConnectionsFileCouldNotBeSaved + Environment.NewLine + ex.Message);
            }
            finally
            {
                if (SQLConnProvider != null)
                {
                    SQLConnProvider.Enable();
                }
            }
        }
Ejemplo n.º 12
0
        public static void LoadConnections(bool withDialog = false, bool update = false)
        {
            var connectionsLoader = new ConnectionsLoader();

            try
            {
                // disable sql update checking while we are loading updates
                SQLConnProvider?.Disable();

                if (ConnectionList != null && ContainerList != null)
                {
                    PreviousConnectionList = ConnectionList.Copy();
                    PreviousContainerList  = ContainerList.Copy();
                }

                ConnectionList = new ConnectionList();
                ContainerList  = new ContainerList();

                if (!Settings.Default.UseSQLServer)
                {
                    if (withDialog)
                    {
                        var loadDialog = Tools.Controls.ConnectionsLoadDialog();
                        if (loadDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        connectionsLoader.ConnectionFileName = loadDialog.FileName;
                    }
                    else
                    {
                        connectionsLoader.ConnectionFileName = GetStartupConnectionFileName();
                    }

                    CreateBackupFile(Convert.ToString(connectionsLoader.ConnectionFileName));
                }

                connectionsLoader.ConnectionList = ConnectionList;
                connectionsLoader.ContainerList  = ContainerList;

                if (PreviousConnectionList != null && PreviousContainerList != null)
                {
                    connectionsLoader.PreviousConnectionList = PreviousConnectionList;
                    connectionsLoader.PreviousContainerList  = PreviousContainerList;
                }

                if (update)
                {
                    connectionsLoader.PreviousSelected = LastSelected;
                }

                ConnectionTree.ResetTree();

                connectionsLoader.RootTreeNode     = Windows.treeForm.tvConnections.Nodes[0];
                connectionsLoader.UseDatabase      = Settings.Default.UseSQLServer;
                connectionsLoader.DatabaseHost     = Settings.Default.SQLHost;
                connectionsLoader.DatabaseName     = Settings.Default.SQLDatabaseName;
                connectionsLoader.DatabaseUsername = Settings.Default.SQLUser;
                var cryptographyProvider = new LegacyRijndaelCryptographyProvider();
                connectionsLoader.DatabasePassword = cryptographyProvider.Decrypt(Convert.ToString(Settings.Default.SQLPass), GeneralAppInfo.EncryptionKey);
                connectionsLoader.DatabaseUpdate   = update;
                connectionsLoader.LoadConnections(false);

                if (Settings.Default.UseSQLServer)
                {
                    LastSqlUpdate = DateTime.Now;
                }
                else
                {
                    if (connectionsLoader.ConnectionFileName == GetDefaultStartupConnectionFileName())
                    {
                        Settings.Default.LoadConsFromCustomLocation = false;
                    }
                    else
                    {
                        Settings.Default.LoadConsFromCustomLocation = true;
                        Settings.Default.CustomConsPath             = connectionsLoader.ConnectionFileName;
                    }
                }

                // re-enable sql update checking after updates are loaded
                SQLConnProvider?.Enable();
            }
            catch (Exception ex)
            {
                if (Settings.Default.UseSQLServer)
                {
                    MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
                    var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
                    CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
                    switch (CTaskDialog.CommandButtonResult)
                    {
                    case 0:
                        LoadConnections(withDialog, update);
                        return;

                    case 1:
                        Settings.Default.UseSQLServer = false;
                        LoadConnections(true, update);
                        return;

                    default:
                        Application.Exit();
                        return;
                    }
                }
                if (ex is FileNotFoundException && !withDialog)
                {
                    MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoader.ConnectionFileName), ex, MessageClass.InformationMsg);
                    NewConnections(Convert.ToString(connectionsLoader.ConnectionFileName));
                    return;
                }

                MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionsLoader.ConnectionFileName), ex);
                if (connectionsLoader.ConnectionFileName != GetStartupConnectionFileName())
                {
                    LoadConnections(withDialog, update);
                }
                else
                {
                    MessageBox.Show(frmMain.Default,
                                    string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
                                    "Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
        }
 public void CheckRuleWithExpressionCausingFormatException()
 {
     var executor = new MessageCollector <string>(() => "Hello");
     var result   = executor.Assert(x => bool.Parse(x.Length.ToString())).Results;
 }
Ejemplo n.º 14
0
        private async Task OnCollect(SocketReaction reaction)
        {
            var emote             = reaction.Emote;
            var hasManageMessages = false;

            if (reaction.Channel is SocketTextChannel textChannel)
            {
                hasManageMessages = textChannel.Guild.CurrentUser.GetPermissions(textChannel).ManageMessages;

                if (hasManageMessages)
                {
                    await _message.RemoveReactionAsync(emote, reaction.UserId).ConfigureAwait(false);
                }
            }

            if (emote.Equals(Reactions.Front))
            {
                if (_currentPageIndex == 0)
                {
                    return;
                }
                _currentPageIndex = 0;
            }
            else if (emote.Equals(Reactions.Rear))
            {
                if (_currentPageIndex == _lastPageIndex)
                {
                    return;
                }
                _currentPageIndex = _lastPageIndex;
            }
            else if (emote.Equals(Reactions.Previous))
            {
                if (_circularEnabled)
                {
                    if (_currentPageIndex == 0)
                    {
                        _currentPageIndex = _lastPageIndex;
                    }
                    else
                    {
                        _currentPageIndex--;
                    }
                }
                else
                {
                    if (_currentPageIndex == 0)
                    {
                        return;
                    }
                    _currentPageIndex--;
                }
            }
            else if (emote.Equals(Reactions.Next))
            {
                if (_circularEnabled)
                {
                    if (_currentPageIndex == _lastPageIndex)
                    {
                        _currentPageIndex = 0;
                    }
                    else
                    {
                        _currentPageIndex++;
                    }
                }
                else
                {
                    if (_currentPageIndex == _lastPageIndex)
                    {
                        return;
                    }
                    _currentPageIndex++;
                }
            }
            else if (emote.Equals(Reactions.Stop))
            {
                _collector.Stop();
                return;
            }
            else if (emote.Equals(Reactions.Trash))
            {
                _collector.Stop();
                await _message.DeleteAsync().ConfigureAwait(false);

                return;
            }
            else if (emote.Equals(Reactions.Jump))
            {
                var promptMessage = _jumpOptions.PromptEnabled
                    ? await _message.Channel.SendMessageAsync(_jumpOptions.Prompt).ConfigureAwait(false)
                    : null;

                var collectorConfig = new MessageCollectorConfig(_client)
                {
                    Channel = _message.Channel,
                    Timeout = _jumpOptions.Timeout,
                    Max     = 1
                };

                var messageCollector = new MessageCollector(
                    x => x.Author.Id == reaction.UserId, collectorConfig);

                var collected = await messageCollector.StartAsync().ConfigureAwait(false);

                var collectedMessage = collected.FirstOrDefault();

                if (promptMessage != null)
                {
                    await promptMessage.DeleteAsync().ConfigureAwait(false);
                }

                if (collectedMessage != null)
                {
                    if (_jumpOptions.DeleteResponse && hasManageMessages)
                    {
                        await collectedMessage.DeleteAsync().ConfigureAwait(false);
                    }

                    if (int.TryParse(collectedMessage.Content, out var pageNumber) &&
                        pageNumber >= 1 && pageNumber <= _pageCount)
                    {
                        _currentPageIndex = pageNumber - 1;
                    }
                }
            }
            else if (emote.Equals(Reactions.Info))
            {
                var message = await _message.Channel.SendMessageAsync(_infoOptions.Text).ConfigureAwait(false);

                await Task.Delay(_infoOptions.Timeout).ConfigureAwait(false);

                await message.DeleteAsync().ConfigureAwait(false);

                return;
            }

            await EditMessageAsync().ConfigureAwait(false);
        }
Ejemplo n.º 15
0
 public SelectedTreeItemTranslator(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <ModelVersionCreated, SelectedTreeViewItemChanged>(OnMessagesCollected);
 }
Ejemplo n.º 16
0
 public TreeViewModelBuilder(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <ModelLoaded, TreeViewModelCreated>(OnMessagesCollected);
 }
Ejemplo n.º 17
0
 public NamedPipeCommunicationProtocolAgent(MessageBoard messageBoard) : base(NamedPipeCommunicationProtocolAgentDefinition, messageBoard)
 {
     connectCollector = new MessageCollector <NamedPipeConnectedMessage, StreamFactoryCreatedMessage>(OnConnectMessagesCollected);
 }
Ejemplo n.º 18
0
 public ConsoleMessageJoiner(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <HelloConsoleMessage, WorldConsoleMessage>(OnMessagesCollected);
 }
Ejemplo n.º 19
0
 public SearchSourceUpdater(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <SearchViewModelCreated, TreeViewModelCreated, TreeViewModelUpdated>(OnMessagesCollected);
 }
Ejemplo n.º 20
0
 public static void CheckCompatibility(MessageCollector messageCollector)
 {
     CheckFipsPolicy(messageCollector);
     CheckLenovoAutoScrollUtility(messageCollector);
 }
Ejemplo n.º 21
0
 public ViewModelChangeApplier(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <ViewModelChangeApplying, MainWindowCreated>(OnMessagesCollected);
 }
Ejemplo n.º 22
0
 public MessageConsoleWriter(IMessageBoard messageBoard, IConsole console, Action terminateAction) : base(messageBoard)
 {
     this.console         = console;
     this.terminateAction = terminateAction;
     collector            = new MessageCollector <ConsumedAllMessages, InterceptedAllMessages>(OnMessagesCollected);
 }
Ejemplo n.º 23
0
 public GraphSelector(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <MainWindowCreated, SelectedModelObjectChanged>(OnMessagesCollected);
 }
Ejemplo n.º 24
0
        public static void LoadConnections(bool withDialog = false, bool update = false)
        {
            var connectionsLoader = new ConnectionsLoader();

            try
            {
                // disable sql update checking while we are loading updates
                RemoteConnectionsSyncronizer?.Disable();

                if (!Settings.Default.UseSQLServer)
                {
                    if (withDialog)
                    {
                        var loadDialog = Controls.ConnectionsLoadDialog();
                        if (loadDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        connectionsLoader.ConnectionFileName = loadDialog.FileName;
                    }
                    else
                    {
                        connectionsLoader.ConnectionFileName = GetStartupConnectionFileName();
                    }

                    CreateBackupFile(Convert.ToString(connectionsLoader.ConnectionFileName));
                }

                connectionsLoader.UseDatabase        = Settings.Default.UseSQLServer;
                ConnectionTreeModel                  = connectionsLoader.LoadConnections(false);
                Windows.TreeForm.ConnectionTreeModel = ConnectionTreeModel;

                if (Settings.Default.UseSQLServer)
                {
                    LastSqlUpdate = DateTime.Now;
                }
                else
                {
                    if (connectionsLoader.ConnectionFileName == GetDefaultStartupConnectionFileName())
                    {
                        Settings.Default.LoadConsFromCustomLocation = false;
                    }
                    else
                    {
                        Settings.Default.LoadConsFromCustomLocation = true;
                        Settings.Default.CustomConsPath             = connectionsLoader.ConnectionFileName;
                    }
                }

                // re-enable sql update checking after updates are loaded
                RemoteConnectionsSyncronizer?.Enable();
            }
            catch (Exception ex)
            {
                if (Settings.Default.UseSQLServer)
                {
                    MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
                    var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
                    CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
                    switch (CTaskDialog.CommandButtonResult)
                    {
                    case 0:
                        LoadConnections(withDialog, update);
                        return;

                    case 1:
                        Settings.Default.UseSQLServer = false;
                        LoadConnections(true, update);
                        return;

                    default:
                        Application.Exit();
                        return;
                    }
                }
                if (ex is FileNotFoundException && !withDialog)
                {
                    MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionsLoader.ConnectionFileName), ex, MessageClass.InformationMsg);
                    NewConnections(Convert.ToString(connectionsLoader.ConnectionFileName));
                    return;
                }

                MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionsLoader.ConnectionFileName), ex);
                if (connectionsLoader.ConnectionFileName != GetStartupConnectionFileName())
                {
                    LoadConnections(withDialog, update);
                }
                else
                {
                    MessageBox.Show(frmMain.Default,
                                    string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
                                    @"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
        }
Ejemplo n.º 25
0
 public GraphViewModelUpdater(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <GraphCreated, GraphViewModelCreated>(OnMessagesCollected);
 }
Ejemplo n.º 26
0
 public AgentViewModelWatcher(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <ModelVersionCreated, SelectedTreeViewItemChanged>(OnMessagesCollected);
 }
Ejemplo n.º 27
0
 public DeleteSelectedModelObject(IMessageBoard messageBoard) : base(messageBoard)
 {
     collector = new MessageCollector <SelectedModelObjectChanged, DeleteItemRequested>(OnMessagesCollected);
 }
Ejemplo n.º 28
0
        public static void LoadConnections(bool withDialog = false)
        {
            var connectionFileName = "";

            try
            {
                // disable sql update checking while we are loading updates
                ConnectionsService.RemoteConnectionsSyncronizer?.Disable();

                if (!Settings.Default.UseSQLServer)
                {
                    if (withDialog)
                    {
                        var loadDialog = DialogFactory.BuildLoadConnectionsDialog();
                        if (loadDialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                        connectionFileName = loadDialog.FileName;
                    }
                    else
                    {
                        connectionFileName = ConnectionsService.GetStartupConnectionFileName();
                    }
                }

                ConnectionsService.LoadConnections(Settings.Default.UseSQLServer, false, connectionFileName);

                if (Settings.Default.UseSQLServer)
                {
                    ConnectionsService.LastSqlUpdate = DateTime.Now;
                }

                // re-enable sql update checking after updates are loaded
                ConnectionsService.RemoteConnectionsSyncronizer?.Enable();
            }
            catch (Exception ex)
            {
                if (Settings.Default.UseSQLServer)
                {
                    MessageCollector.AddExceptionMessage(Language.strLoadFromSqlFailed, ex);
                    var commandButtons = string.Join("|", Language.strCommandTryAgain, Language.strCommandOpenConnectionFile, string.Format(Language.strCommandExitProgram, Application.ProductName));
                    CTaskDialog.ShowCommandBox(Application.ProductName, Language.strLoadFromSqlFailed, Language.strLoadFromSqlFailedContent, MiscTools.GetExceptionMessageRecursive(ex), "", "", commandButtons, false, ESysIcons.Error, ESysIcons.Error);
                    switch (CTaskDialog.CommandButtonResult)
                    {
                    case 0:
                        LoadConnections(withDialog);
                        return;

                    case 1:
                        Settings.Default.UseSQLServer = false;
                        LoadConnections(true);
                        return;

                    default:
                        Application.Exit();
                        return;
                    }
                }
                if (ex is FileNotFoundException && !withDialog)
                {
                    MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), ex, MessageClass.InformationMsg);

                    string[] commandButtons =
                    {
                        Language.ConfigurationCreateNew,
                        Language.ConfigurationCustomPath,
                        Language.ConfigurationImportFile,
                        Language.strMenuExit
                    };

                    var answered = false;
                    while (!answered)
                    {
                        try
                        {
                            CTaskDialog.ShowTaskDialogBox(
                                GeneralAppInfo.ProductName,
                                Language.ConnectionFileNotFound,
                                "", "", "", "", "",
                                string.Join(" | ", commandButtons),
                                ETaskDialogButtons.None,
                                ESysIcons.Question,
                                ESysIcons.Question);

                            switch (CTaskDialog.CommandButtonResult)
                            {
                            case 0:
                                ConnectionsService.NewConnectionsFile(connectionFileName);
                                answered = true;
                                break;

                            case 1:
                                LoadConnections(true);
                                answered = true;
                                break;

                            case 2:
                                ConnectionsService.NewConnectionsFile(connectionFileName);
                                Import.ImportFromFile(ConnectionsService.ConnectionTreeModel.RootNodes[0]);
                                answered = true;
                                break;

                            case 3:
                                Application.Exit();
                                answered = true;
                                break;
                            }
                        }
                        catch (Exception exc)
                        {
                            MessageCollector.AddExceptionMessage(string.Format(Language.strConnectionsFileCouldNotBeLoadedNew, connectionFileName), exc, MessageClass.InformationMsg);
                        }
                    }
                    return;
                }

                MessageCollector.AddExceptionStackTrace(string.Format(Language.strConnectionsFileCouldNotBeLoaded, connectionFileName), ex);
                if (connectionFileName != ConnectionsService.GetStartupConnectionFileName())
                {
                    LoadConnections(withDialog);
                }
                else
                {
                    MessageBox.Show(FrmMain.Default,
                                    string.Format(Language.strErrorStartupConnectionFileLoad, Environment.NewLine, Application.ProductName, ConnectionsService.GetStartupConnectionFileName(), MiscTools.GetExceptionMessageRecursive(ex)),
                                    @"Could not load startup file.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }
        }
Ejemplo n.º 29
0
        private static void ParseCommandLineArgs(MessageCollector messageCollector)
        {
            var interpreter = new StartupArgumentsInterpreter(messageCollector);

            interpreter.ParseArguments(Environment.GetCommandLineArgs());
        }
 public AgentViewModelUpdater(IMessageBoard messageBoard)
     : base(messageBoard)
 {
     collector = new MessageCollector <TreeViewModelCreated, ModifyModel>(OnMessagesCollected);
 }
Ejemplo n.º 31
0
 public CasinoService(DiscordSocketClient client)
 {
     _collector = new MessageCollector(client);
 }