示例#1
0
        private void ClientListener()
        {
            try
            {
                Start(); // Start listening.
                while (true)
                {
                    // Buffer for reading data
                    Console.WriteLine("Waiting for a connection... ");
                    // Perform a blocking call to accept requests.
                    // You could also user server.AcceptSocket() here.

                    var client = new TCPInitializer.Client(AcceptTcpClient(), Metadata);
                    AllClients.Add(client);

                    Thread clientThread = new Thread(StreamHandler);
                    clientThread.Start(client);


                    // Shutdown and end connection
                    // AllClients.Disconnect(client);
                }
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                // Stop listening for new clients.
                Stop();
                AllClients.Disconnect(Metadata);
            }
        }
示例#2
0
        /// <summary>
        ///     Creates a new http client.
        /// </summary>
        /// <param name="host">Base host address.</param>
        /// <param name="configFile">Config file path.</param>
        /// <returns>Http client.</returns>
        public HttpClient CreateClient(
            string host,
            string configFile = "net.config")
        {
            XmlDocument configXml = new XmlDocument();

            configXml.Load(configFile);

            HttpClient client = new HttpClient(
                new HttpClientHandler()
            {
                AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
            });

            foreach (XmlNode headerNode in
                     configXml.SelectNodes("configuration/Headers/*/header"))
            {
                client.DefaultRequestHeaders.Add(
                    headerNode.Attributes["key"].Value,
                    headerNode.InnerText);
            }

            client.BaseAddress = new Uri(host);

            AllClients.Add(client);

            return(client);
        }
示例#3
0
        /// <summary>
        /// Create a fresh start for an <see cref="Neat"/> object
        /// </summary>
        private void Reset()
        {
            AllConnections.Clear();
            AllNodes.Clear();
            AllClients.Clear();

            for (int i = 0; i < Constants.InputSize; i++)
            {
                NodeGene node = CreateNode();
                node.X = 0.1;;
                node.Y = (i + 1) / (double)(Constants.InputSize + 1);
            }

            for (int i = 0; i < Constants.OutputSize; i++)
            {
                NodeGene node = CreateNode();
                node.X = 0.9;;
                node.Y = (i + 1) / (double)(Constants.OutputSize + 1);

                ActivationEnumeration a = ActivationEnumeration.Random();
                node.Activation     = a.Activation;
                node.ActivationName = a.Name;
            }

            for (int i = 0; i < Constants.MaxClients; i++)
            {
                Client c = new Client(EmptyGenome());
                AllClients.Add(c);
            }
        }
示例#4
0
        /// <summary>
        /// Метод выгрузки данных по клиентам и их счетов из БД
        /// </summary>
        Task <bool> AddLoadClientsToDB()
        {
            // Используйте метод FillDB() если нужно заполнить БД
            //FillDB();

            try
            {
                SqlDataReader reader;

                ProgressBarStatus = "Загрузка данных из бд. Ожидайте.";

                // Запрос на выгрузку данных из таблицы клиентов
                sqlCommand = new SqlCommand($"SELECT * FROM Clients", ConnectionInfo.connection);

                reader = sqlCommand.ExecuteReader();

                // Цикл загрузки данных клиентов
                while (reader.Read())
                {
                    Application.Current.Dispatcher.Invoke(() => AllClients.Add(new Client(reader.GetInt32(0), reader.GetString(1),
                                                                                          reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5))));
                }

                reader.Close();

                // Запрос на выгрузку данных из таблицы счетов
                sqlCommand = new SqlCommand($"SELECT * FROM Bills", ConnectionInfo.connection);

                reader = sqlCommand.ExecuteReader();

                // Цикл выгрузки данных по счетам клиентов
                while (reader.Read())
                {
                    Application.Current.Dispatcher.Invoke(() => allInclusions.Add(new InclusionModel(reader.GetInt32(1), reader.GetInt32(2),
                                                                                                     reader.GetString(3), reader.GetString(4), reader.GetDouble(5), reader.GetDouble(6), reader.GetBoolean(7), reader.GetInt32(8),
                                                                                                     reader.GetString(9))));
                }

                reader.Close();

                // Определение количества счетов для каждого клиента
                foreach (var t in AllClients)
                {
                    t.Inclusions = new ObservableCollection <InclusionModel>(allInclusions.Where(x => x.ClientID == t.Id));

                    t.ColBills = t.Inclusions.Count;
                }

                ProgressBarStatus = $"Загрузка завершена.";

                return(Task.FromResult(true));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                return(Task.FromResult(false));
            }
        }
 public void PullAllClients()
 {
     AllClients.Clear();
     foreach (var client in AppViewModel.GetAllClients())
     {
         AllClients.Add(client);
     }
 }
示例#6
0
 public void RemoveClient()
 {
     Clients.Remove(SomePerson);
     GetOrders();
     AllClients.Clear();
     foreach (Client c in Clients)
     {
         AllClients.Add(c);
     }
 }
