1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using System.Data.SqlClient;
- using System.Linq;
- using JLHHJSvr.BLL;
- using JLHHJSvr.Com;
- using JLHHJSvr.LJException;
- using LJLib.DAL.SQL;
- using LJLib.Net.SPI.Server;
- namespace JLHHJSvr.Excutor
- {
- internal sealed class DeleteBedNetVarExcutor : ExcutorBase<DeleteBedNetVarRequest, DeleteBedNetVarResponse>
- {
- protected override void ExcuteInternal(DeleteBedNetVarRequest request, object state, DeleteBedNetVarResponse rslt)
- {
- var tokendata = BllHelper.GetToken(request.token);
- if (tokendata == null)
- {
- rslt.ErrMsg = "会话已经中断,请重新登录";
- return;
- }
- if (!request.list.Any())
- {
- rslt.ErrMsg = "至少提交一条需要删除的记录";
- return;
- }
- using (var con = new SqlConnection(GlobalVar.ConnectionString))
- using (var cmd = con.CreateCommand())
- {
- con.Open();
- using (cmd.Transaction = con.BeginTransaction())
- {
- try
- {
- foreach (var bednetvar in request.list)
- {
- // 删除明细
- cmd.CommandText = @"DELETE FROM u_bednet_varmx WHERE varid = @varid";
- cmd.Parameters.Clear();
- cmd.Parameters.AddWithValue("@varid", bednetvar.varid.Value);
- cmd.ExecuteNonQuery();
- if (DbSqlHelper.Delete(cmd, bednetvar) == 0)
- {
- throw new LJCommonException($"弹簧资料不存在");
- }
- }
- cmd.Transaction.Commit();
- }
- catch (Exception e)
- {
- cmd.Transaction.Rollback();
- rslt.ErrMsg = e.ToString();
- }
- }
- }
- }
- }
- }
|