// public bool ApproveNewUser(sec_UserRepo repo_user) // { // //Get connectoin // var app = new AppSettings(); // TransactionOptions tsOp = new TransactionOptions(); // tsOp.IsolationLevel = System.Transactions.IsolationLevel.Snapshot; // TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, tsOp); // tsOp.Timeout = TimeSpan.FromMinutes(20); // using (OracleConnection conn = new OracleConnection(app.conString())) // // { // try // { // string queryinternet = "select * from setup_company"; // #region get email properties // { // var paramuser = new DynamicParameters(); // paramuser.Add("P_USER_ID", repo_user.User_Id, DbType.String, ParameterDirection.Input); // paramuser.Add("REMAIL", "", DbType.String, ParameterDirection.Output); // paramuser.Add("RPASSWORD", "", DbType.String, ParameterDirection.Output); // paramuser.Add("RFULLNAME", "", DbType.String, ParameterDirection.Output); // con.Execute("SEL_EMAIL_PROP", paramuser, commandType: CommandType.StoredProcedure); // repo_user.Email = paramuser.Get<string>("REMAIL"); // repo_user.Password = paramuser.Get<string>("RPASSWORD"); // repo_user.Employee_Name = paramuser.Get<string>("RFULLNAME"); // } // #endregion // #region send email // OracleCommand commandinternet = new OracleCommand(queryinternet, conn); // conn.Open(); // OracleDataReader readerinternet; // readerinternet = commandinternet.ExecuteReader(); // // Always call Read before accessing data. // while (readerinternet.Read()) // { // internetRepo.smtp = (string)readerinternet["smtp"]; // internetRepo.email_from = (string)readerinternet["email_from"]; // internetRepo.email_password = (string)readerinternet["email_password"]; // internetRepo.port = Convert.ToInt16(readerinternet["port"]); // internetRepo.company_name = (string)readerinternet["company_name"]; // } // string security_Code = "[email protected]"; // repo_user.Password = GlobalValue.AES_Decrypt(repo_user.Password, security_Code); // var msg = $@"<b>Dear {repo_user.Employee_Name}</b> <br/> <br/><font color=blue>Your User Name is {repo_user.User_Id} and Password is {repo_user.Password}</font>"; // string from = internetRepo.email_from, pass = internetRepo.email_password, subj = "Teksol Penfad authentication for " + repo_user.Employee_Name, to = repo_user.Email; // string smtp = internetRepo.smtp; // int port = internetRepo.port; // internetRepo.SendIt(from, pass, subj, msg, to, smtp, port); // #endregion // #region Approve user // var param = new DynamicParameters(); // param.Add(name: "p_UserId", value: repo_user.User_Id, dbType: DbType.String, direction: ParameterDirection.Input); // param.Add(name: "p_UserStatus", value: "ACTIVE", dbType: DbType.String, direction: ParameterDirection.Input); // param.Add(name: "p_AuthStatus", value: "AUTHORIZED", dbType: DbType.String, direction: ParameterDirection.Input); // param.Add(name: "p_AuthDate", value: GlobalValue.Scheme_Today_Date, dbType: DbType.Date, direction: ParameterDirection.Input); // param.Add(name: "p_AuthId", value: GlobalValue.User_ID, dbType: DbType.String, direction: ParameterDirection.Input); // con.Execute(sql: "APP_SEC_USER", param: param, commandType: CommandType.StoredProcedure); // #endregion // //ts.Complete(); // return true; // } // catch (Exception ex) // { // throw ex; // } // finally // { // if (con.State == ConnectionState.Open) // { // con.Close(); // } // } // } //} public void ApproveNewUser(sec_UserRepo repo_user) { var app = new AppSettings(); TransactionOptions tsOp = new TransactionOptions(); tsOp.IsolationLevel = System.Transactions.IsolationLevel.Snapshot; TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew, tsOp); tsOp.Timeout = TimeSpan.FromMinutes(20); string queryinternet = "select * from setup_company"; using (OracleConnection conn = new OracleConnection(app.conString())) // { try { //string password_hash = cSecurityRepo.AES_Encrypt(repo_user.Password); #region get email properties { var paramuser = new DynamicParameters(); paramuser.Add("P_USER_ID", repo_user.User_Id, DbType.String, ParameterDirection.Input); paramuser.Add("REMAIL", "", DbType.String, ParameterDirection.Output); paramuser.Add("RPASSWORD", "", DbType.String, ParameterDirection.Output); paramuser.Add("RFULLNAME", "", DbType.String, ParameterDirection.Output); conn.Execute("SEL_EMAIL_PROP", paramuser, commandType: CommandType.StoredProcedure); repo_user.Email = paramuser.Get <string>("REMAIL"); repo_user.Employee_Name = paramuser.Get <string>("RFULLNAME"); } #endregion #region reassign user var param = new DynamicParameters(); param.Add(name: "p_UserId", value: repo_user.User_Id, dbType: DbType.String, direction: ParameterDirection.Input); param.Add(name: "p_UserStatus", value: "ACTIVE", dbType: DbType.String, direction: ParameterDirection.Input); param.Add(name: "p_AuthStatus", value: "AUTHORIZED", dbType: DbType.String, direction: ParameterDirection.Input); param.Add(name: "p_AuthDate", value: GlobalValue.Scheme_Today_Date, dbType: DbType.Date, direction: ParameterDirection.Input); param.Add(name: "p_AuthId", value: GlobalValue.User_ID, dbType: DbType.String, direction: ParameterDirection.Input); conn.Execute(sql: "APP_SEC_USER", param: param, commandType: CommandType.StoredProcedure); #endregion #region send email OracleCommand commandinternet = new OracleCommand(queryinternet, conn); conn.Open(); OracleDataReader readerinternet; readerinternet = commandinternet.ExecuteReader(); // Always call Read before accessing data. while (readerinternet.Read()) { internetRepo.smtp = (string)readerinternet["smtp"]; internetRepo.email_from = (string)readerinternet["email_from"]; internetRepo.email_password = (string)readerinternet["email_password"]; internetRepo.port = Convert.ToInt16(readerinternet["port"]); internetRepo.company_name = (string)readerinternet["company_name"]; } string security_Code = "[email protected]"; repo_user.Password = GlobalValue.AES_Decrypt(repo_user.Password, security_Code); var msg = $@"<b>Dear {repo_user.Employee_Name}</b> <br/> <br/><font color=blue>Your User Name is {repo_user.User_Id} and Password is {repo_user.Password}</font>"; string from = internetRepo.email_from, pass = internetRepo.email_password, subj = "Teksol Penfad authentication for " + repo_user.Employee_Name, to = repo_user.Email; string smtp = internetRepo.smtp; int port = internetRepo.port; // internetRepo.SendIt(from, pass, subj, msg, to, smtp, port); internetRepo.SendIt(from, pass, subj, msg, to, smtp, port, internetRepo.company_name); #endregion ts.Complete(); } catch (Exception ex) { throw ex; } finally { ts.Dispose(); if (conn.State == ConnectionState.Open) { conn.Close(); } } } }