Exemple #1
0
 /// <summary>
 /// Получение и чтение книг клиентом
 /// </summary>
 private void GettingAndReadingBook()
 {
     try
     {
         TryGettingAndReadingBook();
     }
     catch (Exception exception)
     {
         if (!ControlServerDB.CheckException(exception))
         {
             Log.Error(exception.ToString);
         }
         ServerDB.StopServer();
     }
 }
Exemple #2
0
        static void Main(string[] args)
        {
            ControlServerDB serverDB = null;

            try
            {
                int daysSecond = ReadDaysSecond();
                serverDB = new ControlServerDB(daysSecond);
                if (serverDB.MongoClientsAvailability())
                {
                    serverDB.ObjectOverload();
                }
                serverDB.StartListeningQueuesRabbit();
                Console.WriteLine("Сервер запущен. Нажмите любую клавишу для заершения работы.");
                Console.ReadKey();
            }
            catch (Exception exception)
            {
                if (!ControlServerDB.CheckException(exception))
                {
                    Log.Error(exception.ToString);
                }
            }
            finally
            {
                if (serverDB != null)
                {
                    serverDB.StopServer();
                }
                else
                {
                    Environment.Exit(0);
                }
            }
        }
 /// <summary>
 /// Добавление клиента
 /// </summary>
 /// <param name="clientServer">Объект клиента</param>
 public void AddClient(ClientServerDB clientServer)
 {
     try
     {
         CollectionMongo.InsertOne(clientServer);
     }
     catch (Exception exception)
     {
         Log.Error(exception.ToString);
         ServerDB.StopServer();
     }
 }
        /// <summary>
        /// Конструктор объекта работы с MongoDB
        /// </summary>
        public MongoDbSDB(ControlServerDB serverDB)
        {
            ServerDB = serverDB;
            string         connectionStringMongo = ConfigurationManager.ConnectionStrings["MongoDb"].ConnectionString;;
            string         dataBase      = "SystemDistributionBook";
            string         collection    = "SDBCollection";
            MongoClient    ClientMongo   = new MongoClient(connectionStringMongo);
            IMongoDatabase DatabaseMongo = ClientMongo.GetDatabase(dataBase);

            try
            {
                DatabaseMongo.RunCommand((Command <BsonDocument>) "{ping:1}");
            }
            catch (Exception exception)
            {
                Log.Error(exception.ToString);
                ServerDB.StopServer();
            }
            CollectionMongo = DatabaseMongo.GetCollection <ClientServerDB>(collection);
        }
Exemple #5
0
 /// <summary>
 /// Завершение приложения
 /// </summary>
 public void StopApplication()
 {
     ConnectionMySQL.Close();
     ServerDB.StopServer();
 }