private async Task <bool> _CheckValidTo(ISession session, IEntity entity, IEntityWalker walker, DateTime dtValidTo, CancellationToken ct) { string uidLicence = entity.GetValue("UID_Licence"); // do not check Empty values if (DbVal.IsEmpty(uidLicence, ValType.String)) { return(true); } if (DbVal.IsEmpty(dtValidTo, ValType.Date)) { return(true); } // Get VailidFrom Licence DateTime dtValidToLicence = await walker.GetValueAsync <DateTime>("FK(UID_Licence).ValidTo", ct).ConfigureAwait(false); // Date in Licence is defined ? if (!DbVal.IsEmpty(dtValidToLicence, ValType.Date)) { // and smaler than our Date? if (dtValidToLicence < dtValidTo) { // Get Licence-Display string strLicence = await entity.Columns["UID_Licence"].GetDisplayValueAsync(session, ct).ConfigureAwait(false); // throw exception throw new ViException(2133215, ExceptionRelevance.EndUser, strLicence, dtValidToLicence); } } return(true); }
public override async Task <bool> OnGenerate(IEntity entity, string eventname, LogicReadWriteParameters parameters, CancellationToken cancellationToken) { Hashtable param = new Hashtable(StringComparer.OrdinalIgnoreCase); long ulCo = 0; Query qProfileCanUsedAlso = Query.From("ProfileCanUsedAlso") .Where(c => c.Column("UID_Profile") == entity.GetValue <string>("UID_Profile")) .SelectAll(); IEntityCollection colAlso = await parameters.Session.Source().GetCollectionAsync(qProfileCanUsedAlso, EntityCollectionLoadType.Bulk, cancellationToken).ConfigureAwait(false); foreach (IEntity colElem in colAlso) { IEntityWalker w = colElem.CreateWalker(parameters.Session); param.Add("ProfileCUA_Ident_InstTypeAlso" + ulCo, w.GetValue <string>("Ident_InstTypeAlso")); param.Add("ProfileCUA_Ident_OSAlso" + ulCo, w.GetValue <string>("Ident_OSAlso")); param.Add("ProfileCUA_UID_InstTypeAlso" + ulCo, w.GetValue <string>("UID_InstallationType")); param.Add("ProfileCUA_UID_OSAlso" + ulCo, w.GetValue <string>("UID_OS")); ulCo++; } return(await base.OnGenerate(entity, eventname, parameters, cancellationToken).ConfigureAwait(false)); }
private async Task <bool> Check_MachineType(ISession session, IEntity entity, IEntityWalker walker, string uidMachineType, CancellationToken ct) { if (!session.MetaData().IsTableEnabled("MachineType")) { return(true); } // wenn Spalte nicht geladen wurde if (String.IsNullOrEmpty(uidMachineType)) { return(true); } // no SDL domain defined string sdlDomain = entity.GetValue <string>("UID_SDLDomainRD"); if (String.IsNullOrEmpty(sdlDomain)) { return(true); } DbObjectKey dbokMachineType = DbObjectKey.GetObjectKey("MachineType", uidMachineType); 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(sdlDomain, trMachineType.Result.GetValue <string>("UID_SDLDomain"), StringComparison.OrdinalIgnoreCase)) { throw new ViException(2133091, ExceptionRelevance.EndUser); } return(true); }
/// <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 static async Task <bool> Check_IsCentralLibrary(ISession session, IEntity entity, IEntityWalker walker, bool isCentralLibrary, CancellationToken ct) { if (isCentralLibrary) { if (!String.IsNullOrEmpty(entity.GetValue <string>("UID_ParentApplicationServer"))) { throw new ViException(2116021, ExceptionRelevance.EndUser); } if (!entity.GetValue <bool>("IsCentralLibrary")) { string identOtherCl = await IsThereAnotherCentralLibrary(session, entity, ct).ConfigureAwait(false); if (!string.IsNullOrEmpty(identOtherCl)) { throw new ViException(2116027, ExceptionRelevance.EndUser, identOtherCl); } } if (!String.IsNullOrEmpty(entity.GetValue <string>("UID_ApplicationServerRedirect"))) { throw new ViException(2116167, ExceptionRelevance.EndUser); } } return(true); }
private static async Task <bool> Check_UidParentApplicationServer(ISession session, IEntity entity, IEntityWalker walker, string uidParentApplicationServer, CancellationToken ct) { //die Tests sind nur interessant, wenn ein Wert eingetragen wird if (String.IsNullOrEmpty(uidParentApplicationServer)) { return(true); } // Die CentralLibrary muss im Root liegen if (entity.GetValue <bool>("IsCentralLibrary")) { throw new ViException(2116021, ExceptionRelevance.EndUser); } Query qParent = Query.From("ApplicationServer") .Where(c => c.Column("UID_ApplicationServer") == uidParentApplicationServer) .Select("UID_SDLDomain"); string uidDomainParent = await session.Source().GetSingleValueAsync <string>(qParent, ct).ConfigureAwait(false); if (!string.Equals(uidDomainParent, entity.GetValue <string>("UID_SDLDomain"), StringComparison.Ordinal)) { throw new ViException(2116140, ExceptionRelevance.EndUser); } return(true); }