Ejemplo n.º 1
0
    public string getActionId()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  querySQL = "select max(ac_id) from act;";
        DataSet ds       = mysql.SimpleSql(querySQL);
        string  res_id   = "";

        if (ds != null)
        {
            if (ds.Tables[0].Rows.Count == 1)
            {
                if (ds.Tables[0].Rows[0][0].ToString() == "")
                {
                    res_id = "400001";
                }
                else
                {
                    string cur_max_id = ds.Tables[0].Rows[0][0].ToString();
                    //Debug.Log("max id is: "  + cur_max_id );
                    int next_id = int.Parse(cur_max_id) + 1;
                    res_id = next_id.ToString();
                    //Debug.Log("next id is: " + res_id);
                }
            }
            else
            {
                Debug.Log("Error");
                res_id = "error";
            }
        }
        mysql.Close();
        return(res_id);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 初始化管理员表(将人员表中所有的管理员添加到管理员表中)
    /// </summary>
    public void InitialAdmin()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  query = "select ppl_id from ppl where ppl_role = '管理员'";
        DataSet ds1   = mysql.QuerySet(query);

        if (ds1 != null)
        {
            DataTable table = ds1.Tables [0];
            for (int i = 0; i < table.Rows.Count; i++)
            {
                Debug.Log(table.Rows [i] [0]);
                // 把激活改成1
                string  actquery = "update ppl set ppl_act = 1 where ppl_id = " + table.Rows[i][0];
                DataSet ds2      = mysql.QuerySet(actquery);
                // 往管理员表里加
                string  dupliquery = "select * from adm where adm_id = " + table.Rows[i][0];
                DataSet ds3        = mysql.QuerySet(dupliquery);
                if (ds3 == null)
                {
                    string  addquery = "insert into adm values ('" + table.Rows[i][0] + "', '" + table.Rows[i][0] + "')";
                    DataSet ds4      = mysql.QuerySet(addquery);
                }
            }
            Debug.Log("管理员表初始化完成!");
        }
        else
        {
            Debug.Log("人员表中没有管理员身份的用户!");
        }
        mysql.Close();
    }
Ejemplo n.º 3
0
    public string HistoryRecord(string Date, string actID, int Hand)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string date   = Date;
        string act_id = actID;
        int    hand   = Hand;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string query = "select rec_link from rec where rec_ptID = '" + ptID + "' and rec_hand = " + hand +
                       " and rec_actID = '" + act_id + "' and rec_date = '" + date + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];
        string    res   = "";

        Debug.Log(table.Rows.Count);
        if (table.Rows.Count == 1)
        {
            res = table.Rows [0] [0].ToString();
        }
        Debug.Log(res);
        mysql.Close();
        return(res);
    }
Ejemplo n.º 4
0
    //删
    public string[] deleteStandardAction(string hand_id)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[] res = new string[1];
        res[0] = "null";
        mysql.OpenSql();
        string  querySql = "select * from act where ac_id = '" + hand_id + "'";
        DataSet ds       = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            res    = new string[2];
            res[0] = ds.Tables[0].Rows[0][0].ToString();
            res[1] = ds.Tables[0].Rows[0][1].ToString();
            string picName   = ds.Tables[0].Rows[0][2].ToString();
            string leftData  = ds.Tables[0].Rows[0][3].ToString();
            string rightData = ds.Tables[0].Rows[0][4].ToString();
            querySql = "delete from act where ac_id = '" + hand_id + "'";
            Debug.Log(querySql);
            deletePicture(picName);
            deleteActions(leftData);
            deleteActions(rightData);
            mysql.SimpleSql(querySql);
            Debug.Log("delete!!!!");
        }

        mysql.Close();
        return(res);
    }
