/* * public LogReplayAssociations Play(LogAssociations Associations) * { * return Play(Associations, null, new CookieStore()); * } * * public LogReplayAssociations Play(LogAssociations Associations, CookieStore Cookies) * { * return Play(Associations, null, Cookies); * } * * public LogReplayAssociations Play(LogAssociations Associations, UpdateRequestBeforeReplaying ReqUpdater) * { * return Play(Associations, ReqUpdater, new CookieStore()); * } * public LogReplayAssociations Play(LogAssociations Associations, UpdateRequestBeforeReplaying ReqUpdater, CookieStore Cookies) * { * List<LogReplayAssociation> PlayAssociations = new List<LogReplayAssociation>(); * foreach (int LogId in Associations.LogIds) * { * LogAssociation Asso = Associations.GetAssociation(LogId); * if (!Asso.IsIgnorable) * { * LogReplayAssociation PlayAsso = new LogReplayAssociation(Asso); * PlayAssociations.Add(PlayAsso); * } * } * foreach (LogReplayAssociation PlayAsso in PlayAssociations) * { * LogReplayAssociation PreviousAsso = null; * foreach (LogReplayAssociation PrePlayAsso in PlayAssociations) * { * if (PrePlayAsso.OriginalAssociation != null * && PrePlayAsso.OriginalAssociation.DestinationLog != null * && PlayAsso.OriginalAssociation.SourceLog != null * && PlayAsso.OriginalAssociation.SourceLog.LogId == PrePlayAsso.OriginalAssociation.DestinationLog.LogId) * { * PreviousAsso = PrePlayAsso; * } * } * PlayAssociation(PlayAsso, PreviousAsso, Cookies, ReqUpdater); * } * return new LogReplayAssociations(PlayAssociations, Cookies); * } */ //LogReplayAssociation PlayAssociation(LogAssociation CurrentAsso, List<LogReplayAssociation> PlayAssociations, LogAssociations Associations, CookieStore Cookies) /* * void PlayAssociation(LogReplayAssociation CurrentAsso, LogReplayAssociation PreviousAsso, CookieStore Cookies, UpdateRequestBeforeReplaying ReqUpdater) * { * Request Req = GetRequest(CurrentAsso, PreviousAsso); * Req.Cookie.RemoveAll(); * Req.SetCookie(Cookies); * Req.SetSource("LogReplayer"); * if (ReqUpdater != null) * { * Req = ReqUpdater(Req, CurrentAsso.OriginalAssociation); * } * Response Res = Req.Send(); * Cookies.Add(Req, Res); * if (PreviousAsso != null && PreviousAsso.ReplayAssociation != null && PreviousAsso.ReplayAssociation.DestinationLog != null) * { * CurrentAsso.ReplayAssociation = new LogAssociation(LogAssociationType.Unknown, RefererAssociationType.None, IronHtml.UrlInHtmlMatch.None, LogAssociationMatchLevel.Other, PreviousAsso.ReplayAssociation.DestinationLog, new Session(Req, Res)); * } * else * { * CurrentAsso.ReplayAssociation = new LogAssociation(LogAssociationType.Unknown, RefererAssociationType.None, IronHtml.UrlInHtmlMatch.None, LogAssociationMatchLevel.Other, null, new Session(Req, Res)); * } * } */ Request GetRequest(LogReplayAssociation PlayAsso, LogReplayAssociation PreviousPlayAsso) { LogAssociation OriAsso = PlayAsso.OriginalAssociation; if (OriAsso.AssociationType == LogAssociationType.UnAssociated || OriAsso.AssociationType == LogAssociationType.Unknown) { return(OriAsso.DestinationLog.Request.GetClone()); } if (OriAsso.SourceLog == null || PreviousPlayAsso == null || PreviousPlayAsso.ReplayAssociation == null || PreviousPlayAsso.ReplayAssociation.DestinationLog == null) { return(OriAsso.DestinationLog.Request.GetClone()); } Request Req = GetRequest(OriAsso, PreviousPlayAsso.ReplayAssociation.DestinationLog); if (Req == null) { //do something here //check in nearnest logs for redirect based variations otherwise just send the old request } else { return(Req); } return(OriAsso.DestinationLog.Request.GetClone()); }
public Request PrepareStepForPlay() { if (PlayAssociations.Count == 0 && Associations.NonIgnorableCount > 0) { foreach (int LogId in Associations.LogIds) { LogAssociation Asso = Associations.GetAssociation(LogId); if (!Asso.IsIgnorable) { LogReplayAssociation PlayAsso = new LogReplayAssociation(Asso); PlayAssociations.Add(PlayAsso); } } } //LogReplayAssociation PlayAsso = PlayAssociations[CurrentPlayIndex]; CurrentAssociationBeingPlayed = PlayAssociations[CurrentPlayIndex]; //LogReplayAssociation PreviousAsso = null; PreviousAssociationToOneBeingPlayed = null; foreach (LogReplayAssociation PrePlayAsso in PlayAssociations) { if (PrePlayAsso.OriginalAssociation != null && PrePlayAsso.OriginalAssociation.DestinationLog != null && CurrentAssociationBeingPlayed.OriginalAssociation.SourceLog != null && CurrentAssociationBeingPlayed.OriginalAssociation.SourceLog.LogId == PrePlayAsso.OriginalAssociation.DestinationLog.LogId) { PreviousAssociationToOneBeingPlayed = PrePlayAsso; } } //Request Req = GetRequest(CurrentAsso, PreviousAsso); CurrentRequestBeingPlayed = GetRequest(CurrentAssociationBeingPlayed, PreviousAssociationToOneBeingPlayed); CurrentRequestBeingPlayed.Cookie.RemoveAll(); CurrentRequestBeingPlayed.SetCookie(Cookies); CurrentRequestBeingPlayed.SetSource("LogReplayer"); if (ReqUpdater != null) { CurrentRequestBeingPlayed = ReqUpdater(CurrentRequestBeingPlayed, CurrentAssociationBeingPlayed.OriginalAssociation); } return(CurrentRequestBeingPlayed); }