Beispiel #1
0
    /// <summary>
    /// 学员登陆成功后,写入登陆记录
    /// </summary>
    /// <param name="_obj">收到的json数据</param>
    /// <param name="_sendback">反馈接口</param>
    public static void fns_loadStart(string _obj, I_sendBackClient _sendback)
    {
        //lock (m_lock02)
        //{

        new Task(() =>
        {
            I_sendBackClient t_send     = _sendback;
            N_msg_loadStart t_userstart = JsonMapper.ToObject <N_msg_loadStart>(_obj);
            if (t_userstart != null)
            {
                //组装写入信息语句,
                Task <string> t_makeCmd = new Task <string>(() =>
                {
                    return(S_makeCmd.fns_insert_load_record("xian_user_load_record_1", "studentID", t_userstart.m_studentID));
                });
                t_makeCmd.Start();
                //写入登陆记录
                string t_cmd = t_makeCmd.Result;
                new Task(() =>
                {
                    S_useMysql.fns_insertMsg(t_cmd, "xian_user_load_record_1", t_send);
                }).Start();
            }
        }).Start();
    }
Beispiel #2
0
    /// <summary>
    /// 创建数据库连接
    /// </summary>
    //private static A_connectTodata m_dataBase = new N_connectTodata();
    //private static readonly object m_locker01 = new object();
    /// <summary>
    /// 查询表,用户名,和密码,返回登陆是否成功
    /// </summary>
    /// <param name="_sendback"></param>
    public static void fns_canLoad(string _name, string _pass, string _macID, I_sendBackClient _sendback)
    {
        //lock (m_locker01)
        //{
        string           t_name = _name;
        string           t_pass = _pass;
        I_sendBackClient t_send = _sendback;
        //查询数据库
        string        t_cmd;
        Task <string> t_getCmd = new Task <string>(() => {
            return(S_makeCmd.fns_readCmd2("xian_user_1", "studentID", t_name, "password", _pass));
        });

        t_getCmd.Start();
        t_cmd = t_getCmd.Result;
        //Console.WriteLine("cmd:" + t_cmd);
        //反馈结果
        N_msg_canLoad t_canload = null;

        //检查数据库中有没有账号信息
        if (S_sql.M_instance.fn_read(t_cmd))
        {    //这里还差限制一个账号只能登陆一次
            I_checkIsLoaded t_checkIsLoaded = S_sql.M_instance;
            if (!t_checkIsLoaded.fni_check(t_name))
            {     //没有发现登陆信息
                if (t_checkIsLoaded.fni_addIn(_macID, t_name))
                { //加入登陆队列成功
                    t_canload = new N_msg_canLoad(true);
                }
                else
                {
                    t_canload = new N_msg_canLoad(false);
                }
            }
            else      //登陆失败
            {
                t_canload = new N_msg_canLoad(false);
            }
            //t_canload = new N_msg_canLoad(true);
        }
        else
        {
            t_canload = new N_msg_canLoad(false);
        }

        if (t_canload != null)
        {
            if (t_send != null)
            {
                t_send.fn_sendback(JsonMapper.ToJson(t_canload));
            }
        }


        //}
    }
Beispiel #3
0
 /// <summary>
 /// 学习,练习,考试场景开始记录
 /// </summary>
 /// <param name="_obj">json 数据</param>
 /// <param name="_sendback">反馈接口</param>
 /// <param name="_tableName">要写入数据的表名</param>
 public static void fns_SPT_start(string _obj, I_sendBackClient _sendback, string _tableName)
 {
     if (_obj == "" || _sendback == null || _tableName == "")
     {
         return;
     }
     new Task(() =>
     {
         string t_jsondata                 = _obj;
         string t_table                    = _tableName;
         I_sendBackClient t_send           = _sendback;
         N_msg_SPT_start t_userstudy_start = JsonMapper.ToObject <N_msg_SPT_start>(t_jsondata);
         if (t_userstudy_start != null)
         {
             //组装写入信息语句,
             Task <string> t_makeCmd = new Task <string>(() =>
             {
                 if (_tableName == "study_load_1" || _tableName == "practise_load_1")
                 {
                     return(S_makeCmd.fns_study_insert <string, UInt16, Byte>(t_table,
                                                                              "studentID", t_userstudy_start.m_studentID,
                                                                              "chapterID", t_userstudy_start.m_chapterID,
                                                                              "lastStepID", t_userstudy_start.m_lastStepID,
                                                                              "allStep", t_userstudy_start.m_allStep,
                                                                              "progress", t_userstudy_start.m_progress
                                                                              ));
                 }
                 else if (_tableName == "test_load_1")
                 {
                     return(S_makeCmd.fns_study_insert <string, UInt16, Byte>(t_table,
                                                                              "studentID", t_userstudy_start.m_studentID,
                                                                              "chapterID", t_userstudy_start.m_chapterID,
                                                                              "lastStepID", t_userstudy_start.m_lastStepID,
                                                                              "allStep", t_userstudy_start.m_allStep,
                                                                              "score", t_userstudy_start.m_score
                                                                              ));
                 }
                 else
                 {
                     return("");
                 }
             });
             t_makeCmd.Start();
             //写入登陆记录
             string t_cmd = t_makeCmd.Result;
             new Task(() =>
             {
                 S_useMysql.fns_insertMsg(t_cmd, t_table, t_send);
             }).Start();
         }
     }).Start();
 }