Ejemplo n.º 5
0
    //查
    public string[,] findStandardActions()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string[,] res;
        res = new string[1, 1];
        mysql.OpenSql();
        Debug.Log("database name: " + databaseName);
        string querySql = "select ac_id, ac_name, ac_pic from act";
        //string querySql = "select trp_ptID from trp";
        DataSet ds      = mysql.SimpleSql(querySql);
        int     row_num = ds.Tables[0].Rows.Count;

        //Debug.Log("aaaa" + row_num);
        if (row_num != 0)
        {
            int col_num = ds.Tables[0].Rows[0].ItemArray.Length;
            //Debug.Log("rows num: " + row_num);
            //Debug.Log("cols_num: " + col_num);
            res = new string[row_num, col_num];
            for (int i = 0; i < row_num; i++)
            {
                for (int j = 0; j < col_num; j++)
                {
                    //Debug.Log("content: " + ds.Tables[0].Rows[i][j]);
                    res[i, j] = ds.Tables[0].Rows[i][j].ToString();
                }
            }
        }
        else
        {
            res[0, 0] = "null";
        }
        mysql.Close();
        return(res);
    }
Ejemplo n.º 6
0
    /// <summary>
    /// 查询所有医生,返回医生编号、姓名、性别、职称、电话
    /// </summary>
    public DataTable QueryDoctor()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "select dc_id, dc_name, dc_sex, dc_pro, dc_tele from doc where dc_ex = 1";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
        return(table);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 查询未完成的训练计划
    /// </summary>
    public static DataSet findUnfinishedTrainingPlan(string trp_ptID)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string  querySql = "select * from trp where trp_ptID = '" + trp_ptID + "' and trp_totl > trp_finish";
        DataSet ds       = mysql.SimpleSql(querySql);

        mysql.Close();
        return(ds);
    }
Ejemplo n.º 8
0
    //封装好的数据库类

    public static void addTrainingPlan(string trp_ptID, string trp_actID, int trp_hand, int trp_num, int trp_time, int trp_totl)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "insert into trp(trp_ptID, trp_actID, trp_hand, trp_num, trp_time, trp_totl) values(";

        querySql = querySql + "'" + trp_ptID + "', '" + trp_actID + "', '" + trp_hand + "', '" + trp_num + "', '" + trp_time + "', '" + trp_totl + "')";
        Debug.Log(querySql);
        mysql.SimpleSql(querySql);
        mysql.Close();
    }
Ejemplo n.º 9
0
    /// <summary>
    /// 删除医生
    /// </summary>
//	public void DeleteDoctor(string[] dc_id) {
    public void DeleteDoctor()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        //		string[] dcID = dc_id;
        string[] dcID = { "200001", "200002" };
        for (int i = 0; i < dcID.Length; i++)
        {
            string  query = "update doc set dc_ex = 0 where dc_id = '" + dcID [i] + "'";
            DataSet ds    = mysql.QuerySet(query);
        }
        mysql.Close();
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 更改训练计划,只能改次数、时长、总天数
    /// </summary>
    public static void changeTrainingPlan(string trp_ptID, string trp_actID, int trp_hand, int trp_num, int trp_time, int trp_totl)
    {
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "select trp_ptID, trp_actID, trp_hand from trp where trp_ptID = '"
                          + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
        DataSet ds = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            querySql = "update trp set trp_num='" + trp_num + "' and trp_time='" + trp_time + "' and trp_totl='" + trp_totl +
                       "' where trp_ptID = '" + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
            Debug.Log(querySql);
            mysql.SimpleSql(querySql);
        }
        mysql.Close();
    }
Ejemplo n.º 11
0
    /// <summary>
    /// 按下Add Patient按钮
    /// </summary>
    public void AddPatient(string pt_id, string pt_name, string pt_sex, string pt_tele)
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string ptID   = pt_id;
        string ptName = pt_name;
        string ptSex  = pt_sex;
        string ptTele = pt_tele;
        int    flag   = 1;    // 1可添加,0不可添加

        if (ptID == "" | ptName == "")
        {
            flag = 0;
            Debug.Log("患者编号和姓名不能为空");
        }
        if (ptID != "")
        {
            string    query = "select * from ppl where ppl_id = " + ptID;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count == 0)
            {
                flag = 0;
                Debug.Log("患者编号不在人员表中");
            }
        }
        if (flag == 1)
        {
            string  query  = "insert into pat values ('" + ptID + "','" + ptName + "','" + ptSex + "','" + ptTele + "','" + ptID + "','" + dcID + "',1)";
            DataSet ds     = mysql.QuerySet(query);
            string  query1 = "update ppl set ppl_act = 1 where ppl_id = '" + ptID + "'";
            DataSet ds1    = mysql.QuerySet(query1);
            Debug.Log("添加患者账号成功,患者编号:" + ptID);
        }
        mysql.Close();
    }
