Ejemplo n.º 1
0
 public int SaveChanges()
 {
     try
     {
         return(Db.SaveChanges());
     }
     catch (DbUpdateConcurrencyException ex)
     {
         //A concurrency error occurred
         //Should handle intelligently
         Console.WriteLine(ex);
         throw;
     }
     catch (RetryLimitExceededException ex)
     {
         //DbResiliency retry limit exceeded
         //Should handle intelligently
         Console.WriteLine(ex);
         throw;
     }
     catch (Exception ex)
     {
         //Should handle intelligently
         Console.WriteLine(ex);
         throw;
         //-2146232060
         //throw new Exception($"{ex.HResult}");
     }
 }
Ejemplo n.º 2
0
 public ActionResult Add()
 {
     try
     {
         var StartTime = Convert.ToDateTime(Request["AddStartTime"]);
         var ClassName = Request["AddClassName"].ToString().Trim();
         //string[] CardId = Request["CardId"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         string[] AddInfo = Request["AddInfo"].ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         string[] info;
         if (AddInfo.Length > 0)
         {
             foreach (var item in AddInfo)
             {
                 info = item.Split('-');
                 ClockBatch model = new ClockBatch
                 {
                     guid           = Guid.NewGuid(),
                     EmployeeName   = info[1],
                     CardId         = info[0].Trim(),
                     ClassName      = ClassName,
                     StartClockTime = StartTime,
                     LastClockTime  = Convert.ToDateTime("2000-1-1 00:00"),
                     ClockState     = false,
                     FailedReason   = "新增的数据,还没有打卡记录!" + DateTime.Now.ToString(),
                     flag           = true
                 };
                 Db.ClockBatch.Add(model);
                 Db.Entry <ClockBatch>(model).State = EntityState.Added;
             }
         }
         if (Db.SaveChanges() > 0)
         {
             return(Json("OK"));
         }
         else
         {
             return(Json("添加失败"));
         }
     }
     catch (Exception ex)
     {
         return(Json($"添加失败,请检查数据格式,使用英文符号!异常信息:{ex}"));
     }
 }
Ejemplo n.º 3
0
 public int SaveChanges()
 {
     try
     {
         return(Db.SaveChanges());
     }
     catch (DbUpdateConcurrencyException ex)
     {
         //A concurrency error occurred
         Console.WriteLine(ex);
         throw;
     }
     catch (RetryLimitExceededException ex)
     {
         //DbResiliency retry limit exceeded
         Console.WriteLine(ex);
         throw;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         throw;
     }
 }