示例#1
0
 public Setting(Config.Config config)
 {
     this.config = config;
     stores = new Stores(this);
     hosts = new Hosts(this);
     rules = new Rules(this);
 }
示例#2
0
        private void Initialize()
        {
            new List <ComboBox>()
            {
                cmbUploadRate, cmbUploadBurst, cmbDownloadRate, cmbDownloadBurst
            }.ForEach(x => x.DataSource = Enum.GetValues(typeof(BitByteUnit)));
            cmbUploadRate.SelectedItem = cmbUploadBurst.SelectedItem = cmbDownloadRate.SelectedItem = cmbDownloadBurst.SelectedItem = BitByteUnit.KBit;

            if (Hosts.All(x => x.Status != Host.HostStatus.Free))
            {
                if (Hosts.All(x => x.LimitRule.IsUploadLimited))
                {
                    tglUpload.Checked = true;

                    if (Hosts.All(x => Hosts.First().LimitRule.UploadRate == x.LimitRule.UploadRate))
                    {
                        var rate = NetworkUtilities.BreakDownBitRate(Hosts.First().LimitRule.UploadRate.Value, out BitByteUnit unit);

                        tbUploadRate.Text          = rate.ToString();
                        cmbUploadRate.SelectedItem = unit;
                    }

                    if (Hosts.First().LimitRule.UploadBurst != null && Hosts.All(x => Hosts.First().LimitRule.UploadBurst == x.LimitRule.UploadBurst))
                    {
                        var burst = NetworkUtilities.BreakDownBitRate(Hosts.First().LimitRule.UploadBurst.Value, out BitByteUnit unit);

                        tbUploadBurst.Text          = burst.ToString();
                        cmbUploadBurst.SelectedItem = unit;
                        cbUploadBurst.Checked       = true;
                    }
                }

                if (Hosts.All(x => x.LimitRule.IsDownloadLimited))
                {
                    tglDownload.Checked = true;

                    if (Hosts.All(x => Hosts.First().LimitRule.DownloadRate == x.LimitRule.DownloadRate))
                    {
                        var rate = NetworkUtilities.BreakDownBitRate(Hosts.First().LimitRule.DownloadRate.Value, out BitByteUnit unit);

                        tbDownloadRate.Text          = rate.ToString();
                        cmbDownloadRate.SelectedItem = unit;
                    }

                    if (Hosts.First().LimitRule.DownloadBurst != null && Hosts.All(x => Hosts.First().LimitRule.DownloadBurst == x.LimitRule.DownloadBurst))
                    {
                        var burst = NetworkUtilities.BreakDownBitRate(Hosts.First().LimitRule.DownloadBurst.Value, out BitByteUnit unit);

                        tbDownloadBurst.Text          = burst.ToString();
                        cmbDownloadBurst.SelectedItem = unit;
                        cbDownloadBurst.Checked       = true;
                    }
                }
            }
        }
示例#3
0
        public void AddHost(HostConnection host)
        {
            _hostStates.TryAdd(host.Id, new HostState(host));

            // This part of the code is not concurrent, but only ASP.NET uses concurrent calls, MVVM projects are not.
            // ASP.NET don't use ObservableCollections
            if (_useObservableCollections)
            {
                Hosts.Add(new ObservableHost(GetHostState(host.Id)));
            }
        }
示例#4
0
 public static async Task RespondAsync(DialogContext dc, RecognizerResult luisResults)
 {
     if (Hosts.TryGetHost(luisResults, out Host host))
     {
         await AdaptiveCardHelper.SendCardFromFileAsync(dc, host.GetVersionsFilePath());
     }
     else
     {
         await dc.Context.SendActivityAsync("Please specify which host you're curious about, like \"What version is supported in Outlook?\"");
     }
 }
        public THostViewModel AddHost(HostInfo host)
        {
            var hvm = new THostViewModel {
                Model = new Host(host, Config, PuttyProfile)
            };

            _addingNewHost = hvm;
            Hosts.AddNew();
            Hosts.EndNew(Hosts.Count - 1);
            return(hvm);
        }
