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

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

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

            if (@emailAttachment.IsNew)
                return true;

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

                query = [email protected](lo => lo.@EmailAttachmentId == @emailAttachment.@EmailAttachmentId);

                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.OnDiscardConflictEmailAttachment(unitOfWorkContext, @emailAttachment);

                    return false;
                }

                this.OnPostDeleteEmailAttachment(unitOfWorkContext, @emailAttachment);

                @emailAttachment.IsNew = false;

                return true;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public bool SaveEmailMessage(IUnitOfWorkContext unitOfWorkContext, EmailMessage @emailMessage)
        {
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage query;
            bool wasNew;

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

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

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

                if (wasNew)
                {
                    this.OnPreInsertEmailMessage(unitOfWorkContext, @emailMessage);

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

                    ctx.Context.EmailMessages.InsertOnSubmit(query);
                }
                else
                {
                    this.OnPreUpdateEmailMessage(unitOfWorkContext, @emailMessage);

                    query = ctx.Context.EmailMessages.SingleOrDefault(lo => lo.@EmailMessageId == @emailMessage.@EmailMessageId);

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

                // map caller POCO changes to L2S object
                query.@EmailMessageId = @emailMessage.@EmailMessageId;
                query.@From = @emailMessage.@From;
                query.@Sender = @emailMessage.@Sender;
                query.@ReplyTo = @emailMessage.@ReplyTo;
                query.@To = @emailMessage.@To;
                query.@Cc = @emailMessage.@Cc;
                query.@Bcc = @emailMessage.@Bcc;
                query.@Subject = @emailMessage.@Subject;
                query.@IsBodyHtml = @emailMessage.@IsBodyHtml;
                query.@Body = @emailMessage.@Body;
                query.@Processed = @emailMessage.@Processed;
                query.@CreationTimestamp = @emailMessage.@CreationTimestamp;
                query.@ModificationTimestamp = @emailMessage.@ModificationTimestamp;
                query.@LogicalDelete = @emailMessage.@LogicalDelete;

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

                    return false;
                }

                // map server changes back to POCO from L2S object
                @emailMessage.@EmailMessageId = query.@EmailMessageId;
                @emailMessage.@From = query.@From;
                @emailMessage.@Sender = query.@Sender;
                @emailMessage.@ReplyTo = query.@ReplyTo;
                @emailMessage.@To = query.@To;
                @emailMessage.@Cc = query.@Cc;
                @emailMessage.@Bcc = query.@Bcc;
                @emailMessage.@Subject = query.@Subject;
                @emailMessage.@IsBodyHtml = query.@IsBodyHtml;
                @emailMessage.@Body = query.@Body;
                @emailMessage.@Processed = query.@Processed;
                @emailMessage.@CreationTimestamp = query.@CreationTimestamp;
                @emailMessage.@ModificationTimestamp = query.@ModificationTimestamp;
                @emailMessage.@LogicalDelete = query.@LogicalDelete;

                if (wasNew)
                {
                    this.OnPostInsertEmailMessage(unitOfWorkContext, @emailMessage);
                }
                else
                {
                    this.OnPostUpdateEmailMessage(unitOfWorkContext, @emailMessage);
                }

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

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

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

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

                if (wasNew)
                {
                    this.OnPreInsertEmailAttachment(unitOfWorkContext, @emailAttachment);

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

                    ctx.Context.EmailAttachments.InsertOnSubmit(query);
                }
                else
                {
                    this.OnPreUpdateEmailAttachment(unitOfWorkContext, @emailAttachment);

                    query = ctx.Context.EmailAttachments.SingleOrDefault(lo => lo.@EmailAttachmentId == @emailAttachment.@EmailAttachmentId);

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

                // map caller POCO changes to L2S object
                query.@EmailAttachmentId = @emailAttachment.@EmailAttachmentId;
                query.@EmailMessageId = @emailAttachment.@EmailMessageId;
                query.@MimeType = @emailAttachment.@MimeType;
                if ((object)@emailAttachment.@AttachmentBits != null) // prevent implicit conversion of null -> exception
                    query.@AttachmentBits = @emailAttachment.@AttachmentBits;
                query.@CreationTimestamp = @emailAttachment.@CreationTimestamp;
                query.@ModificationTimestamp = @emailAttachment.@ModificationTimestamp;
                query.@LogicalDelete = @emailAttachment.@LogicalDelete;

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

                    return false;
                }

                // map server changes back to POCO from L2S object
                @emailAttachment.@EmailAttachmentId = query.@EmailAttachmentId;
                @emailAttachment.@EmailMessageId = query.@EmailMessageId;
                @emailAttachment.@MimeType = query.@MimeType;
                @emailAttachment.@AttachmentBits = (object)query.@AttachmentBits != null ? [email protected]() : null;
                @emailAttachment.@CreationTimestamp = query.@CreationTimestamp;
                @emailAttachment.@ModificationTimestamp = query.@ModificationTimestamp;
                @emailAttachment.@LogicalDelete = query.@LogicalDelete;

                if (wasNew)
                {
                    this.OnPostInsertEmailAttachment(unitOfWorkContext, @emailAttachment);
                }
                else
                {
                    this.OnPostUpdateEmailAttachment(unitOfWorkContext, @emailAttachment);
                }

                return true;
            }
        }
