コード例 #1
0
ファイル: SlaveInfoService.cs プロジェクト: liusile/WGProject
 /// <summary>
 /// 持久化数据到数据库
 /// </summary>
 public void SaveAync()
 {
     using (var db = new SortingDbContext())
     {
         var slave = db.SlaveInfo.Include("LatticeInfo").Include("LatticeInfo.Product").FirstOrDefault(o => o.Id == SlaveInfo.Id);
         if (slave == null)
         {
             return;
         }
         slave.IsCompleteHand = SlaveInfo.IsCompleteHand;
         SlaveInfo.LatticeInfo.ForEach(o =>
         {
             var lattice     = slave.LatticeInfo.First(b => b.LatticeNo == o.LatticeNo);
             lattice.OrderNo = o.OrderNo;
             lattice.Status  = o.Status;
             lattice.IsPrint = o.IsPrint;
             o.Product.ForEach(p =>
             {
                 var product = lattice.Product.FirstOrDefault(i => i.BarCode == p.BarCode);
                 if (product == null)
                 {
                     lattice.Product.Add(p);
                 }
                 else
                 {
                     product.PutNum = p.PutNum;
                     product.Status = p.Status;
                 }
             });
         });
         db.SlaveInfo.AddOrUpdate(slave);
         db.SaveChangesAsync();
     }
 }
コード例 #2
0
ファイル: UserService.cs プロジェクト: liusile/WGProject
 public void UpdateRemeberUserName(Domain.Models.UserInfo userInfo, string email)
 {
     using (var db = new SortingDbContext())
     {
         var user = db.UserInfo.FirstOrDefault(o => o.UserId == userInfo.UserId);
         if (user == null)
         {
             db.UserInfo.Add(new Domain.Models.UserInfo
             {
                 IsRemeberUserName = true,
                 LastLoginTime     = DateTime.Now,
                 Pcid     = userInfo.Pcid,
                 PcName   = userInfo.PcName,
                 UserId   = userInfo.UserId,
                 UserName = userInfo.UserName,
                 Email    = email
             });
             db.SaveChangesAsync();
         }
         else
         {
             user.LastLoginTime     = DateTime.Now;
             user.IsRemeberUserName = true;
             db.UserInfo.AddOrUpdate(user);
             db.SaveChanges();
         }
     }
 }
コード例 #3
0
ファイル: SlaveInfoService.cs プロジェクト: liusile/WGProject
 /// <summary>
 /// 清楚历史旧数据
 /// </summary>
 /// <param name="PreDay"></param>
 public void ClearDataAsync(int PreDay = 7)
 {
     using (var db = new SortingDbContext())
     {
         var date     = DateTime.Now.AddDays(-PreDay);
         var waveList = db.WaveApi.Include("OrderApi").Include("OrderApi.ProductApi").Where(o => o.LastTime <= date);
         var slave    = db.SlaveInfo.Join(waveList, s => s.WaveNo, w => w.WaveNo, (s, w) => s).Include("LatticeInfo").Include("LatticeInfo.Product");
         db.WaveApi.RemoveRange(waveList);
         db.SlaveInfo.RemoveRange(slave);
         db.SaveChangesAsync();
     }
 }