/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public DatabaseStatus StatusDatabase(string database)
        {
            try
            {
                var dataDir = Path.Combine(_serverConfiguration.DbFarmDir, database);

                if (Directory.Exists(dataDir))
                {
                    LoggerHelper.Write(LoggerOption.Warning, "Client#{0} -> Checked '{1}' database",
                                       CurrentClient.ClientId, database);

                    return(DiagnosticHelper.IsRunningApplication(MSERVER_PROCESS_NAME, String.Format("--dbpath=\"{0}\"", dataDir))
                        ? DatabaseStatus.Started
                        : DatabaseStatus.Stoped);
                }
            }
            catch (Exception exception)
            {
                LoggerHelper.Write(LoggerOption.Error, exception.Message);

                throw;
            }

            return(DatabaseStatus.None);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="database"></param>
        /// <returns></returns>
        public bool KillDatabase(string database)
        {
            try
            {
                //to check in processes
                var dataDir = Path.Combine(_serverConfiguration.DbFarmDir, database);

                if (!DiagnosticHelper.IsRunningApplication(MSERVER_PROCESS_NAME, String.Format("--dbpath=\"{0}\"", dataDir)) &&
                    !Directory.Exists(dataDir))
                {
                    throw new MonetDbException("Database not exists");
                }

                //database
                if (DiagnosticHelper.KillProcessApplication(MSERVER_PROCESS_NAME, String.Format("--dbpath=\"{0}\"", dataDir)))
                {
                    //logging
                    LoggerHelper.Write(LoggerOption.Warning, "Client#{0} -> Droped '{1}' database", CurrentClient.ClientId, database);

                    return(true);
                }
            }
            catch (Exception exception)
            {
                LoggerHelper.Write(LoggerOption.Error, exception.Message);

                throw;
            }

            return(false);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="database"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        /// <exception cref="Exception">Database already exists</exception>
        /// <exception cref="ArgumentNullException"><paramref name="database"/> is <see langword="null" />.</exception>
        public bool CreateDatabase(string database)
        {
            //to check in processes
            var dataDir = Path.Combine(_serverConfiguration.DbFarmDir, database);
            var model   = new MonetServerOptionsModel();

            if (DiagnosticHelper.IsRunningApplication(MSERVER_PROCESS_NAME, String.Format("--dbpath=\"{0}\"", dataDir)))
            {
                throw new MonetDbException("Database already created");
            }

            try
            {
                //database
                var serverFileName = string.Format("{0}\\bin\\mserver5.exe", _serverConfiguration.DbInstallerDir);
                var serverFileArgs = string.Format("--set \"prefix={0}\" " +
                                                   "--set \"exec_prefix={0}\" " +
                                                   "--set \"mapi_port={1}\" " +
                                                   "--dbpath=\"{2}\"  " +
                                                   "--set \"gdk_nr_threads={3}\" " +
                                                   "--set \"max_clients={4}\"",
                                                   _serverConfiguration.DbInstallerDir,
                                                   model.Port,
                                                   dataDir,
                                                   model.Threads,
                                                   model.MaxClients);

                model.ServerArguments = serverFileArgs;
                model.ServerFileName  = serverFileName;

                //environment
                EnvironmentHelper.SetVariables("PATH", string.Format("{0}\\bin;{0}\\lib;{0}\\lib\\MonetDB5;", _serverConfiguration.DbInstallerDir));

                if (DiagnosticHelper.AutoLaunchApplicationToSleep(serverFileName, serverFileArgs))
                {
                    //server options
                    BinaryFormatterHelper.Serialize(model, Path.Combine(dataDir, SERVER_OPTIONS_FILE));

                    //startup
                    ShellHelper.AddToStartup(ToTitle(database), Path.Combine(IoHelper.CurrentRoot, STARTUP_PROCESS_NAME), $"\"{Path.Combine(dataDir, SERVER_OPTIONS_FILE)}\"");

                    //logging
                    LoggerHelper.Write(LoggerOption.Info, "Client#{0} -> Created '{1}' database", CurrentClient.ClientId, database);

                    return(true);
                }
            }
            catch (Exception exception)
            {
                LoggerHelper.Write(LoggerOption.Error, exception.Message);

                throw;
            }

            return(false);
        }