SaveMattressInterfaceExcutor.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using DirectService.Tools;
  7. using JLHHJSvr.BLL;
  8. using JLHHJSvr.Com;
  9. using JLHHJSvr.Com.Model;
  10. using JLHHJSvr.Helper;
  11. using JLHHJSvr.LJException;
  12. using JLHHJSvr.LJFramework.Tools;
  13. using JLHHJSvr.Tools;
  14. using LJLib.DAL.SQL;
  15. using LJLib.Net.SPI.Server;
  16. namespace JLHHJSvr.Excutor
  17. {
  18. internal sealed class SaveMattressInterfaceExcutor : ExcutorBase<SaveMattressInterfaceRequest, SaveMattressInterfaceResponse>
  19. {
  20. Dictionary<string, object> replacements = new Dictionary<string, object>();
  21. protected override void ExcuteInternal(SaveMattressInterfaceRequest request, object state, SaveMattressInterfaceResponse rslt)
  22. {
  23. var tokendata = BllHelper.GetToken(request.token);
  24. if (tokendata == null)
  25. {
  26. rslt.ErrMsg = "会话已经中断,请重新登录";
  27. return;
  28. }
  29. if (request.mattress == null)
  30. {
  31. rslt.ErrMsg = "缺少主表信息";
  32. return;
  33. }
  34. if (request.interfaceList == null || !request.interfaceList.Any())
  35. {
  36. rslt.ErrMsg = "缺少产品配置明细";
  37. return;
  38. }
  39. if (request.qdList == null || !request.qdList.Any())
  40. {
  41. rslt.ErrMsg = "缺少产品清单明细";
  42. return;
  43. }
  44. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  45. using (var cmd = con.CreateCommand())
  46. {
  47. con.Open();
  48. // 初始化属性
  49. AutoInit.AutoInitS(cmd, request.mattress);
  50. foreach (var mx in request.interfaceList)
  51. {
  52. AutoInit.AutoInitS(cmd, mx);
  53. }
  54. foreach (var mx in request.qdList)
  55. {
  56. AutoInit.AutoInitS(cmd, mx);
  57. }
  58. var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
  59. using (cmd.Transaction = con.BeginTransaction())
  60. {
  61. try
  62. {
  63. interfaceHelper.SaveMattressInterface(request.mattress, request.interfaceList, request.qdList);
  64. cmd.Transaction.Commit();
  65. }
  66. catch (Exception e)
  67. {
  68. cmd.Transaction.Rollback();
  69. rslt.ErrMsg = e.ToString();
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }