private bool?FlushCompletedSessions(SessionModel sourceSession) { lock (this.CompletedSessions) { if (sourceSession.events.Count > 0) { this.CompletedSessions.Add(sourceSession); } this.CompletedSessions.Where <SessionModel>((Func <SessionModel, bool>)(s => s.ReportParameters == null)).ForEach <SessionModel>((Action <SessionModel>)(async s => { SessionModel sessionModel = s; Dictionary <string, object> reportParameters = await ServiceData.GetReportParameters(); sessionModel.ReportParameters = "".GlueGetList(reportParameters, true); sessionModel = (SessionModel)null; })); List <SessionModel> list = this.CompletedSessions.Where <SessionModel>((Func <SessionModel, bool>)(s => !s.AsyncLocationLock)).ToList <SessionModel>(); this.ReportPackages.AddRange((IEnumerable <ReportPackage>)list.ToReportPackages()); list.ForEach((Action <SessionModel>)(s => this.CompletedSessions.Remove(s))); if (this.ReportPackages.Count == 0) { return(new bool?(false)); } foreach (ReportPackage package in this.ReportPackages.ToArray()) { if (!Config.Global.OfflineMode && LiteMetricaCore.TryPostOrIgnore(package)) { this.ReportPackages.Remove(package); package.Fade(); } } this.RemoveOverflowedPackages(this.ReportPackages); this.ReportPackages.Where <ReportPackage>((Func <ReportPackage, bool>)(p => !p.Exists())).ForEach <ReportPackage>((Action <ReportPackage>)(p => p.Keep())); return(new bool?(this.ReportPackages.Count == 0)); } }
public async void Wake(bool activateApiKey = false, bool forceWake = false) { if (!this.IsActivated) { return; } bool flag1 = false; lock (this.PauseLock) { bool isPaused = this.IsPaused; this.IsPaused = false; DateTime?lastLullTime = Config.Global.LastLullTime; int num; if (lastLullTime.HasValue) { DateTime utcNow = DateTime.UtcNow; DateTime?nullable1 = lastLullTime; TimeSpan?nullable2 = nullable1.HasValue ? new TimeSpan?(utcNow - nullable1.GetValueOrDefault()) : new TimeSpan?(); TimeSpan sessionTimeout = Config.Global.SessionTimeout; num = nullable2.HasValue ? (nullable2.GetValueOrDefault() > sessionTimeout ? 1 : 0) : 0; } else { num = 0; } bool flag2 = num != 0; if (!forceWake) { if (!(isPaused & flag2)) { goto label_11; } } flag1 = true; } label_11: if (!flag1) { return; } SessionModel sessionModel = this.StartSession(activateApiKey); Dictionary <string, object> reportParameters = await ServiceData.GetReportParameters(); sessionModel.ReportParameters = "".GlueGetList(reportParameters, true); #pragma warning disable IDE0059 // Ненужное присваивание значения sessionModel = (SessionModel)null; #pragma warning restore IDE0059 // Ненужное присваивание значения await this.ReportIdentityEvent(); }
public virtual async void Expose() { this.ActiveSessionLock = new object(); this.PauseLock = new object(); this.ActiveSession = this.ActiveSession ?? LiteMetricaCore.CreateSession(); this.ReportPackages = this.ReportPackages ?? new List <ReportPackage>(); this.CompletedSessions = this.CompletedSessions ?? new List <SessionModel>(); SessionModel sessionModel = this.ActiveSession; string str = this.ActiveSession.ReportParameters; if (str == null) { str = "".GlueGetList(await ServiceData.GetReportParameters(), true); } sessionModel.ReportParameters = str; #pragma warning disable IDE0059 // Ненужное присваивание значения sessionModel = (SessionModel)null; #pragma warning restore IDE0059 // Ненужное присваивание значения this.IsPaused = true; }