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); } } }
private Task Handle_TroubleProduct(LogicParameter lp) { ISqlFormatter fSQL = lp.SqlFormatter; return(TroubleProductHelper.HandleTroubleProduct( lp, "Application", lp.Entity.GetValue <string>("NameFull"), "ApplicationProfile", fSQL.UidComparison("UID_Application", lp.Entity.GetValue <string>("UID_Application")))); }
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); }
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); } }
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 : ""); }
/// <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 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); } }