public ActionResult ProcessANewRegister(User user)
        {
            SecurityDAO securityDAO = new SecurityDAO();

            securityDAO.RegisterUser(user);
            return(View("Login"));
        }
Example #2
0
 public static void sendMail(int action, List <User> listOfUsers, int projectId, string projectName)
 {
     try
     {
         string fromAddress  = SecurityDAO.decrypt(ConfigurationManager.AppSettings["fromAddress"]);
         string userLogin    = SecurityDAO.decrypt(ConfigurationManager.AppSettings["userLogin"]);
         string userPassword = SecurityDAO.decrypt(ConfigurationManager.AppSettings["userPassword"]);
         string userDomain   = SecurityDAO.decrypt(ConfigurationManager.AppSettings["userDomain"]);
         int    serverTime   = Convert.ToInt32(string.Format("{0:HH}", DateTime.Now));
         string greeting     = string.Empty;
         if (serverTime >= 6 && serverTime < 12)
         {
             greeting = "Bom dia";
         }
         else if (serverTime >= 12 && serverTime < 18)
         {
             greeting = "Boa tarde";
         }
         else
         {
             greeting = "Boa noite";
         }
         string body    = string.Empty;
         string subject = string.Empty;
         //Se zero, notifica que as atividades de execução de lançamento foram finalizadas
         if (action == 0)
         {
             subject = "Finalização Tarefas Execução de Lançamento";
             body    = string.Format("<p>{0}!</p><p>&nbsp;</p><p>Informamos que as atividades de Execu&ccedil;&atilde;o do Lan&ccedil;amento do projeto {1} - {2} foram finalizadas com base nos dados da ata integrada.</p><p>&nbsp;</p><p>Atenciosamente,</p><p>&nbsp;</p><p>SGN.</p>", greeting, projectId, projectName);
         }
         //Se não for zero, notifica que mais atividades de execução de lançamento foram criadas após a finalização
         else
         {
             subject = "Nova Tarefa Execução de Lançamento";
             body    = string.Format("<p>{0}!</p><p>&nbsp;</p><p>Informamos que as atividades de Execu&ccedil;&atilde;o do Lan&ccedil;amento do projeto {1} - {2} j&aacute; haviam sido finalizadas, entretando, uma nova atividade foi criada. Aguarde nova notifica&ccedil;&atilde;o para que a etapa esteja liberada para aprova&ccedil;&atilde;o.</p><p>&nbsp;</p><p>Atenciosamente,</p><p>&nbsp;</p><p>SGN.</p><p>", greeting, projectId, projectName);
         }
         ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
         service.Credentials = new WebCredentials(userLogin, userPassword, userDomain);
         //service.AutodiscoverUrl(fromAddress);
         service.Url = new Uri("https://legacy.natura.net/EWS/Exchange.asmx");
         EmailMessage message = new EmailMessage(service);
         message.From          = fromAddress;
         message.Subject       = subject;
         message.Body          = body;
         message.Body.BodyType = BodyType.HTML;
         foreach (User user in listOfUsers)
         {
             message.ToRecipients.Add(user.getEmail());
         }
         message.SendAndSaveCopy();
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public LockGold UpdateLockGold(long amount, int typeLock, string otp = "")
        {
            try
            {
                if (amount <= 0)
                {
                    return new LockGold
                           {
                               ResponseCode = -99
                           }
                }
                ;

                if (typeLock == 2)
                {
                    long accountId = AccountSession.AccountID;

                    var account = AccountDAO.GetAccountById(accountId);

                    var    infoApp = OtpDAO.GetCurrentCounter(accountId);
                    string token   = infoApp?.AppT;
                    if (!string.IsNullOrEmpty(infoApp?.AppT))
                    {
                        if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", otp))
                        {
                            goto doneOTP;
                        }
                    }

                    if (string.IsNullOrEmpty(otp) || (!OTP.OTP.ValidateOTP(accountId, otp, account.Tel)))
                    {
                        return new LockGold
                               {
                                   ResponseCode = -60
                               }
                    }
                    ;
                }
doneOTP:
                SecurityDAO.UpdateLockGold(AccountSession.AccountID, amount, typeLock, "user lock", out long currGold);
                return(new LockGold
                {
                    ResponseCode = 1,
                    CurrentGold = currGold,
                });
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(new LockGold
            {
                ResponseCode = -99
            });
        }
Example #4
0
 public InformationContract GetInfo(string tokenService, string tokenInfo)
 {
     if (SecurityDAO.CheckToken(tokenService) == true)
     {
         var info = Repositories.GetInfoByToken(tokenInfo);
         return(new InformationContract {
             idInfor = info.idInfor, contentInfo = info.contentInfo, dayCreateInfo = info.dayCreateInfo, newInfo = info.newInfo, titleInfo = info.titleInfo, token = info.token
         });
     }
     return(null);
 }
 public List <GoldLockTransaction> GetLockGoldTransaction()
 {
     try
     {
         return(SecurityDAO.GetLockGoldTransaction(AccountSession.AccountID));
     }
     catch (Exception ex)
     {
         NLogManager.PublishException(ex);
     }
     return(null);
 }
 public AccountOTPInfo GetAccountOTPInfo()
 {
     try
     {
         return(SecurityDAO.GetOTPInfo(AccountSession.AccountID));
     }
     catch (Exception ex)
     {
         NLogManager.PublishException(ex);
     }
     return(null);
 }
Example #7
0
        public IEnumerable <dynamic> GetListUser()
        {
            try
            {
                return(SecurityDAO.GetAccount());
            }catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }

            return(null);
        }
        public int UpdatePhoneNumber(string phoneNumber, string otp)
        {
            try
            {
                if (!PhoneDetector.IsValidPhone(phoneNumber))
                {
                    return(-54);
                }

                var accountId = AccountSession.AccountID;
                var account   = AccountDAO.GetAccountById(AccountSession.AccountID);

                if (!string.IsNullOrEmpty(account.Tel))
                {
                    string p = account.Tel;

                    if (!OTP.OTP.ValidateOTP(accountId, otp, p))
                    {
                        return(-60);
                    }
                }
                else
                {
                    var    infoApp = OtpDAO.GetCurrentCounter(accountId);
                    string token   = infoApp?.AppT;
                    if (!string.IsNullOrEmpty(infoApp?.AppT))
                    {
                        if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", otp))
                        {
                            goto doneOTP;
                        }
                    }

                    if (!OTP.OTP.ValidateOTP(accountId, otp, phoneNumber))
                    {
                        return(-60);
                    }
                }

doneOTP:
                SecurityDAO.UpdatePhoneNumber(AccountSession.AccountID, phoneNumber);

                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
Example #9
0
        public Boolean register(UserModel user)
        {
            SqlConnection connection = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=CLC;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

            connection.Open();

            SecurityDAO dao = new SecurityDAO(connection);

            bool result = dao.register(user);

            connection.Close();

            return(result);
        }
        public int ChangePass(string old, string pass, string otp)
        {
            try
            {
                var accountId   = AccountSession.AccountID;
                var accountInfo = AccountDAO.GetAccountInfo(accountId);

                var    infoApp = OtpDAO.GetCurrentCounter(accountId);
                string token   = infoApp?.AppT;
                if (!string.IsNullOrEmpty(infoApp?.AppT))
                {
                    if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", otp))
                    {
                        goto doneOTP;
                    }
                }

                if (string.IsNullOrEmpty(otp) || (!OTP.OTP.ValidateOTP(accountId, otp, accountInfo.Tel)))
                {
                    return(-60);
                }

doneOTP:

                Regex rPassword = new Regex("^[a-zA-Z0-9_.-]{6,18}$");
                if (!rPassword.IsMatch(old))
                {
                    return(-30);
                }
                if (!rPassword.IsMatch(pass))
                {
                    return(-30);
                }

                var account = SecurityDAO.GetByIdPass(accountId, Security.MD5Encrypt(old));
                if (account == null)
                {
                    return(-31);
                }

                SecurityDAO.ChangePassword(AccountSession.AccountID, Security.MD5Encrypt(old), Security.MD5Encrypt(pass));
                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
Example #11
0
        public List <string> LoadAllMenuByUser(string userID)
        {
            Database db = AppEnvironment.Database;

            List <SecurityMatchDTO> lstDTO = SecurityDAO.LoadSecurityOfUserForMenuMapping(db, userID);

            List <string> lstClass = new List <string>();

            lstDTO.ForEach(action =>
            {
                lstClass.Add(action.ClassName);
            });

            return(lstClass);
        }
Example #12
0
        public bool AddAccount(string username, string password)
        {
            try
            {
                SecurityDAO.AddAccount(username, Utilities.Encryption.Security.MD5Encrypt(password), UserContext.UserInfo.AccountID);
                RoleBuilder.Init();
                return(true);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }

            return(false);
        }
Example #13
0
        public List <MenuItem> GetMenu(string appSymbol, int userId)
        {
            List <MenuItem> items;

            if (MemoryCacher.GetValue("menu_" + userId.ToString()) == null)
            {
                SecurityDAO securityDAO = new SecurityDAO(connectionString);
                items = securityDAO.GetMenu(appSymbol, userId, "");
                MemoryCacher.Add("menu_" + userId.ToString(), items, new DateTimeOffset(DateTime.Now.AddHours(6)));
            }
            else
            {
                items = (List <MenuItem>)MemoryCacher.GetValue("menu_" + userId.ToString());
            }
            return(items);
        }
        public ActionResult ProcessSignUp(Customer customer)
        {
            SecurityDAO security = new SecurityDAO();
            bool        exists   = security.Ifexist(customer);

            if (exists)
            {
                ViewData["exists"] = customer.Name;
                return(View("Login"));
            }

            else
            {
                security.CreateUser(customer);
                return(View("LoginSuccess", customer));
            }
        }
Example #15
0
        public bool DeleteAccount(int accountId)
        {
            try
            {
                if (accountId == 1)
                {
                    return(false);
                }

                SecurityDAO.DeleteAccount(accountId);
                RoleBuilder.Init();
                return(true);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }

            return(false);
        }
        public int CreatedNewPass(string tokenOTP, string newPassword)
        {
            try
            {
                string   decryptToken = Security.TripleDESDecrypt(ConfigurationManager.AppSettings["OTPKey"], System.Web.HttpUtility.UrlDecode(tokenOTP).Replace(" ", "+"));
                string[] splData      = decryptToken.Split('|');

                long time = long.Parse(splData[0]);
                if (TimeSpan.FromTicks(DateTime.Now.Ticks - time).TotalSeconds > 120)
                {
                    return(-1); //Experied captcha
                }
                long accountId = Convert.ToInt64(splData[1]);

                Regex rPassword = new Regex("^[a-zA-Z0-9_.-]{6,18}$");
                if (!rPassword.IsMatch(newPassword))
                {
                    return(-30);
                }
                if (!rPassword.IsMatch(newPassword))
                {
                    return(-30);
                }

                var account = AccountDAO.GetAccountInfo(accountId);
                if (account == null)
                {
                    return(-31);
                }

                SecurityDAO.CreateNewPassword(AccountSession.AccountID, Security.MD5Encrypt(newPassword));
                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
        public int UpdateRegisterSMSPlus(bool isCancel, string otp = "")
        {
            try
            {
                var accountId   = AccountSession.AccountID;
                var accountInfo = AccountDAO.GetAccountInfo(accountId);

                if (string.IsNullOrEmpty(accountInfo.Tel))
                {
                    return(-99);
                }

                if (isCancel)
                {
                    var    infoApp = OtpDAO.GetCurrentCounter(accountId);
                    string token   = infoApp?.AppT;
                    if (!string.IsNullOrEmpty(infoApp?.AppT))
                    {
                        if (OTPApp.ValidateOTP($"{Security.MD5Encrypt($"{accountId}_{token}")}_{token}", otp))
                        {
                            goto doneOTP;
                        }
                    }

                    if (string.IsNullOrEmpty(otp) || (!OTP.OTP.ValidateOTP(accountId, otp, accountInfo.Tel)))
                    {
                        return(-60);
                    }
                }
doneOTP:
                SecurityDAO.UpdateRegisterSMSPlus(AccountSession.AccountID, isCancel);
                return(1);
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }
            return(-99);
        }
        //Method used to retrieve a verse. Pass a BibleVerse param
        public BibleVerse findVerse(BibleVerse bibleVerse)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.findVerse(bibleVerse));
        }
Example #19
0
 public List <SecurityMatchDTO> LoadSecurityOfUserAssignByGroupLevel(string strUserID)
 {
     return(SecurityDAO.LoadSecurityOfUserAssignByGroupLevel(m_db, strUserID));
 }
Example #20
0
 //User
 public void UpdateSecurityOfUser(string strUserID, SecurityMatchDTO[] data, string UserID)
 {
     SecurityDAO.UpdateSecurityOfUser(m_db, strUserID, data, UserID);
 }
Example #21
0
        public bool Authenticate(UserModel user)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.FindByUser(user));
        }
Example #22
0
        public BibleVerseModel Search(BibleVerseModel bibleVerseModel)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.FindVerse(bibleVerseModel));
        }
Example #23
0
        public bool Create(BibleVerseModel bibleVerseModel)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.EnterNewVerse(bibleVerseModel));
        }
