/// <summary>
        /// Manually add new print queue name.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void newQueue_ToolStripButton_Click(object sender, EventArgs e)
        {
            FrameworkServer server    = SelectedServer;
            string          queueName = string.Empty;

            if (server == null)
            {
                MessageBox.Show("Please select a Print Server.", "Print Server not selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("Error Adding Print Queue. No Print Server selected");
                return;
            }

            // Determine if this server is categorized as an ePrint server.  If it is, then prompt the user
            // to enter ePrint related information.  Otherwise it will treat it as a standard print server.
            string ePrintType = ServerType.ePrint.ToString();

            if (server.ServerTypes.Any(x => x.Name.Equals(ePrintType, StringComparison.OrdinalIgnoreCase)))
            {
                queueName = InputDialog.Show("Enter an ePrint email address", "Add ePrint Email Address");
                if (!string.IsNullOrEmpty(queueName))
                {
                    ManuallyAddQueue(server, queueName);
                }
            }
        }
        /// <summary>
        /// Copies to an instance of a <see cref="FrameworkServer"/>.
        /// </summary>
        /// <param name="server">The server.</param>
        public void CopyTo(FrameworkServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            server.Active          = Active;
            server.Architecture    = Architecture;
            server.Cores           = Cores;
            server.DiskSpace       = DiskSpace;
            server.HostName        = HostName;
            server.Memory          = Memory;
            server.OperatingSystem = OperatingSystem;
            server.Processors      = Processors;
            server.Contact         = Contact;
            server.Status          = Status;
            server.IPAddress       = IpAddress;
            server.ServiceVersion  = ServiceVersion;

            server.ServerTypes.Clear();
            foreach (var item in ServerTypes)
            {
                server.ServerTypes.Add(item);
            }
        }
        private void editQueue_ToolStripButton_Click(object sender, EventArgs e)
        {
            RemotePrintQueue queue  = SelectedQueue;
            FrameworkServer  server = SelectedServer;

            if (server == null)
            {
                MessageBox.Show("Please select a Print Server.", "Print Server not selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("No Print Server selected for editing queue");
                return;
            }
            if (queue == null)
            {
                MessageBox.Show("Please select a Print Queue.", "Print Queue Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("Failed to get print queue. No Print Queue selected");
                return;
            }

            // Determine if this server is categorized as an ePrint server.  If it is, then allow the user
            // to edit ePrint related information.  Otherwise it will treat it as a standard print server.
            string ePrintType = ServerType.ePrint.ToString();

            if (server.ServerTypes.Any(x => x.Name.Equals(ePrintType, StringComparison.OrdinalIgnoreCase)))
            {
                string queueName = InputDialog.Show("ePrint email address", "Edit ePrint Email Address", queue.Name);
                if (!string.IsNullOrEmpty(queueName))
                {
                    EditQueue(queue, SelectedServer, queueName);
                }
            }
        }
        private void RemovePrintServer(FrameworkServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            // Determine if there are any queues associated with this server and if they are in use
            if (_controller.SelectQueuesInUse(server).Count > 0)
            {
                MessageBox.Show
                (
                    "This server is configured as a Print Server and has Print Queues associated with Test Scenarios.  " +
                    "You must use the 'Print Servers' configuration option to manage this server.",
                    "Delete Print Server",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation
                );
                return;
            }

            var dialogResult = MessageBox.Show
                               (
                "This server is configured as a Print Server and will be removed from the STF configuration database.  Do you want to continue?",
                "Delete Print Server",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question

                               );

            if (dialogResult == DialogResult.Yes)
            {
                _controller.Remove(server);
            }
        }
示例#5
0
        private void serverFilter_ToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedServer = serverFilter_ToolStripComboBox.ComboBox.SelectedItem as FrameworkServerType;

            dispatchers_DataGridView.DataSource = null;
            if (_context == null)
            {
                _context = new AssetInventoryContext();
            }

            if (selectedServer.Name == "Dispatcher")
            {
                var dispatchers =
                    FrameworkServer.Select(_context, ServerType.Dispatcher, GlobalSettings.Environment).ToList();
                dispatchers_DataGridView.DataSource = dispatchers;
            }
            else if (selectedServer.Name == "Print")
            {
                var printServers =
                    FrameworkServer.Select(_context, ServerType.Print, GlobalSettings.Environment).ToList();
                dispatchers_DataGridView.DataSource = printServers;
            }
            else if (selectedServer.Name == "Citrix")
            {
                var citrixServers =
                    FrameworkServer.Select(_context, ServerType.Citrix, GlobalSettings.Environment).ToList();
                dispatchers_DataGridView.DataSource = citrixServers;
            }
        }
        /// <summary>
        /// Helper to create the camera detail info.
        /// </summary>
        /// <param name="asset"></param>
        /// <param name="camera"></param>
        /// <returns></returns>
        private static CameraDetail CreateCameraDetail(AssetReservationResult asset, Camera camera)
        {
            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                FrameworkServer             server         = context.FrameworkServers.Include(n => n.ServerSettings).FirstOrDefault(n => n.HostName == camera.CameraServer);
                Dictionary <string, string> serverSettings = server?.ServerSettings.ToDictionary(n => n.Name, n => n.Value, StringComparer.OrdinalIgnoreCase);

                if (serverSettings == null)
                {
                    // If there are no ServerSettings for the specified camera server, return as much data as we have.
                    // Even if it's incomplete, we don't want to fail here, we want it to fail later in the process when
                    // the framework attempts to contact the camera server during the Validate stage.  Log a warning.
                    TraceFactory.Logger.Warn($"Server settings for Camera Server '{camera.CameraServer}' not found in configuration.");
                }

                return(new CameraDetail(asset.AssetId, asset.AvailabilityStart, asset.AvailabilityEnd)
                {
                    Address = serverSettings?["ServerAPIUrl"] ?? string.Empty,
                    CameraId = camera.AssetId,
                    PrinterId = camera.PrinterId,
                    CameraServer = camera.CameraServer,
                    ServerUser = serverSettings?["ServerAPIUserName"] ?? string.Empty,
                    ServerPassword = serverSettings?["ServerAPIPassword"] ?? string.Empty,
                    Availability = asset.Availability
                });
            }
        }
示例#7
0
        public static bool ConnectToDispatcher()
        {
            var result = false;

            if (GlobalSettings.IsDistributedSystem)
            {
                FrameworkServer dispatcher = null;
                using (MainFormConnectDialog connectDialog = new MainFormConnectDialog())
                {
                    connectDialog.ShowDialog();
                    if (connectDialog.DialogResult == DialogResult.OK)
                    {
                        try
                        {
                            dispatcher = connectDialog.SelectedDispatcher;

                            //Subscribe to dispatcher updates
                            SessionClient.Instance.Initialize(dispatcher.IPAddress);
                            SessionClient.Instance.Refresh();

                            Dispatcher = dispatcher;
                            GlobalSettings.SetDispatcher(dispatcher.IPAddress);
                            DispatcherChanged?.Invoke(dispatcher, new EventArgs());
                            result = true;
                        }
                        catch (EndpointNotFoundException ex)
                        {
                            Connected = result;
                            throw new EnvironmentConnectionException(
                                      "Could not connect to '{0}' at {1}.".FormatWith(dispatcher.HostName, dispatcher.IPAddress), ex);
                        }
                    }
                }
            }
            else
            {
                // If we are in a standalone mode then there will not be a remote dispatcher running
                // and in this case just collect information on the local machine and use that for
                // the Dispatcher information.
                Dispatcher = new FrameworkServer()
                {
                    FrameworkServerId = SequentialGuid.NewGuid()
                };
                Dispatcher.HostName = Environment.MachineName;

                // This is needed to run on a 192 or 10 net.
                Dispatcher.IPAddress = "localhost";

                SessionClient.Instance.Initialize(Dispatcher.IPAddress);
                SessionClient.Instance.Refresh();

                GlobalSettings.SetDispatcher(Dispatcher.IPAddress);
                DispatcherChanged(Dispatcher, new EventArgs());

                result = true;
            }
            Connected = result;
            return(result
                   );
        }
        private void remove_ToolStripButton_Click(object sender, EventArgs e)
        {
            GridViewRowInfo row = GetFirstSelectedRow();

            if (row != null)
            {
                ServerSetting setting = row.DataBoundItem as ServerSetting;

                DialogResult dialogResult = MessageBox.Show
                                            (
                    $"Removing setting '{setting.Name}'.  Do you want to continue?",
                    "Delete Setting",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question

                                            );

                if (dialogResult == DialogResult.Yes)
                {
                    using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
                    {
                        FrameworkServer server = context.FrameworkServers.First(n => n.FrameworkServerId == setting.FrameworkServerId);
                        server.ServerSettings.Remove(server.ServerSettings.First(n => n.Name == setting.Name));
                        context.SaveChanges();

                        BindSettingsToGrid(context);
                    }
                }
            }
        }
        /// <summary>
        /// Adds Queues for the specified server.  Only adds new queues to the database,
        /// does not check for PrintQueue database records that don't exist on the server.
        /// </summary>
        /// <param name="server">The Framework Server.</param>
        private bool AddServerQueues(FrameworkServer server)
        {
            Collection <string> queueNames = null;

            try
            {
                // Get the queues for the print server
                SetWaitCursor();
                queueNames = GetPrintQueueNames($"{server.HostName}.{GlobalSettings.Items[Setting.DnsDomain]}");
            }
            catch (SystemException ex)
            {
                MessageBox.Show("Failed to get print queues: {0}".FormatWith(ex.Message), "Print Queue Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("Failed to get print queues", ex);
                return(false);
            }
            finally
            {
                SetDefaultCursor();
            }

            if (queueNames.Count > 0)
            {
                // Prompt the user to choose the queues they want to add from the Server.
                return(FindMissingDatabaseQueues(server, queueNames));
            }

            MessageBox.Show(string.Format(Resources.NoQueuesAvailable, server.HostName), "Refresh Print Queues", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            return(false);
        }
        /// <summary>
        /// Copies from an instance of a <see cref="FrameworkServer"/>.
        /// </summary>
        /// <param name="server">The server.</param>
        public void CopyFrom(FrameworkServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            Active          = server.Active;
            Architecture    = server.Architecture;
            Cores           = server.Cores;
            DiskSpace       = server.DiskSpace;
            HostName        = server.HostName;
            Memory          = server.Memory;
            OperatingSystem = server.OperatingSystem;
            Processors      = server.Processors;
            Contact         = server.Contact;
            Status          = server.Status;
            IpAddress       = server.IPAddress;
            ServiceVersion  = server.ServiceVersion;

            foreach (var type in server.ServerTypes)
            {
                ServerTypes.Add(type);
            }
        }
示例#11
0
 static void Main(string[] args)
 {
     Win32.RemoveMenu(Win32.GetSystemMenu(Win32.FindWindow(null, System.Console.Title), 0), 0xf060, Convert.ToInt32(false));
     AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
     Server = new FrameworkServer();
     Server.Start();
     Cmd();
 }
        /// <summary>
        /// Processes queues that are in the database but don't show up on the server anymore.
        /// The user is prompted to remove these queues if they choose, but if the queues
        /// are still referenced within an activity then they can't be deleted.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="queuesOnServer">The queues on server.</param>
        /// <returns></returns>
        private bool FindMissingServerQueues(FrameworkServer server, Collection <string> queuesOnServer)
        {
            bool changesExist = false;

            // There are queues that no longer exist on the server, ask the user what they want
            // to do.  Should they keep the information around, but inactive, or should they
            // remove the queue entry from the database?
            Collection <RemotePrintQueue> queuesMissingOnServer = new Collection <RemotePrintQueue>();

            foreach (var item in _controller.Context.RemotePrintQueues.Where(n => n.PrintServerId == server.FrameworkServerId))
            {
                if (!queuesOnServer.Contains(item.Name))
                {
                    queuesMissingOnServer.Add(item);
                }
            }

            SortableBindingList <PrintQueueInUse> queuesInUse        = _controller.SelectQueuesInUse(server);
            Collection <Tuple <string, string> >  queuesAndScenarios = new Collection <Tuple <string, string> >();

            foreach (string queueName in queuesMissingOnServer.Select(q => q.Name))
            {
                PrintQueueInUse queue = queuesInUse.Where(q => q.QueueName == queueName).FirstOrDefault();

                if (queue != null)
                {
                    queuesAndScenarios.Add(new Tuple <string, string>(queueName, queue.ScenarioName));
                }
                else
                {
                    queuesAndScenarios.Add(new Tuple <string, string>(queueName, string.Empty));
                }
            }

            if (queuesMissingOnServer.Count > 0)
            {
                changesExist = true;

                // If there are queues missing on the server, the user selects which queues to forcefully remove from the database, EVEN IF THEY ARE BEING USED IN A SCENARIO
                using (PrintQueueRefreshForm form = new PrintQueueRefreshForm(queuesAndScenarios, Properties.Resources.RemoveQueues.FormatWith('\n'), "Remove", "Remove Missing Queues From Database", "Force Remove"))
                {
                    DialogResult result = form.ShowDialog(this);
                    if (result == DialogResult.OK)
                    {
                        foreach (string queue in form.SelectedQueues)
                        {
                            RemotePrintQueue remoteQueue = queuesMissingOnServer.Where(q => q.Name == queue).FirstOrDefault();
                            _controller.Context.RemotePrintQueues.Remove(remoteQueue);
                        }

                        SaveChanges();
                        RefreshQueueDisplay(server);
                    }
                }
            }

            return(changesExist);
        }
        private AddressParser ParseAddress(FrameworkServer vPrintServer)
        {
            if (string.IsNullOrEmpty(vPrintServer.IPAddress))
            {
                throw new MissingFieldException("IP Address is not set for {0}".FormatWith(vPrintServer.HostName));
            }

            return(new AddressParser(vPrintServer.IPAddress));
        }
        private void newServer_ToolStripButton_Click(object sender, EventArgs e)
        {
            bool result = false;

            // Prompt for the hostname
            string serverName = InputDialog.Show("Server Hostname:", "Add Server");

            if (string.IsNullOrEmpty(serverName))
            {
                // User cancelled
                return;
            }

            if (serverName.StartsWith(@"\", StringComparison.OrdinalIgnoreCase))
            {
                serverName = serverName.TrimStart(new char[] { '\\' });
            }

            try
            {
                Guid serverId = Guid.Empty;
                if (_controller.HostNameExists(serverName))
                {
                    FrameworkServer existingServer = _controller.Select(serverName);
                    serverId = existingServer.FrameworkServerId;
                    result   = UpdateServerProperties(existingServer);
                }
                else
                {
                    serverId = SequentialGuid.NewGuid();
                    result   = AddNewServer(serverName, serverId);
                }

                if (result)
                {
                    //Refesh The entire UI
                    RefreshServerDisplay();
                    int index = GetDataBoundItemIndex(serverId);
                    SetSelectedIndex(printServer_GridView, index);

                    if (_printServers.Count > 0)
                    {
                        RefreshQueueDisplay((FrameworkServer)printServer_GridView.CurrentRow.DataBoundItem);
                    }
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message, "Add Print Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("Error Adding Print Server with associated Queues", ex);
            }
            finally
            {
                SetDefaultCursor();
            }
        }
示例#15
0
            public CitrixServerComboBoxItem(FrameworkServer server)
            {
                float memory = (float)server.Memory / 1000.0F;

                HostName        = server.HostName;
                Version         = server.ServiceVersion;
                Architecture    = server.Architecture.ToLowerInvariant();
                Stats           = "{0}x{1}, {2:F}GB".FormatWith(server.Processors, server.Cores, memory);
                OperatingSystem = server.OperatingSystem;
            }
        /// <summary>
        /// Handles the Click event of the usage_ToolStripButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void usage_ToolStripButton_Click(object sender, EventArgs e)
        {
            FrameworkServer server = SelectedServer;

            if (server != null)
            {
                var queuesInUse = _controller.SelectQueuesInUse(server);
                PrintServerUsageDetails details = new PrintServerUsageDetails(server.HostName, queuesInUse);
                details.ShowDialog();
            }
        }
 /// <summary>
 /// Because Queue name is part of the primary key, we can't just change the name.
 /// We have to delete the old one and add it new.  This will work as long as the
 /// new name doesn't already exist.
 /// </summary>
 /// <param name="queueToDelete"></param>
 /// <param name="server"></param>
 /// <param name="newQueueName"></param>
 private void EditQueue(RemotePrintQueue queueToDelete, FrameworkServer server, string newQueueName)
 {
     if (CanRemoveQueue(queueToDelete))
     {
         RemoveQueue(queueToDelete);
         if (!ManuallyAddQueue(server, newQueueName))
         {
             //At this point the data context is in a bad state.  Reload.
             ReloadForm();
         }
     }
 }
        /// <summary>
        /// Displays the print queue data for the specified server.
        /// </summary>
        /// <param name="server">The server</param>
        private void RefreshQueueDisplay(FrameworkServer server)
        {
            printQueue_GridView.DataSource = null;
            _printQueues.Clear();

            foreach (RemotePrintQueue queue in _controller.Context.RemotePrintQueues.Where(n => n.PrintServerId == server.FrameworkServerId).OrderBy(x => x.Name))
            {
                _printQueues.Add(queue);
            }

            printQueue_GridView.DataSource = _printQueues;
            printQueue_GridView.BestFitColumns();
        }
        private int GetDataBoundItemIndex(Guid frameworkServerId)
        {
            foreach (GridViewRowInfo row in printServer_GridView.Rows)
            {
                FrameworkServer dataItem = (FrameworkServer)row.DataBoundItem;
                if (dataItem.FrameworkServerId == frameworkServerId)
                {
                    return(row.Index);
                }
            }

            return(-1);
        }
示例#20
0
        static ExchangeEmailMonitor()
        {
            _analyzers.Add(new EmailAnalyzer());

            // Retrieve Exchange Server Settings
            AssetInventoryConnectionString connectionString = new AssetInventoryConnectionString(GlobalSettings.Items[Setting.AssetInventoryDatabase]);

            using (AssetInventoryContext context = new AssetInventoryContext(connectionString))
            {
                string          serverType = ServerType.Exchange.ToString();
                FrameworkServer server     = context.FrameworkServers.FirstOrDefault(n => n.ServerTypes.Any(m => m.Name == serverType) && n.Active);
                _exchangeServerSettings = new SettingsDictionary(server.ServerSettings.ToDictionary(n => n.Name, n => n.Value));
            }
        }
        /// <summary>
        /// Refreshes the queue list.
        /// </summary>
        /// <param name="server">The server data.</param>
        private void RefreshQueueList(FrameworkServer server)
        {
            Collection <string> queues = null;

            try
            {
                bool changesMade = false;

                SetWaitCursor();
                string serverName = $"{server.HostName}.{GlobalSettings.Items[Setting.DnsDomain]}";
                TraceFactory.Logger.Debug("Getting queue names from: {0}".FormatWith(serverName));
                queues = GetPrintQueueNames(serverName);

                if (queues != null)
                {
                    if (FindMissingDatabaseQueues(server, queues))
                    {
                        changesMade = true;
                    }

                    if (FindMissingServerQueues(server, queues))
                    {
                        changesMade = true;
                    }
                }

                if (!changesMade)
                {
                    MessageBox.Show
                    (
                        Properties.Resources.PrintServerUpToDate,
                        "Refresh Print Queues",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                    );
                }
            }
            catch (SystemException ex)
            {
                MessageBox.Show(ex.Message, "Error Retrieving Print Queues", MessageBoxButtons.OK, MessageBoxIcon.Error);
                TraceFactory.Logger.Error("Error Retrieving Print Queues", ex);
                return;
            }
            finally
            {
                SetDefaultCursor();
            }
        }
        private static string BuildRequestDetails(License license, FrameworkServer server)
        {
            StringBuilder result = new StringBuilder("Solution: ");

            result.AppendLine(license.Solution);
            result.Append("Hostname: ").AppendLine(server.HostName);
            if (!string.IsNullOrEmpty(license.InstallationKey))
            {
                result.Append("ID Key: ").AppendLine(license.InstallationKey);
            }
            result.Append("Version: ").AppendLine(license.SolutionVersion);
            result.Append("OS: ").AppendLine(server.OperatingSystem);
            result.Append("Seats Requested: ").AppendLine(license.Seats.ToString());

            return(result.ToString());
        }
        /// <summary>
        /// Adds a new Framework Server with Print properties and retrieves it's print queues.
        /// </summary>
        private bool AddNewServer(string serverName, Guid serverId)
        {
            // The server doesn't exist in configuration, so try to query it and load
            // that information so it can be reviewed and edited by the user.
            Cursor = Cursors.WaitCursor;
            string error = string.Empty;
            FrameworkServerProxy proxy = new FrameworkServerProxy(serverName);
            bool success = _controller.QueryServer(proxy, out error);

            Cursor = Cursors.Default;

            // If there is a failure reading server and/or the user doesn't want to continue, then return
            if (!success && !ContinueEditing(proxy, error))
            {
                return(false);
            }

            FrameworkServer server = new FrameworkServer()
            {
                FrameworkServerId = serverId
            };

            // Add Print as a server type for this server before editing
            FrameworkServerType serverType = _controller.GetServerType(ServerType.Print);

            proxy.ServerTypes.Add(serverType);

            using (FrameworkServerEditForm form = new FrameworkServerEditForm(_controller, proxy))
            {
                if (form.ShowDialog() != DialogResult.OK)
                {
                    return(false);
                }

                proxy.CopyTo(server);
                //Save the new server to the database at this point.  If there is an error getting
                //print queues, the server data will be preserved.
                _controller.AddNewServer(server);
                _printServers.Add(server);
                SaveChanges();
            }

            // Scan the server for queues.
            AddServerQueues(server);

            return(true);
        }
        /// <summary>
        /// Processes queues that are resident on the Print Server but missing from
        /// the database.  The user has the option of adding these new queues to the
        /// database.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="queuesOnServer">The queues on server.</param>
        /// <returns></returns>
        private bool FindMissingDatabaseQueues(FrameworkServer server, Collection <string> queuesOnServer)
        {
            bool changesExist = false;

            // Determine if any of the queues found above for the print server are missing
            // from the database.
            Collection <string> queuesMissingInDatabase = new Collection <string>();

            foreach (string name in queuesOnServer)
            {
                // If the queue name doesn't already exist in the queues for the server then add it.
                // Note: We don't need to use n.Name.Equals(name, StringComparison.OrdinalIgnoreCase) because the LINQ is translated into SQL which is case insensitive
                bool exists = _controller.Context.RemotePrintQueues.Any(n => n.PrintServerId == server.FrameworkServerId && n.Name == name);

                if (!exists)
                {
                    queuesMissingInDatabase.Add(name);
                }
            }

            if (queuesMissingInDatabase.Count > 0)
            {
                changesExist = true;

                // If there are queues missing in the database, the user is prompted to select which ones to add to it.
                using (PrintQueueRefreshForm form = new PrintQueueRefreshForm(queuesMissingInDatabase, Properties.Resources.AddQueues, "Add", "Add Missing Queues To Database"))
                {
                    DialogResult result = form.ShowDialog(this);
                    if (result == DialogResult.OK)
                    {
                        foreach (string queue in form.SelectedQueues)
                        {
                            RemotePrintQueue newQueue = CreatePrintQueue(queue);
                            newQueue.PrintServer = server;

                            _controller.Context.RemotePrintQueues.Add(newQueue);
                        }

                        SaveChanges();
                        RefreshQueueDisplay(server);
                    }
                }
            }

            return(changesExist);
        }
        private void add_Button_Click(object sender, System.EventArgs e)
        {
            FrameworkServerProxy proxy = new FrameworkServerProxy();

            // Prompt for the hostname
            string inputText = InputDialog.Show("Server Hostname: ", "Add Server");

            if (string.IsNullOrWhiteSpace(inputText))
            {
                // User cancelled
                return;
            }

            // Determine if this hostname already exists
            if (_controller.HostNameExists(inputText))
            {
                MessageBox.Show("This hostname already exists", "Hostname Exists", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            proxy.HostName = inputText;
            string error = string.Empty;

            Cursor = Cursors.WaitCursor;
            bool foundHost = _controller.QueryServer(proxy, out error);

            Cursor = Cursors.Default;

            // If there is a failure reading server and the user doesn't want to continue, then return
            if (!foundHost && !ContinueEditing(proxy, error))
            {
                return;
            }

            if (EditEntry(proxy) == DialogResult.OK)
            {
                FrameworkServer server = new FrameworkServer()
                {
                    FrameworkServerId = SequentialGuid.NewGuid()
                };
                proxy.CopyTo(server);
                _controller.ServersList.Add(server);
            }

            server_RadGridView.Refresh();
        }
        private void server_ListBox_MouseMove(object sender, MouseEventArgs e)
        {
            int index = server_ListBox.IndexFromPoint(e.Location);

            if (index >= 0 && index < server_ListBox.Items.Count)
            {
                if (!toolTipServer.GetToolTip(server_ListBox).Contains(server_ListBox.Items[index].ToString()))
                {
                    FrameworkServer hoveredItem = server_ListBox.Items[index] as FrameworkServer;
                    toolTipServer.SetToolTip(server_ListBox, hoveredItem.HostName + ", " +
                                             hoveredItem.Architecture + ", " +
                                             hoveredItem.Cores.ToString(CultureInfo.CurrentCulture) + "x" +
                                             hoveredItem.Processors.ToString(CultureInfo.CurrentCulture) + ", " +
                                             hoveredItem.Memory.ToString(CultureInfo.CurrentCulture) + ", " +
                                             hoveredItem.OperatingSystem);
                }
            }
        }
示例#27
0
 private static void SetLoggingContext(FrameworkServer dispatcher)
 {
     try
     {
         // Set the logging context
         if (dispatcher != null)
         {
             TraceFactory.SetThreadContextProperty("Dispatcher", dispatcher.HostName, false);
         }
         string environment = GlobalSettings.Items[Setting.Environment];
         TraceFactory.SetThreadContextProperty("Environment", environment, false);
         TraceFactory.Logger.Debug("Set logging context");
     }
     catch (Exception ex)
     {
         TraceFactory.Logger.Error("Unable to set logging context", ex);
     }
 }
        /// <summary>
        /// Compares all queues for a server with those assigned to activities to determine those not being used.
        /// </summary>
        /// <param name="server">The server.</param>
        /// <param name="queuesInUse">The queues in use.</param>
        /// <returns></returns>
        public SortableBindingList <RemotePrintQueue> GetQueuesNotInUse(FrameworkServer server, SortableBindingList <PrintQueueInUse> queuesInUse)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            SortableBindingList <RemotePrintQueue> queuesToDelete = new SortableBindingList <RemotePrintQueue>();

            foreach (var queue in _context.RemotePrintQueues.Where(n => n.PrintServerId == server.FrameworkServerId))
            {
                if (!queuesInUse.Any(x => x.QueueName == queue.Name))
                {
                    queuesToDelete.Add(queue);
                }
            }

            return(queuesToDelete);
        }
示例#29
0
        private Usuario InternalLogin(string logon, string senha)
        {
            Usuario user = null;

            try
            {
                //codifica a senha pois ela foi criptografa no banco
                //entao nao sabemos qual é a verdadeira senha
                var result = ASCIIEncodingIts.Coded(senha);

                using (var ctx = new GenericContextIts <Usuario>(AppConfigManager.Configuration.ConnectionString))
                {
                    if (logon.IsContainsLetters())

                    {
                        //busca o User com a senha codificada
                        user = ctx.Dao
                               .Where(u => u.NomeUtilizador == logon && u.Senha == result).First();
                    }
                    else
                    {
                        //tente pelo ID
                        var id    = ParseUtil.ToInt(logon);
                        var users = ctx.Dao.FindAll();
                        user = ctx.Dao
                               .Where(u => u.IdUsuario == id).First();
                    }
                }

                //se achou o usuario, registre a sessao no servidor.
                if (user != null)
                {
                    FrameworkServer.RegisterSession(_sessionID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(user);
        }
示例#30
0
 /// <summary>
 /// Updates Environment, version and database host name in global database.
 /// </summary>
 public static void UpdateServerInfo()
 {
     try
     {
         using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
         {
             FrameworkServer server = context.FrameworkServers.FirstOrDefault(n => n.HostName == Environment.MachineName);
             if (server != null)
             {
                 server.Environment       = GlobalSettings.Items[Setting.Environment];
                 server.StfServiceVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                 context.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         TraceFactory.Logger.Debug(ex.ToString());
     }
 }