Ejemplo n.º 1
0
        private void _RemoveOutdatedAppsInfo()
        {
            // remove outdated entries in MachineAppsInfo
            ISqlFormatter sqlFormatter = ConnectData.Connection.SqlFormatter;
            DateTime      outDate;
            int           age;

            age = _MaxAgeMachine;

            if (age < int.MaxValue)
            {
                outDate = DateTime.UtcNow.Subtract(new TimeSpan(age, 0, 0, 0));

                if (outDate > DbVal.MinDate)
                {
                    _RemoveTableEntries(
                        "MachineAppsInfo",
                        sqlFormatter.AndRelation(
                            sqlFormatter.Comparison("CurrentlyActive", false, ValType.Bool),
                            sqlFormatter.Comparison("DeInstallDate", outDate,
                                                    ValType.Date, CompareOperator.LowerThan)));
                }
            }

            age = _MaxAgeUser;

            if (age < int.MaxValue)
            {
                outDate = DateTime.UtcNow.Subtract(new TimeSpan(age, 0, 0, 0));

                if (outDate > DbVal.MinDate)
                {
                    // remove outdated entries in ADSAccountAppsInfo
                    _RemoveTableEntries(
                        "ADSAccountAppsInfo",
                        sqlFormatter.AndRelation(
                            sqlFormatter.Comparison("CurrentlyActive", false, ValType.Bool),
                            sqlFormatter.Comparison("DeInstallDate", outDate,
                                                    ValType.Date, CompareOperator.LowerThan)));
                }
            }

            age = _MaxAgeClientLog;

            if (age < int.MaxValue)
            {
                outDate = DateTime.UtcNow.Subtract(new TimeSpan(age, 0, 0, 0));

                if (outDate > DbVal.MinDate)
                {
                    // remove outdated entries in ClientLog
                    _RemoveTableEntries(
                        "ClientLog",
                        sqlFormatter.Comparison("InstallDate",
                                                outDate, ValType.Date,
                                                CompareOperator.LowerThan));
                }
            }
        }
        private void UID_Application_ValueChecking(object sender, ColumnEventArgs e)
        {
            string strWhereClause = "";

            using (NoRightsCheck())
            {
                if (0 < e.New.String.Length)
                {
                    ISqlFormatter fSQL = DbObject.Connection.SqlFormatter;

                    //MSSQL:(UID_Application = '0f90b30e-f1cc-11d4-9700-00508b8f013d') and (isnull(IsProfileApplication, 0) = 0)
                    //Oracle:(UID_Application = '0f90b30e-f1cc-11d4-9700-00508b8f013d') and (nvl(IsProfileApplication, 0) = 0)
                    strWhereClause =
                        fSQL.AndRelation(
                            fSQL.Comparison("UID_Application", e.New.String, ValType.String, CompareOperator.Equal, FormatterOptions.None),
                            fSQL.Comparison("IsProfileApplication", false, ValType.Bool));

                    // Die zugewiesene Applikation ist keine ProfilApplikation
                    if (DbObject.Connection.Exists("Application", strWhereClause))
                    {
                        throw new ViException(881106, ExceptionRelevance.EndUser);
                    }
                }
            }
        }
        /// <exclude/>
        /// <summary>
        /// Es wird geprüft, ob zu der zu diesem Profil zugehörigen Applikation Profile vorhanden sind.
        /// Falls ja, wird das Flag IsProfileApplication in Application auf 1 gesetzt
        /// Falls nicht, wird das Flag IsProfileApplication in Application auf 0 gesetzt.
        /// </summary>
        private void _CheckIsProfileApplication()
        {
            IColDbObject  colApplicationProfile = DbObject.Connection.CreateCol("ApplicationProfile");;
            ISqlFormatter fSQL = DbObject.Connection.SqlFormatter;

            // Objekt wurde gelöscht
            if (DbObject.IsDeleted)
            {
                // geloescht

                // gibt es noch andere Profile ???
                colApplicationProfile.Prototype.WhereClause =
                    fSQL.AndRelation(fSQL.Comparison("UID_Application", DbObject["UID_Application"].New.String,
                                                     ValType.String, CompareOperator.Equal, FormatterOptions.None),
                                     fSQL.Comparison("UID_Profile", DbObject["UID_Profile"].New.String,
                                                     ValType.String, CompareOperator.NotEqual, FormatterOptions.None)
                                     );

                // nein
                if (colApplicationProfile.DBCount == 0)
                {
                    // exists the Application ( we are not in DeleteCascade )
                    // This Check is required because the UID_Application is filled, but the Object is already deleted
                    if (DbObject.Connection.Exists("Application", fSQL.Comparison("UID_Application", DbObject["UID_Application"].New.String,
                                                                                  ValType.String, CompareOperator.Equal, FormatterOptions.None)))
                    {
                        // auf false setzen
                        ISingleDbObject dbApplication = DbObject.GetFK("UID_Application").Create();

                        if (dbApplication != null)
                        {
                            if (dbApplication["IsProfileApplication"].New.Bool == true)
                            {
                                dbApplication["IsProfileApplication"].NewValue = false;
                                dbApplication.Save();
                            }
                        }
                    }
                }
            }

            // Objekt wurde neu angelegt
            if (!DbObject.IsLoaded)
            {
                // Insert
                ISingleDbObject dbApplication = DbObject.GetFK("UID_Application").Create();

                if (dbApplication != null)
                {
                    if (dbApplication["IsProfileApplication"].New.Bool == false)
                    {
                        dbApplication["IsProfileApplication"].NewValue = true;
                        dbApplication.Save();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private async Task Check_IdentSectionName(LogicParameter lp)
        {
            string identSectionName = lp.Entity.GetValue <string>("Ident_SectionName");

            //Leerer SectionName wird nicht getestet
            if (String.IsNullOrEmpty(identSectionName))
            {
                return;
            }

            ISqlFormatter fSQL = lp.SqlFormatter;

            string strWhereClause = fSQL.AndRelation(
                fSQL.Comparison("Ident_SectionName", identSectionName, ValType.String),
                fSQL.Comparison("AppsNotDriver", false, ValType.Bool));

            //Test, ob es eine TreiberSection mit diesem Ident gibt
            if (await lp.Session.Source().ExistsAsync("SectionName", strWhereClause, lp.CancellationToken).ConfigureAwait(false))
            {
                throw new ViException(2117033, ExceptionRelevance.EndUser, identSectionName);
            }

            strWhereClause = fSQL.Comparison("Ident_SectionName", identSectionName, ValType.String);

            if (lp.Entity.IsLoaded)
            {
                //wenn es sich um die eigene Applikation handelt
                strWhereClause = fSQL.AndRelation(
                    strWhereClause,
                    fSQL.UidComparison("UID_Application", lp.Entity.GetValue <string>("UID_Application"), CompareOperator.NotEqual));
            }

            if (await lp.Session.Source().ExistsAsync("Application", strWhereClause, lp.CancellationToken).ConfigureAwait(false))
            {
                throw new ViException(2117031, ExceptionRelevance.EndUser, identSectionName);
            }
        }
        private async Task _HandleIsProfileApplication(LogicParameter lp)
        {
            ISqlFormatter fSQL = lp.SqlFormatter;

            // Objekt wurde gelöscht
            if (lp.Entity.IsDeleted())
            {
                // geloescht
                // gibt es noch andere Profile ???
                string strWhereClause =
                    fSQL.AndRelation(fSQL.UidComparison("UID_Application", lp.Entity.GetValue <string>("UID_Application")),
                                     fSQL.UidComparison("UID_Profile", lp.Entity.GetValue <string>("UID_Profile"), CompareOperator.NotEqual)
                                     );

                // nein
                if (!await lp.Session.Source().ExistsAsync("ApplicationProfile", strWhereClause, lp.CancellationToken).ConfigureAwait(false))
                {
                    DbObjectKey dbokApplication = DbObjectKey.GetObjectKey("Application", lp.Entity.GetValue <string>("UID_Application"));

                    TryResult <IEntity> trApplication = await lp.Session.Source().TryGetAsync(dbokApplication, lp.CancellationToken).ConfigureAwait(false);

                    if (trApplication.Success &&
                        trApplication.Result.GetValue <bool>("IsProfileApplication"))
                    {
                        trApplication.Result.SetValue("IsProfileApplication", false);

                        await lp.UnitOfWork.PutAsync(trApplication.Result, lp.CancellationToken).ConfigureAwait(false);
                    }
                }
            }

            // Objekt wurde neu angelegt
            if (!lp.Entity.IsLoaded)
            {
                DbObjectKey dbokApplication = DbObjectKey.GetObjectKey("Application", lp.Entity.GetValue <string>("UID_Application"));

                TryResult <IEntity> trApplication = await lp.Session.Source().TryGetAsync(dbokApplication, lp.CancellationToken).ConfigureAwait(false);

                if (trApplication.Success && !
                    trApplication.Result.GetValue <bool>("IsProfileApplication"))
                {
                    // mark as IsProfileApplication
                    trApplication.Result.SetValue("IsProfileApplication", true);

                    await lp.UnitOfWork.PutAsync(trApplication.Result, lp.CancellationToken).ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 6
0
        private async Task Handle_DriverProfiles(LogicParameter lp)
        {
            bool bUpdateProfiles =
                (lp.Session.MetaData().IsTableEnabled("DriverProfile")
                 &&
                 (
                     lp.Entity.Columns["Ident_Driver"].IsDifferent ||
                     lp.Entity.Columns["Ident_Language"].IsDifferent ||
                     lp.Entity.Columns["Ident_Sectionname"].IsDifferent ||
                     lp.Entity.Columns["Version"].IsDifferent ||
                     lp.Entity.Columns["Ident_OS"].IsDifferent
                 )
                );

            if (!bUpdateProfiles)
            {
                return;
            }

            ISqlFormatter fSQL = lp.SqlFormatter;

            string strWhereClause = fSQL.AndRelation(
                fSQL.UidComparison("UID_Driver", lp.Entity.GetValue <string>("UID_Driver")),
                fSQL.OrRelation(
                    fSQL.Comparison("UpdatePathVII", false, ValType.Bool),
                    fSQL.Comparison("UpdateProfileVII", false, ValType.Bool))

                );

            Query qDriverProfile = Query.From("DriverProfile")
                                   .Where(strWhereClause)
                                   .SelectAll();

            IEntityCollection colDriverProfile = await lp.Session.Source().GetCollectionAsync(qDriverProfile, EntityCollectionLoadType.Bulk, lp.CancellationToken).ConfigureAwait(false);

            foreach (IEntity eDriverProfile in colDriverProfile)
            {
                // set the flags
                eDriverProfile.SetValue("UpdatePathVII", true);
                eDriverProfile.SetValue("UpdateProfileVII", true);

                // and save
                await lp.UnitOfWork.PutAsync(eDriverProfile).ConfigureAwait(false);
            }
        }
Ejemplo n.º 7
0
        private static async Task <string> IsThereAnotherCentralLibrary(ISession session, IEntity entity, CancellationToken ct)
        {
            if (String.IsNullOrEmpty(entity.GetValue <string>("UID_Applicationserver")))
            {
                return("");
            }

            ISqlFormatter fSQL = session.Resolve <ISqlFormatter>();

            string strWhereClause = fSQL.AndRelation(
                fSQL.UidComparison("UID_ApplicationServer", entity.GetValue <string>("UID_Applicationserver"), CompareOperator.NotEqual),
                fSQL.Comparison("IsCentralLibrary", true, ValType.Bool));

            Query qApplicationServer = Query.From("ApplicationServer")
                                       .Where(strWhereClause)
                                       .SelectDisplays();

            IEntityCollection colApplicationServer = await session.Source().GetCollectionAsync(qApplicationServer, EntityCollectionLoadType.Default, ct).ConfigureAwait(false);

            return(colApplicationServer.Count > 0 ? colApplicationServer[0].Display : "");
        }
Ejemplo n.º 8
0
        /// <exclude/>
        /// <summary>
        /// Test, ob HW und MachineType der HW in der gleichen Domäne sind
        /// </summary>
        private async Task <bool> Check_SDLDomainRD(ISession session, IEntity entity, IEntityWalker walker, string uidSDLDomainRD, CancellationToken ct)
        {
            if (!session.MetaData().IsTableEnabled("MachineType"))
            {
                return(true);
            }

            // wenn Spalte leer ist -> raus
            if (String.IsNullOrEmpty(uidSDLDomainRD))
            {
                return(true);
            }

            DbObjectKey dbokMachineType = DbObjectKey.GetObjectKey("MachineType", entity.GetValue <string>("UID_MachineType"));

            var trMachineType = await session.Source().TryGetAsync(dbokMachineType, ct).ConfigureAwait(false);

            // FK not valid
            if (!trMachineType.Success)
            {
                return(true);
            }

            // compare the domain-id's
            if (!String.Equals(uidSDLDomainRD, trMachineType.Result.GetValue <string>("UID_SDLDomain"), StringComparison.OrdinalIgnoreCase))
            {
                // try to find same mactype name in new resource domain
                ISqlFormatter fSQL           = session.Resolve <ISqlFormatter>();
                string        strWhereClause = fSQL.AndRelation(
                    fSQL.Comparison("Ident_MachineType", trMachineType.Result.GetValue <string>("Ident_MachineType"), ValType.String, CompareOperator.Equal),
                    fSQL.UidComparison("UID_SDLDomain", uidSDLDomainRD));

                // query for this object
                var uidMachineType = await session.Source().TryGetSingleValueAsync <string>("MachineType", "UID_MachineType", strWhereClause, ct).ConfigureAwait(false);

                await entity.PutValueAsync("UID_MachineType", uidMachineType.Success?uidMachineType.Result : "", ct).ConfigureAwait(false);
            }

            return(true);
        }
        private async Task _SetRightOrderNumber(LogicParameter lp)
        {
            ISqlFormatter fSQL = lp.SqlFormatter;

            string strWhereClause = SqlStrings.Format(lp.Session.Database().SystemIdentifier,
                                                      "SDL_AppProfile_MaxOrderNumber",
                                                      fSQL.AndRelation(
                                                          fSQL.UidComparison("UID_SDLDomainRD", lp.Entity.GetValue <string>("UID_SDLDomainRD")),
                                                          fSQL.UidComparison("UID_Profile", lp.Entity.GetValue <string>("UID_Profile"), CompareOperator.NotEqual)
                                                          ));

            // try to get the highest OrderNumber
            var trumber = await lp.Session.Source().TryGetSingleValueAsync <double>("ApplicationProfile", "OrderNumber", strWhereClause, lp.CancellationToken).ConfigureAwait(false);

            double number = trumber.Success ? trumber.Result : 0;

            if (number < 10000)
            {
                number += 10000;
            }

            lp.Entity.SetValue("OrderNumber", number + 1);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Wird aufgerufen, bevor der MainActivator aktiviert wird.
        /// Hier sollten alle von einem DB-Objekt abhängige Initialisierungen
        /// durchgeführt werden.
        /// </summary>
        private void MainActivator_OnActivating(object sender, System.EventArgs e)
        {
            try
            {
                // Daten holen und prüfen
                ISingleDbObject dbobject = m_MainActivator.DbObject;

                if (dbobject == null)
                {
                    return;
                }

                ISqlFormatter f = dbobject.Connection.SqlFormatter;

                string statement = string.Format("select UpdateWhereClause from DialogTableGroupRight where {0} and UID_DialogGroup in (select UID_DialogGroup from DialogUserInGroup where UID_DialogUser in (select UID_DialogUser from DialogUser where {1}))",
                                                 f.AndRelation(
                                                     f.Comparison("UID_DialogTable", "SDL-T-SDLDomain", ValType.String),
                                                     f.Comparison("CanEdit", true, ValType.Bool)
                                                     ),
                                                 f.Comparison("username", dbobject.Connection.User.Identifier, ValType.String));

                SqlExecutor exec       = dbobject.Connection.CreateSqlExecutor((byte[])m_MainActivator.Variables[GenericPropertyDictionary.ConnectionPublicKey, null]);
                IDataReader datareader = null;

                using (datareader = exec.SqlExecute(statement))
                {
                    statement = "select count(*) from SDLDOmain where " + SqlFormatter.UidComparison("UID_SDLDomain", dbobject["UID_SDLDomainRDOwner"].New.String);
                    string wherest = "";

                    while (datareader.Read())
                    {
                        string where = datareader.GetString(0).Trim();

                        if (where == "")
                        {
                            wherest = "";
                            break;
                        }

                        wherest = wherest.Length == 0 ? string.Format("({0})", where) :
                                  string.Format("{0} or ({1})", wherest, where);
                    }

                    if (wherest != "")
                    {
                        statement = statement + string.Format(" and ({0})", wherest);
                    }
                }

                object result = exec.SqlExecuteScalar(Connection.Variables.Replace(statement));

                if (result != null && Convert.ToInt32(result) > 0)
                {
                    m_MemberRelation1.WhereClause = string.Format("(UID_SDLDomain in (select UID_SDLDomain from ApplicationServer) or {0}) and not (UID_SDLDomain in (select UID_SDLDomain from ApplicationServer Where {1}))",
                                                                  SqlFormatter.UidComparison("UID_ServerTAS", "", CompareOperator.NotEqual),
                                                                  SqlFormatter.Comparison("IsCentralLibrary", true, ValType.Bool));
                    m_LblHinweis.Visible = false;
                }
                else
                {
                    m_MemberRelation1.WhereClause = string.Format("{0} = {1}", SqlFormatter.FormatValue(1, ValType.Int), SqlFormatter.FormatValue(2, ValType.Int));
                    m_LblHinweis.Visible          = true;
                }
            }
            finally
            {
            }
        }