DeleteSoftBedQuoteExcutor.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using System.Linq;
  3. using JLHHJSvr.BLL;
  4. using JLHHJSvr.Com;
  5. using JLHHJSvr.Helper;
  6. using JLHHJSvr.LJException;
  7. using LJLib.DAL.SQL;
  8. using LJLib.Net.SPI.Server;
  9. using LJLib.SQLEX;
  10. namespace JLHHJSvr.Excutor
  11. {
  12. internal sealed class DeleteSoftBedQuoteExcutor : ExcutorBase<DeleteSoftBedQuoteRequest, DeleteSoftBedQuoteResponse>
  13. {
  14. protected override void ExcuteInternal(DeleteSoftBedQuoteRequest request, object state, DeleteSoftBedQuoteResponse rslt)
  15. {
  16. var tokendata = BllHelper.GetToken(request.token);
  17. if (!request.list.Any())
  18. {
  19. rslt.ErrMsg = "至少提交一条需要删除的记录";
  20. return;
  21. }
  22. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  23. using (var cmd = con.CreateCommand())
  24. {
  25. con.Open();
  26. var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd,new HelperBase.Context() { tokendata = tokendata });
  27. using (cmd.Transaction = con.BeginTransaction())
  28. {
  29. try
  30. {
  31. foreach(var mx in request.list)
  32. {
  33. softBedHelper.DeleteSoftBed(mx.softbed_id);
  34. }
  35. cmd.Transaction.Commit();
  36. }
  37. catch (Exception e)
  38. {
  39. cmd.Transaction?.Rollback();
  40. rslt.ErrMsg = e.Message;
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }