コード例 #1
0
        private void _bSendMessage_Click(object sender, EventArgs e)
        {
            this.AddLogEntry("Creating message.");

            // We create the message object
            ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

            // We assign the sender email
            message.From.Email = this._tbFromEmail.Text;

            // We assign the recipient email
            message.To.Add(this._tbToEmail.Text);

            // We assign the subject
            message.Subject = this._tbSubject.Text;

            // We assign the body text
            message.BodyText.Text = this._tbBodyText.Text;

            ServerCollection smtpServers = new ServerCollection();

            smtpServers.Add(this._tbMainSmtpServer.Text);
            smtpServers.Add(this._tbBackupSmtpServer.Text);

            // We send the email using the specified SMTP server
            this.AddLogEntry("Sending message.");

            try
            {
                SmtpClient.Send(message, smtpServers);

                this.AddLogEntry("Message sent successfully.");
            }

            catch (SmtpException ex)
            {
                this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
コード例 #2
0
 private void RefreshServers()
 {
     Application.Current.Dispatcher.BeginInvoke(() =>
     {
         ServerCollection.Clear();
         foreach (var server in _vtubeMonServerConnection.Servers)
         {
             ServerCollection.Add(new ServerViewModel(server));
         }
     });
 }
        // Creates a Dictionary of DGS Servers, using the server name as the key
        private static ServerCollection CreateServerItemList()
        {
            ServerCollection itemDic = new ServerCollection();

            // Get the Server Inventory as a ListItemCollection
            ListItemCollection list = GetServerListItems();

            // Itterate through each item in the list
            foreach (ListItem lItem in list)
            {
                try
                {
                    ServerItem serv = new ServerItem(lItem["Title"].ToString().ToLower());

                    // Get each user in the "Support Staff" field
                    var str = (FieldUserValue[])lItem.FieldValues[_supportStaffField];
                    // Add support staff if it exists
                    if (str != null)
                    {
                        foreach (FieldUserValue user in str)
                        {
                            serv.AddStaff(user.LookupValue);
                        }
                    }

                    // Set the simple text fields
                    serv.BusinessUnit = lItem[_businessUnitField] != null ? (string)lItem[_businessUnitField] : "";
                    serv.ServerType   = lItem[_serverTypeField] != null ? (string)lItem[_serverTypeField] : "";
                    serv.Environment  = lItem[_environmentField] != null ? (string)lItem[_environmentField] : "";

                    // Set the FieldNote value for Server Description
                    string description = lItem[_serverDescriptionField] != null ? lItem.FieldValuesAsText[_serverDescriptionField] : "";

                    // Remove non-ASCII characters from the string
                    description = description.Replace("\n", "");
                    description = Regex.Replace(description, @"[^\u0000-\u007F]", string.Empty);

                    serv.ServerDescription = description;

                    // Add server to the Dictionary
                    if (!itemDic.ContainsKey(serv.ServerName))
                    {
                        itemDic.Add(serv);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            return(itemDic);
        }
コード例 #4
0
        public void ReadConfig(Configuration config)
        {
            ServerCollection.Clear();
            foreach (var server in config.configs)
            {
                ServerCollection.Add(server);
            }
            if (config.index >= 0 && config.index < ServerCollection.Count)
            {
                SelectedServer = ServerCollection[config.index];
            }

            ServerCollection.CollectionChanged -= ServerCollection_CollectionChanged;
            ServerCollection.CollectionChanged += ServerCollection_CollectionChanged;
        }
コード例 #5
0
        public void Enviar()
        {
            ServerCollection  servers  = new ServerCollection();
            Server            Nlayer   = new Server();
            Message           message  = new Message();
            MimeBody          mimeBody = new MimeBody(BodyFormat.Html);
            AddressCollection destinos = new AddressCollection();

            Nlayer.Host     = "mail.softwareNlayer.com";
            Nlayer.Password = "******";
            Nlayer.Port     = 25;
            Nlayer.Username = "******";

            servers.Add(Nlayer);

            if (_destinos != null)
            {
                foreach (string destino in _destinos)
                {
                    destinos.Add(new Address(destino));
                }
            }

            if (_adjuntos != null)
            {
                foreach (string adjunto in _adjuntos)
                {
                    message.Attachments.Add(adjunto, false);
                }
            }

            mimeBody.Text = _mensaje;

            message.BodyHtml     = mimeBody;
            message.Date         = DateTime.Now;
            message.From         = new Address("*****@*****.**");
            message.Organization = "Nlayer Software";
            message.Priority     = MessagePriority.Normal;
            message.To           = destinos;
            message.Subject      = _asunto;

            AsyncCallback beginCallback = IniciaEnvio;

            SmtpClient.BeginSend(message, servers, beginCallback);
        }
コード例 #6
0
        public void ReadConfig(Configuration config)
        {
            ServerCollection.Clear();
            foreach (var server in config.configs)
            {
                var serverObject = ServerObject.CopyFromServer(server);

                serverObject.Enable       = server.enable;
                serverObject.Protocoldata = server.getProtocolData();
                serverObject.Obfsdata     = server.getObfsData();

                ServerCollection.Add(serverObject);
            }

            if (config.index >= 0 && config.index < ServerCollection.Count)
            {
                SelectedServer = ServerCollection[config.index];
            }
        }
コード例 #7
0
        //TODO: Create a "ConfigurationManager" so that process and server info can be queried and provided seperately.
        //This will remove the need to pass references to Process and Server configs to each object.

        /// <summary>
        /// Creates a server based on the supplied configuration data, and adds
        /// it to the Server Manager.
        /// </summary>
        public static void RegisterServer(ProcessConfigurationData processConfig, ServerConfigurationData serverConfig)
        {
            //TODO: Decide how best to determine which type of server to create.
            //For now, we will use the if/then approach.
            if (serverConfig.ServerType == ServerType.Game)
            {
                if (serverConfig.SubType == "HaloCombatEvolved")
                {
                    try
                    {
                        Server s = new GenericServer(processConfig, serverConfig);
                        servers.Add(s);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("Unable to create server object: " + ex.Message);
                    }
                }
                else
                {
                    throw new Exception("Unable to create server object: " + serverConfig.SubType + " is not a supported game server type.");
                }
            }
        }
コード例 #8
0
        public static void DetectServers(bool Inital = false)
        {
            var serverProcesses = Process.GetProcessesByName("h2Server");

            if (Inital)
            {
                MainThread.WriteLine($"Servers Detected:\t{serverProcesses.Length}");
                if (serverProcesses.Length > 0)
                {
                    ExecutionPath = serverProcesses[0].MainModule?.FileName.Replace("\\h2server.exe", "")
                                    .Replace("\\H2Server.exe", "");
                    MainThread.WriteLine($"Server Launch Path:\t{ExecutionPath}");
                    MainThread.WriteLine($"Server Playlist Folder:\t{PlaylistFolder}");
                }
            }
            else
            {
                for (var i = 0; i < Servers.Count; i++)
                {
                    if (Servers[i].ServerProcess.HasExited)
                    {
                        if (!Servers[i].AutoRestart)
                        {
                            MainThread.WriteLine($"{Servers[i].FormattedName} has closed detaching..");
                            Servers[i].KillConsoleProxy();
                            Servers.RemoveAt(i);
                        }
                        else
                        {
                            MainThread.WriteLine($"{Servers[i].FormattedName} has closed restarting service..");
                            var Service = new ServiceController(Servers[i].ServiceName);
                            if (Service.Status != ServiceControllerStatus.Stopped)
                            {
                                Service.Stop();
                                Servers[i].ServerProcess.Kill();
                            }
                            Service.Start();
                            Servers[i].KillConsoleProxy();
                            Servers.RemoveAt(i);
                        }
                    }
                }
            }
            for (var i = 0; i < serverProcesses.Length; i++)
            {
                if (!Servers.ServerCollected(serverProcesses[i]))
                {
                    MainThread.WriteLine($"Attaching To Server...");
                    var newServer = new ServerContainer(serverProcesses[i]);
                    newServer.Index = i;
                    if (newServer.isLive)
                    {
                        MainThread.WriteLine($"Attached to: {newServer.FormattedName}");
                        MainThread.WriteLine($"Service Name: {newServer.ServiceName}");
                        newServer.LaunchConsoleProxy();
                        Servers.Add(newServer);
                    }
                    else
                    {
                        MainThread.WriteLine(
                            $"Skipping LAN Server: {newServer.FormattedName}");
                    }
                }
            }
        }