Ejemplo n.º 1
0
    private int _GetDiffId(int diff)
    {
        DBSetup db = new DBSetup();

        // Connect to Database
        string connection = "URI=file:" + db.getLocation();

        IDbConnection dbcon = new SqliteConnection(connection);

        dbcon.Open();

        IDbCommand dbcmd;

        dbcmd = dbcon.CreateCommand();
        IDataReader reader;
        string      select = "SELECT id FROM song_difficulty WHERE Song_id = " + _id + " and Difficulty = " + diff + ";";

        dbcmd.CommandText = select;
        reader            = dbcmd.ExecuteReader();
        int id = -1;

        if (reader.Read())
        {
            id = reader.GetInt32(0);
            // Debug.Log(id);
        }
        reader.Close();
        dbcon.Dispose();
        return(id);
    }
Ejemplo n.º 2
0
        public static void WriteAll()
        {
            DBSetup.Initialize();
            World.EnsureMapDataLoaded();
            SpellHandler.Initialize();
            FactionMgr.Initialize();
            SkillHandler.Initialize();
            TalentMgr.Initialize();

            WriteZoneEnum();
            WriteMapEnum();
            WriteSkillEnums();
            WriteRangeEnum();
            WriteFactionEnums();
            WriteSpellFocusEnum();
            WriteSpellId();
            WriteSpellMechanicEnum();
            WriteTalentEnums();
            WriteItemId();
            WriteItemSetId();
            WriteNpcId();
            WriteGOEntryId();
            WriteRealmCategory();

            NPCMgr.ForceInitialize();
            WriteRideEnum();
        }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    public Songs()
    {
        /*
         *      Connect to the database and store the number of songs in _num;
         */
        DBSetup db = new DBSetup();

        // Connect to Database
        string connection = "URI=file:" + db.getLocation();

        IDbConnection dbcon = new SqliteConnection(connection);

        dbcon.Open();

        // Create SELECT Statement
        IDbCommand  dbcmd;
        IDataReader reader;

        dbcmd = dbcon.CreateCommand();
        string select = "SELECT id From songs;";

        dbcmd.CommandText = select;

        // Run Query
        reader = dbcmd.ExecuteReader();

        list = new List <Song>();

        while (reader.Read())
        {
            list.Add(new Song(reader.GetInt32(0) - 1));
        }
        reader.Dispose();
        dbcon.Dispose();
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            this.InitializeComponent();
            Microsoft.Data.Sqlite.Internal.SqliteEngine.UseWinSqlite3();
            this.Suspending += OnSuspending;
            DBSetup.CreateDB();

            PhotoFunctions.DeleteTemporaryFiles();
        }
Ejemplo n.º 5
0
    public void AddTop(int score, string name, int diff)
    {
        List <Rank> topTen  = GetTen(diff);
        Rank        newRank = new Rank(name, score, 0);

        topTen.Add(newRank);

        List <Rank> newList = topTen.OrderByDescending(o => o.score).ToList();

        if (newList.Count > 10)
        {
            newList.RemoveAt(newList.Count - 1);
        }

        int count = 1;

        foreach (Rank r in newList)
        {
            r.rank = count;
            count += 1;
        }

        // List <Rank> newList = new List<Rank>();
        int id = _GetDiffId(diff);

        count = 0;
        int rank = 1;

        DBSetup db = new DBSetup();

        // Connect to Database
        string        connection = "URI=file:" + db.getLocation();
        IDbConnection dbcon      = new SqliteConnection(connection);

        dbcon.Open();

        // Create SELECT Statement
        IDbCommand dbcmd;

        dbcmd = dbcon.CreateCommand();
        string delete = "DELETE from top_ten where song_diff_id = " + id + ";";

        dbcmd.CommandText = delete;
        dbcmd.ExecuteNonQuery();

        foreach (Rank r in newList)
        {
            string insert = "INSERT into top_ten (song_diff_id, rank, score, name) VALUES (" + id + ", " + r.rank + ", " + r.score + ", \"" + r.name + "\");";

            //Debug.Log(insert);
            dbcmd.CommandText = insert;
            var result = dbcmd.ExecuteNonQuery();
        }

        dbcon.Dispose();
    }
Ejemplo n.º 6
0
        private void DBSetup_Click(object sender, RoutedEventArgs e)
        {
            DBSetup frm    = new DBSetup();
            bool?   result = frm.ShowDialog(this);

            if (result == true)
            {
                IsReload = true;
                this.Close();
            }
            else
            {
                IsConnected = false;
            }
        }
