コード例 #1
0
ファイル: CmdProcessor.cs プロジェクト: DmitrySheenko/SSMM2.0
        public CmdProcessor(SMM apphandler, MySQLClient sqlclient)
        {
            this.appHandler = apphandler;
            this.sqlClient = sqlclient;

            DispatcherTimer timer = new DispatcherTimer();
            timer.Tick += new EventHandler(CmdTimer_Tick);
            timer.Interval = new TimeSpan(0, 0, 3);
            timer.Start();
        }
コード例 #2
0
ファイル: MapProcessor.cs プロジェクト: DmitrySheenko/SSMM2.0
        public MapProcessor(SMM apphandler, MapsGraphicalInterface mgi, UserFilesManager userfiles, MySQLClient sqlclient)
        {
            this.appHandler = apphandler;
            this.MGI = mgi;
            this.sqlClient = sqlclient;
            this.userFiles = userfiles;
            Maps = new ObservableCollection<MAP>();
            Maps.CollectionChanged += mgi.maps_CollectionChanged;

            // bind the map graphical interface to the map processor
            this.MGI.setMapProcessor(this);
        }
コード例 #3
0
ファイル: SMM.cs プロジェクト: DmitrySheenko/SSMM2.0
        public void ConnectTo(string hostname, string database, string password, string username)
        {
            if(isConnectionEstablished)
            {
                DisconnectFrom();
            }

            this.sqlClient = new MySQLClient(hostname, database, username, password);

            this.mapProcessor.sqlClient = this.sqlClient;
            this.cmdProcessor.sqlClient = this.sqlClient;

            consoleHandler.WriteLine(String.Format(FindResource("i_ConnSetts_connectingTo").ToString(), hostname));
            mapProcessor.CheckTablesExist(database);

        }
コード例 #4
0
ファイル: MainWindow.xaml.cs プロジェクト: DmitrySheenko/SSMM
        /*
         *
         *
         * "Подключается" к БД и загружает карты
         *
         */
        public void ConnectToDatabase(string host, string database, string user, string password)
        {
            sqlClient = new MySQLClient(
                host,
                database,
                user,
                password
            );

            ConsoleWriteLine("Подключаюсь к " + host);
            try
            {
                if (!IsTablesChecked)
                {
                    ConsoleWriteLine("Проверка таблиц ... ");
                    int result = 0;

                    Dictionary<string, string> LoadedIDS = new Dictionary<string, string>();
                    LoadedIDS["ID"] = "0";
                    try
                    {
                        LoadedIDS = sqlClient.Select("`ssmm_maps_ids`", "`ID` = '1'");
                        Int32.TryParse(LoadedIDS["ID"], out result);
                        if (result == 1)
                        {
                            ConsoleWriteLine("Таблицы существуют");
                            IsTablesChecked = true;
                        }
                        else
                        {
                            ConsoleWriteLine("Таблицы не были обнаружены. Они будут созданы автоматически");
                            DB_CreateTables(); // создать их!
                            ConsoleWriteLine("Нажмите кнопку \"Подключиться\" еще раз");
                            IsTablesChecked = true;
                            return;
                        }
                    }
                    catch
                    {
                        if (sqlClient.getConn().State == System.Data.ConnectionState.Open)
                        {
                            sqlClient.getConn().Close();
                        }

                        ConsoleWriteLine("Таблицы не были обнаружены. Они будут созданы автоматически");
                        DB_CreateTables(); // создать их!
                        ConsoleWriteLine("Нажмите кнопку \"Подключиться\" еще раз");
                        IsTablesChecked = true;

                        return;
                    }

                }

                ConsoleWriteLine("Загружается список карт...");
                LoadAllMapsFromDatabase();
                ConsoleWriteLine("Список карт загружен");

                ActiveConnectionHost = host;
                ActiveConnectionDatabase = database;
                ActiveConnectionUserName = user;
                ActiveConnectionPassword = password;

                IsConnected = true;

                DispatcherTimer timer = new DispatcherTimer();
                timer.Tick += new EventHandler(timer_Tick);
                timer.Interval = new TimeSpan(0, 0, 3);
                timer.Start();

                PanelConnectionSettings.Visibility = System.Windows.Visibility.Collapsed;
                ConsoleWriteLine("Подключение выполнено.");
            }

            catch//(Exception e)
            {
                //Console.WriteLine(e.ToString());
                ConsoleWriteLine("Не получилось подключиться к " + host);
                ConsoleWriteLine("Проверьте правильность настроек соединения во вкладке \"Параметры подключения\"");
            }
        }