コード例 #1
0
        public void Deve_Criar_Um_Novo_Cliente()
        {
            var code         = 1;
            var firstName    = "Victor";
            var lastName     = "Domingues";
            var name         = new NameVo(firstName, lastName);
            var number       = "11992535010";
            var phone        = new PhoneVo(number);
            var phone2       = new PhoneVo(number);
            var cpf          = "3333333333";
            var document     = new DocumentVo(cpf, EDocumentType.Cpf);
            var emailAddress = "*****@*****.**";
            var email        = new EmailVo(emailAddress);

            var address = new Address(Tenant.Id, "", "", "", "", "", "", "", "");

            var customer = new Customer(Tenant.Id, code, name, phone, phone2, email, document, address.Id, null);

            Assert.IsTrue(customer.Valid);
            Assert.AreEqual(customer.TenantId, Tenant.Id);
            Assert.AreEqual(customer.Name, name);
            Assert.AreEqual(customer.Phone, phone);
            Assert.AreEqual(customer.Phone2, phone2);
            Assert.AreEqual(customer.Email, email);
            Assert.AreEqual(customer.Document, document);
            Assert.AreEqual(customer.Code, code);
        }
コード例 #2
0
        public bool CreateReportBulkMailRequest(EmailVo emailVo)
        {
            bool        isCompleted = false;
            EmailSMSDao emailSMSDao = new EmailSMSDao();

            try
            {
                isCompleted = bool.Parse(emailSMSDao.CreateReportBulkMailRequest(emailVo).ToString());
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "EmailSMSBo.cs:AddToEmailQueue(EmailVo emailVo)");
                object[] objects = new object[1];
                objects[0] = emailVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(isCompleted);
        }
コード例 #3
0
        private bool ProcessBulkMailRequest(int requestId, int dependentRequestId)
        {
            EmailVo   emailVo = new EmailVo();
            DataSet   dsReportInputOutPutData = GetBulkMailReportInputOutData(requestId, dependentRequestId);
            DataTable dtRequestInputData      = dsReportInputOutPutData.Tables[0];
            DataTable dtRequestOutPutData     = dsReportInputOutPutData.Tables[1];
            bool      flag;

            try
            {
                emailVo          = FillBulkMailParamerValues(dtRequestInputData, dtRequestOutPutData);
                emailVo.Body     = "Dear Customer Please find attached report";
                emailVo.Subject  = "MF Report";
                emailVo.SourceId = requestId;
                flag             = CreateBulkMailRequest(emailVo);
                return(flag);
            }
            catch (BaseApplicationException Ex)
            {
                UpdateRequestDetails(requestId);
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "BulkMailRequestGenerationBo:ProcessBulkMailRequest()");
                object[] objects = new object[1];
                objects[0]   = daemonCode;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
コード例 #4
0
        private EmailVo FillBulkMailParamerValues(DataTable dtRequestInputData, DataTable dtRequestOutPutData)
        {
            EmailVo emailVo = new EmailVo();

            try
            {
                foreach (DataRow dr in dtRequestInputData.Rows)
                {
                    switch (dr["WP_ParameterCode"].ToString())
                    {
                    case "AID":
                        emailVo.AdviserId = Int32.Parse(dr["WRD_InputParameterValue"].ToString());
                        break;

                    case "CID":
                        emailVo.CustomerId = Int32.Parse(dr["WRD_InputParameterValue"].ToString());
                        break;

                    case "CMAIL":
                        emailVo.To = dr["WRD_InputParameterValue"].ToString();
                        break;

                    case "RMAIL":
                        emailVo.EmailFrom = dr["WRD_InputParameterValue"].ToString();
                        break;

                    case "ONAME":
                        emailVo.OrgName = dr["WRD_InputParameterValue"].ToString();
                        break;
                    }
                }

                foreach (DataRow dr in dtRequestOutPutData.Rows)
                {
                    emailVo.FileName += reportRepositoryFileLocation + @"\" + dr["WRD_OutPutParameterValue"].ToString() + "~";
                }

                if (emailVo.FileName.EndsWith("~"))
                {
                    emailVo.FileName = emailVo.FileName.Substring(0, emailVo.FileName.Length - 1);
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "BulkMailRequestGenerationBo:FillBulkMailParamerValues()");
                object[] objects = new object[1];
                objects[0]   = daemonCode;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(emailVo);
        }
コード例 #5
0
        /// <summary>
        /// Method to Add Email Log Infor to the Table
        /// </summary>
        /// <param name="emailVo">EmailVo Object with the Details of the Email Sent</param>
        /// <returns name="EmailLogId">The Unique Id created for the email Log Entry</returns>
        ///
        public int AddToEmailLog(EmailVo emailVo)
        {
            int         emailLogId  = 0;
            EmailSMSDao emailSMSDao = new EmailSMSDao();

            try
            {
                emailLogId = emailSMSDao.AddToEmailLog(emailVo);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "EmailSMSBo.cs:AddToEmailLog(EmailVo emailVo)");
                object[] objects = new object[1];
                objects[0] = emailVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(emailLogId);
        }
コード例 #6
0
 public void Update(NameVo name, EmailVo email, PhoneVo phone)
 {
     Name  = name;
     Email = email;
     Phone = phone;
     SetUpdatedAt();
 }
コード例 #7
0
        public void Deve_Criar_Um_Valor_De_Objeto_Email()
        {
            var email = new EmailVo("*****@*****.**");

            Assert.AreEqual(email.Address, "*****@*****.**");
            Assert.IsTrue(email.Valid);
        }
コード例 #8
0
        public IResult Handle(CreateCustomerCommand command)
        {
            //transações de negócios, regras de negócio, comunicação com outros handlers
            //Criacao dos objetos
            var name     = new NameVo(command.Nome, command.Sobrenome);
            var cpf      = new CpfVo(command.Documento);
            var email    = new EmailVo(command.Email);
            var customer = new Customer(name, cpf, email, command.Telefone);

            //Validar
            AddNotifications(name.Notifications);
            AddNotifications(cpf.Notifications);
            AddNotifications(email.Notifications);

            if (Invalid)
            {
                return(new ApiContract(false,
                                       "Erro. Corrija os campos abaixo:",
                                       Notifications));
            }

            try
            {
                _repository.Save(customer, null);
            }
            catch (Exception ex)
            {
                //TO-DO: implementa log depois
                throw new Exception("Erro - Handler CustomerCommandHandler" + ex.Message);
            }

            return(new ApiContract(true, "Customer criado com sucesso!", null));
        }
コード例 #9
0
        public ICommandResult Handle(AddCustomerCommand command)
        {
            // Verificar se o CPF já existe
            if (_customerRepository.checkDocumentExists(command.documentNumber))
            {
                AddNotification("Document", "Este CPF já está em uso!");
                return(null);
            }

            // Verificar se o email já existe
            if (_customerRepository.checkEmailExists(command.emailAddress))
            {
                AddNotification("Email", "Este email já está em uso!");
                return(null);
            }

            // Gerar o novo cliente
            var document = new DocumentVo(command.documentNumber);
            var email    = new EmailVo(command.emailAddress);
            var address  = new AddressVo(
                command.addressStreet,
                command.addressNumber,
                command.addressNeighborhood,
                command.addressCity,
                command.addressState,
                command.addressZipCode
                );
            var customer = new CustomerEntity(
                command.name,
                command.birthDate,
                document,
                address,
                email,
                DateTime.Now);

            // Adicionar as notificação
            AddNotifications(document.Notifications);
            AddNotifications(email.Notifications);
            AddNotifications(address.Notifications);
            AddNotifications(customer.Notifications);

            if (this.Invalid)
            {
                return(null);
            }

            // Inserir no banco
            _customerRepository.save(customer);

            // Enviar E-mail de boas vindas

            /*_emailService.Send(
             *  customer.Name.ToString(),
             *  customer.Email.Address,
             *  string.Format(EmailTemplates.WelcomeEmailTitle, customer.Name),
             *  string.Format(EmailTemplates.WelcomeEmailBody, customer.Name));*/

            return(new AddCustomerCommandResult(customer.id.ToString()));
        }
コード例 #10
0
 public Customer(NameVo name, CpfVo cpf, EmailVo email, string phone)
 {
     Name       = name;
     Cpf        = cpf;
     Email      = email;
     Phone      = phone;
     _addresses = new List <Address>();
 }
コード例 #11
0
        public Customer Get(Guid id)
        {
            var name  = new NameVo("Ray", "Carneiro");
            var cpf   = new CpfVo("88041300081");
            var email = new EmailVo("*****@*****.**");

            return(new Customer(name, cpf, email, "(11) 99999-9999"));
        }
コード例 #12
0
 public User(NameVo name, EmailVo email, UserRole role, PasswordVo password, PhoneVo phone, Guid tenantId)
 {
     Name     = name;
     Email    = email;
     Role     = role;
     Phone    = phone;
     Password = password;
     SetTenantId(tenantId);
     Validate();
 }
コード例 #13
0
        public Customer(NameVo name, CpfVo cpf, EmailVo email, string phone)
        {
            Id         = Guid.NewGuid();
            Name       = name;
            Cpf        = cpf;
            Email      = email;
            Phone      = phone;
            _addresses = new List <Address>();

            Validate();
        }
コード例 #14
0
        private bool CreateBulkMailRequest(EmailVo emailVo)
        {
            try
            {
                bool           flag   = false;
                SqlParameter[] Params = new SqlParameter[9];
                Params[0]        = new SqlParameter("@TO", emailVo.To);
                Params[0].DbType = DbType.String;

                Params[1]        = new SqlParameter("@CC", emailVo.Cc);
                Params[1].DbType = DbType.String;

                Params[2]        = new SqlParameter("@BCC", emailVo.Bcc);
                Params[2].DbType = DbType.String;

                Params[3]        = new SqlParameter("@Subject", emailVo.Subject);
                Params[3].DbType = DbType.String;

                Params[4]        = new SqlParameter("@Body", emailVo.Body);
                Params[4].DbType = DbType.String;

                Params[5]        = new SqlParameter("@AdviserId", emailVo.AdviserId);
                Params[5].DbType = DbType.Int32;

                Params[6]        = new SqlParameter("@FromEmailId", emailVo.EmailFrom);
                Params[6].DbType = DbType.String;

                Params[7]        = new SqlParameter("@SourceId", emailVo.SourceId);
                Params[7].DbType = DbType.Int32;

                Params[8]        = new SqlParameter("@FilePathList", emailVo.FileName);
                Params[8].DbType = DbType.String;

                Utils.ExecuteNonQuery("SPROC_CreateReportBulkMailRequest", Params);
                flag = true;
                return(flag);
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "BulkMailRequestGenerationBo:CheckDependentRequestStatus()");
                object[] objects = new object[1];
                objects[0]   = daemonCode;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
コード例 #15
0
        public void Setup()
        {
            var name  = new NomeVo("Jeff", "Almeida");
            var email = new EmailVo("*****@*****.**");

            _monitor    = new Produto("Monitor", 50M, 3);
            _carregador = new Produto("Carregador", 50M, 5);
            _lixeira    = new Produto("Lixeira", 50M, 1);

            _cliente = new Cliente(name, email);
            _pedido  = new Pedido(_cliente);
        }
コード例 #16
0
 public Customer(Guid tenantId, int code, NameVo name, PhoneVo phone, PhoneVo phone2, EmailVo email, DocumentVo document, Guid addressId, string ie)
 {
     SetTenantId(tenantId);
     Code      = code;
     Name      = name;
     Phone     = phone;
     Phone2    = phone2;
     Email     = email;
     Document  = document;
     AddressId = addressId;
     Ie        = ie;
 }
コード例 #17
0
        public Company(Guid tenantId, string name, DocumentVo document, PhoneVo phone, EmailVo emailVo, Address address, Guid addressId, string site)
        {
            SetTenantId(tenantId);

            Name      = name;
            Document  = document;
            Phone     = phone;
            Email     = emailVo;
            Address   = address;
            AddressId = addressId;
            Site      = site;
        }
コード例 #18
0
        public void Setup()
        {
            //Simular dados
            var name  = new NameVo("Ray", "Carneiro");
            var cpf   = new CpfVo("15366015006");
            var email = new EmailVo("*****@*****.**");

            _teclado = new Product("Teclado Microsoft", "Melhor teclado", "teclado.jpg", 10M, 10);
            _mouse   = new Product("Mouse Microsoft", "Melhor mouse", "mouse.jpg", 5M, 10);
            _monitor = new Product("Dell", "Melhor monitor", "dell.jpg", 50M, 10);

            _customer = new Customer(name, cpf, email, "11-5555-5555");
            _order    = new Order(_customer);
        }
コード例 #19
0
 public Cliente(string nomePessoa, DateTime dtNascimento, string nomeMae, string nomePai, string nomeSocial, CpfCnpjVo cpf, EmailVo email, TipoCliente tipoCliente)
 {
     NomePessoa      = nomePessoa;
     DtNascimento    = dtNascimento;
     NomeMae         = nomeMae;
     NomePai         = nomePai;
     NomeSocial      = nomeSocial;
     Cpf             = cpf;
     Email           = email;
     TipoCliente     = tipoCliente;
     Ativo           = true;
     DataCriacao     = DateTime.Now;
     _enderecosLista = new List <Enderecos>();
 }
コード例 #20
0
        public void CreateCustomerCommandTests_CreateOrder_ShouldBeValid()
        {
            var command  = new CreateCustomerCommand();
            var name     = new NameVo("Ray", "Carneiro");
            var cpf      = new CpfVo("15366015006");
            var email    = new EmailVo("*****@*****.**");
            var customer = new Customer(name, cpf, email, command.Telefone);

            //Validar
            AddNotifications(name.Notifications);
            AddNotifications(cpf.Notifications);
            AddNotifications(email.Notifications);

            Assert.AreEqual(true, !Invalid);
        }
コード例 #21
0
        //To-DO: criar uma padrão para retorno com smart notification
        public string Execute(PlaceOrderInput order)
        {
            #region Obter dados do banco
            //Customer customer = _customerReadOnlyRepository.Get(customerId);
            //if (customer == null)
            //{
            //    AddNotification("Customer", "Customer does not exist.");
            //}
            #endregion

            //Simulando dados, não implementei acesso a dados
            var name  = new NameVo("Ray", "Carneiro");
            var cpf   = new CpfVo("15366015006");
            var email = new EmailVo("*****@*****.**");
            _customer = new Customer(name, cpf, email, "11-5555-5555");

            if (_customer.Invalid)
            {
                AddNotification("Cliente", "Erros identificados nos dados de cliente: ");
                return(_customer.Notifications.FirstOrDefault().Message);
            }

            _order = new Order(_customer);
            var product = new Product(order.ProductItem.Title, order.ProductItem.Description, order.ProductItem.Image, order.ProductItem.Price, 10);
            _order.AddItem(product, order.ProductItem.Quantity);

            if (_order.Invalid)
            {
                AddNotification("Pedido", "Erros identificados nos dados do seu pedido: ");
                return(_order.Notifications.FirstOrDefault().Message);
            }

            string orderId;

            try
            {
                orderId = _orderWriteOnlyRepository.PlaceOrder(_customer, _order);

                _kafkaProducer.Produce(orderId);
            }
            catch (Exception ex)
            {
                //TO-DO: Implement log
                throw;
            }

            return("Número do pedido: " + orderId);
        }
コード例 #22
0
        public ICommandResult Handle(EditCustomerCommand command)
        {
            var oldCustomer = _customerRepository.getById(command.id);

            // Verificar se existe o cliente
            if (oldCustomer == null)
            {
                AddNotification("Customer", "Cliente não encontrado");
                return(null);
            }

            // Gerar o novo cliente
            var document = new DocumentVo(command.documentNumber);
            var email    = new EmailVo(command.emailAddress);
            var address  = new AddressVo(
                command.addressStreet,
                command.addressNumber,
                command.addressNeighborhood,
                command.addressCity,
                command.addressState,
                command.addressZipCode
                );
            var customer = new CustomerEntity(
                command.name,
                command.birthDate,
                document,
                address,
                email,
                oldCustomer.createAt,
                id: oldCustomer.id);

            // Adicionar as notificação
            AddNotifications(document.Notifications);
            AddNotifications(email.Notifications);
            AddNotifications(address.Notifications);
            AddNotifications(customer.Notifications);

            if (this.Invalid)
            {
                return(null);
            }

            // altera
            _customerRepository.update(customer);

            return(new AddCustomerCommandResult(customer.id.ToString()));
        }
コード例 #23
0
        public string Execute(PlaceOrderInput order)
        {
            //Simulação de dados e regras de negócios
            var name  = new NameVo("Ray", "Carneiro");
            var cpf   = new CpfVo("15366015006");
            var email = new EmailVo("*****@*****.**");

            _customer = new Customer(name, cpf, email, "11-5555-5555");

            if (_customer.Invalid)
            {
                AddNotification("Cliente", "Erros identificados nos dados de cliente: ");
                return(_customer.Notifications.FirstOrDefault().Message);
            }

            _order = new Order(_customer);
            var product = new Product(order.ProductItem.Title, order.ProductItem.Description, order.ProductItem.Image, order.ProductItem.Price, 10);

            _order.AddItem(product, order.ProductItem.Quantity);

            if (_order.Invalid)
            {
                AddNotification("Pedido", "Erros identificados nos dados do seu pedido: ");
                return(_order.Notifications.FirstOrDefault().Message);
            }

            string orderId;

            try
            {
                //Salva ordem no banco de dados
                orderId = _orderWriteOnlyRepository.PlaceOrder(_customer, _order);

                //Envia mensagem para Kafka
                _kafkaAdapter.Produce(orderId);
            }
            catch
            {
                throw;
            }

            return("Número do pedido: " + orderId);
        }
コード例 #24
0
        public CustomerEntity(
            string name,
            DateTime?birthDate,
            DocumentVo document,
            AddressVo address,
            EmailVo email,
            DateTime createAt,
            Guid?id = null) : base(id: id, createAt: createAt)
        {
            this.name      = name;
            this.birthDate = birthDate;
            this.document  = document;
            this.address   = address;
            this.email     = email;

            AddNotifications(new Contract()
                             .IsNotNullOrEmpty(name, "CustomerEntity.name", "Nome é obrigatório")
                             );
        }
コード例 #25
0
        protected DomainBaseUnitTest()
        {
            Settings.SecurityKey = "cbffeba849124af8b7b89675c223fd3d";
            Tenant = new AppTenant("Treeze", "localhost:43500", null, null);
            User   = new User(new NameVo("Victor", "Luiz"), new EmailVo("*****@*****.**"), UserRole.User, new PasswordVo("12345678", "12345678"), null, Tenant.Id);

            var code         = 1;
            var firstName    = "Victor";
            var lastName     = "Domingues";
            var name         = new NameVo(firstName, lastName);
            var number       = "11992535010";
            var phone        = new PhoneVo(number);
            var phone2       = new PhoneVo(number);
            var cpf          = "3333333333";
            var document     = new DocumentVo(cpf, EDocumentType.Cpf);
            var emailAddress = "*****@*****.**";
            var email        = new EmailVo(emailAddress);

            var address = new Address(Tenant.Id, "", "", "", "", "", "", "", "");

            Customer = new Customer(Tenant.Id, code, name, phone, phone2, email, document, address.Id, null);
        }
コード例 #26
0
 public Cliente(NomeVo name, EmailVo email)
 {
     Nome  = name;
     Email = email;
 }
コード例 #27
0
 public void Setup()
 {
     _emailValido   = new EmailVo("*****@*****.**");
     _emailInvalido = new EmailVo("jefferson.almeida.konia");
 }
コード例 #28
0
 public static void SendEmail(EmailVo emailVo, Action <IRestResponse <ResultSrv <ServiceCallResultSrv <ResponseSrv <SmsSrv> > > > > callback)
 {
     PrepareRestClient(ServiceCallProducts.SendEmail, emailVo, Method.POST, out var client, out var request);
     callback(client.Execute <ResultSrv <ServiceCallResultSrv <ResponseSrv <SmsSrv> > > >(request));
 }
コード例 #29
0
        /// <summary>
        /// Method to Add Email Log Infor to the Table
        /// </summary>
        /// <param name="emailVo">EmailVo Object with the Details of the Email Sent</param>
        /// <returns name="EmailLogId">The Unique Id created for the email Log Entry</returns>
        public int AddToEmailLog(EmailVo emailVo)
        {
            int       emailLogId = 0;
            Database  db;
            DbCommand addToEmailLogCmd;

            try
            {
                db = DatabaseFactory.CreateDatabase("wealtherp");
                addToEmailLogCmd = db.GetStoredProcCommand("SP_AddOutGoingEmailLog");
                if (emailVo.EmailQueueId != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_EmailQueueId", DbType.Int32, emailVo.EmailQueueId);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_EmailQueueId", DbType.Int32, DBNull.Value);
                }

                if (emailVo.AdviserId != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@A_AdviserId", DbType.Int32, emailVo.AdviserId);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@A_AdviserId", DbType.Int32, DBNull.Value);
                }

                if (emailVo.CustomerId != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@C_CustomerId", DbType.Int32, emailVo.CustomerId);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@C_CustomerId", DbType.Int32, DBNull.Value);
                }

                if (emailVo.EmailType != null && emailVo.EmailType != "")
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_EmailType", DbType.String, emailVo.EmailType);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_EmailType", DbType.String, DBNull.Value);
                }
                if (emailVo.HasAttachment != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_Attachment", DbType.Int16, emailVo.HasAttachment);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_Attachment", DbType.Int16, DBNull.Value);
                }
                if (emailVo.AttachmentPath != null && emailVo.AttachmentPath != "")
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_AttachmentPath", DbType.String, emailVo.AttachmentPath);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_AttachmentPath", DbType.String, DBNull.Value);
                }
                if (emailVo.SentDate != DateTime.MinValue && emailVo.SentDate != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_DateSent", DbType.DateTime, emailVo.SentDate);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_DateSent", DbType.DateTime, DBNull.Value);
                }
                if (emailVo.FileName != null && emailVo.FileName != "")
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_FileName", DbType.String, emailVo.FileName);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_FileName", DbType.String, DBNull.Value);
                }
                if (emailVo.ReportCode != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_ReportCode", DbType.Int16, emailVo.ReportCode);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_ReportCode", DbType.Int16, DBNull.Value);
                }
                if (emailVo.Status != null)
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_Status", DbType.Int16, emailVo.Status);
                }
                else
                {
                    db.AddInParameter(addToEmailLogCmd, "@AEML_Status", DbType.Int16, DBNull.Value);
                }

                db.AddOutParameter(addToEmailLogCmd, "@Id", DbType.Int32, 10000);
                if (db.ExecuteNonQuery(addToEmailLogCmd) != 0)
                {
                    emailLogId = int.Parse(db.GetParameterValue(addToEmailLogCmd, "Id").ToString());
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorDao.cs:AddToEmailLog(EmailVo emailVo)");
                object[] objects = new object[1];
                objects[0] = emailVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(emailLogId);
        }
