SetOptionExcutor.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. using LJLib.SQLEX;
  11. namespace JLHHJSvr.Excutor
  12. {
  13. internal sealed class SetOptionExcutor : ExcutorBase<SetOptionRequest, SetOptionResponse>
  14. {
  15. protected override void ExcuteInternal(SetOptionRequest request, object state, SetOptionResponse rslt)
  16. {
  17. var tokendata = BllHelper.GetToken(request.token);
  18. if (tokendata == null)
  19. {
  20. rslt.ErrMsg = "会话已经中断,请重新登录";
  21. return;
  22. }
  23. if (request.optionInfo.optionid == null || request.optionInfo.optionid == 0)
  24. {
  25. rslt.ErrMsg = "信息缺失:ID";
  26. return;
  27. }
  28. if (request.optionInfo.optionvalue == null)
  29. {
  30. rslt.ErrMsg = "信息缺失:值";
  31. return;
  32. }
  33. using (var con = GlobalVar.ConnectionString.NewSqlConnection())
  34. using (var cmd = con.CreateCommand())
  35. {
  36. con.Open();
  37. using (cmd.Transaction = con.BeginTransaction())
  38. {
  39. try
  40. {
  41. var stOption = new st_option();
  42. stOption.SetValue(cmd, request.optionInfo.optionid.Value, request.optionInfo.optionvalue,
  43. tokendata.username);
  44. cmd.Transaction.Commit();
  45. }
  46. catch (Exception e)
  47. {
  48. cmd.Transaction.Rollback();
  49. rslt.ErrMsg = e.ToString();
  50. return;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }