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); } } } }
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)); } } }
/// <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(); } } } }
private void _InsertDomains(TreeListNode tlnParent, string identParentDomain) { ISqlFormatter isql = clsMain.Instance.CurrentConnection.Connection.SqlFormatter; try { Cursor.Current = Cursors.WaitCursor; // create the collection IColDbObject dbcolDomains = clsMain.Instance.CurrentConnection.Connection.CreateCol("SDLDomain"); // assign the where-clause if (String.IsNullOrEmpty(identParentDomain)) { dbcolDomains.Prototype.WhereClause = isql.Comparison("UID_SDLDomainParent", "", ValType.String); } else { dbcolDomains.Prototype.WhereClause = isql.FkComparison("UID_SDLDomainParent", "UID_SDLDomain", "SDLDomain", isql.Comparison("Ident_Domain", identParentDomain, ValType.String)); } // appand the userdefined filter if (clsMain.Instance.DomainFilter.Length > 0) { dbcolDomains.Prototype.WhereClause = "(" + dbcolDomains.Prototype.WhereClause + ") and (" + clsMain.Instance.DomainFilter + ")"; } // mark as DisplayColumn dbcolDomains.Prototype["Ident_Domain"].IsDisplayItem = true; // load the collection dbcolDomains.Load(); //now do for each domain foreach (IColElem colElem in dbcolDomains) { // create a doamin-node TreeListNode tlnDomain = tlnParent.Nodes.Add(colElem.Display, 1); tlnDomain.Tag = new NodeData(NodeType.Domain, colElem.GetValue("Ident_Domain"), ""); // insert static subitems of domain _PrepareDomainNode(tlnDomain); // insert all childdomains _InsertDomains(tlnDomain, colElem.Display); } } catch (Exception ex) { ExceptionDialog.Show(this.ParentForm, ex); } finally { Cursor.Current = Cursors.Default; } }
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); } }
/// <exclude/> /// <summary> /// /// </summary> private void _SetRightOrderNumber() { Double number = 0; ISqlFormatter fSQL = DbObject.Connection.SqlFormatter; //MSSQL:isnull(ordernumber, 0) = (Select MAX(ordernumber) from ApplicationProfile where (Ident_DomainRD = 'domainRD') and (UID_Profile <> '08e4d48f-0f3e-11d6-b1e8-00508b8f0145')) //Oracle:ordernumber = (SELECT MAX(ORDERNUMBER) FROM APPLICATIONPROFILE WHERE (UPPER(IDENT_DOMAINRD) = 'DOMAINRD') AND (UID_PROFILE <> '08e4d48f-0f3e-11d6-b1e8-00508b8f0145')) string strWhereClause = string.Format( DbObject.Connection.SqlStrings["AppProfile_MaxOrderNumber"], fSQL.Comparison("Ident_DomainRD", DbObject["Ident_DomainRD"].NewValue, ValType.String), fSQL.Comparison("UID_Profile", DbObject["UID_Profile"].NewValue, ValType.String, CompareOperator.NotEqual, FormatterOptions.None)); number = DbObject.Connection.GetSingleProperty("ApplicationProfile", "OrderNumber", strWhereClause).Double; if (number < 10000) { number += 10000; } SetValue("OrderNumber", number + 1); }
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 void _GetCentralLibrary() { ISqlFormatter fSQL = clsMain.Instance.CurrentConnection.Connection.SqlFormatter; IColDbObject colApplicationServer = clsMain.Instance.CurrentConnection.Connection.CreateCol("ApplicationServer"); colApplicationServer.Prototype.WhereClause = fSQL.Comparison("IsCentralLibrary", true, ValType.Bool); colApplicationServer.Load(); if (colApplicationServer.Count > 0) { m_dbCentralLibrary = colApplicationServer[0].Create(); } else { m_dbCentralLibrary = null; } }
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); }
/// <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 { } }