コード例 #1
0
 protected override void PreSaving(PreSavingContext ctx)
 {
     if (token != null)
     {
         TokenString = token.FullKey();
     }
 }
コード例 #2
0
ファイル: GraphExplorer.cs プロジェクト: xareas/framework
        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);
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Customer.cs プロジェクト: stammr/southwind
 protected override void PreSaving(PreSavingContext ctx)
 {
     base.PreSaving(ctx);
     if (this.Corrupt && base.EntityIntegrityCheck() == null)
     {
         this.Corrupt = false;
     }
 }
コード例 #5
0
 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);
     }
 }
コード例 #6
0
        protected override void PreSaving(PreSavingContext ctx)
        {
            if (OnPreSaving == null)
            {
                throw new InvalidOperationException("OnPreSaving not set");
            }

            OnPreSaving(this);
        }
コード例 #7
0
ファイル: UserChart.cs プロジェクト: ywscr/extensions
 protected override void PreSaving(PreSavingContext ctx)
 {
     Columns.ForEach(c =>
     {
         if (c.Token == null)
         {
             c.OrderByIndex = null;
             c.OrderByType  = null;
         }
     });
 }
コード例 #8
0
 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");
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: FilePathLogic.cs プロジェクト: goldenauge/framework
    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();
            };
        }
    }
コード例 #11
0
ファイル: IsolationLogic.cs プロジェクト: zeevir/extensions
 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));
         }
     }
 }
コード例 #12
0
        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();
                }
            }
        }
コード例 #13
0
    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;
        }
    }
コード例 #14
0
ファイル: CorruptMixin.cs プロジェクト: goldenauge/framework
    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);
            }
        }
    }
コード例 #15
0
        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);
        }
コード例 #16
0
        protected override void PreSaving(PreSavingContext ctx)
        {
            CompileIfNecessary();

            base.PreSaving(ctx);
        }
コード例 #17
0
 void IEntityEvents.OnPreSaving(Entity entity, PreSavingContext ctx)
 {
     PreSaving?.Invoke((T)entity, ctx);
 }
コード例 #18
0
        protected override void PreSaving(PreSavingContext ctx)
        {
            base.PreSaving(ctx);

            MissRate = TotalCount == 0 ? (double?)null : Math.Round(MissCount / (double)TotalCount, 2);
        }
コード例 #19
0
 protected override void PreSaving(PreSavingContext ctx)
 {
     this.toStr = this.ToString();
 }
コード例 #20
0
 protected override void PreSaving(PreSavingContext ctx)
 {
     PreSavingAction?.Invoke(this, ctx);
 }
コード例 #21
0
 protected override void PreSaving(PreSavingContext ctx)
 {
     base.PreSaving(ctx);
     this.Duration = this.DoneDate == null ? (double?)null :
                     (this.DoneDate.Value - this.StartDate).TotalMinutes;
 }
コード例 #22
0
 protected override void PreSaving(PreSavingContext ctx)
 {
     DisplayName = displayName;
 }
コード例 #23
0
 protected internal override void PreSaving(PreSavingContext ctx)
 {
 }
コード例 #24
0
 protected internal virtual void PreSaving(PreSavingContext ctx)
 {
 }