Ejemplo n.º 12
0
    /// <summary>
    /// 查询某个医生的所有患者,返回患者编号、姓名、性别、电话
    /// </summary>
    public DataTable QueryPatient()
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "select pt_id, pt_name, pt_sex, pt_tele from pat where pt_dcID = '" + dcID + "' and pt_ex = 1";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
        return(table);
    }
Ejemplo n.º 13
0
    //增
    public void addStandardAction(string next_id, string actionName, string picPath)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        string next_pic   = next_id + ".jpg";
        string next_left  = next_id + "0.json";
        string next_right = next_id + "1.json";

        mysql.OpenSql();
        uploadPicture(next_id, picPath);
        uploadActions(next_id, "0");
        uploadActions(next_id, "1");
        string querySql = "insert into act(ac_id, ac_name, ac_pic, ac_left, ac_right) values(";

        querySql = querySql + "'" + next_id + "', '" + actionName + "', '" + next_pic + "', '" + next_left + "', '" + next_right + "')";
        Debug.Log(querySql);
        //Debug.Log("next_pic: " + next_pic + " next left: " + next_left + " next right: " + next_right);
        mysql.SimpleSql(querySql);
        mysql.Close();
    }
Ejemplo n.º 14
0
    void testMysql()
    {
        DataSet ds = mysql.SimpleSql("Select * from act");

        if (ds != null)
        {
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                for (int j = 0; j < ds.Tables[0].Rows[i].ItemArray.Length; j++)
                {
                    Debug.Log("Result" + i + ":" + ds.Tables[0].Rows[i][j]);
                }
            }
        }
        else
        {
            Debug.Log("无结果");
        }
        mysql.Close();
    }
Ejemplo n.º 15
0
    /// <summary>
    /// 删除患者
    /// </summary>
//	public void DeletePatient(string[] pt_id) {
    public void DeletePatient()
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
//		string[] ptID = pt_id;
        string[] ptID = { "300002", "300003" };
        for (int i = 0; i < ptID.Length; i++)
        {
            string  query = "update pat set pt_ex = 0 where pt_dcID = '" + dcID + "' and pt_id = '" + ptID [i] + "'";
            DataSet ds    = mysql.QuerySet(query);
        }
        mysql.Close();
    }
Ejemplo n.º 16
0
    /// <summary>
    /// 按下AddDoctor按钮
    /// </summary>
    public void AddDoctor(string dc_id, string dc_name, string dc_sex, string dc_pro, string dc_tele)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string dcID   = dc_id;
        string dcName = dc_name;
        string dcSex  = dc_sex;
        string dcPro  = dc_pro;
        string dcTele = dc_tele;

        int flag = 1;         // 1可添加,0不可添加

        if (dcID == "" | dcName == "")
        {
            flag = 0;
            Debug.Log("医生编号和姓名不能为空");
        }
        if (dcID != "")
        {
            string    query = "select * from ppl where ppl_id = " + dcID;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count == 0)
            {
                flag = 0;
                Debug.Log("医生编号不在人员表中");
            }
        }
        if (flag == 1)
        {
            string  query = "insert into doc values ('" + dcID + "','" + dcName + "','" + dcSex + "','" + dcPro + "','" + dcTele + "','" + dcID + "',1)";
            DataSet ds    = mysql.QuerySet(query);
            //			DataTable table = ds.Tables [0];
            string  query1 = "update ppl set ppl_act = 1 where ppl_id = '" + dcID + "'";
            DataSet ds1    = mysql.QuerySet(query1);
            Debug.Log("添加医生账号成功,医生编号:" + dcID);
        }
        mysql.Close();
    }
