public static void CreateAndAddInputParameter(this SqlCommandLRAP command, string name, object value, int size = 0) { SqlParameter p = command.Parameters.AddWithValue(parameterName: name, value: value); if (size > 0) { p.Size = size; } }
private static SqlCommandDTO MapSqlCommandLRAPToSqlCommandDTO(SqlCommandLRAP cmd, LoggingDBType type, CommandBehavior behavior) { var result = new SqlCommandDTO(); result.BundleGUID = Guid.NewGuid(); result.Type = type; result.CommandType = cmd.CommandType; result.CommandText = cmd.CommandText; result.CommandBehavior = behavior; foreach (SqlParameter p in cmd.Parameters) { var param = new SqlParamDTO(); param.Type = p.SqlDbType; param.Value = MapObjectToString(p.Value == DBNull.Value ? null : p.Value); result.Params.Add(param); } return(result); }
public static void CreateAndAddParameter(this SqlCommandLRAP command, SqlDbType type, string name, object value, int size, ParameterDirection direction) { var parameter = command.CreateParameter(); parameter.Direction = direction; parameter.SqlDbType = type; parameter.ParameterName = name; if (size > 0) { parameter.Size = size; } if (value == null) { parameter.IsNullable = true; parameter.Value = DBNull.Value; } else { parameter.Value = value; } command.Parameters.Add(parameter); }
public static LogElementResponse LogRequest(SqlCommandLRAP cmd, LoggingDBType type, CommandBehavior behavior = CommandBehavior.Default) { var context = HttpContext.Current; var page = HttpContext.Current.Handler as Page; var logType = LogType.OnPersistenceRequest; var sessionGUID = LoggingHelper.GetSessionGUID(HttpContext.Current, HttpContext.Current.Handler as Page, () => new Guid()).Value; var pageGUID = LoggingHelper.GetPageGUID(HttpContext.Current, HttpContext.Current.Handler as Page, () => new Guid()).Value; var cmdDTO = MapSqlCommandLRAPToSqlCommandDTO(cmd, type, behavior); var newLogElement = new LogElementDTO( guid: Guid.NewGuid(), sessionGUID: sessionGUID, pageGUID: pageGUID, bundleGUID: cmdDTO.BundleGUID, progressGUID: null, unixTimestamp: TimeHelper.UnixTimestamp(), logType: logType, element: cmdDTO.CommandText, element2: null, value: SerializationHelper.Serialize(cmdDTO, SerializationType.Json), times: 1, unixTimestampEnd: null, instanceTime: DateTime.Now, stackTrace: ConfigurationHelper.GetConfigurationSection().LogStackTrace ? new StackTrace().ToString() : "" ); if (LoggingHelper.IsPlaying(context, page?.Request.Params)) { var serverGUID = LoggingHelper.GetServerGUID(HttpContext.Current, null, page?.Request.Params).Value; if (LoggingHelper.FetchAndExecuteLogElement(serverGUID, sessionGUID, pageGUID, logType, (logElement) => { TimeHelper.SetNow(HttpContext.Current, logElement.InstanceTime); var loggedCmdDTO = SerializationHelper.Deserialize <SqlCommandDTO>(logElement.Value, SerializationType.Json); if (!cmdDTO.Equals(loggedCmdDTO)) { //Show UI-warning.. something in the request differs } //Kan jo ikke bare overskrive... uden at spørge brugeren om det er det der ønskes, det kan ihf ikke være default behavior //LoggingHelper.SetRequestValues(context, requestParams.Form, requestForm); //var requestParams = requestForm != null ? WebHelper.ParamsWithSpecialRequestForm(context, requestForm) : context.Request?.Params; PlayerCommunicationHelper.SetLogElementAsDone(serverGUID, sessionGUID, pageGUID, logElement.GUID, new JobStatus() { Success = true }); //, async: false); })) { return new LogElementResponse() { Success = true, Object = cmdDTO } } ; } var result = LoggingHelper.LogElement(newLogElement); result.Object = cmdDTO; return(result); }
public static void CreateAndAddInputParameter(this SqlCommandLRAP command, SqlDbType type, string name, object value, int size) { command.CreateAndAddParameter(type, name, value, size, ParameterDirection.Input); }
public static void CreateAndAddInputParameter(this SqlCommandLRAP command, SqlDbType type, string name, object value) { command.CreateAndAddInputParameter(type, name, value, -1); }