コード例 #30
0
        public bool CreateReportBulkMailRequest(EmailVo emailVo)
        {
            Database  db;
            bool      isComplete = false;
            DbCommand addToEmailQueueCmd;
            Int16     noOfRecord;

            try
            {
                db = DatabaseFactory.CreateDatabase("wealtherp");
                addToEmailQueueCmd = db.GetStoredProcCommand("SPROC_CreateReportBulkMailRequest");
                if (emailVo.To != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@To", DbType.String, emailVo.To);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@To", DbType.String, DBNull.Value);
                }

                if (emailVo.Cc != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Cc", DbType.String, emailVo.Cc);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Cc", DbType.String, DBNull.Value);
                }

                if (emailVo.Bcc != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Bcc", DbType.String, emailVo.Bcc);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Bcc", DbType.String, DBNull.Value);
                }

                if (emailVo.Subject != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Subject", DbType.String, emailVo.Subject);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Subject", DbType.String, DBNull.Value);
                }

                if (emailVo.Body != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Body", DbType.String, emailVo.Body);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@Body", DbType.String, DBNull.Value);
                }

                if (emailVo.HasAttachment != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@HasAttachment", DbType.Int32, emailVo.HasAttachment);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@HasAttachment", DbType.Int32, DBNull.Value);
                }

                if (emailVo.SourceId != 0)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@SourceId", DbType.String, emailVo.SourceId);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@SourceId", DbType.String, DBNull.Value);
                }

                if (emailVo.AttachmentPath != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@FilePathList", DbType.String, emailVo.AttachmentPath);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@FilePathList", DbType.String, DBNull.Value);
                }

                if (emailVo.AdviserId != 0)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@AdviserId", DbType.String, emailVo.AdviserId);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@AdviserId", DbType.String, DBNull.Value);
                }

                if (emailVo.EmailFrom != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@FromEmailId", DbType.String, emailVo.EmailFrom);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@FromEmailId", DbType.String, DBNull.Value);
                }
                if (emailVo.EmailType != null)
                {
                    db.AddInParameter(addToEmailQueueCmd, "@TypeCode", DbType.String, emailVo.EmailType);
                }
                else
                {
                    db.AddInParameter(addToEmailQueueCmd, "@TypeCode", DbType.String, DBNull.Value);
                }

                db.ExecuteNonQuery(addToEmailQueueCmd);
                isComplete = true;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "AdvisorDao.cs:CreateReportBulkMailRequest(EmailVo emailVo)");
                object[] objects = new object[1];
                objects[0] = emailVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(isComplete);
        }