/// <summary> /// Ermittelt den Pfad auf dem TAS. /// </summary> /// <param name="profile_object"></param> /// <param name="strReturn">Pfad als String oder Fehlermeldung</param> /// <returns>Wahr, wenn der Pfad vollständig ermittelt werden konnte.</returns> public static bool GetPathOnTas(ISingleDbObject profile, string strReturn) { try { bool isapp = isApplicationProfile(profile); string prefix = "VIP7_Sync" + (isapp ? "App" : "Driver") + "Profile_"; if (profile.GetValue("UID_SDLDomainRD").String.Length == 0) { strReturn = LanguageManager.Instance[prefix + "ErrNoDomain"]; return(false); } ISingleDbObject domain = profile.GetFK("UID_SDLDomainRD").Create(); if (domain.GetValue("UID_ServerTAS").String.Length == 0) { strReturn = LanguageManager.Instance[prefix + "ErrNoTASinDomain"]; return(false); } string shareontas = domain.GetValue("ShareOnTAS").String; if (shareontas.Length == 0) { strReturn = LanguageManager.Instance[prefix + "ErrNoShareOnTASinDomain"]; return(false); } string clientpart = domain.GetValue((isapp ? "ClientPartApps" : "ClientPartDriver")).String; if (clientpart.Length == 0) { strReturn = LanguageManager.Instance[prefix + "ErrNoClientPartinDomain"]; return(false); } strReturn = @"\\" + domain.GetFK("UID_ServerTAS").Create().GetValue("Ident_Server") + @"\" + shareontas + @"\" + clientpart + @"\"; return(true); } catch (Exception exception) { strReturn = exception.Message; } return(false); }
private void _InsertCLRootNode( ) { TreeListNode tlnRoot; ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter; SqlExecutor cSQL = clsMain.Instance.CurrentConnection.Connection.CreateSqlExecutor(clsMain.Instance.CurrentConnection.PublicKey); try { Cursor.Current = Cursors.WaitCursor; _GetCentralLibrary(); // begin treeupdate tlcProfile.BeginUpdate(); // remove all old items tlcProfile.Nodes.Clear(); // Query for FDS string strIdentFDS = m_dbCentralLibrary == null ? "" : m_dbCentralLibrary.GetValue("Ident_Domain").String; // create a new rootnode tlnRoot = tlcProfile.Nodes.Add(LanguageManager.Instance.FormatString("frmFDSProfileOnServer_CLRoot", strIdentFDS), 0); tlnRoot.Tag = new NodeData(NodeType.Root, strIdentFDS, ""); // insert static subitems of CL domain _PrepareFDSDomainNode(tlnRoot); // expand our rootnode tlnRoot.Expand(false); tlcProfile.SelectedNode = tlnRoot; } catch (Exception ex) { ExceptionDialog.Show(this.ParentForm, ex); } finally { // end treeupdate tlcProfile.EndUpdate(); Cursor.Current = Cursors.Default; } }
/// <summary> /// Erzeuge einen ClientLog-Eintrag. /// </summary> /// <param name="machine"></param> /// <param name="account"></param> /// <param name="lastModified"></param> /// <param name="appInfo"></param> public void CreateClientLogEntry(ISingleDbObject machine, ISingleDbObject account, DateTime lastModified, ApplicationInfo appInfo) { ISingleDbObject clientLog = Conn.CreateSingle("ClientLog"); if (account != null) { clientLog.PutValue(ClientLogKeyColumn, GetAccountUID(account)); } if (machine != null) { clientLog.PutValue("UID_Hardware", machine.GetValue("UID_Hardware")); } clientLog.PutValue("InstallDate", lastModified); clientLog.PutValue("LogContent", appInfo.InstallLog); clientLog.Save(); }
/// <summary> /// /// </summary> private void MainActivator_OnActivated(object sender, System.EventArgs e) { try { if (m_MainActivator.DbObject == null) { return; } string path = ""; ISingleDbObject domain = m_MainActivator.DbObject; if (domain != null) { ISingleDbObject tas = domain.GetFK("UID_ServerTAS").Create(); if (tas != null && FormTool.CanSee(tas, "Ident_Server") && FormTool.CanSee(domain, "NetLogonOnTAS")) { path = @"\\" + tas.GetValue("Ident_Server") + @"\" + domain.GetValue("NetLogonOnTAS") + @"\"; if (!Directory.Exists(path)) { FormTool.ShowMessage("Der Pfad: " + path + " konnte nicht gefunden werden" + Environment.NewLine + "oder keine Verbindung zum Netzlaufwerk vorhanden."); } } } m_EditPath.Text = m_SaveFileDialog.InitialDirectory = m_OpenFileDialog.InitialDirectory = (path == "" || !Directory.Exists(path)) ? @"C:\" : path; } catch (Exception ex) { HandleException(ex); } }
/// <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(); } }
public static void RefreshProfileCopy(NodeType nodeType, string UID_Server, string UID_Profile, string ChgNrSoll) { ISingleDbObject oSgP = null; try { // Change mouse cursor Cursor.Current = Cursors.WaitCursor; switch (nodeType) { case NodeType.AppProfile: // create the object oSgP = clsMain.Instance.CurrentConnection.Connection.CreateSingle("AppServerGotAppProfile"); // fill primary keys oSgP["UID_ApplicationServer"].NewValue = UID_Server; oSgP["UID_Profile"].NewValue = UID_Profile; break; case NodeType.DrvProfile: // create the object oSgP = clsMain.Instance.CurrentConnection.Connection.CreateSingle("AppServerGotDriverProfile"); // fill primary keys oSgP["UID_ApplicationServer"].NewValue = UID_Server; oSgP["UID_Profile"].NewValue = UID_Profile; break; case NodeType.MacType: // create the object oSgP = clsMain.Instance.CurrentConnection.Connection.CreateSingle("AppServerGotMactypeInfo"); // fill primary keys oSgP["UID_ApplicationServer"].NewValue = UID_Server; oSgP["UID_MachineType"].NewValue = UID_Profile; break; default: throw new Exception("Invalid nodeType " + nodeType.ToString() + " for _RefreshProfileCopy."); } // try to load oSgP.Load(); // Change properties required for Update oSgP.PutValue("ProfileStateProduction", "EMPTY"); // Reverse the ChgNumber for MAC-Types if (nodeType == NodeType.MacType) { if (oSgP.GetValue("ChgNumber").Int > 0) { oSgP.PutValue("ChgNumber", -oSgP.GetValue("ChgNumber").Int); } } // now save the object oSgP.Save(); // and now fire the event VI.DB.JobGeneration.JobGen.Generate(oSgP, "Copy2PAS"); } catch (Exception ex) { ExceptionDialog.Show(null, ex); } finally { Cursor.Current = Cursors.Default; } }
private void cmPopup_Popup(object sender, System.EventArgs e) { // enable only for PAS-Server if (m_tlnServer != null && tlcProfile.SelectedNode != null) { NodeData nd = m_tlnServer.ParentNode.Tag as NodeData; bool bServer = nd.Type == NodeType.Server; bool bCL = m_dbCentralLibrary != null; mnuPopup_Copy.Enabled = bServer; mnuPopup_CL2FDS.Enabled = (nd.Type == NodeType.Domain) && bCL && (m_tlnServer.Tag as NodeData).Data1 != m_dbCentralLibrary.GetValue("UID_ApplicationServer").String; } else { mnuPopup_Copy.Enabled = false; mnuPopup_CL2FDS.Enabled = false; } }
public override string GetAccountUID(ISingleDbObject obj) { return(obj.GetValue <string>("UID_ADSAccount")); }
/// <summary> /// Synchronisation zwischen rofile.vii und Profil-Objekt. /// </summary> /// <param name="profile">Profil Objekt.</param> /// <param name="profviiPath">Vollständiger Pfad zur Profile.vii.</param> /// <returns></returns> public static bool SyncWithProfileVii(ISingleDbObject profile, string profviiPath) { /* * profile_object profile.vii master * ---------------------------------------------------------------------- * App.Ident_Sectionname Sektion db * ChgTest ChgNr max * Displayname Bezeichnung db * ClientStepCounter AnzahlEintraege vii * OSMode OSMode vii * MemoryUsage Speicherbedarf vii * OrderNumber OrdnungsNr db * ProfileType ProfileType vii * HashValueTAS ProfileHash vii * CachingBehavior LokaleZwischenspeicherbarkeit vii * RemoveHKeyCurrentUser VerarbeitungHkcuBeimDeinstallieren vii */ try { string profvii = ""; if (!ReadFileFromProfile(profviiPath, out profvii)) { throw new ViException(profviiPath); } if (string.IsNullOrEmpty(getViiValue(profvii, "ProfileHash"))) { throw new ViException(LanguageManager.Instance["VIP7_SyncAppProfile_ErrProfileNotAutark"]); } bool profviiChanged = false; string section = SectionName(profvii); string chgnr = getViiValue(profvii, "ChgNr"); string bezeichnung = getViiValue(profvii, "Bezeichnung"); string anzahleintraege = getViiValue(profvii, "AnzahlEintraege"); string osmode = getViiValue(profvii, "OSMode"); string speicherbedarf = getViiValue(profvii, "Speicherbedarf"); string ordnungsnr = getViiValue(profvii, "OrdnungsNr"); if (string.IsNullOrEmpty(ordnungsnr)) { ordnungsnr = FormatOrderNumber("0"); } string profiletype = getViiValue(profvii, "ProfileType"); string profilehash = getViiValue(profvii, "ProfileHash"); string cachingbehavior = getViiValue(profvii, "LokaleZwischenspeicherbarkeit").Trim(); bool removehkeycurrentuser = false; if (string.IsNullOrEmpty(chgnr)) { chgnr = "0"; profviiChanged = true; } //ChgNr or Changetest ? - take allways the max of both chgNumbers int intchgnr = int.Parse(chgnr); int objchgnr = profile.GetValue("ChgTest").Int; if (intchgnr > objchgnr) { profile.PutValue("ChgTest", intchgnr); } else if (intchgnr < objchgnr) { chgnr = profile.GetValue("ChgTest").String; profviiChanged = true; } if (string.IsNullOrEmpty(anzahleintraege)) { anzahleintraege = profile.GetValue("ClientStepCounter").String; profviiChanged = true; } if (string.IsNullOrEmpty(osmode)) { osmode = profile.GetValue("OSMode").String; profviiChanged = true; } if (string.IsNullOrEmpty(speicherbedarf)) { speicherbedarf = profile.GetValue("MemoryUsage").String; profviiChanged = true; } if (string.IsNullOrEmpty(profiletype)) { profiletype = profile.GetValue("ProfileType").String; profviiChanged = true; } if (string.IsNullOrEmpty(cachingbehavior)) { cachingbehavior = profile.GetValue("CachingBehavior").String; profviiChanged = true; } string dummy = getViiValue(profvii, "VerarbeitungHkcuBeimDeinstallieren").Trim().ToLowerInvariant(); if (string.IsNullOrEmpty(dummy)) { removehkeycurrentuser = profile.GetValue("RemoveHKeyCurrentUser").Bool; profviiChanged = true; } else { if (dummy == "wahr") { removehkeycurrentuser = true; } else if (dummy == "falsch") { removehkeycurrentuser = false; } else { removehkeycurrentuser = bool.Parse(dummy); } } // profile.vii is master if (profile.GetValue("ClientStepCounter").String != anzahleintraege) { profile.PutValue("ClientStepCounter", int.Parse(anzahleintraege)); } if (profile.GetValue("OSMode").String != osmode) { profile.PutValue("OSMode", osmode); } if (profile.GetValue("MemoryUsage").String != speicherbedarf) { profile.PutValue("MemoryUsage", speicherbedarf); } if (profile.GetValue("ProfileType").String != profiletype) { profile.PutValue("ProfileType", profiletype); } if (profile.GetValue("HashValueTAS").String != profilehash) { profile.PutValue("HashValueTAS", int.Parse(profilehash)); } if (profile.GetValue("CachingBehavior").String != cachingbehavior) { profile["CachingBehavior"].NewValue = cachingbehavior; } if (profile.GetValue("RemoveHKeyCurrentUser").Bool != removehkeycurrentuser) { profile["RemoveHKeyCurrentUser"].NewValue = removehkeycurrentuser; } // db is master ISingleDbObject appobject = (isApplicationProfile(profile) ? profile.GetFK("UID_Application").Create() : profile.GetFK("UID_Driver").Create()); if (appobject.GetValue("Ident_Sectionname").String != section) { section = appobject.GetValue("Ident_Sectionname").String; profviiChanged = true; } if (profile.GetValue("Displayname").String != bezeichnung) { bezeichnung = profile.GetValue("Displayname").String; profviiChanged = true; } string objordnungsnr = FormatOrderNumber(profile.GetValue("OrderNumber").String); if (ordnungsnr != objordnungsnr) { ordnungsnr = objordnungsnr; profviiChanged = true; } if (profviiChanged && IsProfileViiWriteable(profviiPath)) { profvii = "[" + section + "]" + Environment.NewLine + "ChgNr=" + chgnr + Environment.NewLine + "Bezeichnung=" + bezeichnung + Environment.NewLine + "AnzahlEintraege=" + anzahleintraege + Environment.NewLine + "OSMode=" + osmode + Environment.NewLine + "Speicherbedarf=" + speicherbedarf + Environment.NewLine + "OrdnungsNr=" + ordnungsnr + Environment.NewLine + "ProfileType=" + profiletype + Environment.NewLine + "ProfileHash=" + profilehash + Environment.NewLine + "LokaleZwischenspeicherbarkeit=" + cachingbehavior + Environment.NewLine + "VerarbeitungHkcuBeimDeinstallieren=" + removehkeycurrentuser.ToString(); // + "Autark=TRUE"; WriteToFile(profviiPath, profvii); } return(true); } catch (Exception exception) { VI.FormBase.ExceptionMgr.Instance.HandleException(exception, null); } return(false); }
/// <summary> /// Abspeichern der Übergabeparementer für Profile Eidtor. /// </summary> /// <param name="profile">Applikations- bzw. Treiberprofil.</param> /// <param name="domain">Domäne.</param> /// <param name="application">Application bzw. Treiber</param> /// <param name="path">Pfad des Profils, wenn bekannt.</param> /// <returns></returns> private static bool storeParameters(ISingleDbObject profile, ISingleDbObject domain, ISingleDbObject application, params string[] path) { try { string profpath = ""; if (path.Length > 0) { profpath = path[0]; } else if (!GetProfilePathOnTas(profile, out profpath)) { profpath = ""; } if (string.IsNullOrEmpty(profpath)) { return(false); } bool isapp = isApplicationProfile(profile); ISingleDbObject ptas = domain.GetFK("UID_ServerTAS").Create(); string server = ""; if (isapp && profile.GetValue("ServerDrive").String.Length != 0) { server = profile.GetValue("PackagePath").String.Length >= 0 ? @"\\" + ptas.GetValue("Ident_Server").String + @"\" + domain.GetValue("ServerPartShareOnTAS").String + @"\" + profile.GetValue("PackagePath").String : @"\\" + ptas.GetValue("Ident_Server").String + @"\" + domain.GetValue("ServerPartShareOnTAS").String + @"\" + profile.GetValue("SubPath").String; } saveProfileEditParm("Language", LanguageManager.Instance.Language); saveProfileEditParm("SectionName", application.GetValue("Ident_SectionName").String); saveProfileEditParm("ProfileName", profile.GetValue("DisplayName").String); saveProfileEditParm("OrderNumber", FormatOrderNumber(profile.GetValue("OrderNumber").String)); saveProfileEditParm("ChgNr", profile.GetValue("ChgTest").String); saveProfileEditParm("ProfilePath", profpath); saveProfileEditParm("ProfileKind", (isapp ? "ApplicationProfile" : "DriverProfile")); saveProfileEditParm("ProfilePathServer", server); saveProfileEditParm("MasterDomain", domain.GetValue("Ident_Domain").String); // saveProfileEditParm("DomainClientDrive", domain.GetValue("ClientDrive").String); saveProfileEditParm("DomainAppsDrive", (isapp ? profile.GetValue("ServerDrive").String : "")); saveProfileEditParm("DefDriveTarget", profile.GetValue("DefDriveTarget").String); saveProfileEditParm("ClientPartPathOnServers", domain.GetValue("ClientPartPathOnServers").String); saveProfileEditParm("DomainClientPart", (isapp ? domain.GetValue("ClientPartApps").String : domain.GetValue("ClientPartDriver").String)); saveProfileEditParm("ProfileSubPath", profile.GetValue("subpath").String); saveProfileEditParm("VariableStart", profile.Connection.GetConfigParm(@"Software\SoftwareDistribution\Variable\Start")); saveProfileEditParm("VariableEnd", profile.Connection.GetConfigParm(@"Software\SoftwareDistribution\Variable\End")); saveProfileEditParm("CachingBehavior", profile.GetValue("CachingBehavior").String); saveProfileEditParm("RemoveHKeyCurrentUser", profile.GetValue("RemoveHKeyCurrentUser").Bool ? "1" : "0"); saveProfileEditParm("ProfileType", profile.GetValue("ProfileType").String); saveProfileEditParm("OSMode", profile.GetValue("OSMode").String); saveProfileEditParm("ScanType", "NT4"); // in AE3 imemr NT4 damit der ProfilEditor CMDs schreibt return(true); } catch (Exception exception) { VI.FormBase.ExceptionMgr.Instance.HandleException(exception, null); } return(false); }
private void _CollectSoftwareFeedback(string directory) { /* * Garbage Collection für Einträge, die älter als das * eingestellte Intervall sind. */ _RemoveOutdatedAppsInfo(); var userDBAppDrvs = new Dictionary <string, DBAppDrvInfo>(StringComparer.Ordinal); var machineDBAppDrvs = new Dictionary <string, DBAppDrvInfo>(StringComparer.Ordinal); var installationTypesById = _GetIdMapping("InstallationType", "Ident_InstType", "UID_InstallationType"); var operatingSystemsById = _GetIdMapping("OS", "Ident_OS", "UID_OS"); foreach (string currFileName in Directory.GetFiles(directory, "*.ia")) { SetProgressInfo(LanguageManager.Instance.FormatString("SDL_ProcessingFile", currFileName)); try { using (Transaction t = new Transaction(ConnectData.Connection)) { // Hole Zeit der letzten Modifikation DateTime lastModified = File.GetLastWriteTimeUtc(currFileName); // cleanup hashtables userDBAppDrvs.Clear(); machineDBAppDrvs.Clear(); // Befülle das ApplicationInfo-Objekt aus der Datei FeedBackFile currFeedBackFile = new FeedBackFile(currFileName); ApplicationInfo appInformation = currFeedBackFile.GetApplicationInfo(); // Hole den passenden Namespace AccountNameSpace ns; switch (appInformation.MachineNamespace.ToUpperInvariant()) { case "ADS": ns = new ADSNameSpace(ConnectData); break; default: // Default: NT, LDAP throw new NotSupportedException($"Namespace {appInformation.MachineNamespace} is not supported (anymore)."); } // Hole den passenden User-Account zu den Informationen des ApplicationInfos. ISingleDbObject userAccount = ns.GetUserAccount(appInformation); if (userAccount == null) { Result.Messages.Add(LanguageManager.Instance["UserInformationNotSupported"]); } // Hole das Hardware-Objekt zu den Informationen des ApplicationInfos. ISingleDbObject machineAccount = ns.GetMachine(appInformation); if (machineAccount == null) { Result.Messages.Add(LanguageManager.Instance.FormatString("MachineInformationNotSupported", appInformation.MachineNamespace)); } // nicht bei ClientAbbruch if (appInformation.ErrorLevel != "4") { #region Client erfolgreich if (ns.NewerInstallDataDoesExist(lastModified, userAccount, machineAccount)) { /* * Es gibt bereits neuere Daten in der Datenbank. */ Result.Messages.Add(LanguageManager.Format("SDL_WarnNewerData", currFileName)); } else { /* * Einsammeln der DB-Daten für die Nutzerapplikationen */ if (userAccount != null) { _CollectDBAppInfos( appInformation.UserApplications, installationTypesById, operatingSystemsById, ns.GetAccountUID(userAccount), userDBAppDrvs, true); } /* * Einsammeln der DB-Daten für die Maschinenapplikationen */ if (machineAccount != null) { _CollectDBAppInfos( appInformation.MachineApplications, installationTypesById, operatingSystemsById, machineAccount.GetValue("UID_Hardware").String, machineDBAppDrvs, false); } /* * Behandle die dem Nutzer zugeordneten Applikationen */ if (userAccount != null) { foreach (DBAppDrvInfo currUserDbAppDrvInfo in userDBAppDrvs.Values) { // Applikationen sind deselektiert, wenn ein Nutzeranteil existiert, // aber kein Maschinenanteil. if (!machineDBAppDrvs.ContainsKey(currUserDbAppDrvInfo.UidAppDrv)) { currUserDbAppDrvInfo.IsDeselected = true; } } // Führe die Über- bzw. Untermengenbehandlung in der DB // durch. Dabei werden AppsInfo-Einträge angelegt bzw. als // deinstalliert markiert. ns.SetUserInstallStateInDB( ns.GetAccountUID(userAccount), userDBAppDrvs, lastModified); } /* * Behandle die der Maschine zugeordneten Applikationen * und Treiber. */ if (machineAccount != null) { _SetMachineInstallStateInDB( machineAccount.GetValue("UID_Hardware").String, machineDBAppDrvs, lastModified); } } #endregion } if (_MaxAgeClientLog == 0) { // remove all associated client log entries ns.RemoveClientLogEntries(machineAccount, userAccount); } else if (appInformation.InstallLog != null) { // create new client log entry ns.CreateClientLogEntry(machineAccount, userAccount, lastModified, appInformation); } t.Commit(); } if (File.Exists(currFileName)) { File.Delete(currFileName); } } finally { // rename response file, if still exists (to handle those files // that caused error messages / exceptions) if (File.Exists(currFileName)) { File.Move(currFileName, string.Format("{0}_{1:yyyyMMddHHmmss}", currFileName, DateTime.Now)); } } } // foreach file }