Exemple #1
0
        private static void Sync(
            Context context,
            ParameterAccessor.Parts.Ldap ldap,
            string pattern,
            DateTime synchronizedTime)
        {
            var logs = new Logs()
            {
                new Log("pattern", pattern)
            };

            try
            {
                var directorySearcher = DirectorySearcher(
                    ldap.LdapSyncUser,
                    ldap.LdapSyncPassword,
                    ldap);
                directorySearcher.Filter   = pattern;
                directorySearcher.PageSize = 1000;
                var results = directorySearcher.FindAll();
                logs.Add("results", results.Count.ToString());
                foreach (SearchResult result in results)
                {
                    DirectoryEntry entry = result.Entry(
                        ldap.LdapSyncUser,
                        ldap.LdapSyncPassword);
                    if (Enabled(entry, ldap))
                    {
                        logs.Add("entry", entry.Path);
                        if (Authentications.Windows())
                        {
                            UpdateOrInsert(
                                context: context,
                                loginId: NetBiosName(
                                    context: context,
                                    entry: entry,
                                    ldap: ldap),
                                entry: entry,
                                ldap: ldap,
                                synchronizedTime: synchronizedTime);
                        }
                        else
                        {
                            UpdateOrInsert(
                                context: context,
                                loginId: entry.Property(
                                    context: context,
                                    name: ldap.LdapSearchProperty),
                                entry: entry,
                                ldap: ldap,
                                synchronizedTime: synchronizedTime);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                new SysLogModel(context: context, e: e, logs: logs);
            }
        }
Exemple #2
0
        public void GetLog_Should_Return_Correct_ResultSet()
        {
            //Arrange

            var entryDate = new DateTime(2020, 01, 01);

            var sut = new Logs();

            var expected = new List <KeyValuePair <DateTime, decimal> >();

            expected.Add(new KeyValuePair <DateTime, decimal>(entryDate, 1.1m));
            expected.Add(new KeyValuePair <DateTime, decimal>(entryDate, 2.1m));
            expected.Add(new KeyValuePair <DateTime, decimal>(entryDate, 3.1m));

            //Act

            sut.Add(new KeyValuePair <DateTime, decimal>(entryDate, 1.1m));
            sut.Add(new KeyValuePair <DateTime, decimal>(entryDate, 2.1m));
            sut.Add(new KeyValuePair <DateTime, decimal>(entryDate, 3.1m));

            var result = sut.Get(entryDate);

            //Assert

            result.Should().BeEquivalentTo(expected);
        }
        private static void Sync(
            Context context,
            ParameterAccessor.Parts.Ldap ldap,
            string pattern,
            DateTime synchronizedTime)
        {
            var logs = new Logs()
            {
                new Log("pattern", pattern)
            };

            try
            {
                using (var con = LdapConnection(
                           ldap.LdapSyncUser,
                           ldap.LdapSyncPassword,
                           ldap))
                {
                    var results = con.Search(
                        con.DN(ldap),
                        Novell.Directory.Ldap.LdapConnection.ScopeSub,
                        pattern,
                        null,
                        false,
                        new LdapSearchConstraints()
                    {
                        MaxResults = 0, ReferralFollowing = true
                    });
                    logs.Add("results", results.Count.ToString());
                    while (results.HasMore())
                    {
                        var entry = results.Next();
                        if (Enabled(entry, ldap))
                        {
                            logs.Add("entry", entry.Dn);
                            UpdateOrInsert(
                                context: context,
                                entry: entry,
                                ldap: ldap,
                                synchronizedTime: synchronizedTime);
                        }
                    }
                }
            }
            catch (LdapException le)
            {
                logs.Add(new Log("LdapErrorMessage", le.LdapErrorMessage?.TrimEnd('\0')));
                new SysLogModel(context: context, e: le, logs: logs);
            }
            catch (Exception e)
            {
                new SysLogModel(context: context, e: e, logs: logs);
            }
        }
Exemple #4
0
        private static void Sync(
            Context context,
            ParameterAccessor.Parts.Ldap ldap,
            string pattern,
            DateTime synchronizedTime)
        {
            var logs = new Logs()
            {
                new Log("pattern", pattern)
            };

            try
            {
                var directorySearcher = DirectorySearcher(
                    ldap.LdapSyncUser,
                    ldap.LdapSyncPassword,
                    ldap);
                directorySearcher.Filter = pattern;
                if (ldap.LdapSyncPageSize == 0)
                {
                    directorySearcher.PageSize = 1000;
                }
                else if (ldap.LdapSyncPageSize > 0)
                {
                    directorySearcher.PageSize = ldap.LdapSyncPageSize;
                }
                var results = directorySearcher.FindAll();
                logs.Add("results", results.Count.ToString());
                foreach (SearchResult result in results)
                {
                    if (Enabled(result, ldap))
                    {
                        logs.Add("result", result.Path);
                        UpdateOrInsert(
                            context: context,
                            result: result,
                            ldap: ldap,
                            synchronizedTime: synchronizedTime);
                    }
                }
            }
            catch (DirectoryServicesCOMException e)
            {
                new SysLogModel(
                    context: context,
                    extendedErrorMessage: e.ExtendedErrorMessage,
                    e: e);
            }
            catch (Exception e)
            {
                new SysLogModel(context: context, e: e, logs: logs);
            }
        }
        private void UnbindProgress(object sender, UnbindProgressEvents e)
        {
            FileEntry entry     = e.File;
            string    eventType = ParseType.GetStringType(entry.Type);

            if (e.Success)
            {
                ParseMessageType type = ParseType.GetType(entry.Type);
                _logs.Add(string.Format("Unbinding file: {0} was successfully completed.", entry.Name), "Events", eventType + " " + entry.Name, type);
            }
            else
            {
                _logs.Add(string.Format("Unsuccessfull unbinding file: {0} ", entry.Name), "Events", eventType + " " + entry.Name, ParseMessageType.Error);
            }
        }
Exemple #6
0
        private async Task <string> CreateArchiveAsync(string path, string outFileName)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (string.IsNullOrWhiteSpace(outFileName))
            {
                throw new ArgumentNullException(nameof(outFileName));
            }

            Logs.Add(new Log(DateTime.Now, $"{DateTime.Now}: Creating result archive...."));
            _logger.Log(SentryLevel.Info, $"{DateTime.Now}: Creating result archive....");

            string archivePath          = Path.Combine(Path.GetTempPath(), $"{outFileName}.tar.bz2");
            string createArchiveCommand = $"tar -cvjf {archivePath} {path}";

            await ExecuteCommandAsync(createArchiveCommand)
            .ConfigureAwait(continueOnCapturedContext: false);

            Logs.Add(new Log(DateTime.Now, $"{DateTime.Now}: Successfully created {Path.GetFileNameWithoutExtension(archivePath)} archive..."));
            _logger.Log(SentryLevel.Info, $"{DateTime.Now}: Successfully created {Path.GetFileNameWithoutExtension(archivePath)} archive...");

            return(archivePath);
        }
Exemple #7
0
 private void LogToUiThread(string s)
 {
     Application.Current.Dispatcher.BeginInvoke(new Action(() =>
     {
         Logs.Add(s);
     }));
 }
Exemple #8
0
        private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs args)
        {
            try
            {
                var res = _chronograph.Interpret(_serialPortManager.SerialPort);
                res.Order += _worksheetManager.Offset;
                var raceTimeViewModel = new RaceTimeViewModel(res)
                {
                    Resend = new GalaSoft.MvvmLight.Command.RelayCommand <RaceTimeViewModel>(x => SendRaceTime(x))
                };
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    if (res.Departure != null)
                    {
                        Departures.Add(raceTimeViewModel);
                        _writer.WriteLine($"1-{res.Order}-{res.Departure}");
                    }
                    else if (res.Arrival != null)
                    {
                        Arrivals.Add(raceTimeViewModel);
                        _writer.WriteLine($"2-{res.Order}-{res.Arrival}");
                    }
                });

                SendRaceTime(raceTimeViewModel);
            }
            catch (Exception ex)
            {
                // I said no crash !
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    Logs.Add(ex.Message);
                });
            }
        }
