Example #1
0
        public MessageStatus GetCurrentMessageStatusByMessageId(int id)
        {
            MessageStatus status = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageStatusGetMostRecentByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id)
                {
                    DbType = DbType.Int32
                });
                while (proxy.Read())
                {
                    status = new MessageStatus
                    {
                        MessageId           = (int)proxy["MessageId"],
                        TypeMessageStatusId = (int)proxy["TypeMessageStatusId"],
                        Description         = proxy["MessageStatusText"] as string,
                        AdditionalMessage   = proxy["AdditionalMessage"] as string,
                        Exception           = JsonSerializer.DeserializeFromString <Exception>(proxy["Exception"] as string),
                        CreateDate          = (DateTime)proxy["CreateDate"]
                    };
                }
            }

            return(status);
        }
Example #2
0
        private IEnumerable <TypeMessageStatus> GetAllTypeMessageStatus()
        {
            var list = new List <TypeMessageStatus>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageReplyToSelectByMessageId]", CommandType.StoredProcedure))
            {
                while (proxy.Read())
                {
                    list.Add(new TypeMessageStatus
                    {
                        Id = (int)proxy["Id"],
                        MessageStatusText = proxy["MessageStatusText"] as string
                    });
                }
            }

            return(list);
        }
Example #3
0
        private IEnumerable <string> GetMessageReplyToByMessageId(int id)
        {
            var list = new List <string>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageReplyToSelectByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id)
                {
                    DbType = DbType.Int32
                });
                while (proxy.Read())
                {
                    list.Add(proxy["ReplyTo"] as string);
                }
            }

            return(list);
        }
Example #4
0
        public Credential GetCredential(int id)
        {
            Credential credential = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[CredentialSelectByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id) { DbType = DbType.Int32 });
                while (proxy.Read())
                {
                    credential = new Credential
                    {
                        Username = proxy["Username"] as string,
                        Password = proxy["Password"] as string,
                        Domain = proxy["Domain"] as string
                    };
                }
            }

            return credential;
        }
Example #5
0
        public List<Application> GetAllApplications()
        {
            var list = new List<Application>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[SelectAllApplications]", CommandType.StoredProcedure))
            {
                while (proxy.Read())
                {
                    var app = new Application
                    {
                        Id = (int)proxy["Id"],
                        ApplicationName = proxy["ApplicationName"] as string,
                    };

                    list.Add(app);
                }
            }

            return list;
        }
Example #6
0
        public List <Application> GetAllApplications()
        {
            var list = new List <Application>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[SelectAllApplications]", CommandType.StoredProcedure))
            {
                while (proxy.Read())
                {
                    var app = new Application
                    {
                        Id = (int)proxy["Id"],
                        ApplicationName = proxy["ApplicationName"] as string,
                    };

                    list.Add(app);
                }
            }

            return(list);
        }
Example #7
0
        public List <Message> GetMessagesByApplicationId(int id)
        {
            var list = new List <Message>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageSelectByApplication]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@ApplicationId", id)
                {
                    DbType = DbType.Int32
                });
                while (proxy.Read())
                {
                    var msg = new Message
                    {
                        Id      = (int)proxy["Id"],
                        From    = proxy["From"] as string,
                        Sender  = proxy["Sender"] as string,
                        Subject = proxy["Subject"] as string,
                        Body    = proxy["Body"] as string,
                    };

                    list.Add(msg);
                }
            }

            // Load children
            foreach (var msg in list)
            {
                msg.To         = GetMessageToByMessageId(msg.Id);
                msg.ReplyTo    = GetMessageReplyToByMessageId(msg.Id);
                msg.Cc         = GetMessageCcByMessageId(msg.Id);
                msg.Bcc        = GetMessageBccByMessageId(msg.Id);
                msg.Status     = GetCurrentMessageStatusByMessageId(msg.Id);
                msg.Credential = GetCredential(msg.Id);
            }

            return(list);
        }
Example #8
0
        public Message GetMessage(int id)
        {
            Message msg = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageSelectById]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@Id", id)
                {
                    DbType = DbType.Int32
                });
                while (proxy.Read())
                {
                    msg = new Message
                    {
                        Id         = (int)proxy["Id"],
                        From       = proxy["From"] as string,
                        Sender     = proxy["Sender"] as string,
                        Subject    = proxy["Subject"] as string,
                        Body       = proxy["Body"] as string,
                        To         = GetMessageToByMessageId(id),
                        ReplyTo    = GetMessageReplyToByMessageId(id),
                        Cc         = GetMessageCcByMessageId(id),
                        Bcc        = GetMessageBccByMessageId(id),
                        CreateDate = proxy.GetDateTime(proxy.GetOrdinal("CreateDate")),
                        Status     = GetCurrentMessageStatusByMessageId(id),
                        Connection = new Connection
                        {
                            EnableSsl = proxy.GetBoolean(proxy.GetOrdinal("EnableSsl")),
                            Host      = proxy["Host"] as string,
                            Port      = proxy.GetInt32(proxy.GetOrdinal("Port"))
                        },
                        Credential = GetCredential(id),
                    };
                }
            }

            return(msg);
        }
