CancelTask.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Common.Wechat;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Text;
  7. using ZcPeng.PublicLibrary;
  8. namespace CoreEntity.TimeJob
  9. {
  10. public class CancelTask
  11. {
  12. public static int CancelRecord(string RecordId,out string result)
  13. {
  14. List<DataAccessCommand> list = new List<DataAccessCommand>();
  15. string IsCancel = "1";
  16. string SalemanAccountId = "1";
  17. #region 更新记录状态
  18. string commandTextStateR = "UPDATE " + Config.TablePrefix + "PushRecord " +
  19. " SET CancelTime = @CancelTime, " +
  20. " CancelPerson = @CancelPerson, " +
  21. " IsCancel = @IsCancel" +
  22. " WHERE Id = @RecordId " +
  23. " and (state IS NULL or state = 0) or state in(2) " +
  24. " and IsCancel = " + (IsCancel == "1" ? "0" : "1")
  25. ;
  26. //string resultStateR;
  27. //准备参数
  28. List<List<Object>> parametersStateR = new List<List<Object>>();
  29. parametersStateR.Add(new List<Object>() { "CancelTime", DateTime.Now });
  30. parametersStateR.Add(new List<Object>() { "CancelPerson", SalemanAccountId });
  31. parametersStateR.Add(new List<Object>() { "IsCancel", IsCancel });
  32. parametersStateR.Add(new List<Object>() { "RecordId", RecordId });
  33. List<SqlParameter> parametersStateR1 = DataAccess.ToParameters(parametersStateR);
  34. list.Add(new DataAccessCommand(commandTextStateR, parametersStateR1, CommandType.Text, true));
  35. #endregion
  36. #region 更新明细状态
  37. string commandTextStateF = "UPDATE " + Config.TablePrefix + "PushFeedback " +
  38. " SET CancelTime = @CancelTime, " +
  39. " CancelPerson = @CancelPerson, " +
  40. " IsCancel = @IsCancel" +
  41. " WHERE PushRecordId = @RecordId " +
  42. " and (state IS NULL or state = 0 or state in(5,6))" +
  43. " and IsCancel = " + (IsCancel == "1" ? "0" : "1")
  44. ;
  45. //string resultStateF;
  46. //准备参数
  47. List<List<Object>> parametersStateF = new List<List<Object>>();
  48. parametersStateF.Add(new List<Object>() { "CancelTime", DateTime.Now });
  49. parametersStateF.Add(new List<Object>() { "CancelPerson", SalemanAccountId });
  50. parametersStateF.Add(new List<Object>() { "IsCancel", IsCancel });
  51. parametersStateF.Add(new List<Object>() { "RecordId", RecordId });
  52. List<SqlParameter> parametersStateF1 = DataAccess.ToParameters(parametersStateF);
  53. list.Add(new DataAccessCommand(commandTextStateF, parametersStateF1, CommandType.Text, true));
  54. #endregion
  55. bool success = DataAccess.ExecuteBatchCommands(list, out result);
  56. if (success)
  57. return 1;
  58. else
  59. return 0;
  60. }
  61. }
  62. }