Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //GETTING DATA
- db = new CM_PS1Context();
- var software = (from c in db.Collections
- join d in db.v_DeploymentSummary on c.SiteID equals d.CollectionID
- join q in db.v_CollectionRuleQuery on d.CollectionID equals q.CollectionID
- join p in db.v_Package on d.PackageID equals p.PackageID
- where q.QueryExpression.Contains("ECHRISTUS") && !d.CollectionName.Contains("Limiting Collection") &&
- !d.CollectionName.Contains("group test")
- orderby c.CollectionName
- select
- new Software()
- {
- Name = c.CollectionName,
- Group =
- q.QueryExpression.Substring(q.QueryExpression.IndexOf("ECHRISTUS\\"))
- .Replace("ECHRISTUS\\", "")
- }
- ).ToList().Distinct(new SoftwareComparer());
- var result = new BindableCollection<Software>();
- foreach (var s in software)
- {
- s.Group = s.Group.Substring(0, s.Group.IndexOf('\''));
- //validate the group, some are wrong
- if (GroupPrincipal.FindByIdentity(new PrincipalContext(ContextType.Domain), s.Group) != null)
- result.Add(new Software {Name = s.Name, Group = s.Group});
- }
- return result;
- //INSERTING DATA
- public static void AddEvent(Event e, string user, string source, string destination)
- {
- //Validate the database has been initialized
- using (var db = new AuditContext())
- {
- db.Database.Connection.Open();
- var version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
- db.AuditLogs.Add(new AuditLog
- {
- UserID = user,
- DestPC = destination,
- SourcePC = source,
- Timestamp = DateTime.Now,
- Action = e.ToString(),
- AppVersion = version
- });
- db.SaveChanges();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement