public SqlDataReaderLRAP(SqlCommandDTO cmdDTO, SqlDataReader reader)
 {
     CommandDTO             = cmdDTO;
     Reader                 = reader;
     CurrentResultIndex     = 0;
     CurrentReaderResultDTO = null;
 }
        public static void LogResponse(SqlCommandDTO cmdDTO, object value)
        {
            var context = HttpContext.Current;

            var page        = HttpContext.Current.Handler as Page;
            var logType     = LogType.OnPersistenceResponse;
            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 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: value != null ? SerializationHelper.Serialize(value, SerializationType.Json) : null,
                times: 1,
                unixTimestampEnd: null,
                instanceTime: DateTime.Now,
                stackTrace: null
                );

            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 loggedValue = logElement.Value != null ? SerializationHelper.Deserialize <object>(logElement.Value, SerializationType.Json) : null;

                    if (loggedValue != null && value != null && !loggedValue.Equals(value))
                    {
                        //Show UI-warning.. something in the response 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;
                }
            }

            LoggingHelper.LogElement(newLogElement);
        }
        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);
        }