protected override IColDbObject CreateColUserAccount(ApplicationInfo app) { var colUserAccount = Conn.CreateCol("ADSAccount"); colUserAccount.Prototype.WhereClause = string.Format( "({0}) AND (UID_ADSDomain IN ( SELECT UID_ADSDomain FROM ADSDomain WHERE {1}))", Formatter.Comparison("SAMACCOUNTNAME", app.UserAccount, ValType.String), Formatter.Comparison("IDENT_DOMAIN", app.UserDomainContext, ValType.String)); colUserAccount.Load(); return(colUserAccount); }
protected override IColDbObject CreateColHardware(ApplicationInfo app) { var colMachineAccount = Conn.CreateCol("Hardware"); colMachineAccount.Prototype.WhereClause = $@"exists ( select 1 from ADSMachine m join ADSDomain d on m.UID_ADSDomain = d.UID_ADSDomain where m.UID_Hardware = Hardware.UID_Hardware and {Formatter.Comparison("m.SAMAccountName", app.MachineAccount, ValType.String)} and {Formatter.Comparison("d.Ident_Domain", app.MachineDomainContext, ValType.String)} )"; colMachineAccount.Load(); return(colMachineAccount); }
/// <summary> /// Entferne alle ClientLog-Einträge für diese Nutzer-Maschine-Kombination /// </summary> /// <param name="machine"></param> /// <param name="account"></param> public void RemoveClientLogEntries(ISingleDbObject machine, ISingleDbObject account) { IColDbObject colClientLog = Conn.CreateCol("ClientLog"); if (machine != null) { colClientLog.Prototype.PutValue("UID_Hardware", machine.GetValue("UID_Hardware")); } if (account != null) { colClientLog.Prototype.PutValue(ClientLogKeyColumn, GetAccountUID(account)); } colClientLog.Load(); foreach (IColElem elem in colClientLog) { ISingleDbObject clientLog = elem.Create(); clientLog.Delete(); clientLog.Save(); } }
/// <summary> /// Führt die Mengenbehandlung zwischen Feedback-File und DB durch. /// Einträge werden dabei neu angelegt bzw. als deinstalliert markiert. /// </summary> public void SetUserInstallStateInDB(string uid, IDictionary <string, DBAppDrvInfo> appInfos, DateTime lastModified) { IColDbObject colAppsInfo = Conn.CreateCol(AppsInfoTable); ISingleDbObject proto = colAppsInfo.Prototype; proto["UID_Application"].IsDisplayItem = true; proto["Revision"].IsDisplayItem = true; proto.PutValue(AppsInfoKeyColumn, uid); proto.PutValue("CurrentlyActive", true); proto.OrderBy = "InstallDate desc"; colAppsInfo.Load(); /* * Überprüfe den Status aller als installiert * gesetzten AppInfo-Einträge in der DB. * Setze deren Status gegebenenfalls auf * deinstalliert, wenn sie im Feedback-File * nicht vorkommen oder als deselektiert markiert * sind. */ foreach (IColElem elem in colAppsInfo) { var deinstalled = false; // AppsInfo voahnden und Revision gleich DBAppDrvInfo appInfo; if (appInfos.TryGetValue(elem.GetValue <string>("UID_Application"), out appInfo) && string.Equals(appInfo.AssociatedAppsDrvProfileInfo.Revision, elem.GetValue("Revision").String, StringComparison.Ordinal)) { if (appInfo.IsDeselected) { // Applikation is abgewählt -> markiere als deinstalliert deinstalled = true; } else { // Merke: Diese Applikation ist bereits als installiert vermerkt appInfo.IsInstalledInDB = true; } } else { // Applikation war im Feedback-File nicht vorhanden // -> markiere als deinstalled deinstalled = true; } if (deinstalled) { // Wir markieren dieses AppInfo als deinstalliert ISingleDbObject currAppsInfo = elem.Create(); currAppsInfo.PutValue("DeInstallByUser", true); currAppsInfo.PutValue("CurrentlyActive", false); currAppsInfo.PutValue("DeInstallDate", lastModified); currAppsInfo.Save(); } } /* * Lege alle Einträge an, die nicht bereits in der Datenbank * als installiert vorhanden sind. */ foreach (DBAppDrvInfo info in appInfos.Values) { if (!info.IsInstalledInDB && !info.IsDeselected) { CreateApplicationEntryInDB(info, lastModified); } } }