public override object this[string name] { set { SiteProperty prop; var sitePropetiesCollection = GetSitePropertiesCollection(); if (sitePropetiesCollection.TryGetValueByName(name, out prop)) { // Check if it is a system var if (prop.Key == null) { throw (new ArgumentException("The site property '" + name + "' is a system property and cannot be changed.")); } if (prop.Value != value) { string databaseValue = prop.ChangeValue(value); HeContext heContext = AppInfo.GetAppInfo().OsContext; GenericExtendedActions.UpdateSiteProperty(heContext, prop.DefId, prop.IsShared, databaseValue); heContext.QueueEspaceToInvalidate(this.ESpaceId, prop.IsShared ? 0 : heContext.Session.TenantId); } } else { throw (new ArgumentException("The site property '" + name + "' does not exist.")); } } }
internal bool DeleteProcesses(Transaction trans) { if (!IsBulkDeletion) { string sql = @"select PARENT_PROCESS_ID, IS_TERMINAL from OSSYS_BPM_PROCESS p inner join OSSYS_BPM_PROCESS_STATUS ps on p.STATUS_ID = ps.ID where p.ID = @processId"; using (Command cmd = CreateSQLCommand(trans, sql)) { using (IDataReader reader = cmd.ExecuteReader()) { if (reader.Read()) { if (DataReaderUtils.SafeGet <int>(reader, "PARENT_PROCESS_ID") != 0) { throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.ProcessNotTopLevelException(); } if (!DataReaderUtils.SafeGet <bool>(reader, "IS_TERMINAL")) { throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.InvalidProcessStatusException(); } } else { throw new OutSystems.RuntimePublic.Processes.ProcessDeletion.ProcessNotFoundException(); } } } } string processesToDeleteSQL = ProcessesToDeleteQuery(trans.DatabaseServices, /*isDeletingTopProcesses*/ false); // remove circular reference in top process id using (Command cmd = CreateSQLCommand(trans, "UPDATE OSSYS_BPM_PROCESS SET PARENT_ACTIVITY_ID = NULL WHERE TOP_PROCESS_ID IN ({0})", processesToDeleteSQL)) { cmd.ExecuteNonQuery(); } // Remove sub processes string subProcessesSQL = string.Format(@"FROM OSSYS_BPM_PROCESS WHERE ID <> TOP_PROCESS_ID AND ID NOT IN ( SELECT PARENTID FROM ( SELECT DISTINCT PARENT_PROCESS_ID AS PARENTID FROM OSSYS_BPM_PROCESS WHERE PARENT_PROCESS_ID IS NOT NULL ) PARENTPROCS ) AND TOP_PROCESS_ID IN ({0})", processesToDeleteSQL); bool moreSubProcessesToDelete = true; while (moreSubProcessesToDelete) { using (Command cmd = CreateSQLCommand(trans, "SELECT COUNT(*) " + subProcessesSQL)) { moreSubProcessesToDelete = DataReaderUtils.SafeGet <bool>(cmd.ExecuteScalar()); } if (moreSubProcessesToDelete) { using (Command cmd = CreateSQLCommand(trans, "DELETE " + subProcessesSQL)) { cmd.ExecuteNonQuery(); } } } // Remove circular references in TOP_PROCESS_ID using (Command cmd = CreateSQLCommand(trans, "UPDATE OSSYS_BPM_PROCESS SET TOP_PROCESS_ID = NULL WHERE ID IN ({0})", processesToDeleteSQL)) { cmd.ExecuteNonQuery(); } // Delete top processes processesToDeleteSQL = ProcessesToDeleteQuery(trans.DatabaseServices, /*isDeletingTopProcesses*/ true); using (Command cmd = CreateSQLCommand(trans, "DELETE FROM OSSYS_BPM_PROCESS WHERE ID IN ({0})", processesToDeleteSQL)) { int deleted = cmd.ExecuteNonQuery(); AppInfo info = AppInfo.GetAppInfo(); if (info != null) { GenericExtendedActions.LogMessage(info.OsContext, IsBulkDeletion ? string.Format("Bulk deleted {0} top processes older than {1} (ProcessDefinitionId = {2})", deleted, olderThan.Value.ToString(FormatInfo.GetOutputDateFormatString()), processDefinitionId.HasValue ? processDefinitionId.ToString() : "NULL") : string.Format("Deleted top-process #{0}", processId), "BPT_API"); } } if (IsBulkDeletion) { return(HasProcessesToDelete(trans)); } return(false); }