Exemplo n.º 1
0
 private void ScanForServer()
 {
     //Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         IsScanForServerEnabled = false;
         IsProgressBarVisible   = true;
         List <string> servers = WCFProxy.DiscoverHosts();
         ExecuteOnUIThread.Invoke(() =>
         {
             Servers.Clear();
             if (servers == null || !servers.Any())
             {
                 Servers.Add("No server found");
             }
             else
             {
                 foreach (string s in servers)
                 {
                     Servers.Add(s);
                 }
             }
         });
     }
     catch
     {
         ExecuteOnUIThread.Invoke(() => Servers.Add("Error while scanning"));
     }
     finally
     {
         IsProgressBarVisible   = false;
         IsScanForServerEnabled = true;
         //Mouse.OverrideCursor = null;
     }
 }
Exemplo n.º 2
0
 public void UpdateFileModel()
 {
     ReadFromFile();
     Servers.Clear();
     PrepareServerList();
     CreateAvailableMap();
 }
Exemplo n.º 3
0
        public async Task ExecuteGetServersCommand()
        {
            Servers.Clear();

            var entities = await cache.GetAllObjects <Model.Entity.Server>();

#if DEBUG
            if (!entities.Any())
            {
                var data = InitialData.GetServers();

                foreach (var item in data)
                {
                    await cache.InsertObject(item.ToString(), item);
                }

                settings.SevendaysSelectedServer = data.First().ToString();

                entities = await cache.GetAllObjects <Model.Entity.Server>();
            }
#endif

            var servers = entities.Select(x => new ServerViewModel(x)).ToList();

            logger.Track(string.Format("Loaded {0} servers from cache", servers.Count));

            Servers = new ObservableCollection <ServerViewModel>(servers);
        }
