protected override void PreSaving(PreSavingContext ctx) { if (token != null) { TokenString = token.FullKey(); } }
public static DirectedGraph <Modifiable> PreSaving(Func <DirectedGraph <Modifiable> > recreate, ModifyEntityEventHandler modifier) { DirectedGraph <Modifiable> graph = recreate(); PreSavingContext ctx = new PreSavingContext(graph); bool graphModified = false; foreach (var m in graph) { modifier(m, ctx); } if (!graphModified) { return(graph); //common case } do { var newGraph = recreate(); ctx = new PreSavingContext(graph); foreach (var m in newGraph.Except(graph)) { modifier(m, ctx); } graph = newGraph; } while (graphModified); return(graph); }
static void Newsletter_PreSaving(NewsletterEntity newsletter, PreSavingContext ctx) { var queryname = QueryLogic.ToQueryName(newsletter.Query !.Key); QueryDescription qd = QueryLogic.Queries.QueryDescription(queryname); newsletter.Subject = TextTemplateParser.Parse(newsletter.Subject, qd, null).ToString(); newsletter.Text = TextTemplateParser.Parse(newsletter.Text, qd, null).ToString(); }
protected override void PreSaving(PreSavingContext ctx) { base.PreSaving(ctx); if (this.Corrupt && base.EntityIntegrityCheck() == null) { this.Corrupt = false; } }
public static void FilePath_PreSaving(FilePathEntity fp, PreSavingContext ctx) { if (fp.IsNew && !unsafeMode.Value) { var alg = fp.FileType.GetAlgorithm(); alg.ValidateFile(fp); alg.SaveFile(fp); } }
protected override void PreSaving(PreSavingContext ctx) { if (OnPreSaving == null) { throw new InvalidOperationException("OnPreSaving not set"); } OnPreSaving(this); }
protected override void PreSaving(PreSavingContext ctx) { Columns.ForEach(c => { if (c.Token == null) { c.OrderByIndex = null; c.OrderByType = null; } }); }
protected internal override void PreSaving(PreSavingContext ctx) { if (AllowChange) { base.PreSaving(ctx); } else if (Modified == ModifiedState.SelfModified) { throw new InvalidOperationException("Attempt to save a not new modified ImmutableEntity"); } }
internal void OnPreSaving(Entity entity, PreSavingContext ctx) { AssertAllowed(entity.GetType(), inUserInterface: false); IEntityEvents ee = entityEvents.TryGetC(entity.GetType()); if (ee != null) { ee.OnPreSaving(entity, ctx); } entityEventsGlobal.OnPreSaving(entity, ctx); }
public static void FilePath_PreSaving(FilePathEntity fp, PreSavingContext ctx) { if (fp.IsNew && !unsafeMode.Value) { var alg = fp.FileType.GetAlgorithm(); alg.ValidateFile(fp); var task = alg.SaveFileAsync(fp); Transaction.PreRealCommit += data => { var a = fp; //For ebuggin task.Wait(); }; } }
static void EntityEventsGlobal_PreSaving(Entity ident, PreSavingContext ctx) { if (strategies.TryGet(ident.GetType(), IsolationStrategy.None) != IsolationStrategy.None && IsolationEntity.Current != null) { if (ident.Mixin <IsolationMixin>().Isolation == null) { ident.Mixin <IsolationMixin>().Isolation = IsolationEntity.Current; ctx.InvalidateGraph(); } else if (!ident.Mixin <IsolationMixin>().Isolation.Is(IsolationEntity.Current)) { throw new ApplicationException(IsolationMessage.Entity0HasIsolation1ButCurrentIsolationIs2.NiceToString(ident, ident.Mixin <IsolationMixin>().Isolation, IsolationEntity.Current)); } } }
static void EmailTemplate_PreSaving(SMSTemplateEntity smsTemplate, PreSavingContext ctx) { using (smsTemplate.DisableAuthorization ? ExecutionMode.Global() : null) { var queryName = QueryLogic.ToQueryName(smsTemplate.Query.Key); QueryDescription qd = QueryLogic.Queries.QueryDescription(queryName); List <QueryToken> list = new List <QueryToken>(); foreach (var message in smsTemplate.Messages) { message.Message = TextTemplateParser.Parse(message.Message, qd, smsTemplate.Model?.ToType()).ToString(); } } }
public static void PreSaving(BigStringMixin mixin, PreSavingContext ctx) { var bs = (BigStringEmbedded)mixin.MainEntity; PropertyRoute pr = FindPropertyRoute(bs); var config = Configurations.GetOrThrow(pr); switch (config.Mode) { case BigStringMode.Database: break; case BigStringMode.File: if (bs.Modified == ModifiedState.SelfModified) { mixin.File = string.IsNullOrEmpty(bs.Text) ? null : new FilePathEmbedded(config.FileTypeSymbol !, pr.PropertyInfo !.Name + ".txt", Encoding.UTF8.GetBytes(bs.Text)); ctx.InvalidateGraph(); } break; case BigStringMode.Migrating_FromDatabase_ToFile: if (bs.Modified == ModifiedState.SelfModified || bs.Text.HasText() && mixin.File == null) { mixin.File = string.IsNullOrEmpty(bs.Text) ? null : new FilePathEmbedded(config.FileTypeSymbol !, pr.PropertyInfo !.Name + ".txt", Encoding.UTF8.GetBytes(bs.Text)); ctx.InvalidateGraph(); } break; case BigStringMode.Migrating_FromFile_ToDatabase: if (bs.Modified == ModifiedState.SelfModified || string.IsNullOrEmpty(bs.Text) && mixin.File != null) { bs.Text = mixin.File == null ? null : Encoding.UTF8.GetString(mixin.File.GetByteArray()); ctx.InvalidateGraph(); mixin.File?.DeleteFileOnCommit(); } break; default: break; } }
protected internal override void PreSaving(PreSavingContext ctx) { base.PreSaving(ctx); if (Corrupt) { var integrity = ((Entity)MainEntity).EntityIntegrityCheckBase(); // So, no corruption allowed if (integrity == null) { this.Corrupt = false; if (!((Entity)MainEntity).IsNew) { Corruption.OnCorruptionRemoved((Entity)MainEntity); } } else if (((Entity)MainEntity).IsNew) { Corruption.OnSaveCorrupted((Entity)MainEntity, integrity); } } }
protected override void PreSaving(PreSavingContext ctx) { try { var ci = CultureInfo.GetCultureInfo(Name); //To be more resilient with diferent versions of windows if (this.IsGraphModified || EnglishName == null) { EnglishName = ci.EnglishName; } if (this.IsGraphModified || NativeName == null) { NativeName = ci.NativeName; } } catch (CultureNotFoundException) { } base.PreSaving(ctx); }
protected override void PreSaving(PreSavingContext ctx) { CompileIfNecessary(); base.PreSaving(ctx); }
void IEntityEvents.OnPreSaving(Entity entity, PreSavingContext ctx) { PreSaving?.Invoke((T)entity, ctx); }
protected override void PreSaving(PreSavingContext ctx) { base.PreSaving(ctx); MissRate = TotalCount == 0 ? (double?)null : Math.Round(MissCount / (double)TotalCount, 2); }
protected override void PreSaving(PreSavingContext ctx) { this.toStr = this.ToString(); }
protected override void PreSaving(PreSavingContext ctx) { PreSavingAction?.Invoke(this, ctx); }
protected override void PreSaving(PreSavingContext ctx) { base.PreSaving(ctx); this.Duration = this.DoneDate == null ? (double?)null : (this.DoneDate.Value - this.StartDate).TotalMinutes; }
protected override void PreSaving(PreSavingContext ctx) { DisplayName = displayName; }
protected internal override void PreSaving(PreSavingContext ctx) { }
protected internal virtual void PreSaving(PreSavingContext ctx) { }