private void OnViewHistoryDetail(object sender, System.Windows.Input.ExecutedRoutedEventArgs e) { HistoryItem item = e.Parameter as HistoryItem; if (item != null) { XtraTabPage result = new XtraTabPage(); System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost(); elementHost1.Dock = DockStyle.Fill; System.Windows.Controls.ContentControl contentCtrl = new System.Windows.Controls.ContentControl(); System.Windows.ResourceDictionary res = new System.Windows.ResourceDictionary(); res.BeginInit(); res.Source = new Uri("pack://application:,,,/Assistant;component/Template/FillResult.xaml"); res.EndInit(); contentCtrl.ContentTemplate = res["fillResult"] as System.Windows.DataTemplate; try { contentCtrl.DataContext = HistoryHelper.GetRecordList(item.Id); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } contentCtrl.Content = contentCtrl.DataContext; elementHost1.Child = contentCtrl; result.Controls.Add(elementHost1); result.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True; result.Text = "历史填报明细"; this.tabPageControl.TabPages.Add(result); this.tabPageControl.SelectedTabPage = result; } }
public ActionResult Edit([Bind(Include = "Id,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId,Title,Description,Created")] Ticket ticket) { if (ModelState.IsValid) { var original = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); //var edit = db.Tickets.Find(ticket.Id); db.Entry(ticket).State = EntityState.Modified; ticket.Updated = DateTime.Now; db.SaveChanges(); var notificationHelper = new NotificationHelper(); notificationHelper.ManageNotifications(original, ticket); HistoryHelper.RecordHistory(original, ticket); ////NotificationHelper.Manage...... //NotificationHelper.CreateAssignmentNotification(original, ticket); //HistoryHelper.RecordHistory(original, edit); return(RedirectToAction("Index")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "DisplayName", ticket.AssignedToUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public ActionResult Edit([Bind(Include = "Id,ProjectId,Title,Description,Created,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Ticket ticket) { if (ModelState.IsValid) { //getting a reference to the old ticket somehow var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); ticket.Updated = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); var notificationHelper = new NotificationHelper(); notificationHelper.Notify(oldTicket, ticket); var historyHelper = new HistoryHelper(); historyHelper.AddHistory(oldTicket, ticket); return(RedirectToAction("Index", "Tickets")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
private void ContentService_Created(IContentService sender, NewEventArgs <IContent> e) { var user = GetUserSignature(CurrentUser); var contentSignature = GetContentSignature(e.Entity); HistoryHelper.AddHistoryItem($"{user} created {contentSignature}"); }
/// <summary> /// Make the square root calculation for the operand /// </summary> /// <param name="operand">Operand to be calculated the square root</param> /// <param name="trackingId">Tracking id of the operations</param> /// <returns>SquareRootResponse for the square root of the operand</returns> public SquareRootResponse SquareRoot(int operand, string trackingId) { double total = 0; // Make sure the operand is a positive integer value if (operand < 0) { string exceptionMessage = "Operand must be a positive integer value."; HistoryHelper.GetInstance() .AddFailureHistoryItem(OperationTypes.SquareRoot, new int[] { operand }, exceptionMessage, trackingId); throw new Exception(exceptionMessage); } total = Math.Sqrt(operand); HistoryHelper.GetInstance() .AddSuccessHistoryItem(OperationTypes.SquareRoot, new int[] { operand }, total, trackingId); return(new SquareRootResponse { Square = total }); }
public async System.Threading.Tasks.Task <ActionResult> Delete(int id) { Ticket ticket = db.Tickets.Find(id); var strLoginUser = User.Identity.GetUserId(); HistoryHelper audit = new HistoryHelper(); audit.AddHistory(ticket.Id, "Status", ticket.TicketStatus.Name, "Resolved", strLoginUser); ticket.TicketStatusId = 4; // Sends a notification var developer = db.Users.Find(ticket.AssignedToUserId); if (developer != null && developer.Email != null) { var svc = new EmailService(); var msg = new IdentityMessage(); msg.Destination = developer.Email; msg.Subject = " Aj's Bug Tracker Update: " + ticket.Title; msg.Body = ("Ticket ID: " + ticket.Id + " - " + ticket.Title + "has been resolved"); await svc.SendAsync(msg); } db.Tickets.Attach(ticket); db.Entry(ticket).Property("TicketStatusId").IsModified = true; db.SaveChanges(); return(RedirectToAction("Index", new { Id = ticket.Id })); }
private void ViewRecordHistory() { XtraTabPage result = new XtraTabPage(); System.Windows.Forms.Integration.ElementHost elementHost1 = new System.Windows.Forms.Integration.ElementHost(); elementHost1.Dock = DockStyle.Fill; System.Windows.Controls.ContentControl contentCtrl = new System.Windows.Controls.ContentControl(); System.Windows.ResourceDictionary res = new System.Windows.ResourceDictionary(); res.BeginInit(); res.Source = new Uri("pack://application:,,,/Assistant;component/Template/RecordViewer.xaml"); res.EndInit(); contentCtrl.ContentTemplate = res["recordViewer"] as System.Windows.DataTemplate; try { contentCtrl.DataContext = HistoryHelper.GetHistoryList(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } contentCtrl.Content = contentCtrl.DataContext; contentCtrl.CommandBindings.Add(new System.Windows.Input.CommandBinding(Commands.View, this.OnViewHistoryDetail)); elementHost1.Child = contentCtrl; result.Controls.Add(elementHost1); result.ShowCloseButton = DevExpress.Utils.DefaultBoolean.True; result.Text = "历史记录"; this.tabPageControl.TabPages.Add(result); this.tabPageControl.SelectedTabPage = result; }
private void MediaService_Created(IMediaService sender, NewEventArgs <IMedia> e) { var signature = GetUserSignature(CurrentUser); var mediaSignature = GetContentSignature(e.Entity); HistoryHelper.AddHistoryItem($"{signature} created new media item: {mediaSignature}"); }
private void MediaService_Moved(IMediaService sender, MoveEventArgs <IMedia> e) { var signature = GetUserSignature(CurrentUser); var mediaSignature = GetContentSignatures(e.MoveInfoCollection.Select(i => i.Entity)); HistoryHelper.AddHistoryItem($"{signature} moved the following media item: {mediaSignature}"); }
private void MediaService_EmptiedRecycleBin(IMediaService sender, RecycleBinEventArgs e) { var signature = GetUserSignature(CurrentUser); var ids = e.Ids.Select(i => i.ToString()).CombineStrings(ListSeparator); HistoryHelper.AddHistoryItem($"{signature} emptied the recycle bin, permanently deleting media items with the following ids: {ids}"); }
private void ContentService_Trashed(IContentService sender, MoveEventArgs <IContent> e) { var user = GetUserSignature(CurrentUser); var contentSignature = GetContentSignatures(e.MoveInfoCollection.Select(i => i.Entity)); HistoryHelper.AddHistoryItem($"{user} moved the following content into the trash: {contentSignature}"); }
private void ContentService_UnPublished(IPublishingStrategy sender, PublishEventArgs <IContent> e) { var user = GetUserSignature(CurrentUser); var contentSignature = GetContentSignatures(e.PublishedEntities); HistoryHelper.AddHistoryItem($"{user} unpublished the following content: {contentSignature}"); }
private void ContentService_Saved(IContentService sender, SaveEventArgs <IContent> e) { var user = GetUserSignature(CurrentUser); var contentSignature = GetContentSignatures(e.SavedEntities); HistoryHelper.AddHistoryItem($"{user} saved the following content: {contentSignature}"); }
private void ContentService_RolledBack(IContentService sender, RollbackEventArgs <IContent> e) { var user = GetUserSignature(CurrentUser); var contentSignature = GetContentSignature(e.Entity); HistoryHelper.AddHistoryItem($"{user} rolled back the following content: {contentSignature}"); }
private void ContentService_EmptiedRecycleBin(IContentService sender, RecycleBinEventArgs e) { var user = GetUserSignature(CurrentUser); var contentSignature = e.Ids.Select(i => i.ToString()).CombineStrings(ListSeparator); HistoryHelper.AddHistoryItem($"{user} emptied the recycle bin, permanently deleting nodes with the following ids: {contentSignature}"); }
public ActionResult Edit([Bind(Include = "Id,ProjectId,TicketTypeId,TicketStatusId,TicketPriorityId,OwnerUserId,AssignedToUserId,Title,Description,Created,Updated")] Ticket ticket) { if (ModelState.IsValid) { var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); var localDate = DateTime.UtcNow.AddHours(-4); //Takes extra four hours off so the appropriate time is returned. ticket.Updated = localDate; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); nh.ManageNotifications(oldTicket, ticket); HistoryHelper.RecordHistory(oldTicket, ticket); return(RedirectToAction("Index")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "LastName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "LastName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
private void MediaService_Deleted(IMediaService sender, DeleteEventArgs <IMedia> e) { var signature = GetUserSignature(CurrentUser); var mediaSignature = GetContentSignatures(e.DeletedEntities); HistoryHelper.AddHistoryItem($"{signature} deleted the following media item: {mediaSignature}"); }
private void ContentService_Copied(IContentService sender, CopyEventArgs <IContent> e) { var signature = GetUserSignature(CurrentUser); var fromSignature = GetContentSignature(e.Original); var toSignature = GetContentSignature(e.Copy); HistoryHelper.AddHistoryItem($"{signature} copied content from {fromSignature} to {toSignature}"); }
private void TextBuffer_ChangedLowPriority(object sender, TextContentChangedEventArgs e) { var changedSpans = e.Changes.Select(c => c.OldSpan); foreach (var span in changedSpans) { HistoryHelper.AddItemToHistory(_control.CodeDocumentViewModel, span); } }
public ActionResult Edit([Bind(Include = "Id,Title,Description,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusid,OwnerUserId,AssignToUserId")] Ticket ticket) { ViewBag.UserTimeZone = db.Users.Find(User.Identity.GetUserId()).TimeZone; ViewBag.AssignToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Title", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPrioritites, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusid = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusid); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); var user = db.Users.Find(User.Identity.GetUserId()); if (ModelState.IsValid) { ticket.Updated = DateTimeOffset.UtcNow; HistoryHelper helper = new HistoryHelper(); TicketHistory ticketHistory = new TicketHistory(); Ticket oldTicket = db.Tickets.AsNoTracking().First(t => t.Id == ticket.Id); if (oldTicket.Title != ticket.Title) { helper.AssignTicketTitle(ticket, user.Id); } if (oldTicket.Description != ticket.Description) { helper.AssignTicketDescription(ticket, user.Id); } if (oldTicket.TicketPriorityId != ticket.TicketPriorityId) { helper.AssignTicketPriority(ticket, user.Id); } if (oldTicket.TicketStatusid != ticket.TicketStatusid) { helper.AssignTicketStatus(ticket, user.Id); } if (oldTicket.TicketTypeId != ticket.TicketTypeId) { helper.AssignTickettype(ticket, user.Id); } if (ticket.TicketStatusid == 1) { ticket.Archive = true; } db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = ticket.Id })); } return(View(ticket)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Title,Created,Updated,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Ticket ticket) { if (ModelState.IsValid) { HistoryHelper historyHelper = new HistoryHelper(); StringBuilder updateMessage = new StringBuilder(); var oldTicketInfo = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); if (oldTicketInfo.Title != ticket.Title) { historyHelper.AddHistory(ticket.Id, "Title", oldTicketInfo.Title, ticket.Title, User.Identity.GetUserId()); updateMessage.AppendFormat("Ticket Title: {0}, ", ticket.Title); } if (oldTicketInfo.TicketTypeId != ticket.TicketTypeId) { var oldTicketType = db.TicketTypes.Find(oldTicketInfo.TicketTypeId).Name; var newTicketType = db.TicketTypes.Find(ticket.TicketTypeId).Name; historyHelper.AddHistory(ticket.Id, "Ticket Type", oldTicketType, newTicketType, User.Identity.GetUserId()); updateMessage.AppendFormat("Ticket Type: {0}, ", ticket.TicketTypeId); } if (oldTicketInfo.TicketPriorityId != ticket.TicketPriorityId) { var oldTicketPriority = db.TicketPriorities.Find(oldTicketInfo.TicketPriorityId).Name; var newTicketPriority = db.TicketPriorities.Find(ticket.TicketPriorityId).Name; historyHelper.AddHistory(ticket.Id, "Ticket Type", oldTicketPriority, newTicketPriority, User.Identity.GetUserId()); updateMessage.AppendFormat("Ticket Priority: {0}, ", ticket.TicketTypeId); } ticket.Updated = DateTime.Now; db.SaveChanges(); // Add Notifcations var developer = db.Users.Find(ticket.AssignedToUserId); if (developer != null && developer.Email != null) { var svc = new EmailService(); var msg = new IdentityMessage(); msg.Destination = developer.Email; msg.Subject = " Aj Bug Tracker Update:" + ticket.Title; msg.Body = ("The following items have been updated the :" + ticket.Title + updateMessage); await svc.SendAsync(msg); } return(RedirectToAction("Index")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public async Task <ActionResult> EditDash([Bind(Include = "Id,Title,Description,Created,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,OwnerUserId,AssignedToUserId")] Ticket ticket) { if (ModelState.IsValid) { var notificationHelper = new NotificationHelper(); var historyHelper = new HistoryHelper(); var currentStatus = ticket.TicketStatusId; if (currentStatus == 0) { ticket.TicketStatusId = db.TicketStatuses.FirstOrDefault(t => t.Name == "In Progress").Id; } //reference old Ticket var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); if (User.Identity.GetUserId() == "db9a774b-807c-4b9b-9b22-34c191872996") { if (ticket.AssignedToUserId == "5f84068f-4213-4d02-81a4-21936ae10cdc" || ticket.OwnerUserId == "60f316c5-536c-4f06-83d3-38a555febc29") { ticket.Updated = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); //compare to the incoming Ticket (ticket) notificationHelper.Notify2(oldTicket, ticket); historyHelper.AddHistory(oldTicket, ticket); return(RedirectToAction("TicketsDashboard")); } else { return(RedirectToAction("InvalidAttempt", "Home")); } } ticket.Updated = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); //compare to the incoming Ticket (ticket) notificationHelper.Notify2(oldTicket, ticket); historyHelper.AddHistory(oldTicket, ticket); return(RedirectToAction("TicketsDashboard")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }
public ActionResult History() { //var userId = User.Identity.GetUserId(); //var ticketHistories = new List<TicketHistory>(); //if (User.IsInRole("Submitter")) //{ // ticketHistories = db.TicketHistories.Include(t => t.Ticket).Include(t => t.User).Where(t => t.Ticket.SubmitterId == userId).ToList(); //} //return View(ticketHistories); return(View(HistoryHelper.ListMyHistory())); }
/// <summary> /// Make the substraction calculation for the array of operands /// </summary> /// <param name="operands">Array of operands to be substracted</param> /// <param name="trackingId">Tracking id of the operations</param> /// <returns>SubstractionResponse for the substraction of all the operands</returns> public SubstractionResponse Substract(int[] operands, string trackingId) { // Make sure the operands array is not empty. if (operands == null) { string exceptionMessage = "Operands list can not be null."; HistoryHelper.GetInstance() .AddFailureHistoryItem(OperationTypes.Substraction, operands, exceptionMessage, trackingId); throw new Exception(exceptionMessage); } int total = 0; bool isFirst = true; foreach (int operand in operands) { // Make sure the operands are positive integer values if (operand < 0) { string exceptionMessage = "Operands must be positive integer values."; HistoryHelper.GetInstance() .AddFailureHistoryItem(OperationTypes.Substraction, operands, exceptionMessage, trackingId); throw new Exception(exceptionMessage); } //Take the first operand to start the substraction if (isFirst) { total = operand; isFirst = false; } else { total -= operand; } } HistoryHelper.GetInstance() .AddSuccessHistoryItem(OperationTypes.Substraction, operands, total, trackingId); return(new SubstractionResponse { Difference = total }); }
public override int SaveChanges() { var modifiedEntities = ChangeTracker.Entries().Where(p => p.State == EntityState.Modified).ToList(); bool wasModifyed = false; Ticket ticket = new Ticket(); foreach (var change in modifiedEntities) { var entityName = change.Entity.GetType().Name; var primaryKey = Convert.ToInt32(GetPrimaryKeyValue(change).ToString()); ticket = Tickets.FirstOrDefault(t => t.Id == primaryKey); foreach (var prop in change.OriginalValues.PropertyNames) { if (Enum.IsDefined(typeof(PropertyNames), prop)) { var originalValue = "not assigned"; var currentValue = "not assigned"; if (change.OriginalValues[prop] != null) { originalValue = change.OriginalValues[prop].ToString(); } if (change.CurrentValues[prop] != null) { currentValue = change.CurrentValues[prop].ToString(); } if (originalValue != currentValue) { historyHelper = new HistoryHelper(Create()); historyHelper.CreatePropertyHistory(primaryKey, prop, originalValue, currentValue); wasModifyed = true; } } } notificationHelper = new NotificationHelper(Create()); if (wasModifyed) { var message = notificationHelper.CreateModificationNotification(ticket.Title); notificationHelper.SendNotification(ticket, message, false); } } return(base.SaveChanges()); }
public async Task <ActionResult> AssignDeveloper(string AssignToUserId, int id, EmailModel model) { var user = db.Users.Find(User.Identity.GetUserId()); Ticket ticket = db.Tickets.Find(id); ticket.AssignToUserId = AssignToUserId; ticket.TicketStatusid = db.TicketStatuses.FirstOrDefault(t => t.Name == "Assigned").Id; HistoryHelper helper = new HistoryHelper(); Ticket oldTicket = db.Tickets.AsNoTracking().First(t => t.Id == ticket.Id); if (oldTicket.AssignToUserId != ticket.AssignToUserId) { helper.AssignChange(ticket, user.Id); } db.SaveChanges(); try { var body = "<p>{0}</p><p>({1})</p>"; var from = "BugTrackerServerNOREPLY<*****@*****.**>"; //model.Body = "This is a message from your bugtacker notification system. You have been assigned to a ticket! "; var email = new MailMessage(from, db.Users.Find(ticket.AssignToUserId).Email) { Subject = "Notification of Ticket Assignment", Body = string.Format(body, "subject", "This is a message from your bugtacker notification system. You have been assigned to a ticket! Please do not respond to this message as you will not get a reply back. "), IsBodyHtml = true }; var svc = new PersonalEmail(); await svc.SendAsync(email); } catch (Exception ex) { Console.WriteLine(ex.Message); await Task.FromResult(0); } return(RedirectToAction("UserProjects", "Projects")); }
public HttpResponseMessage DownloadCsv(GenerateCsvModel model) { // Variables. var start = model.StartDate.HasValue ? model.StartDate.Value : SqlDateTime.MinValue.Value; var stop = model.EndDate.HasValue ? model.EndDate.Value.AddDays(1) : SqlDateTime.MaxValue.Value; // Get history items. var items = HistoryHelper.GetHistoryItems(start, stop); var config = new CsvHelper.Configuration.CsvConfiguration() { HasHeaderRecord = true, QuoteAllFields = true }; // write CSV data to memory stream using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { using (var csvWriter = new CsvHelper.CsvWriter(writer, config)) { csvWriter.WriteHeader <HistoryCsvHeader>(); foreach (var item in items) { csvWriter.WriteField(item.Timestamp.ToString()); csvWriter.WriteField(item.Message); csvWriter.NextRecord(); } } } stream.Seek(0, SeekOrigin.Begin); return(CreateFileResponse( stream.ToArray(), $"site-activity_{start.ToString("yyyy-MM-dd")}_{stop.ToString("yyyy-MM-dd")}.csv", "text/csv" )); } }
public ActionResult Edit([Bind(Include = "Id,Title,Description,ProjectId,TicketTypeId,TicketPriorityId,TicketStatusId,AssignedToUserId,OwnerUserId,Created")] Ticket ticket) { if (ModelState.IsValid) { var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); db.Entry(ticket).State = EntityState.Modified; ticket.Updated = DateTime.Now; NotifyHelper.ManageNotification(oldTicket, ticket); HistoryHelper.SaveHistory(oldTicket, ticket); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FullName", ticket.AssignedToUserId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatus, "Id", "Name", ticket.TicketStatusId); return(View(ticket)); }
public ActionResult CreateComment([Bind(Include = "Id,Body,TicketId,AuthorId,Created,Updated")] TicketComment comment, int TicketId) { ViewBag.UserTimeZone = db.Users.Find(User.Identity.GetUserId()).TimeZone; if (ModelState.IsValid) { comment.TicketId = TicketId; comment.AuthorId = User.Identity.GetUserId(); comment.Created = DateTimeOffset.Now; db.TicketComments.Add(comment); HistoryHelper helper = new HistoryHelper(); db.SaveChanges(); return(RedirectToAction("Details", new { id = TicketId })); } ViewBag.AuthorId = new SelectList(db.Users, "Id", "FullName", comment.AuthorId); return(View(comment)); }
public async Task <ActionResult> Edit([Bind(Include = "Id,ProjectId,TicketTypeId,TicketStatusId,TicketPriorityId,OwnerUserId,AssignedToUserId,Title,Description,Created,Updated")] Ticket ticket, HttpPostedFileBase[] files) { if (ModelState.IsValid) { List <Tuple <string, string, string> > fileUploadResult = FileUploadHelper.UploadMultipleFiles(files); foreach (Tuple <string, string, string> upload in fileUploadResult) { TicketAttachment ticketAttachment = new TicketAttachment(); ticketAttachment.Title = upload.Item1; ticketAttachment.AttachmentUrl = upload.Item2; ticketAttachment.Description = upload.Item3; ticketAttachment.Created = DateTime.Now; ticketAttachment.UserId = User.Identity.GetUserId(); ticketAttachment.TicketId = ticket.Id; db.TicketAttachments.Add(ticketAttachment); ticket.TicketAttachments.Add(ticketAttachment); HistoryHelper.AnyAttachment(ticket, ticketAttachment, true); } var oldTicket = db.Tickets.AsNoTracking().FirstOrDefault(t => t.Id == ticket.Id); ticket.Updated = DateTime.Now; db.Entry(ticket).State = EntityState.Modified; db.SaveChanges(); var newTicket = db.Tickets.Where(n => n.Id == ticket.Id).Include(n => n.TicketPriority).Include(n => n.TicketStatus).Include(n => n.TicketType).FirstOrDefault(); var callbackUrl = Url.Action("Details", "Tickets", new { id = ticket.Id }, protocol: Request.Url.Scheme); await NotificationHelper.ManageNotifications(oldTicket, newTicket, callbackUrl, false); HistoryHelper.AnyChanges(oldTicket, ticket); return(RedirectToAction("MyIndex")); } ViewBag.AssignedToUserId = new SelectList(db.Users, "Id", "FirstName", ticket.AssignedToUserId); ViewBag.OwnerUserId = new SelectList(db.Users, "Id", "FirstName", ticket.OwnerUserId); ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Name", ticket.ProjectId); ViewBag.TicketPriorityId = new SelectList(db.TicketPriorities, "Id", "Name", ticket.TicketPriorityId); ViewBag.TicketStatusId = new SelectList(db.TicketStatuses, "Id", "Name", ticket.TicketStatusId); ViewBag.TicketTypeId = new SelectList(db.TicketTypes, "Id", "Name", ticket.TicketTypeId); return(View(ticket)); }