public void CreateAllThumbnails() { //var db = this.GetDatabaseState(); var settings = new DbSettingsComponent(this.Session); var areThumbnailsCreated = (settings.Exists("AreThumbnailsCreated")) ? bool.Parse(settings["AreThumbnailsCreated"]) : false; if (!areThumbnailsCreated) { settings["AreThumbnailsCreated"] = false.ToString(); this.Logger.Info("Creation of the thumbnails"); using (var bench = new Benchmark(e => this.Logger.InfoFormat("Thumbnails created in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds))) { var pictures = (from p in this.Session.Query <Picture>() select p).ToList(); new ImageHelper().TryCreateThumbnail(pictures); using (var tx = this.Session.BeginTransaction()) { new Updator(this.Session).Update(pictures); bench.CheckNow(e => this.Logger.DebugFormat("Thumbnails created in memory in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds)); areThumbnailsCreated = true; settings["AreThumbnailsCreated"] = areThumbnailsCreated.ToString(); tx.Commit(); bench.CheckNow(e => this.Logger.DebugFormat("Transaction commited {0,3}.{1:###} sec", e.Seconds, e.Milliseconds)); } } } else { this.Logger.Debug("Thumbnails creation already executed. Action aborded."); } }
private void Flush(ISession session) { var settings = new DbSettingsComponent(session); this.IsDebug = bool.Parse(settings["IsDebug"]); var isExportEnabled = bool.Parse(settings["IsRemoteStatisticsEnabled"]); Guid appKey = new Guid(settings["AppKey"]); using (var tx = session.BeginTransaction()) { var appVersion = this.GetApplicationVersion(); foreach (var item in Statistics) { item.Version = appVersion; session.Save(item); } tx.Commit(); } if (!this.IsDebug && this.RemoteStatisticsEnabled) { var toImport = this.GetNotImportedStatistics(session); this.ExportToRemoteServer(toImport, appKey); this.MarkAsExported(session, toImport); } else if (this.IsDebug) { Logger.Warn("The application is in debug mode, the statistics are not exported. The setting 'IsRemoteStatisticsEnabled' is overriden!"); } Statistics.Clear(); }
public void CreateAllThumbnails() { //var db = this.GetDatabaseState(); var settings = new DbSettingsComponent(this.Session); var areThumbnailsCreated = (settings.Exists("AreThumbnailsCreated")) ? bool.Parse(settings["AreThumbnailsCreated"]) : false; if (!areThumbnailsCreated) { settings["AreThumbnailsCreated"] = false.ToString(); this.Logger.Info("Creation of the thumbnails"); using (var bench = new Benchmark(e => this.Logger.InfoFormat("Thumbnails created in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds))) { var pictures = (from p in this.Session.Query<Picture>() select p).ToList(); new ImageHelper().TryCreateThumbnail(pictures); using (var tx = this.Session.BeginTransaction()) { new Updator(this.Session).Update(pictures); bench.CheckNow(e => this.Logger.DebugFormat("Thumbnails created in memory in {0,3}.{1:###} sec", e.Seconds, e.Milliseconds)); areThumbnailsCreated = true; settings["AreThumbnailsCreated"] = areThumbnailsCreated.ToString(); tx.Commit(); bench.CheckNow(e => this.Logger.DebugFormat("Transaction commited {0,3}.{1:###} sec", e.Seconds, e.Milliseconds)); } } } else { this.Logger.Debug("Thumbnails creation already executed. Action aborded."); } }