Exemple #9
0
        /*
         * The function loggs recieved massage
         */
        public void Log(string message, MessageTypeEnum type)
        {
            LogObject newLog = new LogObject(type.ToString(), message);

            Logs.Add(newLog);
            MessageRecieved?.Invoke(this, new MessageRecievedEventArgs(type, message));
        }
Exemple #10
0
        /// <summary>
        /// Logs a formatted debug message.
        /// </summary>
        /// <param name="msg">Log message.</param>
        /// <param name="args">Arguments.</param>
        public void DebugFormat(string msg, params object[] args)
        {
            var message = string.Format(BuildLogMsg(msg), args);

            Logger.DebugFormat(message);
            Logs.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + "  DEBUG - " + message);
        }
Exemple #11
0
 /// <summary>
 /// Recieves a new command.
 /// </summary>
 /// <param name="commandRead">The commnad received arguments.</param>
 private void ServerCommandRecieved(CommandRecievedEventArgs commandRead)
 {
     //LogCommand recieved. We add the Logs to the Logs ObservableCollection.
     if (commandRead != null && commandRead.CommandID == (int)CommandEnum.LogCommand)
     {
         Object thisLock = new Object();
         //BindingOperations.EnableCollectionSynchronization(Logs, thisLock);
         List <MessageRecievedEventArgs> recievedLogs = JsonConvert.DeserializeObject <List <MessageRecievedEventArgs> >(commandRead.Args[0]);
         foreach (MessageRecievedEventArgs log in recievedLogs)
         {
             //App.Current.Dispatcher.Invoke((Action)delegate
             //{
             Logs.Add(log);
             //});
         }
         canAcceptLogs = true;
     }
     //NewLogCommand recieved. We add the Log to the Logs ObservableCollection.
     else if (commandRead != null && commandRead.CommandID == (int)CommandEnum.NewLogCommand && Logs != null && canAcceptLogs == true)
     {
         Object thisLock = new Object();
         //BindingOperations.EnableCollectionSynchronization(Logs, thisLock);
         MessageRecievedEventArgs recievedLog = JsonConvert.DeserializeObject <MessageRecievedEventArgs>(commandRead.Args[0]);
         //App.Current.Dispatcher.Invoke((Action)delegate
         // {
         Logs.Add(recievedLog);
         //});
     }
 }
