From f6849535b0008d2fa9438e4ff7c79517271209f5 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Tue, 30 Apr 2013 13:33:06 +1000 Subject: [PATCH] Merge: Repository Monitor --- Disco.BI/Disco.BI.csproj | 2 +- Disco.BI/Properties/AssemblyInfo.cs | 5 + Disco.Client/Properties/AssemblyInfo.cs | 5 + .../Properties/AssemblyInfo.cs | 5 + Disco.Data/Properties/AssemblyInfo.cs | 5 + Disco.Data/Repository/DiscoDataContext.cs | 7 + .../Repository/Monitor/RepositoryMonitor.cs | 42 ++ .../Monitor/RepositoryMonitorEvent.cs | 9 + Disco.Models/Properties/AssemblyInfo.cs | 5 + Disco.Services/Properties/AssemblyInfo.cs | 5 + .../Properties/AssemblyInfo.cs | 5 + Disco.Web/Properties/AssemblyInfo.cs | 5 + Disco.Web/Views/Job/JobParts/Resources.cshtml | 163 ++++++++ .../Views/Job/JobParts/Resources.generated.cs | 376 ++++++++++++++++++ 14 files changed, 638 insertions(+), 1 deletion(-) diff --git a/Disco.BI/Disco.BI.csproj b/Disco.BI/Disco.BI.csproj index fc403727..e94ff4a7 100644 --- a/Disco.BI/Disco.BI.csproj +++ b/Disco.BI/Disco.BI.csproj @@ -237,7 +237,7 @@ - + diff --git a/Disco.BI/Properties/AssemblyInfo.cs b/Disco.BI/Properties/AssemblyInfo.cs index d6e78dc0..fa692972 100644 --- a/Disco.BI/Properties/AssemblyInfo.cs +++ b/Disco.BI/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Client/Properties/AssemblyInfo.cs b/Disco.Client/Properties/AssemblyInfo.cs index 557e67c2..f8d18446 100644 --- a/Disco.Client/Properties/AssemblyInfo.cs +++ b/Disco.Client/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0429.1616")] [assembly: AssemblyFileVersion("1.2.0429.1616")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs b/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs index dcea1094..fcdfcfdd 100644 --- a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs +++ b/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0426.1841")] [assembly: AssemblyFileVersion("1.2.0426.1841")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Data/Properties/AssemblyInfo.cs b/Disco.Data/Properties/AssemblyInfo.cs index 7d881942..750b4bbb 100644 --- a/Disco.Data/Properties/AssemblyInfo.cs +++ b/Disco.Data/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Data/Repository/DiscoDataContext.cs b/Disco.Data/Repository/DiscoDataContext.cs index a1b1762d..fb2acfb4 100644 --- a/Disco.Data/Repository/DiscoDataContext.cs +++ b/Disco.Data/Repository/DiscoDataContext.cs @@ -76,10 +76,17 @@ namespace Disco.Data.Repository // Notify before changes are committed var changes = Monitor.RepositoryMonitor.BeforeSaveChanges(this); +<<<<<<< HEAD changeCount = base.SaveChanges(); if (changes.Length > 0) { +======= + if (changes.Length > 0) + { + changeCount = base.SaveChanges(); + +>>>>>>> origin/Repository-Monitor // Notify after changes are committed Monitor.RepositoryMonitor.AfterSaveChanges(this, changes); } diff --git a/Disco.Data/Repository/Monitor/RepositoryMonitor.cs b/Disco.Data/Repository/Monitor/RepositoryMonitor.cs index e5c87736..dec1cf51 100644 --- a/Disco.Data/Repository/Monitor/RepositoryMonitor.cs +++ b/Disco.Data/Repository/Monitor/RepositoryMonitor.cs @@ -23,6 +23,7 @@ namespace Disco.Data.Repository.Monitor internal static RepositoryMonitorEvent[] BeforeSaveChanges(DiscoDataContext dbContext) { var contextStateManager = ((IObjectContextAdapter)dbContext).ObjectContext.ObjectStateManager; +<<<<<<< HEAD //var changes = contextStateManager.GetObjectStateEntries(System.Data.EntityState.Added).Concat(contextStateManager.GetObjectStateEntries(System.Data.EntityState.Deleted)).Concat(contextStateManager.GetObjectStateEntries(System.Data.EntityState.Modified)); dbContext.ChangeTracker.DetectChanges(); @@ -32,6 +33,17 @@ namespace Disco.Data.Repository.Monitor var monitorEvent = EventFromEntryState(dbContext, entryState, contextStateManager.GetObjectStateEntry(entryState.Entity)); // Push to Stream streamBefore.OnNext(monitorEvent); +======= + var changes = contextStateManager.GetObjectStateEntries(System.Data.EntityState.Added).Concat(contextStateManager.GetObjectStateEntries(System.Data.EntityState.Deleted)).Concat(contextStateManager.GetObjectStateEntries(System.Data.EntityState.Modified)); + + var events = changes.Select(entryState => + { + var monitorEvent = EventFromEntryState(entryState); + + // Push to Stream + streamBefore.OnNext(monitorEvent); + +>>>>>>> origin/Repository-Monitor return monitorEvent; }).ToArray(); @@ -79,18 +91,28 @@ namespace Disco.Data.Repository.Monitor var entryState = stateManager.GetObjectStateEntry(monitorEvent.Entity); monitorEvent.EntityKey = entryState.EntityKey.EntityKeyValues.Select(kv => kv.Value).ToArray(); } +<<<<<<< HEAD monitorEvent.afterCommit = true; } internal static RepositoryMonitorEvent EventFromEntryState(DiscoDataContext dbContext, DbEntityEntry dbEntryState, ObjectStateEntry objectEntryState) +======= + } + + internal static RepositoryMonitorEvent EventFromEntryState(ObjectStateEntry entryState) +>>>>>>> origin/Repository-Monitor { RepositoryMonitorEventType eventType; string[] modifiedProperties = null; object[] entityKey = null; Type entityType; +<<<<<<< HEAD switch (dbEntryState.State) +======= + switch (entryState.State) +>>>>>>> origin/Repository-Monitor { case System.Data.EntityState.Added: eventType = RepositoryMonitorEventType.Added; @@ -108,6 +130,7 @@ namespace Disco.Data.Repository.Monitor eventType = RepositoryMonitorEventType.Unchanged; break; default: +<<<<<<< HEAD throw new NotSupportedException(string.Format("Database Entry State not supported: {0}", dbEntryState.State.ToString())); } @@ -128,6 +151,25 @@ namespace Disco.Data.Repository.Monitor dbContext = dbContext, EventType = eventType, Entity = dbEntryState.Entity, +======= + throw new NotSupportedException(string.Format("Database Entry State not supported: {0}", entryState.State.ToString())); + } + + entityType = EntityTypeFromProxy(entryState.Entity.GetType()); + + // Only pass modified properties on Modified Event (Ignore Added/Deleted) + if (eventType == RepositoryMonitorEventType.Modified) + modifiedProperties = entryState.GetModifiedProperties().ToArray(); + + // Don't pass entity key when entity newly added + if (eventType != RepositoryMonitorEventType.Added) + entityKey = entryState.EntityKey.EntityKeyValues.Select(kv => kv.Value).ToArray(); + + return new RepositoryMonitorEvent() + { + EventType = eventType, + Entity = entryState.Entity, +>>>>>>> origin/Repository-Monitor EntityKey = entityKey, EntityType = entityType, ModifiedProperties = modifiedProperties diff --git a/Disco.Data/Repository/Monitor/RepositoryMonitorEvent.cs b/Disco.Data/Repository/Monitor/RepositoryMonitorEvent.cs index cf3cc5ca..8914080e 100644 --- a/Disco.Data/Repository/Monitor/RepositoryMonitorEvent.cs +++ b/Disco.Data/Repository/Monitor/RepositoryMonitorEvent.cs @@ -1,8 +1,11 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; +<<<<<<< HEAD using System.Data.Entity.Infrastructure; using System.Data.Objects; +======= +>>>>>>> origin/Repository-Monitor using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,6 +14,7 @@ namespace Disco.Data.Repository.Monitor { public class RepositoryMonitorEvent { +<<<<<<< HEAD [JsonIgnore] internal ObjectStateEntry objectEntryState { get; set; } [JsonIgnore] @@ -21,6 +25,8 @@ namespace Disco.Data.Repository.Monitor [JsonIgnore] public DiscoDataContext dbContext { get; set; } +======= +>>>>>>> origin/Repository-Monitor public RepositoryMonitorEventType EventType { get; set; } [JsonIgnore] @@ -40,6 +46,7 @@ namespace Disco.Data.Repository.Monitor public object[] EntityKey { get; set; } public string[] ModifiedProperties { get; set; } +<<<<<<< HEAD public T GetPreviousPropertyValue(string PropertyName) { @@ -52,5 +59,7 @@ namespace Disco.Data.Repository.Monitor { return (T)dbEntityState.CurrentValues[PropertyName]; } +======= +>>>>>>> origin/Repository-Monitor } } diff --git a/Disco.Models/Properties/AssemblyInfo.cs b/Disco.Models/Properties/AssemblyInfo.cs index 6940ba47..6642216b 100644 --- a/Disco.Models/Properties/AssemblyInfo.cs +++ b/Disco.Models/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Services/Properties/AssemblyInfo.cs b/Disco.Services/Properties/AssemblyInfo.cs index 0943b85a..3732a436 100644 --- a/Disco.Services/Properties/AssemblyInfo.cs +++ b/Disco.Services/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Web.Extensions/Properties/AssemblyInfo.cs b/Disco.Web.Extensions/Properties/AssemblyInfo.cs index ba5cf0f2..0b5dab92 100644 --- a/Disco.Web.Extensions/Properties/AssemblyInfo.cs +++ b/Disco.Web.Extensions/Properties/AssemblyInfo.cs @@ -32,5 +32,10 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Web/Properties/AssemblyInfo.cs b/Disco.Web/Properties/AssemblyInfo.cs index 80c5d38e..7e14a89b 100644 --- a/Disco.Web/Properties/AssemblyInfo.cs +++ b/Disco.Web/Properties/AssemblyInfo.cs @@ -31,5 +31,10 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: +<<<<<<< HEAD [assembly: AssemblyVersion("1.2.0430.1219")] [assembly: AssemblyFileVersion("1.2.0430.1219")] +======= +[assembly: AssemblyVersion("1.2.0411.1608")] +[assembly: AssemblyFileVersion("1.2.0411.1608")] +>>>>>>> origin/Repository-Monitor diff --git a/Disco.Web/Views/Job/JobParts/Resources.cshtml b/Disco.Web/Views/Job/JobParts/Resources.cshtml index bd32dd8b..49870b9a 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.cshtml +++ b/Disco.Web/Views/Job/JobParts/Resources.cshtml @@ -20,6 +20,169 @@ +<<<<<<< HEAD +======= + +>>>>>>> origin/Repository-Monitor
diff --git a/Disco.Web/Views/Job/JobParts/Resources.generated.cs b/Disco.Web/Views/Job/JobParts/Resources.generated.cs index e548c2c5..ed019ffd 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.generated.cs +++ b/Disco.Web/Views/Job/JobParts/Resources.generated.cs @@ -167,7 +167,193 @@ WriteLiteral(">\r\n \r\n
\r\n \r\n \r\n \r\n \r\n $(function () {\r\n var jobId = parseInt(\'"); + + + #line 25 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Model.Job.Id); + + + #line default + #line hidden +WriteLiteral("\');\r\n $Comments = $(\'#Comments\');\r\n $Commen" + +"tOutput = $Comments.find(\'.commentOutput\');\r\n $CommentOutputC" + +"ontainer = $Comments.find(\'.commentOutputContainer\');\r\n $Comm" + +"entInput = $Comments.find(\'textarea.commentInput\');\r\n\r\n windo" + +"w.setTimeout(function () {\r\n $CommentOutput[0].scrollTop " + +"= $CommentOutput[0].scrollHeight; // Scroll to Bottom\r\n }, 0)" + +";\r\n $(\'#jobDetailTabs\').on(\'tabsactivate\', function (event, u" + +"i) {\r\n if (ui.newPanel && ui.newPanel.is(\'#jobDetailTab-R" + +"esources\')) {\r\n $CommentOutput[0].scrollTop = $Commen" + +"tOutput[0].scrollHeight; // Scroll to Bottom\r\n }\r\n " + +" });\r\n\r\n $Comments.find(\'.commentInputPost\').clic" + +"k(postComment);\r\n $CommentInput.keypress(function (e) {\r\n " + +" if (e.which == 13 && !e.shiftKey) {\r\n " + +" postComment();\r\n return false;\r\n " + +" }\r\n });\r\n $CommentOutput.find(\'spa" + +"n.remove\').click(removePost);\r\n\r\n $dialogRemoveLog = $(\'#dial" + +"ogRemoveLog\');\r\n $dialogRemoveLog.dialog({\r\n " + +" resizable: false,\r\n height: 140,\r\n " + +" modal: true,\r\n autoOpen: false\r\n " + +" });\r\n\r\n function postComment() {\r\n " + +"var comment = $CommentInput.val();\r\n if (comment != \'\') {" + +"\r\n var data = { comment: comment }\r\n " + +" $.ajax({\r\n url: \'"); + + + #line 62 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Url.Action(MVC.API.Job.CommentPost(Model.Job.Id, null))); + + + #line default + #line hidden +WriteLiteral("\',\r\n dataType: \'json\',\r\n " + +" data: data,\r\n success: function (d) {\r\n " + +" if (d.Result == \'OK\') {\r\n " + +" // Should be added via Repository Notifications\r\n " + +" // addComment(d.Comment, false);\r\n " + +" $CommentInput.val(\'\').attr(\'disabled\', false).focus();\r\n " + +" } else {\r\n " + +" alert(\'Unable to post comment: \' + d.Result);\r\n " + +" $CommentInput.attr(\'disabled\', false);\r\n " + +" }\r\n },\r\n erro" + +"r: function (jqXHR, textStatus, errorThrown) {\r\n " + +" alert(\'Unable to post comment: \' + textStatus);\r\n " + +" $CommentInput.attr(\'disabled\', false);\r\n " + +" }\r\n });\r\n }\r\n " + +" }\r\n function removePost() {\r\n $thi" + +"s = $(this);\r\n var data = { id: $this.closest(\'div\').attr" + +"(\'data-logid\') };\r\n\r\n $dialogRemoveLog.dialog(\"enable\");\r" + +"\n $dialogRemoveLog.dialog(\'option\', \'buttons\', {\r\n " + +" \"Remove\": function () {\r\n $d" + +"ialogRemoveLog.dialog(\"disable\");\r\n $dialogRemove" + +"Log.dialog(\"option\", \"buttons\", null);\r\n $.ajax({" + +"\r\n url: \'"); + + + #line 92 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Url.Action(MVC.API.Job.CommentRemove())); + + + #line default + #line hidden +WriteLiteral("\',\r\n dataType: \'json\',\r\n " + +" data: data,\r\n success: function" + +" (d) {\r\n if (d == \'OK\') {\r\n " + +" // Should be removed via Repository Notifications\r" + +"\n //$this.closest(\'div\').slideUp(300)" + +".delay(300).queue(function () {\r\n // " + +" $(this).remove();\r\n //});\r\n " + +" } else {\r\n " + +" alert(\'Unable to remove comment: \' + d);\r\n " + +" }\r\n $dialogRemoveLog.dialog(\"clo" + +"se\");\r\n },\r\n " + +" error: function (jqXHR, textStatus, errorThrown) {\r\n " + +" alert(\'Unable to remove comment: \' + textStatus);\r\n " + +" $dialogRemoveLog.dialog(\"close\");\r\n " + +" }\r\n });\r\n " + +" },\r\n \"Cancel\": function () {\r\n " + +" $dialogRemoveLog.dialog(\"close\");\r\n }\r\n" + +" });\r\n\r\n $dialogRemoveLog.dialog(\'" + +"open\');\r\n\r\n return false;\r\n }\r\n " + +" function loadLiveComment(id) {\r\n $.ajax({\r\n " + +" url: \'"); + + + #line 123 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Url.Action(MVC.API.Job.Comment())); + + + #line default + #line hidden +WriteLiteral(@"', + dataType: 'json', + data: { id: id }, + success: function (d) { + if (d && d.JobId == jobId) { + addComment(d, false); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('Unable to load live comment ' + id + ': ' + textStatus); + } + }); + } + function addComment(c, quick) { + var e = $('
'); + e.attr('data-logid', c.Id); + e.find('.author').text(c.Author); + e.find('.timestamp').text(c.TimestampFuzzy).attr('title', c.TimestampFull); + e.find('.remove').click(removePost); + var eComment = e.find('.comment').text(c.Comments); + var commentHtml = eComment.text().replace(/\r\n|\r|\n/g, '
'); + commentHtml = commentHtml.replace(/\#(\d+)/g, ''); + eComment.html(commentHtml); + + $CommentOutput.append(e); + + if (!quick) { + e.animate({ backgroundColor: '#ffff99' }, 500, function () { + e.animate({ backgroundColor: '#f4f4f4' }, 500); + }); + $CommentOutput.animate({ scrollTop: $CommentOutput[0].scrollHeight }, 250) + } + } + + // Sign up for Live Events + function liveMessageRecieved(d) { + if (d) { + switch (d.EventType) { + case 0: // Added + loadLiveComment(d.EntityKey[0]); + break; + case 1: // Removed + $CommentOutput.children('div[data-logid=""' + d.EntityKey[0] + '""]').slideUp(300).delay(300).queue(function () { + $(this).remove(); + }); + break; + } + } + } + var liveMessagesConnection = $.connection('"); + + + #line 172 "..\..\Views\Job\JobParts\Resources.cshtml" + Write(Url.Content("~/API/Repository/Notifications")); + + + #line default + #line hidden +WriteLiteral(@"') + liveMessagesConnection.received(liveMessageRecieved); + liveMessagesConnection.error(function (e) { + alert('Error: ' + JSON.stringify(e)); + }); + liveMessagesConnection.start(function () { + liveMessagesConnection.send('/addToGroups:JobLog'); + }); + + }); + + + >>>>>> origin/Repository-Monitor WriteLiteral(" id=\"Attachments\""); @@ -178,13 +364,21 @@ WriteLiteral(" class=\"attachmentOutput\""); WriteLiteral(">\r\n"); +<<<<<<< HEAD #line 26 "..\..\Views\Job\JobParts\Resources.cshtml" +======= + #line 186 "..\..\Views\Job\JobParts\Resources.cshtml" +>>>>>>> origin/Repository-Monitor #line default #line hidden +<<<<<<< HEAD #line 26 "..\..\Views\Job\JobParts\Resources.cshtml" +======= + #line 186 "..\..\Views\Job\JobParts\Resources.cshtml" +>>>>>>> origin/Repository-Monitor foreach (var ja in Model.Job.JobAttachments) { @@ -193,6 +387,7 @@ WriteLiteral(">\r\n"); #line hidden WriteLiteral("