Ejemplo n.º 17
0
    //改
    public void changeStandardAction(string hand_id, string actionName, string picPath)
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string  querySql = "select ac_id from act where ac_id = '" + hand_id + "'";
        DataSet ds       = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count == 1)
        {
            uploadPicture(hand_id, picPath);
            uploadActions(hand_id, "0");
            uploadActions(hand_id, "1");
            querySql = "update act set ac_name = '" + actionName + "' where ac_id = '" + hand_id + "'";
            mysql.SimpleSql(querySql);
            Debug.Log("change already");
        }
        else
        {
            Debug.Log("无指定动作");
        }
        mysql.Close();
    }
Ejemplo n.º 18
0
    /// <summary>
    /// 按下Change Info按钮
    /// </summary>
    public void ChangeInfo(string pt_name, string pt_sex, string pt_tele)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string ptName = pt_name;
        string ptSex  = pt_sex;
        string ptTele = pt_tele;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "update pat set pt_name = '" + ptName + "', pt_sex = '" + ptSex + "', pt_tele = '" + ptTele + "' where pt_id = '" + ptID + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
    }
Ejemplo n.º 19
0
        internal static void TestFunc(MapSettingComponent mapSetting)
        {
            MySqlAccess mySqlAccess = new MySqlAccess("192.168.1.48", "5506", "ckz", "123456", "game_twin_cross");
            //mySqlAccess.CreateTable("game_test", new string[] { "Id", "Width", "Height" }, new string[] { "int", "int", "int" });
            var    data  = mySqlAccess.Select("adventure_map", new string[] { "*" }, new string[] { "" }, new string[] { "" }, new string[] { "" }).Tables[0];
            string field = "";

            foreach (var item in data.Columns)
            {
                field += $"{item}|";
            }
            Debug.Log(field);
            mySqlAccess.Close();

            #region 废弃的代码
            //var bgSet = mySqlAccess.Select("background", new string[] { "*" }, new string[] { "Id" }, new string[] { ">" }, new string[] { "0" });
            //mySqlAccess.Close();
            //for (int i = 0; i < bgSet.Tables[0].Rows.Count; i++)
            //{
            //    for (int j = 0; j < bgSet.Tables[0].Columns.Count; j++)
            //    {
            //        Debug.Log(bgSet.Tables[0].Rows[i][j]);
            //    }

            //}
            //if (!GameObject.Find($"Map-{mapSetting.MapId}"))
            //{
            //    Debug.Log("111");
            //    return;
            //}
            //var nodeComps = GameObject.Find($"Map-{mapSetting.MapId}").GetComponentsInChildren<NodeBaseComponent>();
            //foreach (var nodeComp in nodeComps)
            //{
            //    string outputJson = JsonConvert.SerializeObject(nodeComp.GetComponent<NodeBaseComponent>());
            //    File.AppendAllText("output.json", outputJson);
            //}
            #endregion
        }
Ejemplo n.º 20
0
    /// <summary>
    /// 按下Change Info按钮
    /// </summary>
    public void ChangeInfo(string dc_name, string dc_sex, string dc_pro, string dc_tele)
    {
        string dcID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            dcID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + dcID);

        string dcName = dc_name;
        string dcSex  = dc_sex;
        string dcPro  = dc_pro;
        string dcTele = dc_tele;

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string    query = "update doc set dc_name = '" + dcName + "', dc_sex = '" + dcSex + "', dc_pro = '" + dcPro + "', dc_tele = '" + dcTele + "' where dc_id = '" + dcID + "'";
        DataSet   ds    = mysql.QuerySet(query);
        DataTable table = ds.Tables [0];

        mysql.Close();
    }
Ejemplo n.º 21
0
    public static string[] deleteTrainingPlan(string trp_ptID, string trp_actID, int trp_hand)
    {
        string[] res = new string[1];
        res[0] = "null";
        MySqlAccess mysql = new MySqlAccess(host, port, userName, password, databaseName);

        mysql.OpenSql();
        string querySql = "select trp_ptID, trp_actID, trp_hand from trp where trp_ptID = '"
                          + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
        DataSet ds = mysql.SimpleSql(querySql);

        if (ds.Tables[0].Rows.Count != 0)
        {
            res      = new string[3];
            res[0]   = ds.Tables[0].Rows[0][0].ToString();
            res[1]   = ds.Tables[0].Rows[0][1].ToString();
            res[2]   = ds.Tables[0].Rows[0][2].ToString();
            querySql = "delete from trp where trp_ptID = '" + trp_ptID + "' and trp_actID = '" + trp_actID + "' and trp_hand = '" + trp_hand + "'";
            Debug.Log(querySql);
            mysql.SimpleSql(querySql);
        }
        mysql.Close();
        return(res);
    }
