private static Application ParseApplication(CsspIdentity packet, AtSackChristianService db) { var application = db.Applications.FindOrLoad(packet.ApplicationId); if (application != null) return application; application = db.Applications.NewRow(); packet.CopyInto(application); db.Applications.Add(application); return application; }
private static RComputer ParseRComputer(CsspIdentity packet, AtSackChristianService db) { var computer = db.RComputers.FindOrLoad(packet.ComputerId); if (computer != null) return computer; computer = db.RComputers.NewRow(); packet.CopyInto(computer); db.RComputers.Add(computer); return computer; }
private static ApplicationRelease ParseApplicationRelease(CsspIdentity packet, AtSackChristianService db) { var selector = $"{ApplicationReleasesTable.ApplicationIdCol} = '{packet.ApplicationId}' AND {ApplicationReleasesTable.VersionCol} LIKE '{packet.ApplicationVersion}'"; var localReleases = db.ApplicationReleases.Select(selector); var appRelease = localReleases.Length == 0 ? null : localReleases[0]; if (appRelease != null) return appRelease; var remoteReleases = db.ApplicationReleases.DownloadRows($"SELECT {db.ApplicationReleases.DefaultSqlSelector} FROM {ApplicationReleasesTable.NativeName} WHERE {selector}"); appRelease = remoteReleases.Length == 0 ? null : remoteReleases[0]; if (appRelease != null) return appRelease; appRelease = db.ApplicationReleases.NewRow(); packet.CopyInto(appRelease); appRelease.Application = ParseApplication(packet, db); db.ApplicationReleases.Add(appRelease); return appRelease; }
private static RUser ParseRUser(CsspIdentity packet, AtSackChristianService db) { var rUser = db.RUsers.FirstOrDefault(user => user.Sid.Equals(packet.UserSid, StringComparison.OrdinalIgnoreCase) && user.ComputerId == packet.ComputerId); if (rUser != null) return rUser; var rows = db.RUsers.DownloadRows($"SELECT {db.RUsers.DefaultSqlSelector} FROM {RUsersTable.NativeName} WHERE UPPER({RUsersTable.SidCol}) LIKE UPPER('{CsDbTableBase.SqlParam(packet.UserSid)}') AND {RUsersTable.ComputerIdCol} = '{packet.ComputerId}'"); if (rows.Length != 0) return rows[0]; rUser = db.RUsers.NewRow(); packet.CopyInto(rUser); rUser.RComputer = ParseRComputer(packet, db); db.RUsers.Add(rUser); return rUser; }