Exemplo n.º 1
0
        private void BeginCHeckPassword()
        {
            if (CheckPassword())
            {
                string _insertSql = $"INSERT INTO {table} (Name, Comment,URL, UpdateTime, Title,Progress) " +
                                    "VALUE( @Name " +
                                    ", @Comment " +
                                    ", @URL " +
                                    ", now() " +
                                    ", @Title " +
                                    ", @Progress );";

                string[] _parameters = new string[]
                {
                    "Name", _localData.TeamName,
                    "Comment", _localData.Comment,
                    "Progress", _localData.Progress.ToString(),
                    "Title", _localData.Title,
                    "URL", _localData.URL
                };
                MySQLUtil.DBInsert(_insertSql, _parameters);

                MakeUserPoint();
                MySQLUtil.DBClose();
            }
        }
Exemplo n.º 2
0
        // 3+4+5+6+7 DBに接続してパスワードチェック
        private bool CheckPassword()
        {
            MySQLUtil.DBConnection();
            string selectSql = $"SELECT Password FROM  {database}.{userTable} WHERE Name=@Name ;";

            string[] parameters = new string[] { "Name", _localData.TeamName };

            DataTable tbl = MySQLUtil.DBSelect(selectSql, parameters);

            // 3.exist data?
            if (tbl.Rows.Count == 1)
            {
                // yes
                foreach (DataRow row in tbl.Rows)
                {
                    if (_localData.Password == row[0].ToString())
                    {
                        // 7.check ok
                        return(true);
                    }
                    else
                    {
                        // 5. local data delete
                        MySQLUtil.DBClose();
                        _localData.Password = "";
                        LocalDataExport();

                        EditorUtility.DisplayDialog("パスワードチェックエラー", "パスワードが合いません\r\n再入力をお願いします", "OK");
//                        Debug.Log("password error");
                        return(false);
                    }
                }
            }
            else
            {
                // no 6. db insert
                string insertSql = $"insert into {database}.{userTable} (Name ,Password) " +
                                   " value ( @Name , @Password );";
                parameters = new string[]
                {
                    "Name", _localData.TeamName,
                    "Password", _localData.Password
                };
                MySQLUtil.DBInsert(insertSql, parameters);
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        private void MakePublicData()
        {
            _publicData = ScriptableObject.CreateInstance <PublicData>();

            MySQLUtil.DBConnection();
            string selectPublicData = $"SELECT Name,UpdateTime,Progress " +
                                      $"FROM {database}.{table} " +
                                      $"ORDER BY Name ASC,UpdateTime ASC,Progress ASC;";

            string[]  parameters = { };
            DataTable tbl        = MySQLUtil.DBSelect(selectPublicData, parameters);


            PublicDataStruct[] publicDataStructs = new PublicDataStruct[] { };
            foreach (DataRow row in tbl.Rows)
            {
                PublicDataStruct publicDataStruct = new PublicDataStruct();
                publicDataStruct.TeamName = row["Name"].ToString();
                publicDataStruct.Progress = (int)row["Progress"];
                publicDataStruct.DateTime = (DateTime)row["UpdateTime"];

                if (_publicData.publicDatas.ContainsKey(row["Name"].ToString()))
                {
                    Array.Resize(ref publicDataStructs, publicDataStructs.Length + 1);
                    publicDataStructs[publicDataStructs.Length - 1] = publicDataStruct;
                }
                else
                {
                    //length1
                    publicDataStructs = new PublicDataStruct[] { publicDataStruct };
                }


                if (_publicData.publicDatas.ContainsKey(row["Name"].ToString()))
                {
                    _publicData.publicDatas.Remove(row["Name"].ToString());
                }

                _publicData.publicDatas.Add(row["Name"].ToString(), publicDataStructs);
            }

            if (_localData != null)
            {
                MakeUserPoint();
            }

            MySQLUtil.DBClose();
        }
Exemplo n.º 4
0
        private void MakeUserPoint()
        {
            string selectUserProgress = $"SELECT UpdateTime,Progress " +
                                        $"FROM {database}.{table} " +
                                        $"WHERE Name=@Name " +
                                        $"ORDER BY UpdateTime ASC;";

            string[] parameters = new string[] { "Name", _localData.TeamName };

            DataTable tbl = MySQLUtil.DBSelect(selectUserProgress, parameters);

            _userPoint = new Vector2[] { new Vector2(0f, 0f) };
            foreach (DataRow row in tbl.Rows)
            {
                Array.Resize(ref _userPoint, _userPoint.Length + 1);
                float x = 48f - ((float)(_endDt - ((DateTime)row[0])).TotalMinutes / 60f);
                float y = float.Parse(row[1].ToString());
                _userPoint[_userPoint.Length - 1] = new Vector2(x, y);
//                        Debug.Log(((_endDt-((DateTime)row[0])).TotalMinutes)/60);
            }
        }
Exemplo n.º 5
0
        private bool UserDataUpdate()
        {
            LocalDataExport();
            if (_localData.TeamName == "")
            {
                EditorUtility.DisplayDialog("データ登録エラー", "チーム名を入力してください", "OK");
                return(false);
            }

            if (_localData.Comment.Length > 24)
            {
                EditorUtility.DisplayDialog("データ登録エラー", "ごめんなさい\r\nコメントは24文字までしか登録できません", "OK");
                return(false);
            }

            // 1. exist local pasward?
            if (_localData.Password == "")
            {
                _isDisable = true;
                OpenPasswordWindow(x =>
                {
                    if (string.IsNullOrEmpty(x) == false)
                    {
                        _localData.Password = x;
                        BeginCHeckPassword();
                    }

                    _isDisable = false;
                });
            }

            if (_localData.Password != "")
            {
                BeginCHeckPassword();
            }


            MySQLUtil.DBClose();
            return(true);
        }
Exemplo n.º 6
0
 void OnDestroy()
 {
     LocalDataExport();
     MySQLUtil.DBClose();
 }
Exemplo n.º 7
0
        private void OnDestroy()
        {
            RankingDataExport();

            MySQLUtil.DBClose();
        }
Exemplo n.º 8
0
        void Awake()
        {
            try
            {
                if (_localData == null)
                {
                    _localData = ScriptableObject.CreateInstance <LocalData>();
                }

                LocalDataImport();

                if (_rankingData == null)
                {
                    _rankingData = ScriptableObject.CreateInstance <RankingData>();
                }

                RankingDataImport();

                MySQLUtil.DBConnection();

                string _selectUserProgress =
                    "select tbl1.Name ,tbl1.UpdateTime,tbl1.Progress,tbl1.URL,tbl1.Comment,tbl1.Title " +
                    "FROM Cluster.GameJam2020inWinter as tbl1 " +
                    "INNER JOIN (	 "+
                    "   SELECT tbl2.Name,UpdateTime ,MAX(Progress) as MAXProgress " +
                    "FROM Cluster.GameJam2020inWinter " +
                    "   INNER JOIN ( " +
                    "SELECT Name, MAX(UpdateTime) as LastTime " +
                    "FROM Cluster.GameJam2020inWinter " +
                    "GROUP BY Name  " +
                    ")as tbl2 " +
                    "Where UpdateTime = tbl2.LastTime " +
                    "GROUP BY Name	 "+
                    ") as tbl3 " +
                    "where tbl1.UpdateTime = tbl3.UpdateTime and Progress =tbl3.MAXProgress AND tbl1.Name =tbl3.Name " +
                    "ORDER BY Progress DESC,tbl1.UpdateTime ASC " +
                    "; ";


                DataTable tbl = MySQLUtil.DBSelect(_selectUserProgress);

                foreach (DataRow row in tbl.Rows)
                {
                    if (_rankingData.rankingData.ContainsKey(row["Name"].ToString()))
                    {
                        _rankingData.rankingData[row["Name"].ToString()]._progress = (int)row["Progress"];
                        _rankingData.rankingData[row["Name"].ToString()]._comment  = row["Comment"].ToString();
                        _rankingData.rankingData[row["Name"].ToString()]._url      = row["URL"].ToString();
                        _rankingData.rankingData[row["Name"].ToString()]._title    = row["Title"].ToString();
                        _rankingData.rankingData[row["Name"].ToString()]._dateTime = (DateTime)row["UPdateTime"];
                    }
                    else
                    {
                        RankingDataStruct rankingDataStruct = new RankingDataStruct();
                        rankingDataStruct._progress = (int)row["Progress"];
                        rankingDataStruct._comment  = row["Comment"].ToString();
                        rankingDataStruct._url      = row["URL"].ToString();
                        rankingDataStruct._title    = row["Title"].ToString();
                        rankingDataStruct._dateTime = (DateTime)row["UPdateTime"];
                        _rankingData.rankingData.Add(row["Name"].ToString(), rankingDataStruct);
                    }
                }

                MySQLUtil.DBClose();
            }
            catch (Exception e)
            {
                Debug.Log("error");
                Debug.Log(e);
                MySQLUtil.DBClose();
            }
        }