private void ArchiveEvent(Event @event, bool finished, string conclusion) { var archivedEvent = new ArchivedEvent() { Id = @event.Id, Added = @event.Added, Updated = @event.Updated, Title = @event.Title, Description = @event.Description, EventSeverity = @event.EventSeverity, Shorthand = @event.Shorthand, SourceId = @event.Source.Id, StateId = @event.State.Id, CheckTypeId = @event.CheckType.Id }; if (!conclusion.Equals("")) { archivedEvent.Conclusion = conclusion; } if (finished) { archivedEvent.Finished = DateTime.Now; archivedEvent.Removed = DateTime.MinValue; } else { archivedEvent.Removed = DateTime.Now; archivedEvent.Finished = DateTime.MinValue; } _archive.CheckCenterFinishedEvents.Add(archivedEvent); _archive.SaveChanges(); }
protected void UploadButton_OnClick(object sender, EventArgs e) { if (this.FileControl.HasFile) { var filename = Path.GetFileName(this.FileControl.FileName); if (filename != null && filename.EndsWith(".zip")) { byte[] fileData = null; if (this.FileControl.HasFile) { var length = this.FileControl.PostedFile.ContentLength; fileData = new byte[length + 1]; var fileStream = this.FileControl.PostedFile.InputStream; fileStream.Read(fileData, 0, length); } if (fileData != null) { var ds = new ArchiveDbContext(); using (var inputStream = new MemoryStream(fileData)) { using (var zip = ZipFile.Read(inputStream)) { foreach (var zipEntry in zip.Entries.Where(entry => entry.FileName.EndsWith(".txt"))) { using (var outputStream = new MemoryStream()) { zipEntry.Extract(outputStream); outputStream.Position = 0; var sr = new StreamReader(outputStream); var fileContents = sr.ReadToEnd(); var file = new File() { FileName = zipEntry.FileName, ArchiveName = filename, Content = fileContents }; ds.Files.Add(file); } } } } ds.SaveChanges(); } } else { this.Notification.Text = "Please select a valid .zip file!"; this.Notification.Visible = true; } } else { this.Notification.Text = "Please select a file!"; this.Notification.Visible = true; } }
public void ArchiveAdditionalInfo(AdditionalInfo info, int id) { var archivedInfo = new ArchivedInfo() { EventId = id, Id = info.Id, Key = info.Key, Value = info.Value }; _archive.CheckCenterAdditionalInfo.Add(archivedInfo); _archive.SaveChanges(); DeleteAdditionalInfo(info.Id); }
public void ArchiveComment(Comment comment, int eventId) { var archivedEvent = new ArchivedComment() { Content = comment.Content, Created = comment.Created, EventId = eventId, Id = comment.Id, UserEmail = comment.UserEmail }; _archive.CheckCenterComments.Add(archivedEvent); _archive.SaveChanges(); DeleteComment(comment.Id); }
public void ArchiveFeedback(Feedback feedback, int id) { var archivedFeedback = new ArchivedFeedback() { Content = feedback.Content, Created = feedback.Created, EventId = id, Id = feedback.Id, UserEmail = feedback.UserEmail }; _archive.CheckCenterFeedback.Add(archivedFeedback); _archive.SaveChanges(); DeleteFeedback(feedback.Id); }