Ejemplo n.º 22
0
    /// <summary>
    /// 按下Login按钮
    /// </summary>
    public void LoginButton()
    {
        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();
        string id   = userNameField.text;
        string pswd = passwordNameField.text;

        if (id [0] == '1')
        {
            //管理员
            string    query = "select * from adm where adm_id = " + id + " and adm_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("管理员" + id + ",登录成功!");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("管理员,登录失败,没有此账号或密码错误!");
            }
        }
        else if (id [0] == '2')
        {
            //医生
            string    query = "select * from doc where dc_id = " + id + " and dc_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("医生" + id + ",登录成功!");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("医生,登录失败,没有此账号或密码错误!");
            }
        }
        else if (id [0] == '3')
        {
            //患者
            string    query = "select * from pat where pt_id = " + id + " and pt_pswd = " + pswd;
            DataSet   ds    = mysql.QuerySet(query);
            DataTable table = ds.Tables [0];
            if (table.Rows.Count != 0)
            {
                Debug.Log("患者" + id + ",登录成功");
                PlayerPrefs.SetString("userID", userNameField.text);
            }
            else
            {
                Debug.Log("患者,登录失败,没有此账号或密码错误!");
            }
        }
        else
        {
            Debug.Log("用户账号类型错误!");
        }
        mysql.Close();
    }
Ejemplo n.º 23
0
    /// <summary>
    /// 按下UpdatePswd按钮
    /// </summary>
    public void UpdatePassword(string first_pswd, string second_pswd)
    {
        string userID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            userID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + userID);

        mysql = new MySqlAccess(host, port, userName, password, databaseName);
        mysql.OpenSql();

        string firstPswd  = first_pswd;
        string secondPswd = second_pswd;

        int flag = 0;

        Debug.Log(firstPswd + " " + secondPswd);
        if (firstPswd.Length < 6 || firstPswd.Length > 20)
        {
            flag = 0;
            Debug.Log("密码长度应为6~20个字符");
        }
        else
        {
            string query = "";
            if (userID[0] == '1')
            {
                query = "select adm_pswd from adm where adm_id = '" + userID + "'";
            }
            else if (userID[0] == '2')
            {
                query = "select dc_pswd from doc where dc_id = '" + userID + "'";
            }
            else if (userID[0] == '3')
            {
                query = "select pt_pswd from pat where pt_id = '" + userID + "'";
            }
            DataSet   ds         = mysql.QuerySet(query);
            DataTable table      = ds.Tables [0];
            string    beforePswd = table.Rows[0][0].ToString();
            Debug.Log("beforePswd" + beforePswd);
            if (beforePswd == firstPswd)
            {
                flag = 0;
                Debug.Log("新密码不可与原密码相同");
            }
            else
            {
                if (firstPswd != secondPswd)
                {
                    flag = 0;
                    Debug.Log("两次密码不一致");
                }
                else
                {
                    flag = 1;
                }
            }
        }
        if (flag == 1)
        {
            string query = "";
            if (userID[0] == '1')
            {
                query = "update adm set adm_pswd = '" + firstPswd + "' where adm_id = '" + userID + "'";
            }
            else if (userID[0] == '2')
            {
                query = "update doc set dc_pswd = '" + firstPswd + "' where dc_id = '" + userID + "'";
            }
            else if (userID[0] == '3')
            {
                query = "update pat set pt_pswd = '" + firstPswd + "' where pt_id = '" + userID + "'";
            }
            DataSet ds = mysql.QuerySet(query);
            Debug.Log("修改密码成功,新密码为:" + firstPswd);
        }
        mysql.Close();
    }
