Пример #1
0
        public static void saveToSqlite(CUploadData d)
        {
            string sql = string.Format("INSERT INTO UploadData(Guid,Data,IsUpload,CreateTime,HU) VALUES('{0}','{1}',0,'{2}')", d.Guid
                                       , JsonConvert.SerializeObject(d.Data), d.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), d.HU);
            int result = SqliteDBHelp.ExecuteSql(sql);

            if (result <= 0)
            {
                Log4netHelper.LogInfo(JsonConvert.SerializeObject(d.Data));
            }
        }
Пример #2
0
        public static List <CUploadData> GetExpUploadFromSqlite <T>()
        {
            List <CUploadData> result = new List <CUploadData>();

            string    sql = string.Format("SELECT * FROM UploadData where IsUpload = 1 order by CreateTime");
            DataTable dt  = SqliteDBHelp.GetTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    CUploadData ud = new CUploadData();
                    ud.Guid       = row["Guid"].ToString();
                    ud.Data       = JsonConvert.DeserializeObject <T>(row["Data"].ToString());
                    ud.IsUpload   = uint.Parse(row["IsUpload"].ToString());
                    ud.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
                    ud.HU         = row["HU"].ToString();
                    ud.MSG        = row["MSG"].ToString();
                    result.Add(ud);
                }
                return(result);
            }
            return(result);
        }