Esempio n. 1
0
        public bool RegistroMasivo(string rutaArchivo, string ContracEthereumProposal, string NameProposal)
        {
            SentMail      email   = new SentMail();
            List <string> contrac = new List <string> {
                "0x12890d2cce102216644c59daE5baed380d84830c", "0x12890d2cce102216644c59daE5baed380d84830c", "0x12890d2cce102216644c59daE5baed380d84830c", "0x12890d2cce102216644c59daE5baed380d84830c", "0x72bc90bcee4f850e5f746dccf8afc48faff037b2", "0x6ba8d4304efae5edc7942762af0029ff514f8ceb", "0xca11d36c46848c289e9ab6d94ab012b26a5970bf", "0xae63afbac20dfd5a952bb7efe196196c40a7acd0", "0x6b23d35cfd1ce9c95b52e5cbfdc2ee1ffdec6a93", "0xdd3a891ca6ec6fe35ab69f42707c762868f7edf6", "0xd9708db1b7749e6ed3f4bdcb01ee033fe26f9da4", "0x34a4bab52953d436861d893a0d0133ab84d96c56"
            };

            System.IO.StreamReader objReader = new System.IO.StreamReader(rutaArchivo);
            string sLine = "";

            System.Collections.ArrayList arrText = new System.Collections.ArrayList();
            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    arrText.Add(sLine);
                }
            }
            objReader.Close();
            List <string> correos = new List <string>();

            foreach (string sOutput in arrText)
            {
                correos.AddRange(sOutput.Split(';'));
            }
            foreach (var item in correos)
            {
                if (!IsValidEmail(item))
                {
                    return(false);
                }
            }

            using (ProposalDataAccess propasalDataAccess = new ProposalDataAccess())
            {
                using (UserDataAccess userDataAccess = new UserDataAccess())
                {
                    foreach (var item in correos)
                    {
                        string    AccountNumber = contrac[0];
                        UserModel user          = new UserModel()
                        {
                            Profile       = 3,
                            Email         = item,
                            Password      = GenaratorPass(),
                            IsFirstLogger = EnumRegister.NoRegister,
                        };
                        contrac.Remove(AccountNumber);

                        List <UserModel> list        = userDataAccess.SearchUser(user.Email);
                        bool             isValidUser = false;
                        if (list == null || list.Count == 0)
                        {
                            isValidUser = userDataAccess.InserUser(user);
                        }
                        else
                        {
                            //el usuario existe no se registra
                            isValidUser = true;
                        }
                        if (isValidUser)
                        {
                            isValidUser = propasalDataAccess.InsertProposalUser(ContracEthereumProposal, item);
                            if (list.Count > 0)
                            {
                                string mensaje = "<p>Usted fue invitado a votar a la propuesta " + NameProposal + "</p>" +
                                                 "<p>Su Usuario es :" + item + "</p>" +
                                                 "<p>Ruta de acceso: <a href = 'http://raykel.eastus.cloudapp.azure.com/EthereumWeb/' >Ingreso </a> </p>";

                                email.SentEmail(mensaje, item, "Solicitud de Votación", "Votacion de " + NameProposal);
                            }
                            else
                            {
                                if (isValidUser)
                                {
                                    string mensaje = "<p>Usted fue invitado a votar a la propuesta " + NameProposal + "</p>" +
                                                     "<p>Su Usuario es :" + item + "</p>" +
                                                     "<p>Su número de token para participar en la votación es : " + user.Password + "</p>" +
                                                     "<p>Ruta de acceso: <a href='http://raykel.eastus.cloudapp.azure.com/EthereumWeb/' >Ingreso </a></p>";

                                    email.SentEmail(mensaje, item, "Solicitud de Votación", "Votacion de " + NameProposal);
                                }
                            }
                        }
                    }
                }
            }


            return(true);
        }
Esempio n. 2
0
        public bool RegistroMasivo(string rutaArchivo, string ContracEthereumProposal)
        {
            SentMail email = new SentMail();

            System.IO.StreamReader objReader = new System.IO.StreamReader(rutaArchivo);
            string sLine = "";

            System.Collections.ArrayList arrText = new System.Collections.ArrayList();
            while (sLine != null)
            {
                sLine = objReader.ReadLine();
                if (sLine != null)
                {
                    arrText.Add(sLine);
                }
            }
            objReader.Close();
            List <string> correos = new List <string>();

            foreach (string sOutput in arrText)
            {
                correos.AddRange(sOutput.Split(';'));
            }
            foreach (var item in correos)
            {
                if (!IsValidEmail(item))
                {
                    return(false);
                }
            }

            foreach (var item in correos)
            {
                UserModel user = new UserModel()
                {
                    Profile       = 3,
                    Email         = item,
                    Password      = GenaratorPass(),
                    IsFirstLogger = EnumRegister.NoRegister
                };

                using (UserDataAccess userDataAccess = new UserDataAccess())
                {
                    if (userDataAccess.UpdateUser(user, 3))
                    {
                        using (ProposalDataAccess proposal = new ProposalDataAccess())
                        {
                            if (proposal.InsertProposalUser(ContracEthereumProposal, item))
                            {
                                string mensaje = "<p>Usted fue invitado a votar a la propuesta Salvemos a Lucho</p>" +
                                                 "<p>Su Usuario es :" + item + "</p>" +
                                                 "<p>Su número de token para participar en la votación es : " + user.Password + "</p>";
                                // email.SentEmail(mensaje, item);
                            }
                        }
                    }
                }
            }


            return(true);
        }