public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { List <AccountAuditEntry> result = new List <AccountAuditEntry>(); switch (op) { case DataOperation.Create: result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.Account, string.Format("[user:{0}] and [user:{1}] are now friends", mInstance.Keen.Id, mInstance.Account.Id), string.Format("AccountView.aspx?id={0}", mInstance.Keen.Id))); result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.Keen, string.Format("[user:{0}] and [user:{1}] are now friends", mInstance.Account.Id, mInstance.Keen.Id), string.Format("AccountView.aspx?id={0}", mInstance.Keen.Id))); break; case DataOperation.Delete: result.Add(ManagedAccountAuditEntry.CreateSystemAccountAuditEntry(session, mInstance.Account, string.Format("[user:{0}] and [user:{1}] are no longer friends", mInstance.Keen.Id, mInstance.Account.Id), string.Format("AccountView.aspx?id={0}", mInstance.Keen.Id))); result.Add(ManagedAccountAuditEntry.CreateSystemAccountAuditEntry(session, mInstance.Keen, string.Format("[user:{0}] and [user:{1}] are no longer friends", mInstance.Account.Id, mInstance.Keen.Id), string.Format("AccountView.aspx?id={0}", mInstance.Keen.Id))); break; } return(result); }
public AccountAuditEntry GetPublicAccountAuditEntry(ISession session, ManagedSecurityContext sec) { string url = string.Format("DiscussionThreadView.aspx?id={0}&did={1}", mInstance.DiscussionThread.Id, mInstance.DiscussionThread.Discussion.Id); AccountAuditEntry audit_entry = ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, sec.Account, string.Format("[user:{0}] posted <a href=\"{1}\">{2}</a> in [discussion:{3}]", mInstance.AccountId, url, Renderer.Render(mInstance.Subject), mInstance.DiscussionThread.Discussion.Id), url); return(audit_entry); }
public IEnumerable <AccountAuditEntry> GetAccountAuditEntries(ISession session, Account account, string url) { IList <string> result_strings = GetAccountAuditStrings(); List <AccountAuditEntry> result = new List <AccountAuditEntry>(result_strings.Count); foreach (string s in result_strings) { AccountAuditEntry entry = ManagedAccountAuditEntry.CreatePublicAccountAuditEntry( session, account, s, url); result.Add(entry); } return(result); }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { List <AccountAuditEntry> result = new List <AccountAuditEntry>(); switch (op) { case DataOperation.Create: result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, sec.Account, string.Format("[user:{0}] added [place:{1}] to [group:{2}]", sec.Account.Id, mInstance.Place.Id, mInstance.AccountGroup.Id), string.Format("AccountGroupView.aspx?id={0}", mInstance.AccountGroup.Id))); break; } return(result); }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { List <AccountAuditEntry> result = new List <AccountAuditEntry>(); switch (op) { case DataOperation.Create: result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, sec.Account, string.Format("[user:{0}] posted a new mad lib in [{1}:{2}]", mInstance.AccountId, mInstance.DataObject.Name.ToLower(), mInstance.ObjectId), string.Format("{0}View.aspx?id={1}", mInstance.DataObject.Name, mInstance.ObjectId))); break; } return(result); }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { List <AccountAuditEntry> result = new List <AccountAuditEntry>(); switch (op) { case DataOperation.Create: result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.Account, string.Format("[user:{0}] started a new blog: [blog:{1}]", mInstance.Account.Id, mInstance.Id), string.Format("AccountBlogView.aspx?id={0}", mInstance.Id))); break; } return(result); }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { switch (op) { case DataOperation.Create: List <AccountAuditEntry> result = new List <AccountAuditEntry>(); result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.Account, string.Format("[user:{0}] uploaded a new picture", mInstance.Account.Id, mInstance.Id), string.Format("AccountPictureView.aspx?id={0}", mInstance.Id))); return(result); default: return(null); } }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { List <AccountAuditEntry> result = new List <AccountAuditEntry>(); switch (op) { case DataOperation.Create: string url = string.Format("AccountBlogPostView.aspx?id={0}", mInstance.Id); result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.AccountBlog.Account, string.Format("[user:{0}] posted <a href=\"{1}\">{2}</a> in [blog:{3}]", mInstance.AccountBlog.Account.Id, url, Renderer.Render(mInstance.Title), mInstance.AccountBlog.Id), url)); break; } return(result); }
public override IList <AccountAuditEntry> CreateAccountAuditEntries(ISession session, ManagedSecurityContext sec, DataOperation op) { switch (op) { case DataOperation.Create: List <AccountAuditEntry> result = new List <AccountAuditEntry>(); result.Add(ManagedAccountAuditEntry.CreatePublicAccountAuditEntry(session, mInstance.Account, string.Format("[user:{0}] added [place:{1}]{2}", mInstance.Account.Id, mInstance.Id, mInstance.City == null ? string.Empty : string.Format(" in {0}", mInstance.City.Name)), string.Format("PlaceView.aspx?id={0}", mInstance.Id))); return(result); default: return(null); } }
public bool TryAudit(ISession session, DataOperation op, ManagedSecurityContext sec) { if (SuppressAccountAudit) { return(false); } IList <AccountAuditEntry> audit_entries = CreateAccountAuditEntries(session, sec, op); if (audit_entries == null) { return(false); } foreach (AccountAuditEntry audit_entry in audit_entries) { audit_entry.Md5 = ManagedAccountAuditEntry.GetHash(audit_entry.Description); session.Save(audit_entry); } return(true); }
public int Update(ManagedSecurityContext sec) { GetACL().Check(sec, DataOperation.Update); mInstance.Updated = DateTime.UtcNow; IList <AccountFeedItem> deleted = mInstance.AccountFeedItems; List <AccountFeedItem> updated = new List <AccountFeedItem>(); bool fUpdated = Update(RssFeed.Read(GetFeedStream()), deleted, updated); if (!fUpdated) { fUpdated = Update(AtomFeed.Load(GetFeedStream(), new Uri("http://www.w3.org/2005/Atom")), deleted, updated); } if (!fUpdated) { fUpdated = Update(AtomFeed.Load(GetFeedStream(), new Uri("http://purl.org/atom/ns#")), deleted, updated); } if (!fUpdated) { throw new Exception("Invalid or empty RSS or ATOM feed."); } try { if (deleted != null) { foreach (AccountFeedItem item in deleted) { ManagedAccountFeedItem m_item = new ManagedAccountFeedItem(Session, item); m_item.Delete(sec); } } // group items for auditing ManagedAccountAuditEntryCollection audit_coll = new ManagedAccountAuditEntryCollection(); audit_coll.MessageFormat = string.Format("[user:{0}] x-posted {{0}} in [feed:{1}]", mInstance.Account.Id, mInstance.Id); for (int i = 0; i < updated.Count; i++) { AccountFeedItem item = updated[i]; DataOperation op = (item.Id == 0 ? DataOperation.Create : DataOperation.Update); Session.Save(item); if (op == DataOperation.Create) { string url = string.Format("AccountFeedItemView.aspx?id={0}", item.Id); string trace = string.Format("<a href=\"{0}\">{1}</a>", url, Renderer.Render(item.Title)); audit_coll.Add(trace); } } IEnumerable <AccountAuditEntry> audit_entries = audit_coll.GetAccountAuditEntries( Session, mInstance.Account, string.Format("AccountFeedView.aspx?id={0}", mInstance.Id)); foreach (AccountAuditEntry entry in audit_entries) { entry.Created = entry.Updated = mInstance.Updated; entry.Md5 = ManagedAccountAuditEntry.GetHash(entry.Description); Session.Save(entry); } mInstance.AccountFeedItems = updated; mInstance.LastError = string.Empty; Session.Save(mInstance); } catch (Exception ex) { mInstance.LastError = ex.Message; Session.Save(mInstance); throw; } return(updated.Count); }