Esempio n. 1
0
        /// <summary>
        /// 向临时中专表中插入网关上传的数据
        /// </summary>
        /// <param name="info"></param>
        /// <param name="JsonSource"></param>
        /// <returns></returns>
        public static bool InsertGatewayDataToDB(MessageInfo info, string JsonSource)
        {
            string sql = string.Format(@"insert into GatewayData(BuildID,GatewayID,CollectTime,DatagramType,Status,JsonData)
                            values('{0}','{1}','{2}','{3}',{4},'{5}');", info.BuildID, info.GatewayID, ToolUtil.GetDateTimeFromString(info.MessageContent).ToString("yyyy-MM-dd HH:mm:ss"),
                                       info.MessageAttribute, 0, JsonSource);

            using (SQLiteConnection connection = new SQLiteConnection("Data Source=TempData;Version=3;"))
            {
                connection.Open();
                try
                {
                    SQLiteCommand command = new SQLiteCommand(sql, connection);
                    command.ExecuteNonQuery();
                }
                catch
                {
                    return(false);
                }
            }

            return(true);
        }