示例#6
0
        public string ToYaml()
        {
            var graph = new Dictionary <string, object> {
                { ":pack_path", PackPath },
                { ":exclude", Exclude },
                { ":include", Include },
                { ":hosts", Hosts.Select(x => x.ToString()) }
            };

            return(SyncEvilGlobal.Yaml.ToYaml(graph));
        }
 /// <summary>
 /// Remove hosts that have been on the demoted list for more
 /// than 120,000 milliseconds and add them to the available hosts list.
 /// </summary>
 internal static void ReleaseDemotedHosts(object state)
 {
     while (!DemotedHosts.IsEmpty)
     {
         if (DemotedHosts.TryPeek(out FailoverServer demotedServer) &&
             demotedServer.DemotedTime.AddMilliseconds(DEMOTED_TIMEOUT) < DateTime.Now)
         {
             demotedServer.Attempted = false;
             Hosts?.Add(demotedServer);
             DemotedHosts.TryDequeue(out demotedServer);
         }
        public string Create(Hosts model)
        {
            using (ISession session = NHibernateHelper.GetCurrentSession())
            {
                ITransaction tx = session.BeginTransaction();

                string newId = (string)session.Save(model);
                tx.Commit();
                NHibernateHelper.CloseSession();
                return(newId);
            }
        }
示例#9
0
        public Worker(string serverURL)
        {
            _serverURL = serverURL;

            _host = new Hosts
            {
                Name          = Environment.MachineName,
                NumCores      = Environment.ProcessorCount,
                WorkerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                OSVersion     = Environment.OSVersion.VersionString
            };
        }
示例#10
0
        public FrmMain()
        {
            InitializeComponent();


            var result = Hosts.ListHostsFile();

            if (result != null)
            {
                //listBox1.Items.AddRange(result.Lines);
            }
        }
示例#11
0
        private async Task <bool> InnerBroadcast(Opcode opcode, Stream stream)
        {
            var tasks =
                Hosts.TakeWhile(host => _state == ServerState.Start)
                .AsParallel()
                .Select(host => host.Sessions.InnerBroadcast(opcode, stream))
                .ToArray();

            await Task.WhenAll(tasks).ConfigureAwait(false);

            return(tasks.All(x => x.Result));
        }
示例#12
0
        public MDnsServer(params IPEndPoint[] hosts)
            : base(hosts)
        {
            var localEndPoint = new[] { EndPoint };

            if (Hosts == null)
            {
                Hosts = new[] { new IPEndPoint(IPAddress.Any, 0) }
            }
            ;
            Hosts = Hosts.Union(localEndPoint).ToArray();
        }
        public override void Run()
        {
            using (var webConfig = new WebConfig())
            {
                if (Config.EnvironmentType() == EnvironmentType.VHD)
                {
                    if (!String.IsNullOrEmpty(Config.AADTenantId()))
                    {
                        webConfig.UpdateXElement("Aad.AADTenantId", Config.AADTenantId());
                    }

                    if (!String.IsNullOrEmpty(Config.AzureStorageConnectionString()))
                    {
                        webConfig.UpdateXElement("AzureStorage.StorageConnectionString", Config.AzureStorageConnectionString());
                    }

                    webConfig.UpdateXElement("Infrastructure.FullyQualifiedDomainName", Config.ScaleUnitDomain());
                    webConfig.UpdateXElement("Infrastructure.HostName", Config.ScaleUnitDomain());
                    webConfig.UpdateXElement("Infrastructure.HostedServiceName", Config.ScaleUnitUrlName());

                    string scaleUnitUrl = Config.ScaleUnitAosEndpoint() + "/";
                    webConfig.UpdateXElement("Infrastructure.HostUrl", scaleUnitUrl);
                    webConfig.UpdateXElement("Infrastructure.SoapServicesUrl", scaleUnitUrl);
                }

                webConfig.AddKey("ScaleUnit.InstanceID", Config.ScaleUnitId());
                webConfig.AddKey("ScaleUnit.Enabled", "true");
                webConfig.AddKey("DbSync.TriggersEnabled", "true");
            }

            WifServiceConfig.Update();

            if (Config.EnvironmentType() == EnvironmentType.VHD)
            {
                // Update hosts file
                using (var hosts = new Hosts())
                {
                    hosts.AddMapping("127.0.0.1", Config.ScaleUnitDomain());
                    hosts.AddMapping(Config.HubIp(), Config.HubDomain());
                }

                // Configure IIS binding
                using (ServerManager manager = new ServerManager())
                {
                    Site site = manager.Sites["AOSService"];
                    site.Bindings.Clear();
                    site.Bindings.Add("*:443:" + Config.ScaleUnitDomain(), "https");

                    manager.CommitChanges();
                }
            }
        }
示例#14
0
        static void Main(string[] args)
        {
            var hosts = new Hosts().Discover();

            var docker = hosts.FirstOrDefault(x => x.IsNative) ?? hosts.FirstOrDefault(x => x.Name == "default");

            Console.WriteLine($"Docker host: {docker?.Host.Host}, {docker?.Host.AbsolutePath}, {docker?.Host.AbsoluteUri}");

            var containers = docker?.GetContainers();

            Console.WriteLine(docker?.Host.Host);
            Console.WriteLine($"Number of containers: {containers?.Count}");
        }
示例#15
0
        private void HostsDataGrid_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGrid datagrid = sender as DataGrid;
            var      cell     = datagrid.CurrentCell;
            var      item     = cell.Item as HostsData;

            if (item != null && cell.Column.DisplayIndex == 2)
            {
                item.State = item.State == "激活" ? "失效" : "激活";
                var hostsTxt = (item.State == "激活" ? "" : "#") + item.Ip + " " + item.Domain;
                Hosts.updateHosts(hostsTxt);
            }
        }
示例#16
0
 void LoadHostProfiles()
 {
     Hosts.Load();
     cbxHost.ItemsSource = Hosts.Profile;
     for (int i = 0; i < Hosts.Profile.Count; i++)
     {
         if (Hosts.Profile[i].Default)
         {
             cbxHost.SelectedValue = Hosts.Profile[i];
             break;
         }
     }
 }
 private void WindowLoaded(object sender, RoutedEventArgs e)
 {
     try
     {
         this.records = Hosts.GetRecords().ToList();
         this.HostsList.DataContext = this.records;
     }
     catch (Exception ex)
     {
         WindowHelper.HandleError("The exception occurred during window initialization - it will be closed then.", true, ex);
         this.Close();
     }
 }
示例#18
0
文件: Board.cs 项目: heyx3/FiaCR
 /// <summary>
 /// Removes the given piece/host at the given position.
 /// </summary>
 /// <param name="isHost">
 /// If true, will remove the host at the position.
 /// Otherwise, will remove the piece at the position.
 /// </param>
 public void RemoveElement(bool isHost, Vector2i pos)
 {
     if (isHost)
     {
         Destroy(Hosts.Get(pos).gameObject);
         Hosts.Set(pos, null);
     }
     else
     {
         Destroy(Pieces.Get(pos).gameObject);
         Pieces.Set(pos, null);
     }
 }
示例#19
0
        /// <summary>
        /// Updates the Class C grid Hosts
        /// TODO: move into view
        /// </summary>
        public void UpdateClassCDummies()
        {
            //get all known Hosts of the current range
            var start = CurrentClassCNetwork.ToLong();
            var hosts = Hosts.Where(w => w.IP >= start && w.IP <= start + 255);

            //assign them to the grid
            foreach (var h in hosts)
            {
                ClassCDummies[h.IP - start].Host = h;
            }
            OnPropertyChanged("HostsOnline");
        }
示例#20
0
        public void ListHostsFile()
        {
            var result = Hosts.ListHostsFile();

            if (result == null)
            {
                return;
            }

            foreach (var line in result.Result.Lines)
            {
                Debug.WriteLine(line);
            }
        }
示例#21
0
        public override void OnClientConnect(Client Client)
        {
            Client.AutoFlush             = true;
            Client.Socket.ReceiveTimeout = 15000;

            while (Client.Connected)
            {
                Packet  Packet  = new Net.Http.Packet();
                Request Request = new Request(Client, Packet);

                if (!Packet.Receive(Client))
                {
                    Client.Close();
                    break;
                }

                Request.Host = Hosts.Search <Host>(Packet.Host, true, true);

                if (Request.Host == null)
                {
                    Request.Result = Result.BadRequest;
                    Request.Finish();
                    continue;
                }
                else if (!Request.Host.Ports.IsEmpty)
                {
                    IPEndPoint Point = Client.Socket.LocalEndPoint as IPEndPoint;

                    if (!Request.Host.Ports.ContainsValue(Point.Port))
                    {
                        Request.Result = Result.BadRequest;
                        Request.Finish();
                        continue;
                    }
                }

                if (Request.Host.SessionsEnabled)
                {
                    Request.Session = Session.GetSession(this, Request, Request.Host);
                }

                try {
                    OnClientRequest(Request);
                }
                catch {
                    Client.Close();
                    break;
                }
            }
        }
        public Task Run()
        {
            ScaleUnitInstance scaleUnit = Config.FindScaleUnitWithId(ScaleUnitContext.GetScaleUnitId());

            if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
            {
                // Update hosts file
                using (var hosts = new Hosts())
                {
                    hosts.AddMapping(scaleUnit.IpAddress, scaleUnit.DomainSafe());
                    hosts.AddMapping(Config.HubScaleUnit().IpAddress, Config.HubScaleUnit().DomainSafe());
                }

                IISAdministrationHelper.CreateSite(
                    siteName: scaleUnit.SiteName(),
                    siteRoot: scaleUnit.SiteRoot(),
                    bindingInformation: scaleUnit.IpAddress + ":443:" + scaleUnit.DomainSafe(),
                    certSubject: scaleUnit.DomainSafe(),
                    appPoolName: scaleUnit.AppPoolName());
            }

            using (var webConfig = new WebConfig())
            {
                SharedWebConfig.Configure(webConfig);

                if (scaleUnit.EnvironmentType == EnvironmentType.VHD || Config.UseSingleOneBox())
                {
                    webConfig.UpdateXElement("Infrastructure.FullyQualifiedDomainName", scaleUnit.DomainSafe());
                    webConfig.UpdateXElement("Infrastructure.HostName", scaleUnit.DomainSafe());
                    webConfig.UpdateXElement("Infrastructure.HostedServiceName", scaleUnit.ScaleUnitUrlName());

                    string scaleUnitUrl = scaleUnit.Endpoint() + "/";
                    webConfig.UpdateXElement("Infrastructure.HostUrl", scaleUnitUrl);
                    webConfig.UpdateXElement("Infrastructure.SoapServicesUrl", scaleUnitUrl);

                    webConfig.UpdateXElement("DataAccess.Database", scaleUnit.AxDbName);

                    webConfig.AddValidAudiences(scaleUnit);
                }
            }

            WifServiceConfig.Update();

            if (Config.UseSingleOneBox())
            {
                CreateScaleUnitBatchService(scaleUnit);
            }

            return(Task.CompletedTask);
        }
        private void _fillHosts()
        {
            if (string.IsNullOrWhiteSpace(Hosts))
            {
                _ListHosts             = new List <string>();
                _ListHostsWithAsteriks = new List <string>();
                return;
            }
            var all = Hosts.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)
                      .Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => i.Trim());

            _ListHosts             = all.Where(i => i.IndexOf("*") < 0).ToList();
            _ListHostsWithAsteriks = all.Where(i => i.IndexOf("*") == 0).Select(i => i.TrimStart(new[] { '*' })).ToList();
        }