Ejemplo n.º 24
0
    public string[,] SelectRecords(string start_date, string end_date)
    {
        string ptID = "";

        if (PlayerPrefs.HasKey("userID"))
        {
            ptID = PlayerPrefs.GetString("userID");
        }
        Debug.Log("userID" + ptID);

        string nowTime;

        nowTime = DateTime.Now.ToString("yyyyMMdd");
        int nowTimeInt = Convert.ToInt32(nowTime);

//		Debug.Log ("nowTime" + nowTime);

        string[,] res = new string[1, 1];
        res [0, 0]    = "";
        int startDateInt = Convert.ToInt32(start_date);
        int endDateInt   = Convert.ToInt32(end_date);

        if (startDateInt > endDateInt)
        {
            Debug.Log("开始日期大于结束日期!");
        }
        else if (startDateInt > nowTimeInt || endDateInt > nowTimeInt)
        {
            Debug.Log("开始日期或结束日期大于今日日期!");
        }
        else
        {
            mysql = new MySqlAccess(host, port, userName, password, databaseName);
            mysql.OpenSql();

            string    query   = "select rec_date, ac_id, ac_name, rec_hand from rec,act where ac_id = rec_actID and rec_ptID = '" + ptID + "' and rec_date >= '" + start_date + "' and rec_date <= '" + end_date + "'";
            DataSet   ds      = mysql.QuerySet(query);
            DataTable table   = ds.Tables [0];
            int       row_num = table.Rows.Count;
            if (row_num != 0)
            {
                int col_num = table.Rows [0].ItemArray.Length;
                res = new string[row_num, col_num];
                for (int i = 0; i < row_num; i++)
                {
                    for (int j = 0; j < col_num; j++)
                    {
                        res [i, j] = table.Rows [i] [j].ToString();
                    }
                }
            }
            mysql.Close();
            int row = res.GetLength(0);
            int col = res.GetUpperBound(res.Rank - 1) + 1;
            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < col; j++)
                {
                    Debug.Log(res [i, j]);
                }
            }
        }
        return(res);
    }
Ejemplo n.º 25
0
        /************************ Section 结构 ************************
         * Content-Length: 60408
         * Content-Type:multipart/form-data; boundary=ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC
         *
         * --ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC
         * Content-Disposition: form-data; name="fixedvolume"
         *
         * photo
         * --ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC
         * Content-Disposition: form-data;name="72 x 72 (.png)"; filename="photo.jpg"
         * Content-Type: application/octet-stream
         * Content-Transfer-Encoding: binary
         *
         * ... binary data of the jpg ...
         * --ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC
         * Content-Disposition: form-data;name="thumbnail"; filename="thumbnail.jpg"
         * Content-Type: application/octet-stream
         * Content-Transfer-Encoding: binary
         *
         * ... binary data of the jpg ...
         * --ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC
         * Content-Disposition: form-data;name="00:00:06 (480 x 288)"; filename="ImageStabilization.wmv"
         * Content-Type: application/octet-stream
         * Content-Transfer-Encoding: binary
         *
         * ... binary data ...
         * --ZnGpDtePMx0KrHh_G0X99Yef9r8JZsRJSXC--
         ****************************/

        public async Task Handle()
        {
            // 读取boundary
            var boundary = _context.Request.GetMultipartBoundary();

            if (string.IsNullOrEmpty(boundary))
            {
                // 不支持的媒体类型
                _context.Response.StatusCode = 415;
                Log.Information("无Boundary,上传失败");
                return;
            }

            SortedSetCache cache = null;

            _db = new MySqlAccess(false);

            // 记录已成功接收的文件,以备后续异常时删除这些文件
            List <FileDesc> sucFiles = new List <FileDesc>();

            try
            {
                var reader  = new MultipartReader(boundary, _context.Request.Body);
                var section = await reader.ReadNextSectionAsync(_context.RequestAborted);

                var fmSection = section.AsFormDataSection();
                if (fmSection != null && fmSection.Name == "fixedvolume")
                {
                    // 选择固定卷
                    _volume = (await fmSection.GetValueAsync()).ToLower();
                    if (!Cfg.FixedVolumes.Contains(_volume))
                    {
                        // 无此固定卷,状态码:未满足前提条件
                        _context.Response.StatusCode = 412;
                        Log.Information("不存在固定卷 {0},上传失败!", _volume);
                        return;
                    }
                    section = await reader.ReadNextSectionAsync(_context.RequestAborted);
                }
                else
                {
                    // 选择正在使用数最低的卷
                    cache   = new SortedSetCache(Cfg.VolumeKey);
                    _volume = await cache.GetMin();

                    // 该卷使用数加1
                    await cache.Increment(_volume);
                }

                // Section顺序:固定路径(可无),文件,文件,缩略图,文件
                // 缩略图由客户端生成,因提取视频帧耗资源,属于前面的文件
                FileDesc lastFile = null;
                while (section != null)
                {
                    var fileSection = section.AsFileSection();
                    if (fileSection != null)
                    {
                        if (fileSection.Name == "thumbnail")
                        {
                            if (lastFile != null)
                            {
                                // 将缩略图复制到同路径
                                // 命名规则:原文件名添加后缀"-t.jpg",如 143203944767549440.wmv-t.jpg
                                string fullPath = Path.Combine(Cfg.Root, lastFile.Path + Cfg.ThumbPostfix);
                                try
                                {
                                    using (var writeStream = File.Create(fullPath))
                                    {
                                        await fileSection.FileStream.CopyToAsync(writeStream, _bufferSize, _context.RequestAborted);
                                    }
                                }
                                catch { }
                                lastFile = null;
                            }
                        }
                        else
                        {
                            lastFile = await ReceiveFile(fileSection);

                            sucFiles.Add(lastFile);
                        }
                    }
                    section = await reader.ReadNextSectionAsync(_context.RequestAborted);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "处理上传文件异常");
                _result.Clear();

                if (sucFiles.Count > 0)
                {
                    // 删除已上传成功的文件和记录
                    StringBuilder sb = new StringBuilder();
                    foreach (var desc in sucFiles)
                    {
                        FileInfo fi = new FileInfo(Path.Combine(Cfg.Root, desc.Path));
                        if (fi.Exists)
                        {
                            try
                            {
                                fi.Delete();
                            }
                            catch { }
                        }
                        sb.Append(',');
                        sb.Append(desc.ID);
                    }

                    try
                    {
                        await _db.Exec($"delete from fsm_file where id in ({sb.ToString().TrimStart(',')})");
                    }
                    catch { }
                }
            }
            finally
            {
                await _db.Close(true);

                // 卷使用数减1
                if (cache != null)
                {
                    await cache.Decrement(_volume);
                }
            }

            await Response();
        }