Example #24
0
 //User Group
 public void UpdateSecurityOfUserGroup(int iGroupID, SecurityMatchDTO[] data, string UserID)
 {
     SecurityDAO.UpdateSecurityOfUserGroup(m_db, iGroupID, data, UserID);
 }
Example #25
0
 //Screen
 public void UpdateSecurityOfScreen(int iScreenID, SecurityMatchDTO[] secUsers, SecurityMatchDTO[] secGroups, string UserID)
 {
     SecurityDAO.UpdateSecurityOfScreen(m_db, iScreenID, secUsers, secGroups, UserID);
 }
Example #26
0
 public List <SecurityMatchDTO> LoadSecurityOfUser(string strUserID)
 {
     return(SecurityDAO.LoadSecurityOfUser(m_db, strUserID));
 }
Example #27
0
 //User Group
 public List <UserGroupDTO> LoadSecurityOfScreenForUserGroupLevel(int iScreenID)
 {
     return(SecurityDAO.LoadSecurityOfScreenForUserGroupLevel(m_db, iScreenID));
 }
Example #28
0
 public List <SecurityMatchDTO> LoadSecurityOfUserGroup(int iGroupID)
 {
     return(SecurityDAO.LoadSecurityOfUserGroup(m_db, iGroupID));
 }
        public string Register(RegisterModel user)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.Create(user));
        }
        //Method used to create a verse. Contains a bibleVere param
        public bool createVerse(BibleVerse bibleVerse)
        {
            SecurityDAO service = new SecurityDAO();

            return(service.createVerse(bibleVerse));
        }