db access tracking
This commit is contained in:
parent
65eebf6409
commit
bfc50d262d
63 changed files with 177 additions and 187 deletions
|
|
@ -38,7 +38,6 @@ namespace Yavsc
|
|||
if (Context.User != null)
|
||||
{
|
||||
isAuth = Context.User.Identity.IsAuthenticated;
|
||||
userName = Context.User.Identity.Name;
|
||||
var group = isAuth ?
|
||||
"authenticated" : "anonymous";
|
||||
// Log ("Cx: " + group);
|
||||
|
|
@ -55,9 +54,8 @@ namespace Yavsc
|
|||
UserAgent = Context.Request.Headers["User-Agent"],
|
||||
Connected = true
|
||||
});
|
||||
db.SaveChanges();
|
||||
db.SaveChanges(user.Id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else Groups.Add(Context.ConnectionId, "anonymous");
|
||||
|
|
@ -78,16 +76,16 @@ namespace Yavsc
|
|||
var cx = db.Connections.SingleOrDefault(c => c.ConnectionId == Context.ConnectionId);
|
||||
if (cx != null)
|
||||
{
|
||||
var user = db.Users.Single(u => u.UserName == userName);
|
||||
if (stopCalled)
|
||||
{
|
||||
var user = db.Users.Single(u => u.UserName == userName);
|
||||
user.Connections.Remove(cx);
|
||||
}
|
||||
else
|
||||
{
|
||||
cx.Connected = false;
|
||||
}
|
||||
db.SaveChanges();
|
||||
db.SaveChanges(user.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,7 +108,7 @@ namespace Yavsc
|
|||
if (cx != null)
|
||||
{
|
||||
cx.Connected = true;
|
||||
db.SaveChanges();
|
||||
db.SaveChanges(user.Id);
|
||||
}
|
||||
else cx = new Connection { ConnectionId = Context.ConnectionId,
|
||||
UserAgent = Context.Request.Headers["User-Agent"],
|
||||
|
|
@ -147,10 +145,9 @@ namespace Yavsc
|
|||
var cx = db.Connections.SingleOrDefault(c=>c.ConnectionId == Context.ConnectionId);
|
||||
if (cx!=null) {
|
||||
db.Connections.Remove(cx);
|
||||
db.SaveChanges();
|
||||
db.SaveChanges(cx.ApplicationUserId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue