/// <summary> /// Query Function "GetContacts" of Action "BootstrapContacts" /// </summary> public static RLContactRecordList datasetGetContacts(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount) { // Query Iterations: Never {-unbound-} // Uses binary data: False if (multiplicity == IterationMultiplicity.Never) { maxRecords = 1; } outParamCount = -1; bool useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150)); Transaction trans = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction(); Command sqlCmd = trans.CreateCommand(); string sql = ""; StringBuilder selectBuilder = new StringBuilder(); StringBuilder fromBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); StringBuilder orderByBuilder = new StringBuilder(); StringBuilder groupByBuilder = new StringBuilder(); StringBuilder havingBuilder = new StringBuilder(); selectBuilder.Append("SELECT "); if (maxRecords > 0) { selectBuilder.Append("TOP ("); selectBuilder.Append(maxRecords); selectBuilder.Append(") "); } selectBuilder.Append("NULL o0, NULL o1, NULL o2, NULL o3, NULL o4, NULL o5"); fromBuilder.Append(" FROM {Contact} ENContact"); sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString(); string advSql = sql; sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql); sqlCmd.CommandText = sql; try { RLContactRecordList outParamList = new RLContactRecordList(); outParamList.Transaction = trans; BitArray[] opt = new BitArray[1]; opt[0] = new BitArray(new bool[] { true, true, true, true, true, true }); outParamList.AllOptimizedAttributes = opt; if (multiplicity == IterationMultiplicity.Multiple) { RLContactRecordList _tmp = new RLContactRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; _tmp.MaxRecords = maxRecords; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query BootstrapContacts.GetContacts.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList = (RLContactRecordList)_tmp.Duplicate(); _tmp.CloseDataReader(); return(outParamList); } finally { _tmp.CloseDataReader(); } } else if (multiplicity == IterationMultiplicity.Never) { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query BootstrapContacts.GetContacts.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; return(outParamList); } finally { outParamList.CloseDataReader(); } } else { if (maxRecords > 0 && maxRecords <= 150) { RLContactRecordList _tmp = new RLContactRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query BootstrapContacts.GetContacts.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList = (RLContactRecordList)_tmp.Duplicate(); outParamList.AllOptimizedAttributes = opt; _tmp.CloseDataReader(); return(outParamList); } finally { _tmp.CloseDataReader(); } } else { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query BootstrapContacts.GetContacts.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("4739eddd-b487-c2b7-5dec-e0d4a6541fb7", "BootstrapContacts.GetContacts", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; return(outParamList); } finally { if (maxRecords == 1) { outParamList.CloseDataReader(); } } } } } catch (Exception e) { throw new DataBaseException("Error executing query.", e); } }
/// <summary> /// Query Function "GetCurrentApplication" of Action "GetApplicationName" /// </summary> public static RLApplicationRecordList datasetGetCurrentApplication(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount, int qpinESpaceId) { // Query Iterations: Never {-unbound-} // Uses binary data: False if (multiplicity == IterationMultiplicity.Never) { maxRecords = 1; } outParamCount = -1; CacheHelper myCacheHelper = new CacheHelper(); myCacheHelper.AddValue(Global.eSpaceId); myCacheHelper.AddValue("8ncuMQL0nf3wuIPtCEpJMw"); myCacheHelper.AddValue(heContext.AppInfo.Tenant.Id.ToString()); myCacheHelper.AddValue(Convert.ToString(maxRecords)); myCacheHelper.AddValue(Convert.ToString(qpinESpaceId)); string cacheHash = myCacheHelper.GetHash(); OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long> temp = RuntimeCache.Instance.Get(new CacheKey(cacheHash)) as OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>; if (temp == null) { bool useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150)); Transaction trans = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction(); Command sqlCmd = trans.CreateCommand(); string sql = ""; StringBuilder selectBuilder = new StringBuilder(); StringBuilder fromBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); StringBuilder orderByBuilder = new StringBuilder(); StringBuilder groupByBuilder = new StringBuilder(); StringBuilder havingBuilder = new StringBuilder(); selectBuilder.Append("SELECT "); if (maxRecords > 0) { selectBuilder.Append("TOP ("); selectBuilder.Append(maxRecords); selectBuilder.Append(") "); } selectBuilder.Append("NULL o0, ENApplication.[NAME] o1, NULL o2, NULL o3, NULL o4, NULL o5, NULL o6, NULL o7, NULL o8, NULL o9, NULL o10, NULL o11, NULL o12, NULL o13"); fromBuilder.Append(" FROM {Application} ENApplication"); whereBuilder.Append(" WHERE ("); if (qpinESpaceId != 0) { whereBuilder.Append("((ENApplication.[ENTRY_ESPACE_ID] = @qpinESpaceId) AND (ENApplication.[ENTRY_ESPACE_ID] IS NOT NULL))"); sqlCmd.CreateParameterWithoutReplacements("@qpinESpaceId", DbType.Int32, qpinESpaceId); } else { whereBuilder.Append("(ENApplication.[ENTRY_ESPACE_ID] IS NULL)"); } whereBuilder.Append(" OR "); if (qpinESpaceId != 0) { whereBuilder.Append("((ENApplication.[BACKOFFICE_ESPACE_ID] = @qpinESpaceId) AND (ENApplication.[BACKOFFICE_ESPACE_ID] IS NOT NULL))"); sqlCmd.CreateParameterWithoutReplacements("@qpinESpaceId", DbType.Int32, qpinESpaceId); } else { whereBuilder.Append("(ENApplication.[BACKOFFICE_ESPACE_ID] IS NULL)"); } whereBuilder.Append(")"); sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString(); string advSql = sql; sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql); sqlCmd.CommandText = sql; try { RLApplicationRecordList outParamList = new RLApplicationRecordList(); outParamList.Transaction = trans; BitArray[] opt = new BitArray[1]; opt[0] = new BitArray(new bool[] { true, false, true, true, true, true, true, true, true, true, true, true, true, true }); outParamList.AllOptimizedAttributes = opt; if (multiplicity == IterationMultiplicity.Multiple) { RLApplicationRecordList _tmp = new RLApplicationRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; _tmp.MaxRecords = maxRecords; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query GetApplicationName.GetCurrentApplication.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList = (RLApplicationRecordList)_tmp.Duplicate(); _tmp.CloseDataReader(); RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable); return(outParamList); } finally { _tmp.CloseDataReader(); } } else if (multiplicity == IterationMultiplicity.Never) { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query GetApplicationName.GetCurrentApplication.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable); return(outParamList); } finally { outParamList.CloseDataReader(); } } else { if (maxRecords > 0 && maxRecords <= 150) { RLApplicationRecordList _tmp = new RLApplicationRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query GetApplicationName.GetCurrentApplication.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList = (RLApplicationRecordList)_tmp.Duplicate(); outParamList.AllOptimizedAttributes = opt; _tmp.CloseDataReader(); return(outParamList); } finally { _tmp.CloseDataReader(); } } else { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query GetApplicationName.GetCurrentApplication.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("312e77f2-f402-fd9d-f0b8-83ed084a4933", "GetApplicationName.GetCurrentApplication", "794c445f-f27d-4f61-b47a-0da71440df68", "ContactManager", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; RuntimeCache.Instance.Add(new CacheKey(cacheHash), new OutSystems.RuntimeCommon.Pair <RLApplicationRecordList, long>((RLApplicationRecordList)(outParamList.Duplicate()), -1), new EspaceTenantDependency(Global.eSpaceId, Global.App.Tenant.Id), DateTime.UtcNow.AddMinutes(60), CacheUtils.NoSliding, OutSystems.RuntimeCommon.Caching.CacheItemPriority.Removable); return(outParamList); } finally { if (maxRecords == 1) { outParamList.CloseDataReader(); } } } } } catch (Exception e) { throw new DataBaseException("Error executing query.", e); } } else { lock (temp) { return((RLApplicationRecordList)temp.First.Duplicate()); } } }
/// <summary> /// Query Function "GetAddressTypesByLabel" of Action "AddressType_GetOrCreateByLabel" /// </summary> public static RLAddressTypeRecordList datasetGetAddressTypesByLabel(HeContext heContext, int maxRecords, IterationMultiplicity multiplicity, out long outParamCount, string qpstLabel) { // Query Iterations: Never {-unbound-} // Uses binary data: False if (multiplicity == IterationMultiplicity.Never) { maxRecords = 1; } outParamCount = -1; bool useMainTransaction = (multiplicity != IterationMultiplicity.Single || (maxRecords > 0 && maxRecords <= 150)); Transaction trans = useMainTransaction? DatabaseAccess.ForCurrentDatabase.GetRequestTransaction(): DatabaseAccess.ForCurrentDatabase.GetReadOnlyTransaction(); Command sqlCmd = trans.CreateCommand(); string sql = ""; StringBuilder selectBuilder = new StringBuilder(); StringBuilder fromBuilder = new StringBuilder(); StringBuilder whereBuilder = new StringBuilder(); StringBuilder orderByBuilder = new StringBuilder(); StringBuilder groupByBuilder = new StringBuilder(); StringBuilder havingBuilder = new StringBuilder(); selectBuilder.Append("SELECT "); if (maxRecords > 0) { selectBuilder.Append("TOP ("); selectBuilder.Append(maxRecords); selectBuilder.Append(") "); } selectBuilder.Append("ENAddressType.[ID] o0, ENAddressType.[LABEL] o1, ENAddressType.[ORDER] o2, ENAddressType.[ACTIVE] o3, ENAddressType.[CREATEDDATE] o4, ENAddressType.[CREATEDBY] o5, ENAddressType.[LASTUPDATEDDATE] o6, ENAddressType.[LASTUPDATEDBY] o7"); fromBuilder.Append(" FROM {AddressType} ENAddressType"); whereBuilder.Append(" WHERE (ENAddressType.[LABEL] = @qpstLabel)"); orderByBuilder.Append(" ORDER BY ENAddressType.[LABEL] ASC "); sqlCmd.CreateParameterWithoutReplacements("@qpstLabel", DbType.String, qpstLabel); sql = selectBuilder.ToString() + fromBuilder.ToString() + whereBuilder.ToString() + groupByBuilder.ToString() + havingBuilder.ToString() + orderByBuilder.ToString(); string advSql = sql; sql = AppUtils.Instance.ReplaceEntityReferences(heContext, advSql); sqlCmd.CommandText = sql; RLAddressTypeRecordList outParamList = new RLAddressTypeRecordList(); outParamList.Transaction = trans; BitArray[] opt = new BitArray[1]; opt[0] = new BitArray(new bool[] { false, false, false, false, false, false, false, false }); outParamList.AllOptimizedAttributes = opt; if (multiplicity == IterationMultiplicity.Multiple) { RLAddressTypeRecordList _tmp = new RLAddressTypeRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; _tmp.MaxRecords = maxRecords; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now); } outParamList = (RLAddressTypeRecordList)_tmp.Duplicate(); _tmp.CloseDataReader(); return(outParamList); } finally { _tmp.CloseDataReader(); } } else if (multiplicity == IterationMultiplicity.Never) { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; return(outParamList); } finally { outParamList.CloseDataReader(); } } else { if (maxRecords > 0 && maxRecords <= 150) { RLAddressTypeRecordList _tmp = new RLAddressTypeRecordList(); _tmp.Transaction = trans; _tmp.AllOptimizedAttributes = opt; try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, _tmp, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now); } outParamList = (RLAddressTypeRecordList)_tmp.Duplicate(); outParamList.AllOptimizedAttributes = opt; _tmp.CloseDataReader(); return(outParamList); } finally { _tmp.CloseDataReader(); } } else { try { DateTime startTime = DateTime.Now; DatabaseAccess.ForCurrentDatabase.ExecuteQuery(sqlCmd, outParamList, "Query AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel.List"); int queryExecutionTime = Convert.ToInt32(DateTime.Now.Subtract(startTime).TotalMilliseconds ); RequestTracer reqTracer = RuntimePlatformUtils.GetRequestTracer(); if (reqTracer != null) { reqTracer.RegisterQueryExecuted("3e6b777c-0aa0-4150-ae50-435ca228f661", "AddressType.AddressType_GetOrCreateByLabel.GetAddressTypesByLabel", "070ed75c-5567-4cfd-abec-7c525b0af273", "Address_CS", queryExecutionTime, DateTime.Now); } outParamList.MaxRecords = maxRecords; return(outParamList); } finally { if (maxRecords == 1) { outParamList.CloseDataReader(); } } } } }