Example #9
0
        public MessageStatus GetCurrentMessageStatusByMessageId(int id)
        {
            MessageStatus status = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageStatusGetMostRecentByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id) { DbType = DbType.Int32 });
                while (proxy.Read())
                {
                    status = new MessageStatus
                    {
                        MessageId = (int) proxy["MessageId"],
                        TypeMessageStatusId = (int) proxy["TypeMessageStatusId"],
                        Description = proxy["MessageStatusText"] as string,
                        AdditionalMessage = proxy["AdditionalMessage"] as string,
                        Exception = JsonSerializer.DeserializeFromString<Exception>(proxy["Exception"] as string),
                        CreateDate = (DateTime) proxy["CreateDate"]
                    };
                }
            }

            return status;
        }
Example #10
0
        public Credential GetCredential(int id)
        {
            Credential credential = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[CredentialSelectByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id)
                {
                    DbType = DbType.Int32
                });
                while (proxy.Read())
                {
                    credential = new Credential
                    {
                        Username = proxy["Username"] as string,
                        Password = proxy["Password"] as string,
                        Domain   = proxy["Domain"] as string
                    };
                }
            }

            return(credential);
        }
Example #11
0
        public Message GetMessage(int id)
        {
            Message msg = null;

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageSelectById]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@Id", id) { DbType = DbType.Int32 });
                while (proxy.Read())
                {
                    msg = new Message
                    {
                        Id = (int) proxy["Id"],
                        From = proxy["From"] as string,
                        Sender = proxy["Sender"] as string,
                        Subject = proxy["Subject"] as string,
                        Body = proxy["Body"] as string,
                        To = GetMessageToByMessageId(id),
                        ReplyTo = GetMessageReplyToByMessageId(id),
                        Cc = GetMessageCcByMessageId(id),
                        Bcc = GetMessageBccByMessageId(id),
                        CreateDate = proxy.GetDateTime(proxy.GetOrdinal("CreateDate")),
                        Status = GetCurrentMessageStatusByMessageId(id),
                        Connection = new Connection
                        {
                            EnableSsl = proxy.GetBoolean(proxy.GetOrdinal("EnableSsl")),
                            Host = proxy["Host"] as string,
                            Port = proxy.GetInt32(proxy.GetOrdinal("Port"))
                        },
                        Credential = GetCredential(id),
                    };
                }
            }

            return msg;
        }
Example #12
0
        private IEnumerable<string> GetMessageToByMessageId(int id)
        {
            var list = new List<string>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageToSelectByMessageId]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@MessageId", id) {DbType = DbType.Int32});
                while (proxy.Read())
                {
                    list.Add(proxy["To"] as string);
                }
            }

            return list;
        }
Example #13
0
        private IEnumerable<TypeMessageStatus> GetAllTypeMessageStatus()
        {
            var list = new List<TypeMessageStatus>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageReplyToSelectByMessageId]", CommandType.StoredProcedure))
            {
                while (proxy.Read())
                {
                    list.Add(new TypeMessageStatus
                    {
                        Id = (int)proxy["Id"],
                        MessageStatusText = proxy["MessageStatusText"] as string
                    });
                }
            }

            return list;
        }
Example #14
0
        public List<Message> GetMessagesByApplicationId(int id)
        {
            var list = new List<Message>();

            using (var proxy = new SqlDataReaderProxy("[dbo].[MessageSelectByApplication]", CommandType.StoredProcedure))
            {
                proxy.Parameters.Add(new SqlParameter("@ApplicationId", id) {DbType = DbType.Int32});
                while (proxy.Read())
                {
                    var msg = new Message
                    {
                        Id = (int)proxy["Id"],
                        From = proxy["From"] as string,
                        Sender = proxy["Sender"] as string,
                        Subject = proxy["Subject"] as string,
                        Body = proxy["Body"] as string,
                    };

                    list.Add(msg);
                }
            }

            // Load children
            foreach (var msg in list)
            {
                msg.To = GetMessageToByMessageId(msg.Id);
                msg.ReplyTo = GetMessageReplyToByMessageId(msg.Id);
                msg.Cc = GetMessageCcByMessageId(msg.Id);
                msg.Bcc = GetMessageBccByMessageId(msg.Id);
                msg.Status = GetCurrentMessageStatusByMessageId(msg.Id);
                msg.Credential = GetCredential(msg.Id);
            }

            return list;
        }