Esempio n. 1
0
        private void WriteBack(List <string> list)
        {
            try
            {
                LogHandler.Log("开始回写SQLSERVER");
                DYJXCEntities db   = new DYJXCEntities();
                var           data = (from d in db.t_HK_PGData
                                      where list.Contains(d.batch_no)
                                      select d).ToList();

                data.ForEach(p =>
                {
                    db.t_HK_PGData.Attach(p);
                    p.IsSync          = true;
                    db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                });

                db.SaveChanges();
            }
            catch (Exception ex)
            {
                LogHandler.Error("回写发生错误:\r\n" + ex.InnerException);
                list.ForEach(p =>
                {
                    MySQLWriter db = new MySQLWriter();
                    db.Delete(p);
                });
            }
        }
Esempio n. 2
0
 private List <t_HK_PGData> Check()
 {
     LogHandler.Log("检查需要同步的数据");
     try
     {
         DYJXCEntities db     = new DYJXCEntities();
         var           result = db.t_HK_PGData.Where(p => !p.IsSync).ToList();
         LogHandler.Log(string.Format("发现待同步数据{0}条", result.Count));
         return(result);
     }
     catch (Exception ex)
     {
         LogHandler.Error("发生错误:" + ex.InnerException);
     }
     return(null);
 }