Exemple #12
0
 public LogViewModel()
 {
     if (Log.LogHandler is ILogItemHandler logService)
     {
         logService.Connect((item) => Logs.Add(item));
     }
 }
Exemple #13
0
        public void CheckDirectoryForNewFiles(string pathToDirectory)
        {
            var task = Task.Run(() =>
            {
                string fName;
                while (true)
                {
                    var files = Directory.GetFiles(pathToDirectory);

                    for (int i = 0; i < files.Length; i++)
                    {
                        fName  = Path.GetFileName(files[i]);
                        var lg = Logs.Find(f => f.fileName == fName);
                        if (lg == null)
                        {
                            var log = new SendsLog()
                            {
                                fileName = fName
                            };

                            Logs.Add(log);
                        }
                    }
                }
            });
        }
Exemple #14
0
        /// <summary>
        /// Добавляет нового пользователя в базу данных.
        /// </summary>
        /// <param name="person"> Обьект Person. </param>
        /// <returns></returns>
        public void Insert(Person person)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection())
            {
                try
                {
                    connection.ConnectionString = connectionString;
                    connection.Open();
                    string        inquiryForIdCity = "(SELECT idcity FROM \"Cities\" WHERE town = '" + person.city + "')";
                    NpgsqlCommand adapter          = new NpgsqlCommand("INSERT INTO \"Persons\"" + @"( name
                                                                                            , dateofbirth
			                                                                                , idcity
                                                                                            )
                                                               VALUES ( '" + person.name + @"'
	                                                                  , '"     + person.dateofbirth + @"'
	                                                                  , "     + inquiryForIdCity + @");", connection);
                    adapter.ExecuteReader();
                }
                catch (Exception ex)
                {
                    Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Изменяет информаю о существующем пользователе.
        /// </summary>
        /// <param name="person"> Обьект Person. </param>
        /// <returns></returns>
        public void Update(Person person)
        {
            using (NpgsqlConnection connection = new NpgsqlConnection())
            {
                try
                {
                    connection.ConnectionString = connectionString;
                    connection.Open();
                    string        inquiryForIdCity = "(SELECT idcity FROM \"Cities\" WHERE town = '" + person.city + "')";
                    NpgsqlCommand adapter          = new NpgsqlCommand("UPDATE \"Persons\" SET name = '" + person.name + @"'
			                                                                        , dateofbirth = '"             + person.dateofbirth + "'" + @"
                                                                                    , idcity  = '" + inquiryForIdCity + @"' 
                                                                WHERE idperson = " + person.idperson + @";", connection);
                    adapter.ExecuteReader();
                }
                catch (Exception ex)
                {
                    Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemple #16
0
 /// <summary>
 /// Находит пользователя по номеру идентификатора.
 /// </summary>
 /// <param name="id"> Идентификатор пользователя. </param>
 /// <returns> Возвращает обьект Person. </returns>
 public Person GetPerson(int id)
 {
     using (NpgsqlConnection connection = new NpgsqlConnection())
     {
         try
         {
             connection.ConnectionString = connectionString;
             connection.Open();
             string           qwerty  = "SELECT * FROM \"Persons\" WHERE idperson = '" + id + "';";
             NpgsqlCommand    adapter = new NpgsqlCommand(qwerty, connection);
             NpgsqlDataReader dr      = adapter.ExecuteReader();
             Person           person  = new Person();
             while (dr.Read())
             {
                 person.idperson    = Convert.ToInt32(dr[0]);
                 person.name        = dr[1].ToString();
                 person.dateofbirth = Convert.ToDateTime(dr[2]);
                 person.city        = dr[3].ToString();
             }
             return(person);
         }
         catch (Exception ex)
         {
             Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
             return(null);
         }
         finally
         {
             connection.Close();
         }
     }
 }
Exemple #17
0
        public override void Log(Log log)
        {
            Logs.Add(log);

            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");

                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add("*****@*****.**");
                mail.Subject = $"Log Email {log.Date.ToString("dd/MM/yyyy HH:mm:ss")}";
                mail.Body    = $"Message: { log.Message}, Date: { log.Date}, Type: { log.Type}, It happened: { log.WhereItHappened}";


                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("your_email_address", "password");
                SmtpServer.EnableSsl   = true;


                SmtpServer.Send(mail);
            }
            catch (Exception ex)
            {
            }
        }
Exemple #18
0
        private void HandleFso_Changed()
        {
            if (!Reading)
            {
                lock (this)
                {
                    if (Reading)
                    {
                        return;
                    }

                    Reading = true;
                    int i = 0;
                    using (System.IO.StreamReader file = new StreamReader(Path))
                    {
                        string line = string.Empty;
                        while ((line = file.ReadLine()) != null)
                        {
                            if (i++ <= LastReadIndex)
                            {
                                Debug.WriteLine($"##### Continue : i = {i - 1}, LastReadIndex = {LastReadIndex}");
                                continue;
                            }
                            Dispatcher.Invoke(() => Logs.Add(new Log {
                                Text = line
                            }));
                        }
                    }
                    LastReadIndex = i;
                    Reading       = false;
                }
            }
        }
Exemple #19
0
        /// <summary>
        /// Получает список городов.
        /// </summary>
        /// <returns> Возвращает список пользователей. </returns>
        public List <City> GetCitiesList()
        {
            using (NpgsqlConnection connection = new NpgsqlConnection())
            {
                try
                {
                    connection.ConnectionString = connectionString;
                    connection.Open();
                    string           qwerty  = "SELECT * FROM \"Cities\";";
                    NpgsqlCommand    adapter = new NpgsqlCommand(qwerty, connection);
                    NpgsqlDataReader dr      = adapter.ExecuteReader();
                    _CitiesList = new List <City>();
                    while (dr.Read())
                    {
                        City city = new City
                        {
                            idcity = Convert.ToInt32(dr[0]),
                            town   = dr[1].ToString()
                        };
                        _CitiesList.Add(city);
                    }

                    return(_CitiesList);
                }
                catch (Exception ex)
                {
                    Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
                    return(null);
                }
                finally
                {
                    connection.Close();
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Logs a formatted log message and an exception.
        /// </summary>
        /// <param name="msg">Formatted log message.</param>
        /// <param name="e">Exception.</param>
        /// <param name="args">Arguments.</param>
        public void ErrorFormat(string msg, Exception e, params object[] args)
        {
            var message = string.Format(BuildLogMsg(msg), args);

            Logger.Error(message, e);
            Logs.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + "  ERROR - " + message + "\r\n" + e);
        }
        public void Log(string message, LogType type = LogType.INFO)
        {
            var msg = $"{DateTime.Now.ToString("dd/MM/yyyy hh:mm:ss tt")}: [{type}] {message}";
            var x   = new LogData(message, msg, type);

            Logs.Add(x);
        }
Exemple #22
0
        private void SaveRawJson(JObject json)
        {
            var saveFileDialog = new SaveFileDialog
            {
                InitialDirectory = Path.GetDirectoryName(data.Global["json-path"] ?? SpreadsheetPath),
                FileName         = Path.GetFileName(data.Global["json-path"] ?? "result.json"),
                DefaultExt       = ".json",
                Filter           = "Json Asset (*.json)|*.json"
            };

            var result = saveFileDialog.ShowDialog();

            if (result != true)
            {
                Logs.Add(LogViewModel.Warn("Operation canceled!"));
                return;
            }

            var jsonFileName = saveFileDialog.FileName;

            try
            {
                Directory.CreateDirectory(Path.GetDirectoryName(jsonFileName));
                File.WriteAllText(jsonFileName, json.ToString());
            }
            catch (Exception e)
            {
                Logs.Add(LogViewModel.Error($"An error ocurred while trying to save the file ({e.Message})."));
            }

            data.Global["json-path"] = jsonFileName;
            parser.WriteFile(IniPath, data);

            Logs.Add(LogViewModel.Log($"Json asset saved at {jsonFileName}!"));
        }
Exemple #23
0
        /// <summary>
        /// Logs a Debug log message.
        /// </summary>
        /// <param name="msg">Log message.</param>
        public void Debug(string msg)
        {
            var message = BuildLogMsg(msg);

            Logger.Debug(msg);
            Logs.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + "  DEBUG - " + message);
        }
        public void Process()
        {
            try
            {
                Logs.Add($"Inicio Teste - [Serviço de Emissão {EnumInsurer.Liberty.GetDescriptionEnum()}]");
                SEGURADORAICSCONFIG seguradoraIcs = _icsIsurerConfig.GetConfiguration(EnumIntegrationConfigLiberty.EmissaoApolice);
                if (seguradoraIcs == null)
                {
                    Logs.Add($"Configuração nula", EnumLog.Error);
                    return;
                }

                ServiceConfigurationIcs serviceConfigurationIcs = new ServiceConfigurationIcs();
                serviceConfigurationIcs        = JsonConvert.DeserializeObject <ServiceConfigurationIcs>(seguradoraIcs.JS_REGRAS);
                serviceConfigurationIcs.Config = JsonConvert.DeserializeObject <ServiceConfigurationIcs>(seguradoraIcs.JS_CONFIG).Config;

                if (ExecutaServico(serviceConfigurationIcs))
                {
                    EmissaoApolice(seguradoraIcs, serviceConfigurationIcs);
                }
            }
            catch (Exception ex)
            {
                Logs.Add($"Inicio - [Servico de Emissão {EnumInsurer.Liberty.GetDescriptionEnum()} - Erro: { ex.InnerException.Message} - { ex.StackTrace}", EnumLog.Error);
            }
            finally
            {
                Logs.Add($"Fim - [Serviço de Emissão {EnumInsurer.Liberty.GetDescriptionEnum()}]");
                Logs.Save(EnumInsurer.Liberty);
            }
        }
Exemple #25
0
        /// <summary>
        /// Logs an error message and an exception.
        /// </summary>
        /// <param name="msg">Log message.</param>
        /// <param name="e">Exception.</param>
        public void Error(string msg, Exception e)
        {
            var message = BuildLogMsg(msg);

            Logger.Error(message, e);
            Logs.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture) + "  ERROR - " + message + "\r\n" + e);
        }
Exemple #26
0
        private void DownloadClientUpdate()
        {
            Thread.Sleep(100);
            Directory.CreateDirectory("Client");
            MaximumProgress = 3;
            AddMessage("Downloading client archive...");

            var clientBytes = infoService.GetClientBytes();

            Progress++;

            File.WriteAllBytes("tmpClient.zip", clientBytes);

            Progress++;

            AddMessage("Extracting client archive...");

            ZipFile.ExtractToDirectory("tmpClient.zip", "Client", true);
            File.Delete("tmpClient.zip");

            Progress++;

            Logs.Add("Cliented Extraced!");


            VersionNumber = newVersion.ToString();

            File.WriteAllText("client.version", newVersion.ToString());
        }
Exemple #27
0
    public static void Write(string text, LogTypes logType = LogTypes.Everything, bool isBold = false, string color = "")
    {
        if (Logs == null)
        {
            InitializeLogs();
        }

        string logString = text;

        if (isBold)
        {
            logString = "<b>" + logString + "</b>";
        }
        if (color != "")
        {
            logString = "<color=" + color + ">" + logString + "</color>";
        }

        LogEntry logEntry = new LogEntry(logString + "\n", logType);

        Logs.Add(logEntry);

        if (currentLogTypeToShow == logType || currentLogTypeToShow == LogTypes.Everything)
        {
            ShowLogEntry(logEntry);
        }
    }
        /// <summary>
        /// Запрос на изменение данных пользователя.
        /// </summary>
        public void EditPerson(Person person)
        {
            try
            {
                HttpWebRequest webRequest = ConWebRequest("PUT", null, null);
                JObject        joe        = new JObject(new JProperty("idperson", person.Idperson),
                                                        new JProperty("name", person.Name),
                                                        new JProperty("dateofbirth", person.Dateofbirth),
                                                        new JProperty("city", person.City));
                string s         = JsonConvert.SerializeObject(joe);
                byte[] byteArray = Encoding.UTF8.GetBytes(s);
                webRequest.ContentLength = byteArray.Length;
                Stream dataStream = webRequest.GetRequestStream();
                dataStream.Write(byteArray, 0, byteArray.Length);
                dataStream.Close();

                WebResponse webResponse = webRequest.GetResponse();
                if (((HttpWebResponse)webResponse).StatusCode == HttpStatusCode.OK)
                {
                    webResponse.Close();
                }
            }
            catch (Exception ex)
            {
                Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
            }
        }
        public MainWindow()
        {
            if (!File.Exists("haarcascade_frontalface_default.xml"))
            {
                MessageBox.Show("Файл haarcascade_frontalface_default.xml не найден.");
                Environment.Exit(0);
            }
            InitializeComponent();

            PeopleData     = Watcher.ReadPeopleDataJson();
            HaarCascade    = new CascadeClassifier("haarcascade_frontalface_default.xml");
            FaceRecognizer = LoadFaceRecognizer();
            Refresh_Click(null, null);
            if (PeopleData.Face.Count > 0)
            {
                for (int i = 0; i < PeopleData.Face.Count; i++)
                {
                    FaceItemsPlace.Children.Add(new FaceItem(this, i));
                }
                NoFaces.Visibility = Visibility.Collapsed;
            }
            Logs = Watcher.ReadLogsJson();
            LogList.ItemsSource     = Logs;
            Logs.CollectionChanged += Logs_CollectionChanged;

            AutoSaveLogTimer          = new DispatcherTimer();
            AutoSaveLogTimer.Tick    += new EventHandler(SaveLogs);
            AutoSaveLogTimer.Interval = new TimeSpan(0, 1, 0);
            AutoSaveLogTimer.Start();

            VideoTimer          = new DispatcherTimer();
            VideoTimer.Tick    += new EventHandler(VideoTimerTick);
            VideoTimer.Interval = new TimeSpan(0, 0, 1);
            Logs.Add(DateTime.Now.ToString() + " - программа запущена -");
        }
 /// <summary>
 /// Получает от сервера список городов.
 /// </summary>
 public List <City> GetCitiesList()
 {
     try
     {
         HttpWebRequest webRequest  = ConWebRequest("GET", "Cities", null);
         WebResponse    webResponse = webRequest.GetResponse();
         if (((HttpWebResponse)webResponse).StatusCode == HttpStatusCode.OK)
         {
             Stream       dataStreamResponse = webResponse.GetResponseStream();
             StreamReader reader             = new StreamReader(dataStreamResponse);
             string       responseFromServer = reader.ReadToEnd();
             var          resp = JsonConvert.DeserializeObject <List <City> >(responseFromServer);
             reader.Close();
             webResponse.Close();
             return(resp);
         }
         else
         {
             return(null);
         }
     }
     catch (Exception ex)
     {
         Logs.Add(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
         return(null);
     }
 }