Exemple #1
0
//        static public void InsertXGData( XGData data )
//        {
//            //2007.03.11 replace with InsertXGData ( string remoteIP, XGData data )
//            throw new NotImplementedException ( "insertXGData( XGData data" );
//
//            ArgumentChecker.CheckNotNull( data );
//            string s = string.Format( @"insert into tbl_xgdata(station_address, card_sn, station_time,
//                computer_time, isAuto)
//                values({0}, '{1}', '{2}', '{3}', {4})", data.FromAddress, data.CardSN, data.XGStationDateTime,
//                data.DateTime, data.IsAutoReport ? 1 : 0 );
//
//            DbClient.ExecuteNonQuery( s );
//        }

        /// <summary>
        /// insert a xg data to tbl_xgdata
        /// </summary>
        /// <param name="remoteIP"> form gprs station ip</param>
        /// <param name="data"> xg data </param>
        static public void InsertXGData(string remoteIP, XGData data)
        {
            ArgumentChecker.CheckNotNull(data);

            // find xgstation_id with remoteIP, id not find xgstation_id then return
            //
            int xgStId = XGDB.GetXGStaionID(remoteIP, data.FromAddress);

            // 2007-10-25 Added not find xgStId
            //
            if (xgStId == 0)
            {
                return;
            }

            // find card_id and person with card sn, if not find
            // card sn then the sn to tbl_card and return the id
            //
            int    cardId;
            string person;

            bool b = XGDB.GetCardIdAndPerson(data.CardSN, true, out cardId, out person);

            if (b)
            {
                // insert xgdata to tbl_xgdata
                //
                string sql = string.Format(@"insert into tbl_xgdata ( xgstation_id, card_id, xgtime, person ) 
                    values ( {0}, {1}, '{2}', '{3}')",
                                           xgStId, cardId, data.XGStationDateTime, person);

                DbClient.ExecuteNonQuery(sql);
            }
        }