Ejemplo n.º 26
0
    private void Awake()
    {
        Debug.Log("start database");
        m_player = new PlayerConfig[3];
        for (int i = 0; i < 3; i++)
        {
            m_player[i] = new PlayerConfig();
        }
        mySql = new MySqlAccess("localhost", "root", "klcklc", "gamedata");
        mySql.Close();
        mySql.OpenSql();
        DataSet ds = mySql.SelectAll("user");

        if (ds != null)
        {
            DataTable table = ds.Tables[0];
            foreach (DataRow row in table.Rows)
            {
                int    p   = 0;
                string log = "";
                foreach (DataColumn column in table.Columns)
                {
                    p++;
                    log += (" " + row[column]);
                    if (p == 1)
                    {
                        Debug.Log(log);
                        m_player[playernum].idUser = (int)row[column];
                    }
                    else if (p == 2)
                    {
                        Debug.Log(log);
                        m_player[playernum].Int_Gold = (int)row[column];
                    }
                    else if (p == 3)
                    {
                        Debug.Log(log);
                        m_player[playernum].int_Lvl = (int)row[column];
                    }
                    // gold = (int)row[column];
                }
                playernum++;
                Debug.Log(log + "row end!");
            }
        }
        mySql.Close();

        /*
         * mySql.OpenSql();
         * ds = mySql.Select("user", new string[] { "User_Gold" }, new string[] { "" }, new string[] { "" }, new string[] { "" });
         * if (ds != null)
         * {
         *  DataTable table = ds.Tables[0];
         *  foreach (DataRow row in table.Rows)
         *  {
         *      playernum++;
         *      foreach (DataColumn column in table.Columns)
         *      {
         *          Debug.Log(row[column]);
         *          gold = (int)row[column];
         *      }
         *  }
         * }
         * mySql.Close();*/
    }