コード例 #5
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;
            }
        }
コード例 #6
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public EmailMessage LoadEmailMessage(IUnitOfWorkContext unitOfWorkContext, Int32 @emailMessageId)
        {
            EmailMessage @emailMessage;
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage 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.EmailMessages.SingleOrDefault(lo => lo.@EmailMessageId == @emailMessageId);

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

                @emailMessage = new EmailMessage()
                                {
                                    // map result to POCO from L2S object
                                    @EmailMessageId = query.@EmailMessageId,
                                    @From = query.@From,
                                    @Sender = query.@Sender,
                                    @ReplyTo = query.@ReplyTo,
                                    @To = query.@To,
                                    @Cc = query.@Cc,
                                    @Bcc = query.@Bcc,
                                    @Subject = query.@Subject,
                                    @IsBodyHtml = query.@IsBodyHtml,
                                    @Body = query.@Body,
                                    @Processed = query.@Processed,
                                    @CreationTimestamp = query.@CreationTimestamp,
                                    @ModificationTimestamp = query.@ModificationTimestamp,
                                    @LogicalDelete = query.@LogicalDelete
                                };

                this.OnSelectEmailMessage(unitOfWorkContext, @emailMessage);

                return @emailMessage;
            }
        }
コード例 #7
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public EmailAttachment LoadEmailAttachment(IUnitOfWorkContext unitOfWorkContext, Int32 @emailAttachmentId)
        {
            EmailAttachment @emailAttachment;
            TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailAttachment 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.EmailAttachments.SingleOrDefault(lo => lo.@EmailAttachmentId == @emailAttachmentId);

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

                @emailAttachment = new EmailAttachment()
                                {
                                    // map result to POCO from L2S object
                                    @EmailAttachmentId = query.@EmailAttachmentId,
                                    @EmailMessageId = query.@EmailMessageId,
                                    @MimeType = query.@MimeType,
                                    @AttachmentBits = (object)query.AttachmentBits != null ? [email protected]() : null,
                                    @CreationTimestamp = query.@CreationTimestamp,
                                    @ModificationTimestamp = query.@ModificationTimestamp,
                                    @LogicalDelete = query.@LogicalDelete
                                };

                this.OnSelectEmailAttachment(unitOfWorkContext, @emailAttachment);

                return @emailAttachment;
            }
        }