Beispiel #4
0
 /// <summary>
 /// 学习场景结束学习
 /// </summary>
 /// <param name="_tableName">要写入数据的表名</param>
 public static void fns_SPT_end(string _obj, string _tableName)
 {
     new Task(() =>
     {
         string t_tablename = _tableName;
         //Console.WriteLine("表名=" + t_tablename);
         //I_sendBackClient t_send = _sendback;
         N_msg_SPT_end t_userend = JsonMapper.ToObject <N_msg_SPT_end>(_obj);
         if (t_userend != null)
         {
             //组装写入信息语句,
             Task <string> t_makeCmd = new Task <string>(() =>
             {
                 if (_tableName == "study_load_1" || _tableName == "practise_load_1")
                 {
                     return(S_makeCmd.fns_update3_1 <UInt16, Byte, string, uint>(_tableName,
                                                                                 " lastStepID", t_userend.m_lastID,
                                                                                 " progress ", t_userend.m_progress,
                                                                                 "finishTime", " now() ",
                                                                                 " id ", t_userend.m_id));
                 }
                 else if (_tableName == "test_load_1")
                 {
                     return(S_makeCmd.fns_update3_1 <UInt16, Byte, string, uint>(_tableName,
                                                                                 "lastStepID", t_userend.m_lastID,
                                                                                 "score", t_userend.m_score,
                                                                                 "finishTime", " now() ",
                                                                                 "id", t_userend.m_id));
                 }
                 else
                 {
                     return("");
                 }
             });
             t_makeCmd.Start();
             //写入登陆记录
             string t_cmd = t_makeCmd.Result;
             new Task(() =>
             {
                 if (t_cmd != "")
                 {
                     S_useMysql.fns_updateMsg(t_cmd);
                 }
             }).Start();
         }
     }).Start();
 }
Beispiel #5
0
 /// <summary>
 /// 插入内容,返回插入这条类容的自增id
 /// </summary>
 /// <param name="_cmd"></param>
 /// <returns>自增 id</returns>
 public uint fn_insert(string _cmd, string _tableName)
 {
     if (_cmd == "" || _tableName == "")
     {
         return(0);
     }
     lock (m_lockMysql)
     {
         string t_cmd       = _cmd;
         string t_tableName = _tableName;
         try
         {
             //开始写入
             t_cmdWrite.CommandText = t_cmd;
             int t_result = t_cmdWrite.ExecuteNonQuery();
             if (t_result > 0)
             {//插入成功
                 Console.WriteLine("插入成功");
                 string t_lastID = S_makeCmd.fns_lastID(t_tableName);
                 t_cmdRead.CommandText = t_lastID;
                 object t_value = t_cmdRead.ExecuteScalar();
                 if (t_value != null)
                 {
                     return((uint)t_value);
                 }
                 else
                 {
                     return(0);
                 }
             }
             else
             {
                 return(0);
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine("write" + ex.ToString());
             return(0);
             //throw;
         }
     }
     //return 0;
 }
Beispiel #6
0
 /// <summary>
 /// 练习,考试详细步骤的记录
 /// </summary>
 /// <param name="_obj">json数据</param>
 /// <param name="_tableName">表名</param>
 public static void fns_PT_stepRecord(string _obj, string _tableName)
 {
     if (_obj == "" || _tableName == "")
     {
         return;
     }
     new Task(() =>
     {
         string t_jsondata    = _obj;
         string t_table       = _tableName;
         N_msg_PT_step t_step = JsonMapper.ToObject <N_msg_PT_step>(t_jsondata);
         if (t_step != null)
         {
             //组装写入信息语句,
             Task <string> t_makeCmd = new Task <string>(() =>
             {
                 return(S_makeCmd.fns_insert_step(t_table,
                                                  "handleID", t_step.m_handleID,
                                                  "carName", t_step.m_carName,
                                                  "carDiscribe", t_step.m_carDiscribe,
                                                  "macName", t_step.m_macName,
                                                  "macDiscribe", t_step.m_macDiscribe,
                                                  "objID", t_step.m_objID,
                                                  "objDiscribe", t_step.m_objDiscribe,
                                                  "objState", t_step.m_objState
                                                  ));
             });
             t_makeCmd.Start();
             //写入登陆记录
             string t_cmd = t_makeCmd.Result;
             new Task(() =>
             {
                 if (t_cmd != "")
                 {
                     S_useMysql.fns_insertMsgNoBack(t_cmd, t_table);
                 }
             }).Start();
         }
     }).Start();
 }
Beispiel #7
0
 /// <summary>
 /// 学员退出登录,更新学员的登陆记录
 /// </summary>
 /// <param name="_obj">退出</param>
 /// <param name="_sendback"></param>
 public static void fns_loadEnd(string _obj, I_sendBackClient _sendback)
 {
     new Task(() =>
     {
         //I_sendBackClient t_send = _sendback;
         N_msg_loadEnd t_userend = JsonMapper.ToObject <N_msg_loadEnd>(_obj);
         if (t_userend != null)
         {
             //组装写入信息语句,
             Task <string> t_makeCmd = new Task <string>(() =>
             {
                 return(S_makeCmd.fns_update_load_record("xian_user_load_record_1", "id", t_userend.m_id));
             });
             t_makeCmd.Start();
             //写入登陆记录
             string t_cmd = t_makeCmd.Result;
             new Task(() =>
             {
                 S_useMysql.fns_updateMsg(t_cmd);
             }).Start();
         }
     }).Start();
 }