Пример #1
0
 public object ExecuteScalar(WrapedDatabaseParameter parms)
 {
     long t = DateTime.Now.Ticks;
     try
     {
         DatabaseParameter[] pars = parms.DatabaseParameters ?? new DatabaseParameter[] { };
         DbParameter[] ps = ConvertParameter(pars);
         DAC dac = new DAC(parms.RoutingKey, parms.ConnectionString);
         object o = dac.ExecuteScalar(parms.CmdText, (CommandType)parms.CmdType, ps);
         Log.Write(LogAction.Svc, className, "ExecuteScalarWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + pars.ToKeyString());
         return o;
     }
     catch (Exception e)
     {
         Log.Write(LogAction.Error, className, "ExecuteScalarWraped", parms.ConnectionString, parms.CmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:" + parms + ";" + e.ToString());
     }
     return new object();
 }
Пример #2
0
 public object ExecuteScalar(string connString, string cmdText, CommandType cmdType, params DatabaseParameter[] parameters)
 {
     long t = DateTime.Now.Ticks;
     try
     {
         DbParameter[] ps = ConvertParameter(parameters);
         DAC dac = new DAC(connString);
         object o = dac.ExecuteScalar(cmdText, cmdType, ps);
         Log.Write(LogAction.Svc, className, "ExecuteScalar", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行成功:" + parameters.ToKeyString());
         return o;
     }
     catch (Exception e)
     {
         Log.Write(LogAction.Error, className, "ExecuteScalar", connString, cmdText.TrimSql(128), DateTime.Now.Ticks - t, "执行出错:cmdText:" + cmdText + ";" + parameters.ToKeyString() + ";" + e.ToString());
     }
     return new object();
 }