コード例 #8
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public IList<EventLog> FindEventLogs(IUnitOfWorkContext unitOfWorkContext, Func<IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog>, IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog>> callback)
        {
            IList<EventLog> @eventLogs;
            IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EventLog> queryable;

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

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

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                queryable = callback(ctx.Context.@EventLogs);

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

                @eventLogs = queryable.Select(lo => new EventLog()
                                                 {
                                                    // map results to POCOs from L2S objects
                                                    @EventLogId = lo.@EventLogId,
                                                    @EventText = lo.@EventText,
                                                    @CreationTimestamp = lo.@CreationTimestamp,
                                                    @ModificationTimestamp = lo.@ModificationTimestamp,
                                                    @LogicalDelete = lo.@LogicalDelete
                                                 }).ToList(); // force execution against store

                foreach (EventLog @eventLog in @eventLogs)
                    this.OnSelectEventLog(unitOfWorkContext, @eventLog);

                return @eventLogs;
            }
        }
コード例 #9
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public IList<EmailMessage> FindEmailMessages(IUnitOfWorkContext unitOfWorkContext, Func<IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage>, IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage>> callback)
        {
            IList<EmailMessage> @emailMessages;
            IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailMessage> queryable;

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

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

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                queryable = callback(ctx.Context.@EmailMessages);

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

                @emailMessages = queryable.Select(lo => new EmailMessage()
                                                 {
                                                    // map results to POCOs from L2S objects
                                                    @EmailMessageId = lo.@EmailMessageId,
                                                    @From = lo.@From,
                                                    @Sender = lo.@Sender,
                                                    @ReplyTo = lo.@ReplyTo,
                                                    @To = lo.@To,
                                                    @Cc = lo.@Cc,
                                                    @Bcc = lo.@Bcc,
                                                    @Subject = lo.@Subject,
                                                    @IsBodyHtml = lo.@IsBodyHtml,
                                                    @Body = lo.@Body,
                                                    @Processed = lo.@Processed,
                                                    @CreationTimestamp = lo.@CreationTimestamp,
                                                    @ModificationTimestamp = lo.@ModificationTimestamp,
                                                    @LogicalDelete = lo.@LogicalDelete
                                                 }).ToList(); // force execution against store

                foreach (EmailMessage @emailMessage in @emailMessages)
                    this.OnSelectEmailMessage(unitOfWorkContext, @emailMessage);

                return @emailMessages;
            }
        }
コード例 #10
0
ファイル: Repository.tv.g.cs プロジェクト: sami1971/textmetal
        public IList<EmailAttachment> FindEmailAttachments(IUnitOfWorkContext unitOfWorkContext, Func<IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailAttachment>, IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailAttachment>> callback)
        {
            IList<EmailAttachment> @emailAttachments;
            IQueryable<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.EmailAttachment> queryable;

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

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

            using (ContextWrapper<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext> ctx = unitOfWorkContext.GetContext<TextMetal.HostImpl.AspNetSample.Objects.Model.L2S.TxtMtlPrimaryDataContext>())
            {
                queryable = callback(ctx.Context.@EmailAttachments);

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

                @emailAttachments = queryable.Select(lo => new EmailAttachment()
                                                 {
                                                    // map results to POCOs from L2S objects
                                                    @EmailAttachmentId = lo.@EmailAttachmentId,
                                                    @EmailMessageId = lo.@EmailMessageId,
                                                    @MimeType = lo.@MimeType,
                                                    @AttachmentBits = (object)lo.@AttachmentBits != null ? [email protected]() : null,
                                                    @CreationTimestamp = lo.@CreationTimestamp,
                                                    @ModificationTimestamp = lo.@ModificationTimestamp,
                                                    @LogicalDelete = lo.@LogicalDelete
                                                 }).ToList(); // force execution against store

                foreach (EmailAttachment @emailAttachment in @emailAttachments)
                    this.OnSelectEmailAttachment(unitOfWorkContext, @emailAttachment);

                return @emailAttachments;
            }
        }