Ejemplo n.º 7
0
    private List <Rank> _getTen(int id)
    {
        List <Rank> ranks = new List <Rank>();
        bool        atEnd = false;
        int         rank  = 1;

        // Connect to Database
        DBSetup db = new DBSetup();

        // Connect to Database
        string connection = "URI=file:" + db.getLocation();

        IDbConnection dbcon = new SqliteConnection(connection);

        dbcon.Open();

        IDbCommand dbcmd;

        dbcmd = dbcon.CreateCommand();

        IDataReader reader;

        while (!atEnd)
        {
            string select = "SELECT name, score FROM top_ten WHERE song_diff_id = " + id + " and rank = " + rank + ";";
            dbcmd.CommandText = select;

            reader = dbcmd.ExecuteReader();

            if (reader.Read())
            {
                Rank r = new Rank(reader.GetString(0), reader.GetInt32(1), rank);
                ranks.Add(r);
                rank++;
                if (rank > 10)
                {
                    atEnd = true;
                }
            }
            else
            {
                atEnd = true;
            }
            reader.Close();
        }
        dbcon.Dispose();
        return(ranks);
    }
Ejemplo n.º 8
0
    public Song(int id)
    {
        _id = id + 1;

        DBSetup db = new DBSetup();

        // Connect to Database
        string        connection = "URI=file:" + db.getLocation();
        IDbConnection dbcon      = new SqliteConnection(connection);

        dbcon.Open();

        // Create SELECT Statement
        IDbCommand  dbcmd;
        IDataReader reader;

        dbcmd = dbcon.CreateCommand();
        string select = "SELECT name, location, length, tempo From songs WHERE id = " + _id + ";";

        dbcmd.CommandText = select;

        // Run Query
        reader = dbcmd.ExecuteReader();

        // Make sure a row was returned
        if (reader.Read())
        {
            //Save Data
            _name     = reader.GetString(0);
            _location = reader.GetString(1);
            _length   = reader.GetInt32(2);
            _tempo    = reader.GetInt32(3);
//		Debug.Log(_name + ' ' + _location + ' ' + _length + ' ' + _tempo);
        }
        reader.Close();
        dbcon.Dispose();

        _easyId = _GetDiffId(0);
        _hardId = _GetDiffId(1);

        // string insert = "INSERT into top_ten (song_diff_id, rank, score, name) VALUES (" + _easyId + ", " + 1 + ", " + 20 + ", \"" + "Amy"+ "\");";
        // Debug.Log(insert);
        // dbcmd.CommandText = insert;
        // var result = dbcmd.ExecuteNonQuery();
        // Debug.Log(result);
    }
Ejemplo n.º 9
0
    public void OnEnable()
    {
        bool hasPlayer = false;

        if (Service.db.SelectCount("FROM item") < 1)
        {
            DBSetup.start();
        }

        //NetworkManager.validateGameVersion();

        // @ToDo: create a UI for selection
        foreach (CharacterData character in Service.db.Select <CharacterData>("FROM characters"))
        {
            hasPlayer = true;
            playerId  = character.id;

            nickLabel.text  = character.name;
            LevelLabel.text = character.level.ToString();
            JoinButton.onClick.AddListener(
                delegate {
                this.joinGame(character.id, character.name);
            });
            break;
        }
        if (hasPlayer)
        {
            nickLabel.transform.gameObject.SetActive(true);
            LevelLabel.transform.gameObject.SetActive(true);
            JoinButton.transform.gameObject.SetActive(true);
                        #if UNITY_EDITOR
            GameObject.Find("Canvas/MainPanel/LoginOptions/TestButton").SetActive(true);
                        #endif

            GameObject.Find("Canvas/MainPanel/LoginOptions/CreateButton").SetActive(false);
        }
        else
        {
            nickLabel.transform.gameObject.SetActive(false);
            LevelLabel.transform.gameObject.SetActive(false);
            JoinButton.transform.gameObject.SetActive(false);
            GameObject.Find("Canvas/MainPanel/LoginOptions/TestButton").SetActive(false);
        }
    }
Ejemplo n.º 10
0
    public List <Beat> GetRhythm(int diff)
    {
        DBSetup db = new DBSetup();
        int     id = _easyId;

        if (id == 1)
        {
            id = _hardId;
        }

        // Connect to Database
        string        connection = "URI=file:" + db.getLocation();
        IDbConnection dbcon      = new SqliteConnection(connection);

        dbcon.Open();

        // Create SELECT Statement
        IDbCommand  dbcmd;
        IDataReader reader;

        dbcmd = dbcon.CreateCommand();

        List <Beat> beats  = new List <Beat>();
        string      select = "SELECT hit_time , length FROM notes WHERE song_diff_id = " + id + ";";

        dbcmd.CommandText = select;

        // Run Query
        reader = dbcmd.ExecuteReader();

        while (reader.Read())
        {
            int   hit_time = reader.GetInt32(0);
            float length   = reader.GetFloat(1);
            Beat  b        = new Beat(hit_time, length);
            beats.Add(b);
        }

        reader.Dispose();
        dbcon.Dispose();

        return(beats);
    }
