// Private methods private void ProcessPublish(Object o) { this.BlockWhileFrozen(); int sn; PublishDTO dto = o as PublishDTO; for (int i = 0; i < dto.NumEvents; i++) { lock (this) { sn = sequenceNumber++; logServer.LogAction("PubEvent " + name + ", " + name + ", " + dto.Topic + ", " + sn); brokerSite.Diffuse(new Event(this.name, this.siteName, dto.Topic, "content", sn)); } Thread.Sleep(dto.Interval); } }
protected void RePublishPages(ref PageModel page) { //Generate new File //Update Published Date var dto = new PublishDTO(); dto.Page = page; dto.Setttings = _settingsService.Get(); var result = _viewRenderService.RenderToStringAsync("Pages/Template", dto).Result; if (string.IsNullOrEmpty(page.FileName) == false) { var fileName = Path.Combine(_hostingEnvironment.WebRootPath, (page.FileName + ".html")); if (System.IO.File.Exists(fileName)) { var fileNameVersionControl = fileName + "." + Guid.NewGuid().ToString("D"); System.IO.File.Move(fileName, fileNameVersionControl); } System.IO.File.WriteAllText(fileName, result); } }
// Public specific methods public void Publish(string topicName, int numberOfEvents, int interval) { PublishDTO dto = new PublishDTO(topicName, numberOfEvents, interval); pool.AssyncInvoke(new WaitCallback(ProcessPublish), dto); }