示例#7
0
        public ServiceDepartment(Client client) : this()
        {
            this.currentClient   = client;
            lblCurentClient.Text = client.Person.FullName;

            AllClients.RemoveAll(c => c.ClientID == currentClient.ClientID);
            AllClients.Add(currentClient);

            cbxClient.Enabled = false;

            PopulateClients();
            PopulateUnclaimedClientServiceRequests();
        }
        /// <see cref="IClientViewModel.OnValidSubmit"/>
        public async void OnValidSubmit()
        {
            try
            {
                // Si contient déjà le même nom de client.
                if (AllClients.Any(x => x.NomClient == NouveauClient.NomClient))
                {
                    string msgWarn = $"Aucun ajout : {NouveauClient.NomClient} existe déjà";
                    NotificationMessage messWarn = new NotificationMessage()
                    {
                        Summary  = "Attention",
                        Detail   = msgWarn,
                        Duration = 3000,
                        Severity = NotificationSeverity.Warning
                    };
                    NotificationService.Notify(messWarn);

                    return;
                }

                // Ajout dans la base de donnée.
                int idClient = await SqlContext.AddClient(NouveauClient.NomClient);

                Client nouveauClient = new Client()
                {
                    IdClient  = idClient,
                    NomClient = NouveauClient.NomClient
                };

                AllClients.Add(nouveauClient);
                await ClientGrid.Reload();

                string message = $"Nouveau client : {nouveauClient.NomClient} ajouté";
                NotificationMessage messNotif = new NotificationMessage()
                {
                    Summary  = "Sauvegarde OK",
                    Detail   = message,
                    Duration = 3000,
                    Severity = NotificationSeverity.Success
                };
                NotificationService.Notify(messNotif);

                Log.Information("CLIENT - " + message);

                NouveauClient = new ClientValidation();
            }
            catch (Exception ex)
            {
                Log.Error(ex, "ClientViewModel - OnValidSubmit");
            }
        }
示例#9
0
        /// <summary>
        ///     Gets an existing http client.
        /// </summary>
        /// <param name="username">Account username.</param>
        /// <returns>Http client.</returns>
        public HttpClient GetClient(string username, string host)
        {
            var client = AllClients
                         .Except(Clients.Select(i => i.Value))
                         .FirstOrDefault();

            if (client == null)
            {
                client = CreateClient(host);
                AllClients.Add(client);
                Clients.Add(username, client);
            }

            return(client);
        }
 public RGOClient(string IPAddress, int portNr, string serviceName)
 {
     Name = serviceName;
     log  = log4net.LogManager.GetLogger($"RGOClient<{Name}>");
     try
     {
         client = new CEthernetClient("");
         client.SetConnection(IPAddress, portNr, "TCP");
         client.ByteDataReceived = ProcessReceivedData;
     }
     catch
     {
         log.Error($"RGOClientBase: The name:{Name} does not occur in the RGOService list in the configuration ");
     }
     AllClients.Add(this);
 }
示例#11
0
 public void AddClient()
 {
     AllClients.Add(SomePerson);
     Clients.Add(SomePerson);
     SaveChanges();
 }
示例#12
0
        /// <summary>
        /// Метод выгрузки данных по клиентам и их счетов из БД
        /// </summary>
        Task <bool> AddLoadClientsToDB()
        {
            // Используйте метод FillDB() если нужно заполнить БД
            //FillDB();

            TestBankLocalDBEntities takeClints = new TestBankLocalDBEntities();

            try
            {
                //SqlDataReader reader;

                ProgressBarStatus = "Загрузка данных из бд. Ожидайте.";

                #region Запрос на получение клиентов

                //// Запрос на выгрузку данных из таблицы клиентов
                //sqlCommand = new SqlCommand($"SELECT * FROM Clients", ConnectionInfo.connection);

                //reader = sqlCommand.ExecuteReader();

                //// Цикл загрузки данных клиентов
                //while (reader.Read())
                //{
                //    Application.Current.Dispatcher.Invoke(() => AllClients.Add(new Client(reader.GetInt32(0), reader.GetString(1),
                //        reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5))));
                //}

                //reader.Close();

                #endregion

                // Получение данных из таблицы клиентов
                var tempCLients = takeClints.Clients;

                foreach (var t in tempCLients)
                {
                    Application.Current.Dispatcher.Invoke(() => AllClients.Add(new Client
                                                                                   (t.Id, t.LastName, t.Name,
                                                                                   t.Patronymic, t.ClientStatus,
                                                                                   t.RegistrationDate)));
                }

                #region Запрос на получение счетов

                //// Запрос на выгрузку данных из таблицы счетов
                //sqlCommand = new SqlCommand($"SELECT * FROM Bills", ConnectionInfo.connection);

                //reader = sqlCommand.ExecuteReader();

                //// Цикл выгрузки данных по счетам клиентов
                //while (reader.Read())
                //{
                //    Application.Current.Dispatcher.Invoke(() => allInclusions.Add(new InclusionModel(reader.GetInt32(1), reader.GetInt32(2),
                //    reader.GetString(3), reader.GetString(4), reader.GetDouble(5), reader.GetDouble(6), reader.GetBoolean(7), reader.GetInt32(8),
                //    reader.GetString(9))));
                //}

                //reader.Close();

                #endregion

                // Получение данных из таблицы счетов
                var tempBills = takeClints.Bills;

                foreach (var t in tempBills)
                {
                    Application.Current.Dispatcher.Invoke(() => allInclusions.Add(new InclusionModel
                                                                                      (t.ClientID, t.BillNum, t.InclusionDate,
                                                                                      t.InclusionDateEnd, t.InclusionSum, t.Percents,
                                                                                      t.Capitalize, t.Total, t.StatusInclusion)));
                }

                // Определение количества счетов для каждого клиента
                foreach (var t in AllClients)
                {
                    t.Inclusions = new ObservableCollection <InclusionModel>(allInclusions.Where(x => x.ClientID == t.Id));

                    t.ColBills = t.Inclusions.Count;
                }

                ProgressBarStatus = $"Загрузка завершена.";

                return(Task.FromResult(true));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

                return(Task.FromResult(false));
            }
        }
示例#13
0
 protected Client(long id)
 {
     NeedsFullUpdate  = true;
     SnapshotInterval = TimeSpan.FromMilliseconds(50); // this should be a Variable
     AllClients.Add(id, this);
 }