Ejemplo n.º 11
0
    public void Start()
    {
        Quest quest;

        DBSetup.setAllQuests();

        // recover inprocess quests from db
        foreach (Task task in Service.db.Select <Task>("FROM tasks"))
        {
            if (!quests.ContainsKey(task.quest))
            {
                quest       = allQuests[task.quest];
                quest.tasks = new Dictionary <int, Task>(); // tasks are begin recovered from db

                quests.Add(task.quest, quest);
            }
            quests[task.quest].tasks.Add(task.taskId, task);
        }
        try {
            PlayerPanel.Instance.showActiveQuests();
        } catch (System.Exception) {
        }
    }
Ejemplo n.º 12
0
    void moveDB()
    {
        DBSetup db         = new DBSetup();
        string  connection = db.getLocation();

        db.clearDB();

        string db_file = Application.dataPath + "/StreamingAssets/database";

        //For Mac Builds, the Streaming Assets folder is moved to /Resources/Data
        if (!File.Exists(db_file))
        {
            db_file = Application.dataPath + "/Resources/Data/StreamingAssets/database";
        }

        if (!File.Exists(connection))
        {
            Debug.Log("Copying database file to " + connection);

            byte[] bytes = System.IO.File.ReadAllBytes(db_file);
            System.IO.File.WriteAllBytes(connection, bytes);
        }
        else
        {
            FileInfo fi = new FileInfo(connection);
            FileInfo fo = new FileInfo(db_file);
            if (fi.Length < fo.Length)
            {
                byte[] bytes = System.IO.File.ReadAllBytes(db_file);
                System.IO.File.WriteAllBytes(connection, bytes);
            }
        }

        Debug.Log("Using " + connection);
        isLoaded = true;
    }
Ejemplo n.º 13
0
 public void showNPCText(int npcId)
 {
     text.text = DBSetup.getTalkerPhrase(npcId);
 }
