コード例 #1
0
ファイル: Repository.cs プロジェクト: sami1971/textmetal
partial         void OnPreInsertEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog eventLog)
        {
            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)eventLog == null)
                throw new ArgumentNullException("eventLog");

            //eventLog.Mark();
        }
コード例 #2
0
ファイル: Repository.cs プロジェクト: sami1971/textmetal
        public bool TryWriteEventLogEntry(string eventText)
        {
            EventLog eventLog;
            bool result;

            try
            {
                eventLog = new EventLog();
                eventLog.EventText = eventText;

                result = this.SaveEventLog(eventLog);
                return result;
            }
            catch (Exception ex)
            {
                // swallow intentionally
                return false;
            }
        }
コード例 #3
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnSelectEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #4
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnSaveConflictEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #5
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnPreUpdateEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #6
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnPreInsertEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #7
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnPostDeleteEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #8
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
partial         void OnDiscardConflictEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog);
コード例 #9
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public bool SaveEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog)
        {
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog query;
            bool wasNew;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)@eventLog == null)
                throw new ArgumentNullException("eventLog");

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                wasNew = @eventLog.IsNew;

                if (wasNew)
                {
                    this.OnPreInsertEventLog(unitOfWorkContext, @eventLog);

                    query = new TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog();

                    ctx.Context.EventLogs.InsertOnSubmit(query);
                }
                else
                {
                    this.OnPreUpdateEventLog(unitOfWorkContext, @eventLog);

                    query = ctx.Context.EventLogs.SingleOrDefault(lo => lo.@EventLogId == @eventLog.@EventLogId);

                    if((object)query == null)
                        throw new InvalidOperationException("TODO (enhancement): add meaningful message");
                }

                // map caller POCO changes to L2S object
                query.@EventLogId = @eventLog.@EventLogId;
                query.@EventText = @eventLog.@EventText;
                query.@CreationTimestamp = @eventLog.@CreationTimestamp;
                query.@ModificationTimestamp = @eventLog.@ModificationTimestamp;
                query.@LogicalDelete = @eventLog.@LogicalDelete;

                try
                {
                    ctx.Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
                }
                catch (ChangeConflictException ccex)
                {
                    this.OnSaveConflictEventLog(unitOfWorkContext, @eventLog);

                    return false;
                }

                // map server changes back to POCO from L2S object
                @eventLog.@EventLogId = query.@EventLogId;
                @eventLog.@EventText = query.@EventText;
                @eventLog.@CreationTimestamp = query.@CreationTimestamp;
                @eventLog.@ModificationTimestamp = query.@ModificationTimestamp;
                @eventLog.@LogicalDelete = query.@LogicalDelete;

                if (wasNew)
                {
                    this.OnPostInsertEventLog(unitOfWorkContext, @eventLog);
                }
                else
                {
                    this.OnPostUpdateEventLog(unitOfWorkContext, @eventLog);
                }

                return true;
            }
        }
コード例 #10
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public bool SaveEventLog(EventLog @eventLog)
        {
            bool retval;

            retval = Ambient.ExecuteAmbientUnitOfWorkAware(Repository.UowcFactory.Instance, (uowc, e) => this.SaveEventLog(uowc, e), @eventLog);

            return retval;
        }
コード例 #11
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public EventLog LoadEventLog(IUnitOfWorkContext unitOfWorkContext, Int32 @eventLogId)
        {
            EventLog @eventLog;
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog query;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                query = ctx.Context.EventLogs.SingleOrDefault(lo => lo.@EventLogId == @eventLogId);

                if ((object)query == null)
                    return null; // does not exist

                @eventLog = new EventLog()
                                {
                                    // map result to POCO from L2S object
                                    @EventLogId = query.@EventLogId,
                                    @EventText = query.@EventText,
                                    @CreationTimestamp = query.@CreationTimestamp,
                                    @ModificationTimestamp = query.@ModificationTimestamp,
                                    @LogicalDelete = query.@LogicalDelete
                                };

                this.OnSelectEventLog(unitOfWorkContext, @eventLog);

                return @eventLog;
            }
        }
コード例 #12
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public bool DiscardEventLog(IUnitOfWorkContext unitOfWorkContext, EventLog @eventLog)
        {
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog query;

            if ((object)unitOfWorkContext == null)
                throw new ArgumentNullException("unitOfWorkContext");

            if ((object)@eventLog == null)
                throw new ArgumentNullException("eventLog");

            if (@eventLog.IsNew)
                return true;

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                this.OnPreDeleteEventLog(unitOfWorkContext, @eventLog);

                query = [email protected](lo => lo.@EventLogId == @eventLog.@EventLogId);

                if((object)query == null)
                    throw new InvalidOperationException("TODO (enhancement): add meaningful message");

                [email protected](query);

                try
                {
                    ctx.Context.SubmitChanges(ConflictMode.FailOnFirstConflict);
                }
                catch (ChangeConflictException ccex)
                {
                    this.OnDiscardConflictEventLog(unitOfWorkContext, @eventLog);

                    return false;
                }

                this.OnPostDeleteEventLog(unitOfWorkContext, @eventLog);

                @eventLog.IsNew = false;

                return true;
            }
        }