/// <summary> /// 执行立库任务的存储过程 /// </summary> /// <param name="taskID">任务ID</param> /// <param name="taskState">任务状态</param> /// <returns></returns> public bool RunProcedure(int taskID, int taskState) { bool sucess = false; OracleHelper.LocalConnectionString = connectionString; if (!OracleHelper.CanConnectDb(true)) { OprationState = string.Format("任务{0}执行存储过程出错,任务状态码:{1}\r\n错误原因:数据库未连接!", taskID, taskState); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); return(false); } OracleTransaction tran = OracleHelper.BeginTransaction(); OracleParameter[] param = new OracleParameter[] { new OracleParameter("pi_Task_id", OracleType.Int32), new OracleParameter("ps_Status", OracleType.VarChar), new OracleParameter("ri_ret", OracleType.Int32), new OracleParameter("rs_ret", OracleType.VarChar, 512) }; param[0].Value = taskID; param[1].Value = taskState.ToString();//.ToCharArray ()[0]; param[0].Direction = ParameterDirection.Input; param[1].Direction = ParameterDirection.Input; param[2].Direction = ParameterDirection.Output; param[3].Direction = ParameterDirection.Output; try { OracleHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, "SPPG_WMS.SP_TASK", param); if ((int)param[2].Value != 0) { OracleHelper.RollbackTransaction(tran); sucess = false; OprationState = string.Format("任务{0}执行存储过程出错,任务状态码:{1}\r\n可能是由于:{2}", taskID, taskState, param[3].Value); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); } else { sucess = true; } } catch (System.Exception ex) { OracleHelper.RollbackTransaction(tran);//.Rollback(); sucess = false; OprationState = string.Format("任务{0}执行存储过程出错,任务状态码:{1}\r\n", taskID, taskState); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.Programer, ex)); } finally { if (sucess) { OracleHelper.CommitTransaction(tran); } } return(sucess); }
//SPPG_WMS.sp_pallet_task_init //SPPG_WMS.sp_pallet_task_init(pallet_num in number,pi_Task_id out number,ri_ret out number, rs_ret out varchar2). /// <summary> /// 空托盘返库请求 /// </summary> /// <param name="palletNumber"></param> /// <returns></returns> public bool RunProcedure(int palletNumber) { bool sucess = false; OracleHelper.LocalConnectionString = connectionString; if (!OracleHelper.CanConnectDb(true)) { OprationState = string.Format("空托盘返库执行存储过程出错。\r\n错误原因:数据库未连接!"); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); return(false); } OracleTransaction tran = OracleHelper.BeginTransaction(); OracleParameter[] param = new OracleParameter[] { new OracleParameter("pallet_num", OracleType.Int32), new OracleParameter("pi_Task_id", OracleType.Int32), new OracleParameter("ri_ret", OracleType.Int32), new OracleParameter("rs_ret", OracleType.VarChar, 512) }; param[0].Value = palletNumber; param[0].Direction = ParameterDirection.Input; param[1].Direction = ParameterDirection.Output; param[2].Direction = ParameterDirection.Output; param[3].Direction = ParameterDirection.Output; try { OracleHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, "SPPG_WMS.sp_pallet_task_init", param); if ((int)param[2].Value != 0) { OracleHelper.RollbackTransaction(tran); sucess = false; OprationState = string.Format("空托盘返库执行存储过程出错。托盘数量:{0}\r\n可能是由于:{1}", palletNumber, param[3].Value); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); } else { sucess = true; } } catch (System.Exception ex) { OracleHelper.RollbackTransaction(tran); sucess = false; OprationState = string.Format("空托盘返库执行存储过程出错,托盘数量:{0}\r\n", palletNumber); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.Programer, ex)); } finally { if (sucess) { OracleHelper.CommitTransaction(tran); } } return(sucess); }
public bool UpdateAlarm(string deviceCode, string deviceName, string faultMessage, string faultType, TimeSpan faultDuration) { //SPPG_WMS.sp_error_log(ls_device_id in varchar2,ls_device_name in varchar2,ls_error_inf in varchar2, ri_ret out number, rs_ret out varchar2) //SPPG_WMS.sp_error_log(ls_device_id in varchar2,ls_device_name in varchar2,ls_error_inf in varchar2,li_Error_time in number,ls_Error_type in varchar2,ri_ret out number, rs_ret out varchar2). bool sucess = false; OracleHelper.LocalConnectionString = connectionString; if (!OracleHelper.CanConnectDb(true)) { OprationState = "上传设备错误信息失败,数据库未连接!"; Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); return(false); } OracleTransaction tran = OracleHelper.BeginTransaction(); OracleParameter[] param = new OracleParameter[] { new OracleParameter("ls_device_id", OracleType.VarChar), new OracleParameter("ls_device_name", OracleType.VarChar), new OracleParameter("ls_error_inf", OracleType.VarChar), new OracleParameter("li_Error_time", OracleType.Int32), new OracleParameter("ls_Error_type", OracleType.VarChar), new OracleParameter("ri_ret", OracleType.Int32), new OracleParameter("rs_ret", OracleType.VarChar, 512) }; param[0].Value = deviceCode; param[1].Value = deviceName; param[2].Value = faultMessage; param[3].Value = (int)(faultDuration.Seconds); param[0].Direction = ParameterDirection.Input; param[1].Direction = ParameterDirection.Input; param[2].Direction = ParameterDirection.Input; param[3].Direction = ParameterDirection.Input; param[4].Direction = ParameterDirection.Input; param[5].Direction = ParameterDirection.Output; param[6].Direction = ParameterDirection.Output; try { OracleHelper.ExecuteNonQuery(tran, CommandType.StoredProcedure, "SPPG_WMS.sp_error_log", param); if ((int)param[5].Value != 0) { OracleHelper.RollbackTransaction(tran); sucess = false; OprationState = string.Format("上传设备错误信息失败!代码:{0}可能是由于:{1}", param[5].Value, param[6].Value); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.User)); } else { sucess = true; } } catch (System.Exception ex) { OracleHelper.RollbackTransaction(tran);//.Rollback(); sucess = false; OprationState = string.Format("上传设备错误信息失败!数据库操作错误"); Program.ErrorManager.Add(new RuntimeError(oprationState, RuntimeError.EVisibility.Programer, ex)); } finally { if (sucess) { OracleHelper.CommitTransaction(tran); //Program.ErrorManager.Add(new RuntimeError("上传设备报警信息-成功", RuntimeError.EVisibility.Programer)); } } return(sucess); }
public void Run() { #region 添加 if (false) { OracleHelper.BeginTransaction(); try { //子表的子表 BrandChildChild bcc1 = new BrandChildChild(); bcc1.Id = BrandDal.GetNextID(); bcc1.Name = "bcc1" + DateTime.Now.ToString(); BrandDal.Insert(bcc1); //子表 BrandChild bc1 = new BrandChild(); bc1.Id = BrandDal.GetNextID(); bc1.Name = "bc1" + DateTime.Now.ToString(); bc1.bcc = bcc1; OracleHelper.Insert(bc1); //主表 Brand bd1 = new Brand(); bd1.Id = BrandDal.GetNextID(); bd1.Name = "bd1" + DateTime.Now.ToString(); bd1.bc = bc1; OracleHelper.Insert(bd1); OracleHelper.EndTransaction(); } catch (Exception ex) { OracleHelper.RollbackTransaction(); } } #endregion #region 修改 if (false) { OracleHelper.BeginTransaction(); try { //替换子表 BrandChild bc1 = new BrandChild(); bc1.Id = BrandDal.GetNextID(); bc1.Name = "bc1" + DateTime.Now.ToString(); OracleHelper.Insert(bc1); //更新主表 Brand bd1 = OracleHelper.FindById <Brand>(27); bd1.Name = "bd1" + DateTime.Now.ToString(); bd1.bc = bc1; OracleHelper.Update(bd1); OracleHelper.EndTransaction(); } catch (Exception ex) { OracleHelper.RollbackTransaction(); } } #endregion #region 除 if (false) { OracleHelper.BeginTransaction(); try { OracleHelper.Delete <Brand>(21); OracleHelper.BatchDelete <Brand>("22,23"); OracleHelper.EndTransaction(); } catch (Exception ex) { OracleHelper.RollbackTransaction(); } } #endregion #region 大文本 if (false) { Brand bd1 = OracleHelper.FindById <Brand>(27); bd1.Blb = Encoding.Default.GetBytes("大家好!"); bd1.Clb = "大家好!"; OracleHelper.Update(bd1); Brand bd12 = OracleHelper.FindById <Brand>(27); } #endregion #region 查询列表 List <Brand> brandList = BrandDal.FindListBySql <Brand>("select * from BRAND"); #endregion #region 分页查询列表 PageViewModel pageViewModel = BrandDal.FindPageBySql <Brand>("select * from BRAND", "order by Id desc", 10, 1); #endregion }