Ejemplo n.º 1
0
 private void synchronizeData()
 {
     Data.PoliceModel.SessionModel session = Data.CenterDataFactory.KeyTable();
     Data.CenterDataFactory.BlackName(session.Id);
     Data.CenterDataFactory.WhiteName(session.Id, session.Name);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 同步比赛
        /// </summary>
        public static PoliceModel.SessionModel KeyTable()
        {
            LogManager.WriteLog("开始同步比赛数据");
            int session_id = 0;

            PoliceModel.SessionModel session = new PoliceModel.SessionModel();
            try
            {
                string searchSql = @"select * FROM sessions WHERE `status` = 0 ";

                DataTable sessiondt = MySqlDBHelper.ExecuteDataTable(centerCon, searchSql);

                if (sessiondt.Rows.Count > 0)
                {
                    DataRow sessiondataRow = sessiondt.Rows[0];
                    session_id   = Convert.ToInt32(sessiondataRow["session_id"]);
                    session.Id   = session_id;
                    session.Name = sessiondataRow["session_name"].ToString();

                    LogManager.WriteLog("比赛场次:" + sessiondataRow["session_name"].ToString());

                    string deleteSql = "DELETE FROM key_table where session_id =" + session_id + "; DELETE FROM sessions where session_id =" + session_id + ";";
                    MySqlDBHelper.ExecuteNonQuery(entranceCon, CommandType.Text, deleteSql);


                    string sessionInsertSql = @"INSERT INTO `sessions` 
                (`session_id`,`create_date`,`session_name`,`session_date`,`date_start`,`date_end`,`check_rule`,`status`,`remark`) VALUES 
                (@session_id,@create_date,@session_name,@session_date,@date_start,@date_end,@check_rule,@status,@remark)";

                    MySqlParameter[] mySqlParameters = new MySqlParameter[9];
                    mySqlParameters[0] = new MySqlParameter("session_id", sessiondataRow["session_id"]);
                    mySqlParameters[1] = new MySqlParameter("create_date", sessiondataRow["create_date"]);
                    mySqlParameters[2] = new MySqlParameter("session_name", sessiondataRow["session_name"]);
                    mySqlParameters[3] = new MySqlParameter("session_date", sessiondataRow["session_date"]);
                    mySqlParameters[4] = new MySqlParameter("date_start", sessiondataRow["date_start"]);
                    mySqlParameters[5] = new MySqlParameter("date_end", sessiondataRow["date_end"]);
                    mySqlParameters[6] = new MySqlParameter("check_rule", sessiondataRow["check_rule"]);
                    mySqlParameters[7] = new MySqlParameter("status", sessiondataRow["status"]);
                    mySqlParameters[8] = new MySqlParameter("remark", sessiondataRow["remark"]);

                    MySqlDBHelper.ExecuteNonQuery(entranceCon, CommandType.Text, sessionInsertSql, mySqlParameters);

                    string keysearchSql = @"select * FROM key_table WHERE `session_id` = " + session_id;

                    DataTable keytabledt = MySqlDBHelper.ExecuteDataTable(centerCon, keysearchSql);

                    if (keytabledt.Rows.Count > 0)
                    {
                        DataRow row = keytabledt.Rows[0];

                        string keytableInsertSql = @"INSERT INTO 
                `key_table` (`key_id`,`create_date`,`session_id`,`key_content`,`key_type`,`remark`) 
                VALUES (@key_id,@create_date,@session_id,@key_content,@key_type,@remark)";

                        MySqlParameter[] keySqlParameters = new MySqlParameter[6];

                        keySqlParameters[0] = new MySqlParameter("key_id", row["key_id"]);
                        keySqlParameters[1] = new MySqlParameter("create_date", row["create_date"]);
                        keySqlParameters[2] = new MySqlParameter("session_id", row["session_id"]);
                        keySqlParameters[3] = new MySqlParameter("key_content", row["key_content"]);
                        keySqlParameters[4] = new MySqlParameter("key_type", row["key_type"]);
                        keySqlParameters[5] = new MySqlParameter("remark", row["remark"]);

                        MySqlDBHelper.ExecuteNonQuery(entranceCon, CommandType.Text, keytableInsertSql, keySqlParameters);
                    }
                }
                LogManager.WriteLog("同步比赛数据完成");
            }
            catch (Exception ex)
            {
                LogManager.WriteLog("同步比赛数据异常:" + ex.Message);
            }
            return(session);
        }