예제 #1
0
        private void LoadTable()
        {
            DatabaseTable.Visibility = Visibility.Visible;
            SQLiteClass           sql  = new SQLiteClass();
            List <DatabaseObject> dbos = sql.GetConnections();

            dtrs = new List <DBTableRow>();

            foreach (DatabaseObject dbo in dbos)
            {
                dtrs.Add(new DBTableRow {
                    ConnectionString = dbo.ConnectionString, Preference = dbo.Preference
                });
            }
            DatabaseTable.ItemsSource = dtrs;
            DatabaseTable.Items.Refresh();
            sql.CloseCon();
        }
예제 #2
0
        public DatabaseBackup()
        {
            //Get connection string
            SQLiteClass           sql  = new SQLiteClass();
            List <DatabaseObject> dbos = sql.GetConnections();

            System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(dbos[0].ConnectionString);
            srv = new Server(new ServerConnection(conn));

            //List down all the databases on the server
            foreach (Database myDatabase in srv.Databases)
            {
                Console.WriteLine(myDatabase.Name);
                if (myDatabase.Name.Equals("DuckpondOne"))
                {
                    dtb = myDatabase;
                }
            }
        }
예제 #3
0
        private void HandleLog(int mode)
        {
            SQLiteClass sql = new SQLiteClass(ProgramFilesx86() + "\\DuckServer\\Information.dat");
            MSSQL       msl;

            if (!Service.shouldIBeRunning)
            {
                Console.WriteLine("This server instance should not be handling requests now.");
            }

            switch (mode)
            {
            case IM_Event:
                if (Service.shouldIBeRunning)
                {
                    String eventString = br.ReadString();
                    Events ev          = DeserializeXMLFileToObject <Events>(eventString);
                    sql.CloseCon();
                    msl = new MSSQL();
                    msl.AddEvent(ev);
                    bw.Write(IM_OK);
                }
                else
                {
                    bw.Write(IM_Bad_Credentials);
                }
                break;

            case IM_NewVersions:
                if (Service.shouldIBeRunning)
                {
                    IMClient imc = new IMClient();
                    imc.setConnParams(GetOriginIP(), 25567);
                    imc.SetupConn();
                    imc.SendSignal(IM_NewVersions, Service.DoSerialize(new DateTimeVersions {
                        ServiceVersion = sql.GetServices(), WhitelistVersion = sql.GetWhitelists(), ServiceDateTime = sql.GetLastUpdated(SQLiteClass.GET_SERVICE_LIST), WhitelistDateTime = sql.GetLastUpdated(SQLiteClass.GET_WHITELIST_LIST)
                    }));
                    bw.Write(IM_OK);
                }
                else
                {
                    bw.Write(IM_Bad_Credentials);
                }
                break;

            case IM_AddDatabases:
                sql.AddDatabase(new DatabaseObject(br.ReadString(), br.ReadInt32()));
                bw.Write(IM_OK);
                break;

            case IM_GetDatabases:
                List <DatabaseObject> dbos = sql.GetConnections();
                foreach (DatabaseObject dbo in dbos)
                {
                    bw.Write(dbo.ConnectionString);
                    bw.Write(dbo.Preference);
                }
                bw.Write(IM_OK);
                sql.CloseCon();
                break;

            case IM_NewDatabases:
                List <DatabaseObject> dbs = DeserializeXMLFileToObject <List <DatabaseObject> >(br.ReadString());
                sql.NewConnections(dbs);
                sql.CloseCon();
                break;

            case IM_NewServiceList:
                List <ServicesObject> sros = DeserializeXMLFileToObject <List <ServicesObject> >(br.ReadString());
                sql.NewServices(sros);
                sql.CloseCon();

                //Port scan
                //Broadcast
                break;

            case IM_NewWhitelists:
                List <Whitelists> wls = DeserializeXMLFileToObject <List <Whitelists> >(br.ReadString());
                sql.NewWhitelists(wls);
                sql.CloseCon();
                break;

            case IM_AddWhiteList:
                break;

            case IM_RemoveWhitelist:
                break;

            case IM_Debug:
                Console.WriteLine(br.ReadString());
                break;

            case IM_Diagnostic:
                if (!Service.shouldIBeRunning)
                {
                    bw.Write(IM_Bad_Credentials);
                }
                else
                {
                    bw.Write(IM_OK);
                }
                break;

            default:
                break;
            }
            bw.Write(IM_OK);
        }