Ejemplo n.º 14
0
        void StartupMain(object sender, StartupEventArgs e)
        {
            try
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                this.DispatcherUnhandledException          += App_DispatcherUnhandledException;

                //自分自身のAssemblyを取得
                System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
                System.Version             ver = asm.GetName().Version;;

                this.ShutdownMode = ShutdownMode.OnExplicitShutdown;

                bool IsNeedLicenseCheck = true;
                var  plist = (NameValueCollection)ConfigurationManager.GetSection("serviceSettings");
                if (plist != null)
                {
                    if (plist["mode"] == CommonConst.WithoutLicenceDBMode)
                    {
                        IsNeedLicenseCheck = false;
                    }
                }
                while (true)
                {
                    AppCommonData appcmn = null;
                    if (IsNeedLicenseCheck)
                    {
                        // ログインできたら今までと同様スタートアップ画面を表示する。
                        LicenseLogin licLogin = new LicenseLogin();
                        this.applog = licLogin.appLog;
                        licLogin.viewsCommData.WithLicenseDB = true;
                        licLogin.viewsCommData.AppData       = new AppCommonData();
                        licLogin.ShowDialog();
                        if (licLogin.IsLoginCompleted)
                        {
                            appcmn = new AppCommonData()
                            {
                                CommonDB_CustomerCd         = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_CustomerCd,
                                UserDB_DBId                 = (licLogin.viewsCommData.AppData as AppCommonData).UserDB_DBId,
                                UserDB_DBName               = (licLogin.viewsCommData.AppData as AppCommonData).UserDB_DBName,
                                UserDB_DBPass               = (licLogin.viewsCommData.AppData as AppCommonData).UserDB_DBPass,
                                UserDB_DBServer             = (licLogin.viewsCommData.AppData as AppCommonData).UserDB_DBServer,
                                CommonDB_LastAccessDateTime = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_LastAccessDateTime,
                                CommonDB_LimitDate          = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_LimitDate,
                                CommonDB_LoginFlg           = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_LoginFlg,
                                CommonDB_RegDate            = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_RegDate,
                                CommonDB_StartDate          = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_StartDate,
                                CommonDB_UserId             = (licLogin.viewsCommData.AppData as AppCommonData).CommonDB_UserId,
                            };
                        }
                        else
                        {
                            Application.Current.Shutdown(0);
                        }
                    }
                    else
                    {
                        SqlConnectionStringBuilder sqlBuilder = new SqlConnectionStringBuilder();
                        sqlBuilder = AppCommon.MakeSqlConnectString();
                        if (sqlBuilder == null)
                        {
                            // 接続文字列が設定されていない場合
                            DBSetup dbform = new DBSetup();
                            if (dbform.ShowDialog() == true)
                            {
                                sqlBuilder = dbform.sqlBuilder;
                            }
                            else
                            {
                                Environment.Exit(0);
                                return;
                            }
                        }
                        appcmn = new AppCommonData()
                        {
                            UserDB_DBServer = Utility.Encrypt(sqlBuilder.DataSource),
                            UserDB_DBName   = Utility.Encrypt(sqlBuilder.InitialCatalog),
                            UserDB_DBId     = Utility.Encrypt(sqlBuilder.UserID),
                            UserDB_DBPass   = Utility.Encrypt(sqlBuilder.Password),
                        };
                    }
                    {
                        LOGIN login = new LOGIN();
                        this.applog = login.appLog;
                        login.viewsCommData.WithLicenseDB = IsNeedLicenseCheck;
                        login.viewsCommData.AppData       = appcmn;
                        login.SetupConnectStringuserDB(appcmn.UserDB_DBServer, appcmn.UserDB_DBName, appcmn.UserDB_DBId, appcmn.UserDB_DBPass);
                        login.appLog.Info("START Ver.{0}", ver);

                        StartupWindow start = new StartupWindow();
                        start.viewsCommData.WithLicenseDB = IsNeedLicenseCheck;
                        start.viewsCommData = login.viewsCommData;
                        start.ConnString    = login.ConnString;
                        // スタートアップ画面起動
                        start.ShowDialog();
                        login.viewsCommData = start.viewsCommData;

                        if (start.IsConnected)
                        {
                            // ログイン画面起動
                            login.ShowDialog();
                            if (login.IsLoggedIn)
                            {
                                WindowControler menu = new WindowControler();
                                this.applog  = menu.appLog;
                                menu.Closed += menu_Closed;
                                menu.viewsCommData.WithLicenseDB = IsNeedLicenseCheck;
                                //menu.Topmost = true;
                                menu.Show(login);
                                //menu.Topmost = false;
                            }
                            else
                            {
                                if (login.IsReload)
                                {
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            login.Close();
                            if (start.IsReload)
                            {
                                continue;
                            }
                        }
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                if (this.applog != null)
                {
                    applog.Error("画面で取得できなかった例外発生", ex);
                }
                MessageBox.Show(string.Format("例外が発生しました。\r\nエラーメッセージ:{0}", ex.Message), "例外発生");
                //Environment.Exit(1);
            }
        }
Ejemplo n.º 15
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     DBSetup.init();
 }
Ejemplo n.º 16
0
        public ActionResult DBInstall()
        {
            HttpCookie cookie = System.Web.HttpContext.Current.Request.Cookies.Get("IFDBSignIn");

            if (cookie == null)
            {
                return(RedirectToAction("DBInstallLogin"));
            }
            else
            {
                InstallInfo info       = new InstallInfo();
                string      appVersion = ConfigReader.GetAppSetting();
                info.AppVersion = appVersion;

                try
                {
                    DBSetup  setup = new DBSetup();
                    DBObject db    = setup.Initialize();

                    info.DBVersion   = VersionReader.DatabaseVersion(db).ToString();
                    info.DBDrive     = db.DbDrive.ToString();
                    info.DBCreateNew = false;
                    info.DBServer    = db.DbServer;
                    info.DBUserID    = db.UserId;
                    info.DBPassWord  = db.Password;
                    info.DBName      = db.DbName;
                }

                catch
                {
                    info.DBVersion   = "1.0";
                    info.DBDrive     = "SqlServer2005";
                    info.DBCreateNew = false;
                    info.DBServer    = "";
                    info.DBUserID    = "";
                    info.DBPassWord  = "";
                    info.DBName      = "";
                }


                //Mongo
                string mongoStr = "";
                try
                {
                    mongoStr = ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString;
                }
                catch {}

                if (mongoStr == "")
                {
                    info.MongoSetting = false;
                }
                else
                {
                    info.MongoSetting = true;
                    //mongodb://10.210.160.98:20001/test
                    //mongodb://libin1:[email protected]:27017/test
                    //要区分@ 和没有@两种情况
                    string[] mongoArr = new string[] { };
                    if (mongoStr.Contains('@'))
                    {
                        mongoArr           = mongoStr.Split(new char[] { '/', ':', '@' });
                        info.MongoUserName = mongoArr[3];
                        info.MongoPassword = mongoArr[4];
                    }
                    else
                    {
                        mongoArr           = mongoStr.Split(new char[] { '/', ':' });
                        info.MongoUserName = "******";
                        info.MongoPassword = "******";
                    }
                    info.MongoServer = mongoArr[mongoArr.Length - 3] + ":" + mongoArr[mongoArr.Length - 2];
                    info.MongoDBName = mongoArr[mongoArr.Length - 1];
                }

                Account configAccout = ConfigReader.GetAccount();
                info.LoginUser     = configAccout.UserName;
                info.LoginPassword = configAccout.PassWord;

                return(View(info));
            }
        }