示例#24
0
        /// <summary>
        /// Trata a operação de Remover Host
        /// </summary>
        private void removerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (Hosts.Count > 0)
            {
                if (!ValidaHostSelecionado())
                {
                    return;
                }

                Hosts.Remove(SelectedHost);
            }
            hostList_UpdateStatusBar(null, null);
            hostList.Focus();
        }
示例#25
0
 protected override void Process(ImportArgs args)
 {
     if (args._Bindings.Count == 0)
     {
         Hosts.Append(args._SiteName);
     }
     else
     {
         foreach (string hostname in args._Bindings.Keys)
         {
             Hosts.Append(hostname);
         }
     }
 }
        public bool IsValidDnsSrv()
        {
            if (Scheme != Scheme.Couchbase && Scheme != Scheme.Couchbases)
            {
                return(false);
            }

            if (Hosts.Count > 1)
            {
                return(false);
            }

            return(Hosts.Single().Port == null);
        }
示例#27
0
 public MainWindow()
 {
     host = new Hosts();
     if (host.CheckDataFile())
     {
         InitializeComponent();
         Properties.Settings.Default.FolderPath = null;
         refreshCombo();
     }
     else
     {
         Application.Current.Shutdown();
     }
 }
示例#28
0
        private void BtnAdicionarHost_Click(object sender, EventArgs e)
        {
            int host = Convert.ToInt32(nudHosts.Value);

            if (host >= 0)
            {
                DAOClassesdeRede.AddListaRedes(host);
                Hosts aux = DAOClassesdeRede.ListaHosts[DAOClassesdeRede.ListaHosts.Count - 1];
                dataGridView1.Rows.Add(aux.Host, aux.Mais2, aux.ProximaPotencia);
            }
            else
            {
                Mostrar.ErroNoHosts();
            }
        }
