SetOptionExcutor.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using JLHHJSvr.BLL;
  7. using JLHHJSvr.Com;
  8. using JLHHJSvr.DBA.DBModle;
  9. using LJLib.Net.SPI.Server;
  10. namespace JLHHJSvr.Excutor
  11. {
  12. internal sealed class SetOptionExcutor : ExcutorBase<SetOptionRequest, SetOptionResponse>
  13. {
  14. protected override void ExcuteInternal(SetOptionRequest request, object state, SetOptionResponse rslt)
  15. {
  16. var tokendata = BllHelper.GetToken(request.token);
  17. if (tokendata == null)
  18. {
  19. rslt.ErrMsg = "会话已经中断,请重新登录";
  20. return;
  21. }
  22. if (request.optionInfo.optionid == null || request.optionInfo.optionid == 0)
  23. {
  24. rslt.ErrMsg = "信息缺失:ID";
  25. return;
  26. }
  27. if (request.optionInfo.optionvalue == null)
  28. {
  29. rslt.ErrMsg = "信息缺失:值";
  30. return;
  31. }
  32. using (var con = new SqlConnection(GlobalVar.ConnectionString))
  33. using (var cmd = con.CreateCommand())
  34. {
  35. con.Open();
  36. using (cmd.Transaction = con.BeginTransaction())
  37. {
  38. try
  39. {
  40. var stOption = new st_option();
  41. stOption.SetValue(cmd, request.optionInfo.optionid.Value, request.optionInfo.optionvalue,
  42. tokendata.username);
  43. cmd.Transaction.Commit();
  44. }
  45. catch (Exception e)
  46. {
  47. cmd.Transaction.Rollback();
  48. rslt.ErrMsg = e.ToString();
  49. return;
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }