/// <summary> /// Reverts the range. /// </summary> /// <param name="fromTransactionId">From transaction identifier.</param> /// <param name="toTransactionId">To transaction identifier.</param> /// <param name="tenantId">The tenant identifier.</param> public static void RevertRange(long fromTransactionId, long toTransactionId, long tenantId = -1) { try { using (DatabaseContext ctx = DatabaseContext.GetContext( )) { using (IDbCommand command = ctx.CreateCommand("spRevertRange", CommandType.StoredProcedure)) { ctx.AddParameter(command, "@fromTransactionId", DbType.Int64, fromTransactionId); ctx.AddParameter(command, "@toTransactionId", DbType.Int64, toTransactionId); if (tenantId >= 0) { ctx.AddParameter(command, "@tenantId", DbType.Int64, tenantId); } command.ExecuteNonQuery( ); } } } finally { if (tenantId >= 0) { TenantHelper.Invalidate(tenantId); } } }
/// <summary> /// Deploys the application asynchronously. /// </summary> /// <param name="state">The state.</param> private void DeployAsynchronous(object state) { var package = state as Package; var context = new RoutedProcessingContext(message => BusyMessage = message, message => BusyMessage = message, message => BusyMessage = message, message => BusyMessage = message); if (package != null) { var tenantId = package.SelectedTenant.EntityId; using (new TenantAdministratorContext(0)) { AppManager.UpgradeApp(tenantId, package.AppVerId, context); } using (new TenantAdministratorContext(tenantId)) { TenantHelper.Invalidate(new EntityRef(tenantId)); } } IsBusy = false; System.Windows.Application.Current.Dispatcher.Invoke(LoadPackages); }
private void UninstallEmptyApp() { try { AppManager.RemoveApp(RunAsDefaultTenant.DefaultTenantName, _emptyAppId.ToString("B")); } finally { TenantHelper.Invalidate(); } }
private void InstallEmptyApp() { try { AppManager.DeployApp(RunAsDefaultTenant.DefaultTenantName, _emptyAppId.ToString("B"), "1.0.0.0"); } finally { TenantHelper.Invalidate(); } }
/// <summary> /// Upgrades the application. /// </summary> /// <param name="applicationVersionId">The application version id.</param> public void UpgradeApplication(Guid applicationVersionId) { long tenantId = RequestContext.TenantId; using (new TenantAdministratorContext(0)) { AppManager.UpgradeApp(tenantId, applicationVersionId); } TenantHelper.Invalidate(new EntityRef(tenantId)); }
/// <summary> /// Removes the application from the database and deletes all related entities. /// </summary> /// <param name="applicationVersionId">The application version id.</param> public void UninstallApplication(Guid applicationVersionId) { string tenantName = RequestContext.GetContext( ).Tenant.Name; using (new TenantAdministratorContext(0)) { AppManager.RemoveApp(tenantName, applicationVersionId.ToString("B")); } TenantHelper.Invalidate(new EntityRef(RequestContext.TenantId)); }
/// <summary> /// Gets the response. /// </summary> /// <returns></returns> public override DiagnosticResponse GetResponse( ) { if (TenantId >= 0) { TenantHelper.Invalidate(TenantId); EventLog.Application.WriteInformation($"Diagnostics Cache flush for tenant {TenantId}"); } else { CacheManager.ClearCaches( ); EventLog.Application.WriteInformation($"Diagnostics Cache flush"); } return(new FlushCachesResponse( )); }
/// <summary> /// Deploys the application. /// </summary> /// <param name="applicationId">The application id.</param> public void DeployApplication(Guid applicationId) { if (!CheckIfPossible(applicationId, CanDeploy)) { return; } var tenantName = RequestContext.GetContext( ).Tenant.Name; using (new TenantAdministratorContext(0)) { AppManager.DeployApp(tenantName, applicationId.ToString("B")); } TenantHelper.Invalidate(new EntityRef(RequestContext.TenantId)); }
private void InvalidateTenant(string tenant) { long tid; using (new GlobalAdministratorContext()) { tid = TenantHelper.GetTenantId(tenant); } if (tid > 0) { using (new TenantAdministratorContext(tid)) { TenantHelper.Invalidate(tid); } } }
/// <summary> /// Reverts to. /// </summary> /// <param name="transactionId">The transaction identifier.</param> /// <param name="tenantId">The tenant identifier.</param> public static void RevertTo(long transactionId, long?tenantId = null) { string message = $"Reverting to transaction {transactionId}"; if (tenantId >= 0) { message += $" for tenant {tenantId}"; } long userId; RequestContext.TryGetUserId(out userId); try { using (DatabaseContextInfo info = new DatabaseContextInfo(message)) using (DatabaseContext ctx = DatabaseContext.GetContext( )) { using (IDbCommand command = ctx.CreateCommand("spRevertTo", CommandType.StoredProcedure)) { ctx.AddParameter(command, "@transactionId", DbType.Int64, transactionId); if (tenantId != null) { ctx.AddParameter(command, "@tenantId", DbType.Int64, tenantId); } ctx.AddParameter(command, "@context", DbType.AnsiString, DatabaseContextInfo.GetMessageChain(userId)); command.ExecuteNonQuery( ); } } } finally { if (tenantId >= 0) { TenantHelper.Invalidate(tenantId); } } AuditLogInstance.Get( ).OnTenantRollback(true, transactionId.ToString( )); }
/// <summary> /// Set a set of feature switchs /// </summary> /// <param name="featureSwitchList">List of features.</param> /// <param name="value">Value to set</param> /// <param name="scope">The scope to set the value</param> public void Set(string featureSwitchList) { if (string.IsNullOrEmpty(featureSwitchList)) { return; } var features = featureSwitchList.Split(',').Select(f => { var split = f.Split('='); bool value = true; // defaulting to true if (split.Length >= 2) { var trimmed = split[1].Trim(); try { value = trimmed == string.Empty ? true : value = Boolean.Parse(split[1]); } catch (FormatException) { throw new ArgumentException($"Unable to parse value for {split[0]}"); } } return(new FeatureInfo { Name = split[0], IsSet = value }); }).ToList(); foreach (var feature in features) { Set(feature.Name, feature.IsSet); } CacheManager.ClearCaches(); TenantHelper.Invalidate( ); }
/// <summary> /// Invalidate one tenant only /// </summary> /// <param name="tenantId">The tenant</param> public static void ClearCaches(long tenantId) { TenantHelper.Invalidate(new Model.EntityRef(tenantId)); }
public void Invalidate( ) { TenantHelper.Invalidate( ); }