示例#29
0
        public virtual void Unsubscribe(Type contractType, string operation)
        {
            Debug.Assert(String.IsNullOrEmpty(operation) == false);

            if (Hosts.ContainsKey(contractType) == false)
            {
                return;
            }
            if (Hosts[contractType][operation] != null)
            {
                Hosts[contractType][operation].Close();
                Hosts[contractType].Remove(operation);
                Hosts[contractType][operation] = null;
            }
        }
        // Children of host in parameter. Ordered from parent to child (A <= B <= C, - C depends on B etc).
        public List <THostViewModel> DependentHosts(THostViewModel host, bool deep)
        {
            var result   = new List <THostViewModel>();
            var thisTier = Hosts.Cast <ObjectView <THostViewModel> >().Where(m => m.Object.Model.Info.DependsOn == host.Model.Info).Select(h => h.Object).ToList();

            result.AddRange(thisTier);
            if (deep)
            {
                foreach (var htt in thisTier)
                {
                    result.AddRange(DependentHosts(htt, true));
                }
            }
            return(result);
        }
示例#31
0
 public void AddHost(Host host)
 {
     if (host is null)
     {
         throw new ArgumentNullException(nameof(host));
     }
     else
     {
         decimal maxhost = Math.Ceiling((decimal)Route.Distance / _perkmforhost);
         if (Hosts.Count < maxhost)
         {
             Hosts.Add(host);
         }
     }
 }