Exemplo n.º 4
0
        public void Populate(int serverCount, string[] serverNames, int[] serverIds, int selectedServerId)
        {
            _serverCount      = serverCount;
            _serverNames      = serverNames;
            _serverIds        = serverIds;
            _selectedServerId = selectedServerId;

            // Disable so we can select the new selected server without triggering a new sync request.
            Servers.OnItemSelected   -= OnItemSelected;
            Servers.OnItemDeselected -= OnItemDeselected;

            Servers.Clear();
            for (var i = 0; i < _serverCount; i++)
            {
                var id = _serverIds[i];
                Servers.AddItem(Loc.GetString("research-client-server-selection-menu-server-entry-text", ("id", id), ("serverName", _serverNames[i])));
                if (id == _selectedServerId)
                {
                    Servers[id].Selected = true;
                }
            }

            Servers.OnItemSelected   += OnItemSelected;
            Servers.OnItemDeselected += OnItemDeselected;
        }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Servers.Clear();
                var items = ServerApi.GetServers();
                foreach (var item in items)
                {
                    Servers.Add(item);
                    Debug.WriteLine("Add item " + item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                service.SetServerList(Servers);
                IsBusy = false;
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// clear servers
 /// </summary>
 public void Clear()
 {
     lock (_lck)
     {
         Servers.Clear();
     }
 }
        public void LoadServers()
        {
            var servers = new ObservableCollection <IServer>();

            if (_existingServers != null)
            {
                servers = _existingServers;
            }
            else
            {
                var serverConnections = ServerRepository.Instance.All();
                if (serverConnections != null)
                {
                    servers.AddRange(serverConnections);
                }
            }

            if (Servers == null)
            {
                Servers = new ObservableCollection <IServer>();
            }
            RemoveServerDisconnect();
            Servers.Clear();
            Servers.AddRange(servers);
            SetupServerDisconnect();
            if (_selectedId != null && _selectedId != Guid.Empty)
            {
                var selectConnection = Servers.FirstOrDefault(server => server.EnvironmentID == _selectedId);
                SelectedConnection = null;
                SelectedConnection = selectConnection;
            }
        }
Exemplo n.º 8
0
 private void OnUpdateServersCommandExecuted()
 {
     Servers.Clear();
     foreach (var server in _ServersData.GetAll())
     {
         Servers.Add(server);
     }
 }
Exemplo n.º 9
0
 private void _ServersUpdated()
 {
     Servers.Clear();
     foreach (var item in Controller.GetServers(null))
     {
         Servers.Add(item);
     }
 }
Exemplo n.º 10
0
        protected override void OnLoadedExecute(object obj)
        {
            Servers.Clear();

            BroadcastClient.ServersChanged -= BroadcastClient_ServersChanged;
            BroadcastClient.ServersChanged += BroadcastClient_ServersChanged;

            Task.Factory.StartNew(() => {
                BroadcastClient.Run(null);
            });
        }
Exemplo n.º 11
0
 /// <summary>
 /// Closes all server connections used by the <see cref="BenCmdMainServer.MainServer"/> object.
 /// </summary>
 /// <remarks>
 /// Call <see cref="Dispose"/> when you are finished using the <see cref="BenCmdMainServer.MainServer"/>. The
 /// <see cref="Dispose"/> method leaves the <see cref="BenCmdMainServer.MainServer"/> in an unusable state. After
 /// calling <see cref="Dispose"/>, you must release all references to the <see cref="BenCmdMainServer.MainServer"/> so
 /// the garbage collector can reclaim the memory that the <see cref="BenCmdMainServer.MainServer"/> was occupying.
 /// </remarks>
 public void Dispose()
 {
     if (!_disposed)
     {
         listen.Stop();                 // Stop listening for new connections
         foreach (BenCmdServer s in Servers)
         {
             s.Close();                     // Close existing connections
         }
         Servers.Clear();
         _disposed = true;
     }
 }
Exemplo n.º 12
0
 public SimulationOhneUmgebung(Umgebung umgebung, Warteschlange warteschlange, List <Server> servers) : base(umgebung)
 {
     SetWarteschlange(new Warteschlange {
         Erwartungswert = warteschlange.Erwartungswert
     });
     Servers.Clear();
     foreach (var server in servers)
     {
         AddServer(new Server {
             Erwartungswert = server.Erwartungswert
         });
     }
 }
Exemplo n.º 13
0
        private void GatewaySocket_PacketReceived(Packet packet)
        {
            switch ((OpCodes.GatewayServer)packet.Opcode)
            {
                #region OpCodes.GatewayServer.ServerList
            case OpCodes.GatewayServer.ServerList:
                Servers.Clear();
                while (packet.ReadByte() != 0)
                {
                    packet.ReadByte();    //server ID
                    packet.ReadAscii();   //Server Name
                }

                while (packet.ReadByte() == 1)
                {
                    var serverId        = packet.ReadShort();
                    var serverName      = packet.ReadAscii();
                    var currentCapacity = packet.ReadShort();
                    var maxCapacity     = packet.ReadShort();
                    var status          = packet.ReadByte();
                    Servers.Add(new ServerList(serverId, serverName, currentCapacity, maxCapacity, status));
                }
                break;
                #endregion

                #region OpCodes.GatewayServer.LoginReply
            case OpCodes.GatewayServer.LoginReply:
                if (packet.ReadByte() == 1)
                {
                    var sessionId = packet.ReadUInt();
                    _agentServerIp        = packet.ReadAscii();
                    _agentServerPort      = packet.ReadUShort();
                    _doAgentServerConnect = true;

                    var response = new Packet((ushort)OpCodes.GatewayServer.LoginReply, true);
                    response.WriteByte(1);
                    response.WriteUInt(sessionId);
                    response.WriteAscii("127.0.0.1");
                    response.WriteUShort(_mLocalPort);
                    packet = response;
                    packet.Lock();
                }
                break;
                #endregion
            }
            if (InvokeMethodWithSkip(GatewayPacketReceived, packet))
            {
                return;                                                      //Skip
            }
            SendFromServer(packet);
        }
Exemplo n.º 14
0
 private void GetStatus(List <Server> servers)
 {
     Dispatcher.Invoke(() => Servers.Clear());
     PlayerCount = 0;
     Task.Run(() =>
     {
         foreach (Server server in servers)
         {
             _udp.Send(MessageFactory.GetStatus, MessageFactory.GetStatus.Length,
                       new IPEndPoint(IPAddress.Parse(server.IP), Int32.Parse(server.Port)));
             Thread.Sleep(1);
         }
     });
 }
Exemplo n.º 15
0
        private void FindServers()
        {
            Server s = GetServer();

            if (s == null)
            {
                return;
            }

            Servers.Clear();
            foreach (var item in Controller.GetServers(s))
            {
                Servers.Add(item);
            }
        }
Exemplo n.º 16
0
        public void CreateMapFromDistributor(List <Tuple <ServerId, string, string> > servers)
        {
            Map.Clear();
            Servers.Clear();
            AvailableMap.Clear();

            Map = new List <HashMapRecord>(servers.Select(x =>
                                                          new HashMapRecord(x.Item2, x.Item3)
            {
                Save = new SavedServerId(x.Item1.RemoteHost, x.Item1.Port, x.Item1.Port)
            }
                                                          ));

            PrepareServerList();
            CreateAvailableMap();
        }
Exemplo n.º 17
0
        private Task RefreshServersAsync()
        {
            IsServersRefreshing = true;

            Servers.Clear();

            return(TaskHelper.RunAndWaitAsync(() =>
            {
                var servers = _connectionStringBuilderService.GetDataSources(ConnectionString);
                Servers.AddItems(servers);

                IsServersRefreshing = false;
                _isServersInitialized = true;
                IsServerListVisible = true;
            }));
        }
Exemplo n.º 18
0
        private void LoadConfig()
        {
            try
            {
                Servers.Clear();
                Servers.AddRange(GetAvailabilityGroupList(xml_config, "Servers", "Server", "ServerId"));

                Proxies.Clear();
                Proxies.AddRange(GetAvailabilityGroupList(xml_config, "Proxies", "Proxy", "ProxyId"));
            }
            catch (Exception e)
            {
                Log.WriteLine(LogLevel.Error, "There are errors in your configuration file.");
                Log.WriteLine(e.Message);
                Global.Exit();
            }
        }
Exemplo n.º 19
0
 private void LoadServersAsync()
 {
     ServersLoading = true;
     Servers.Clear();
     //  DataTable dataSources = SqlDataSourceEnumerator.Instance.GetDataSources();
     Task <DataTable> .Factory.StartNew(SmoApplication.EnumAvailableSqlServers).ContinueWith(t1 =>
     {
         if (t1.Result.Rows.Count > 0)
         {
             foreach (DataRow dr in t1.Result.Rows)
             {
                 Servers.Add(dr["Name"].ToString());
             }
         }
         ServersLoading = false;
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
Exemplo n.º 20
0
 public void LBA_Select(int i)
 {
     if (i < 0)
     {
         return;
     }
     mnfAvatar = new MnfAvatar(Avatars[i]);
     Console.WriteLine("Selected avatar " + mnfAvatar.JmenoPostavy);
     AvatarsSelected = i;
     if (VyberAvatara())
     {
         NactiServery();
     }
     else
     {
         Servers.Clear();
     }
 }
Exemplo n.º 21
0
 /// <summary>
 /// Aktivuje avatar a nacte servery
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void LBA_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
 {
     if (LBA.SelectedIndex < 0)
     {
         return;
     }
     mnfAvatar = new MnfAvatar(Avatars[LBA.SelectedIndex]);
     Console.WriteLine("Selected avatar " + mnfAvatar.JmenoPostavy);
     AvatarsSelected = LBA.SelectedIndex;
     if (VyberAvatara())
     {
         NactiServery();
     }
     else
     {
         Servers.Clear();
     }
 }
Exemplo n.º 22
0
        public void CreateMap()
        {
            Map.Clear();
            Servers.Clear();
            AvailableMap.Clear();

            switch (_configuration.Mode)
            {
            case HashMapCreationMode.CreateNew:
                CreateNewMap();
                CreateNewFile();
                PrepareServerList();
                break;

            case HashMapCreationMode.ReadFromFile:
                ReadFromFile();
                PrepareServerList();
                CreateAvailableMap();
                break;
            }
        }
Exemplo n.º 23
0
        public void NactiServery()
        {
            try
            {
                string s;
                ////Zisk Serveru
                var data = new NameValueCollection();
                data["color"]     = mnfAvatar.userCT;
                data["avatar_id"] = mnfAvatar.AvatarID.ToString();
                data["pass"]      = mnfUzivatel.LoginPaswCrypted;
                data["user_id"]   = mnfUzivatel.UserID.ToString();
                Console.WriteLine("read servers");
                var response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteServer, "POST", data);

                s = Encoding.UTF8.GetString(response, 0, response.Length);
                string[] ss = s.Replace("<server ", ";").Split(';');
                Servers.Clear();
                for (int i = 1; i < ss.Length; i++)
                {
                    Server ms = new Server();
                    if (ms.ParseServer(ss[i]))
                    {
                        MessageBox.Show("Bad response\n" + s);
                    }
                    Servers.Add(ms);
                    Console.WriteLine("Server add " + ms.JmenoServeru);

                    /*
                     * foreach (MnfServer a in ms)
                     * {
                     * if (a.Kapacita == 0) lb.Items.Add(a.Jmeno + " 0%");
                     * else lb.Items.Add(a.Jmeno + " " + ((a.PocetMuzu + a.PocetZen) * 100.0 / a.Kapacita).ToString("0.0") + "%");
                     * }
                     */
                }
                response = wc.UploadValues(MnfAddress.SiteMain() + MnfAddress.SiteServer, "POST", data);
            }
            catch (Exception e) { Console.WriteLine("Nepovedlo se nacist servery"); Console.WriteLine(e); }
        }
Exemplo n.º 24
0
        /// <summary>
        /// Loads the available servers from the server provider
        /// </summary>
        private void LoadServers()
        {
            List <IEnvironmentModel> servers = _serverProvider.Load();

            Servers.Clear();

            foreach (var server in servers)
            {
                Servers.Add(server);
            }

            if (servers.Count > 0)
            {
                //
                // Find a source server to select
                //
                SelectedSourceServer = servers.FirstOrDefault(s => ServerEqualityComparer.Current.Equals(s, SelectedSourceServer));

                if (SelectedSourceServer == null)
                {
                    SelectSourceServerFromInitialValue();
                }
            }
        }
Exemplo n.º 25
0
 private void UpdateServers(ICollection <SwaggerSchema> schemes, string host, string basePath)
 {
     if ((schemes == null || schemes.Count == 0) && (!string.IsNullOrEmpty(host) || !string.IsNullOrEmpty(basePath)))
     {
         Servers = new List <OpenApiServer>
         {
             new OpenApiServer
             {
                 Url = host + basePath
             }
         };
     }
     else if (!string.IsNullOrEmpty(host))
     {
         Servers = schemes?.Select(s => new OpenApiServer
         {
             Url = s.ToString().ToLowerInvariant() + "://" + host + basePath
         }).ToList() ?? new List <OpenApiServer>();
     }
     else
     {
         Servers.Clear();
     }
 }
Exemplo n.º 26
0
 private async void OnNavigationToServersView(IToServersView toServersView)
 {
     Servers.Clear();
     await OnNavigationToServersViewAsync(toServersView);
 }
Exemplo n.º 27
0
        public async Task Cluster_identity_should_work_with_smuggler()
        {
            const int    clusterSize  = 3;
            const string databaseName = "Cluster_identity_for_single_document_should_work";
            var          leaderServer = await CreateRaftClusterAndGetLeader(clusterSize);

            using (var leaderStore = new DocumentStore
            {
                Urls = new[] { leaderServer.WebUrl },
                Database = databaseName
            })
            {
                leaderStore.Initialize();

                await CreateDatabasesInCluster(clusterSize, databaseName, leaderStore);

                using (var session = leaderStore.OpenSession())
                {
                    session.Store(new User {
                        Name = "John Dow"
                    }, "users|");
                    session.Store(new User {
                        Name = "Jake Dow"
                    }, "users|");
                    session.Store(new User {
                        Name = "Jessie Dow"
                    }, "users|");
                    session.SaveChanges();
                }

                WaitForIdentity(leaderStore, "users", 3);

                var operation = await leaderStore.Smuggler.ExportAsync(new DatabaseSmugglerExportOptions(), _fileName);

                await operation.WaitForCompletionAsync(TimeSpan.FromMinutes(1));
            }

            foreach (var server in Servers)
            {
                server.Dispose();
            }
            Servers.Clear();

            leaderServer = await CreateRaftClusterAndGetLeader(clusterSize);

            using (var leaderStore = new DocumentStore
            {
                Urls = new[] { leaderServer.WebUrl },
                Database = databaseName
            })
            {
                leaderStore.Initialize();

                await CreateDatabasesInCluster(clusterSize, databaseName, leaderStore);

                var operation = await leaderStore.Smuggler.ImportAsync(new DatabaseSmugglerImportOptions(), _fileName);

                await operation.WaitForCompletionAsync(TimeSpan.FromMinutes(1));

                using (var session = leaderStore.OpenSession())
                {
                    session.Store(new User {
                        Name = "Julie Dow"
                    }, "users|");
                    session.SaveChanges();
                }

                using (var session = leaderStore.OpenSession())
                {
                    var julieDow = session.Query <User>().First(u => u.Name.StartsWith("Julie"));
                    Assert.Equal("users/4", julieDow.Id);
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Прослушивает поток, на наличие сообщений от сервера
        /// Прежде чем добавить какой-нибудь объект в swich подумай 10 раз!
        /// Т.к. создатель этого метода не шибко умный, тебе придется либо увеличивать switch
        /// Либо писать огромный метод, который будет все это обрабатывать, что тоже не оч. верно
        /// </summary>
        private void TakeMessageOfServer()
        {
            Object ob = null;

            do
            {
                try
                {
                    ob = SendMessageToServer.TakeMessageSerialize();
                }
                catch (Exception)
                {
                    break;
                }

                switch (ob)
                {
                /// Получаем сообщения и отправляем их на текстовые чаты
                case Message message:
                    var text = TextChats.Find(x => x.ID == message.IDTextChat);
                    text.Message.Add(message);

                    //// выполняются полиморфные вызовы
                    EventUpMessage((IEnumerable <Message>)text.Message);
                    break;

                /// Получаем пользователя и меняем его статус на сервере
                case ServerUser user:
                    if (user.StatusObj == StatusObj.Add)
                    {
                        User.ServerUser.Add(user);

                        var server = user.Server;
                        Servers.Add(server);

                        EventUpServer?.Invoke(Servers);

                        EventUpServersFromUser?.Invoke(Servers);

                        break;
                    }
                    else if (user.StatusObj == StatusObj.Delete)
                    {
                        User.ServerUser = User.ServerUser.Where(x => user.ID != x.ID).ToList();

                        var server = user.Server;
                        var asd    = Servers.Where(x => server.ID != x.ID).ToList();
                        Servers.Clear();
                        foreach (var item in asd)
                        {
                            Servers.Add(item);
                        }

                        EventUpServer?.Invoke(Servers);

                        EventUpServersFromUser?.Invoke(Servers);

                        break;
                    }

                    if (Users is null)
                    {
                        break;
                    }

                    var a = Users.FirstOrDefault(x => x.IDUser == user.IDUser);
                    if (a is null)
                    {
                        break;
                    }

                    EventUpUserStatus(Users);
                    break;

                /// Получаем пользователей на сервере запоминаем и отправляем в окно редактирования, если оно открыто
                case (List <ServerUser> SU):
                    if (SU is null)
                    {
                        break;
                    }

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(SU);
                        return;
                    }
                    if (WFAU is not null)
                    {
                        EventUpFriendsAndUsers?.Invoke(SU);
                        return;
                    }

                    Users = SU;
                    EventUpUserStatus?.Invoke(SU);

                    break;

                /// получаем список серверов у пользователя или в окне поиска (TODO)
                case (List <Server> Servers):
                    if (Servers is null || Servers.Count() == 0)
                    {
                        break;
                    }

                    EventUpServerSearch(Servers);
                    break;

                /// получаем сервер, если он обновился и отправляем в окно редактирования, если оно открыто
                case (Server Server):
                    if (Server is null)
                    {
                        break;
                    }

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(Server);
                    }

                    break;

                /// получаем текстовые чаты и отправляем их в окно редактирования, если оно открыто
                case List <TextChat> textChat:
                    if (textChat is null)
                    {
                        break;
                    }

                    TextChats = textChat;
                    this.EventUpTextChat?.Invoke(textChat);

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(textChat);
                    }

                    break;

                /// получаем Отзывы о сервере и отправляем их в окно редактирования, если оно открыто
                case List <Opinion> Opinions:
                    if (Opinions is null)
                    {
                        break;
                    }

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(Opinions);
                    }

                    EventUpOpinion(Opinions);

                    break;

                /// получаем Роли на сервере и отправляем их в окно редактирования, если оно открыто
                case List <Role> Role:
                    if (Role is null)
                    {
                        break;
                    }

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(Role);
                    }

                    break;

                /// получаем Журнал событий сервера и отправляем его в окно редактирования, если оно открыто
                case List <EventLog> EL:
                    if (EL is null)
                    {
                        break;
                    }

                    if (WEditingServer is not null)
                    {
                        WEditingServer.StartEventOfObject(EL);
                    }

                    break;

                /// получаем Журнал событий сервера и отправляем его в окно редактирования, если оно открыто
                case List <Request> RL:
                    if (RL is null)
                    {
                        break;
                    }

                    EventUpFriendsAndUsers.Invoke(RL);
                    break;

                case List <User> UL:
                    if (UL is null)
                    {
                        break;
                    }

                    EventUpFriendsAndUsers.Invoke(UL);
                    break;

                case List <UserLog> UL:
                    if (UL is null)
                    {
                        break;
                    }

                    EventUpFriendsAndUsers.Invoke(UL);
                    break;

                case User user:
                    EventUpFriendsAndUsers.Invoke(user);
                    break;

                case String str:
                    if (str == "closestream")
                    {
                        Environment.Exit(0);
                    }
                    break;

                default:
                    MessageBox
                    .Show("Сервер отправил какой-то странный объект.." + ob.GetType().Name);
                    break;
                }
            } while (true);
        }