public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; if (context.Session["UserName"] != null) { UserName = context.Session["UserName"].ToString().ToUpper().Trim(); } else { UserName = ""; } Action = RequstString("Action"); if (Action.Length == 0) { Action = ""; } if (Action == "EquAlarm_Detail") { Equ_AlarmInfo equinfo = new Equ_AlarmInfo(); equinfo.ID = RequstString("EquID"); Equ_AlarmInfo result = new Equ_AlarmInfo(); result = GetEquAlarmDetailObj(equinfo, result); context.Response.Write(jsc.Serialize(result)); } else if (Action == "EquAlarm_Edit") { Equ_AlarmInfo dataEntity = new Equ_AlarmInfo(); dataEntity.ID = RequstString("EquID"); dataEntity.ProcessCode = RequstString("ProcessName"); dataEntity.DeviceName = RequstString("DeviceName"); dataEntity.AlarmItem = RequstString("AlarmItem"); dataEntity.AlarmTime = RequstString("AlarmTime"); dataEntity.DealWithResult = RequstString("DealWithResult"); dataEntity.DealWithTime = RequstString("DealWithTime"); dataEntity.DealWithOper = RequstString("DealWithOper"); dataEntity.DealWithComment = RequstString("DealWithComment"); ResultMsg_Equ_Alarm result = new ResultMsg_Equ_Alarm(); result = editEquAlarmDataInDB(dataEntity, result); context.Response.Write(jsc.Serialize(result)); } else if (Action == "EquAlarm_Handle") { Equ_AlarmInfo dataEntity = new Equ_AlarmInfo(); dataEntity.ID = RequstString("EquID"); //dataEntity.DealWithResult = "已处理"; dataEntity.DealWithTime = RequstString("DealWithTime"); dataEntity.DealWithOper = RequstString("DealWithOper"); dataEntity.DealWithComment = RequstString("DealWithComment"); ResultMsg_Equ_Alarm result = new ResultMsg_Equ_Alarm(); result = handleEquAlarmDataInDB(dataEntity, result); context.Response.Write(jsc.Serialize(result)); } }
public ResultMsg_Equ_Alarm handleEquAlarmDataInDB(Equ_AlarmInfo dataEntity, ResultMsg_Equ_Alarm result) { if (dataEntity.ID.Length == 0) { dataEntity.ID = "0"; } //if (dataEntity.ProcessCode.Length == 0) dataEntity.ProcessCode = ""; //if (dataEntity.ProcessName.Length == 0) dataEntity.ProcessName = ""; //if (dataEntity.ProcessBeat.Length == 0) dataEntity.ProcessBeat = ""; //if (dataEntity.ProcessDsca.Length == 0) dataEntity.ProcessDsca = ""; //if (dataEntity.InturnNumber.Length == 0) dataEntity.InturnNumber = "0"; //if (dataEntity.ProcessManual.Length == 0) dataEntity.ProcessManual = ""; using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ELCO_ConnectionString"].ToString())) { SqlCommand cmd = new SqlCommand(); SqlTransaction transaction = null; try { conn.Open(); cmd.Connection = conn; string strSql = ""; transaction = conn.BeginTransaction(); cmd.Transaction = transaction; strSql = string.Format( @" UPDATE Mes_PLC_AlarmFiles SET DealWithTime= '{0}' , DealWithOper= '{1}' , DealWithComment= '{2}' WHERE id = {3} ", dataEntity.DealWithTime, dataEntity.DealWithOper, dataEntity.DealWithComment, dataEntity.ID ); cmd.CommandType = CommandType.Text; cmd.CommandText = strSql; cmd.ExecuteNonQuery(); transaction.Commit(); result.result = "success"; result.msg = "保存数据成功!"; } catch (Exception ex) { transaction.Rollback(); result.result = "failed"; result.msg = "保存失败! \n" + ex.Message; } } return(result); }