示例#32
0
        public ActionResult Send(MailingModel model)
        {
            if (AuthContext.CurrentContext.CurrentUser == null)
                return View("Login");

            if (!ModelState.IsValid)
                return View("Index", model);

            var recipients = new List<Recipient>();

            if (model.To == "base" || model.To == "todos")
                using (var session = PersistenceHelper.OpenSession())
                    recipients = new RecipientRepository(session).GetActive().ToList();
            else
                model.To.Replace(",", ";").Replace(" ", "").Split(';').ToList().ForEach(
                        r => recipients.Add(new Recipient {IsActive = true, Email = r, Name = r, CreatedAt = DateTime.Now, Id = 0}));

            var hosts = new Hosts();
            var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
            var sender = new NewsSenderManager(hosts.Load(path));

            sender.ProcessQueue(model.Body, model.Subject, recipients);
            return View("Index", new MailingModel { SendReturn = "enviado com sucesso." });
        }
示例#33
0
文件: Objects.cs 项目: sladen/openbve
 /// <summary>Called when the plugin is loaded.</summary>
 /// <param name="host">The host that loaded the plugin.</param>
 public virtual void Load(Hosts.HostInterface host)
 {
 }
示例#34
0
 static void SendOne()
 {
     var hosts = new Hosts();
     var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
     var newsSender = new NewsSenderManager(hosts.Load(path));
     newsSender.ProcessQueue("Testando envio", "Testando envio", new List<Recipient>(new[] { new Recipient { Email = "*****@*****.**", Name = "chalk" } }));
     Console.WriteLine("Sent Test");
     Console.Read();
 }
示例#35
0
 static void TestAll()
 {
     var hosts = new Hosts();
     var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
     var newsSender = new NewsSenderManager(hosts.Load(path));
     newsSender.TestAllHosts(new Recipient {Email = "*****@*****.**", Name = "chalk"});
     Console.WriteLine("Sent Test");
     Console.Read();
 }
示例#36
0
 void HostsManager_UpdatedTemplates(object sender, Hosts.HostEventArgs e)
 {
     itemViewControl_.UpdateTemplates();
 }
示例#37
0
 public NewsSenderManager(Hosts hosts)
 {
     _smtpMailHosts = new Dictionary<Host, SMTPClient>();
     hosts.HostList.ForEach(h => _smtpMailHosts.Add(h,
         new SMTPClient(h.HostName, new NetworkCredential(h.User, h.Pass))));
 }
示例#38
0
        public ActionResult Test(string q)
        {
            if (AuthContext.CurrentContext.CurrentUser == null)
                return View("Login");

            var hosts = new Hosts();
            var path = AppDomain.CurrentDomain.BaseDirectory + "MailHosts.xml";
            var sender = new NewsSenderManager(hosts.Load(path));
            sender.TestAllHosts(new Recipient{Name = q, Email = q});

            return View("Index", new MailingModel { SendReturn = "Um e-mail de teste foi enviado usando cada um dos SMTPs configurados." });
        }
示例#39
0
 void HostsManager_UpdatedMediafiles(object sender, Hosts.HostEventArgs e)
 {
     itemViewControl_.UpdateMediafiles();
 }