예제 #1
0
        /// <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();
        }
예제 #2
0
        /// <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);
                }
            }
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
        public static void RefreshProfileCL2FDS(NodeType nodeType, string UID_Profile, string UID_Server, string Ident_Domain, IValueProvider vpCL)
        {
            IColDbObject    colProfileCL;
            ISingleDbObject cProfileCL  = null;
            ISingleDbObject oProfileFDS = null;

            ISqlFormatter fSQL = clsMain.Instance.CurrentConnection.Connection.SqlFormatter;

            try
            {
                // Change mousecursor
                Cursor.Current = Cursors.WaitCursor;

                switch (nodeType)
                {
                case NodeType.AppProfile:
                    // create the object
                    oProfileFDS = clsMain.Instance.CurrentConnection.Connection.CreateSingle("ApplicationProfile");

                    // fill primarykeys
                    oProfileFDS["UID_Profile"].NewValue = UID_Profile;
                    oProfileFDS.Load();

                    // create the object
                    colProfileCL = clsMain.Instance.CurrentConnection.Connection.CreateCol("ApplicationProfile");
                    colProfileCL.Prototype["UID_Application"].NewValue = oProfileFDS["UID_Application"].New.String;
                    colProfileCL.Prototype["Ident_OS"].NewValue        = oProfileFDS["Ident_OS"].New.String;
                    colProfileCL.Prototype["Ident_InstType"].NewValue  = oProfileFDS["Ident_InstType"].New.String;
                    colProfileCL.Prototype["Ident_DomainRD"].NewValue  = vpCL.GetValue("Ident_Domain").String;

                    break;

                case NodeType.DrvProfile:
                    // create the object
                    oProfileFDS = clsMain.Instance.CurrentConnection.Connection.CreateSingle("DriverProfile");

                    // fill primarykeys
                    oProfileFDS["UID_Profile"].NewValue = UID_Profile;
                    oProfileFDS.Load();

                    // create the object
                    colProfileCL = clsMain.Instance.CurrentConnection.Connection.CreateCol("DriverProfile");
                    colProfileCL.Prototype["UID_Driver"].NewValue     = oProfileFDS["UID_Driver"].New.String;
                    colProfileCL.Prototype["Ident_DomainRD"].NewValue = vpCL.GetValue("Ident_Domain").String;

                    break;

                case NodeType.MacType:
                    // create the object
                    oProfileFDS = clsMain.Instance.CurrentConnection.Connection.CreateSingle("MachineType");

                    // fill primarykeys
                    oProfileFDS["UID_MachineType"].NewValue = UID_Profile;
                    oProfileFDS.Load();

                    // create the object
                    colProfileCL = clsMain.Instance.CurrentConnection.Connection.CreateCol("MachineType");
                    colProfileCL.Prototype["Ident_MachineType"].NewValue       = oProfileFDS["Ident_MachineType"].New.String;
                    colProfileCL.Prototype["Ident_DomainMachineType"].NewValue = vpCL.GetValue("Ident_Domain").String;

                    break;

                default:
                    throw new Exception("Invalid nodeType " + nodeType.ToString() + " for _RefreshProfileCopy.");
                }

                // Source Coll Laden
                colProfileCL.Load();

                if (colProfileCL.Count > 0)
                {
                    cProfileCL = colProfileCL[0].Create();

                    if (nodeType == NodeType.MacType)
                    {
                        cProfileCL.PutValue("MakeFullCopy", true);
                        cProfileCL.Custom.CallMethod("SvrCopy", "COPYCL2FDS", "", "", clsMain.Instance.CurrentConnection.Connection.LocalNow, Ident_Domain);
                    }
                    else
                    {
                        cProfileCL.Custom.CallMethod("SvrCopy", "COPYCL2FDS", "", "", clsMain.Instance.CurrentConnection.Connection.LocalNow, Ident_Domain, false);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionDialog.Show(null, ex);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        /// <summary>
        /// Führt die Mengenbehandlung zwischen Feedback-File und DB durch.
        /// Einträge werden dabei neu angelegt bzw. als deinstalliert markiert.
        /// </summary>
        public void _SetMachineInstallStateInDB(string uid, IDictionary <string, DBAppDrvInfo> appInfos, DateTime lastModified)
        {
            IColDbObject    colMachineAppsInfo = ConnectData.Connection.CreateCol("MachineAppsInfo");
            ISingleDbObject proto = colMachineAppsInfo.Prototype;

            proto.Columns["UID_Hardware"].IsDisplayItem    = true;
            proto.Columns["UID_Application"].IsDisplayItem = true;
            proto.Columns["UID_Driver"].IsDisplayItem      = true;
            proto.Columns["AppsNotDriver"].IsDisplayItem   = true;
            proto.Columns["Revision"].IsDisplayItem        = true;

            proto.PutValue("UID_Hardware", uid);
            proto.PutValue("CurrentlyActive", true);
            proto.OrderBy = "InstallDate desc";

            colMachineAppsInfo.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.
             */
            foreach (IColElem elem in colMachineAppsInfo)
            {
                var uidAppDrv = elem.GetValue <bool>("AppsNotDriver")
                                        ? elem.GetValue <string>("UID_Application")
                                        : elem.GetValue <string>("UID_Driver");

                // AppsInfo vorhanden und Revision gleich
                DBAppDrvInfo appInfo;
                if (appInfos.TryGetValue(uidAppDrv, out appInfo) &&
                    string.Equals(appInfo.AssociatedAppsDrvProfileInfo.Revision, elem.GetValue("Revision").String))
                {
                    // Applikation oder Treiber sind bereits installiert -> merken
                    appInfo.IsInstalledInDB = true;
                }
                else
                {
                    // Diese Applikation oder dieser Treiber ist nicht
                    // mehr installiert -> setze den Status in der DB
                    ISingleDbObject machineAppsInfo = elem.Create();

                    machineAppsInfo.PutValue("CurrentlyActive", false);
                    machineAppsInfo.PutValue("DeInstallDate", lastModified);

                    machineAppsInfo.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)
                {
                    ISingleDbObject machineAppsInfo = ConnectData.Connection.CreateSingle("MachineAppsInfo");

                    machineAppsInfo.PutValue("CurrentlyActive", true);
                    machineAppsInfo.PutValue("InstallDate", lastModified);
                    machineAppsInfo.PutValue("UID_InstallationType", info.UidInstallationType);
                    machineAppsInfo.PutValue("UID_OS", info.UidOperatingSystem);
                    machineAppsInfo.PutValue("Revision", Convert.ToInt32(info.AssociatedAppsDrvProfileInfo.Revision));
                    machineAppsInfo.PutValue("UID_Hardware", uid);

                    if (info.IsApplication)
                    {
                        machineAppsInfo.PutValue("UID_Application", info.UidAppDrv);
                        //machineAppsInfo.PutValue("DisplayName", info.AppDrvNameFull);
                        machineAppsInfo.PutValue("AppsNotDriver", true);
                    }
                    else
                    {
                        machineAppsInfo.PutValue("UID_Driver", info.UidAppDrv);
                        //machineAppsInfo.PutValue("DisplayName", info.AppDrvNameFull);
                        machineAppsInfo.PutValue("AppsNotDriver", false);
                    }

                    machineAppsInfo.Save();
                }
            }
        }