Delete E12LoginRegistration.java_FRMK

parent b6c2cad8
/**
* The E12Registration EJB file implements a Method to use for E12Registratin, loginIn SignUp.
*
*
* @author Dhanendra
* @version 1.0
* @since 2015-12-10
*/
package ibase.webitm.ejb;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;
import javax.ejb.Stateless;
import org.json.simple.JSONObject;
import ibase.ejb.CommonDBAccessEJB;
import ibase.ejb.E12SMSComp;
import ibase.system.config.ConnDriver;
import ibase.system.config.ConnParams;
import ibase.utility.BaseException;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.utility.UserInfoBean;
import ibase.webitm.bean.E12EmpUsrSp;
import ibase.webitm.bean.E12RegistrationBean;
import ibase.webitm.utility.ITMException;
@Stateless
public class E12LoginRegistration extends ValidatorEJB implements E12LoginRegistrationLocal, E12LoginRegistrationRemote
{
private String siteTranDB = "DEFAULT";
public E12LoginRegistration()
{
}
//private E12GenericUtility genericUtility = new E12GenericUtility();
/**
* This method is used for Check UserName and Password is present or not from login page
* @Author: Dhanendra
* */
@Override
public E12RegistrationBean getLoginActionDetail(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
//This method is used for Check UserName and Password is present or not from login page
System.out.println(" In E12LoginRegistration Method getLoginActionDetail ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String emailId = "";
String password = "";
boolean isUserRegisterd;
try
{
conn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
emailId = e12RegistrationBean.getEmailId();
password = e12RegistrationBean.getPassWdSha();
System.out.println("emailId :"+emailId+"======= password :"+password);
sql = "SELECT EMAIL_ID,PASS_WD_SHA,USER_NAME FROM USER_REGISTRATION WHERE EMAIL_ID = ? and PASS_WD_SHA = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, emailId);
pstmt.setString(2, password);
rs = pstmt.executeQuery();
isUserRegisterd = rs.next();
if (!isUserRegisterd)
{
System.out.println("Sorry, you are not a registered user! Please sign up first");
e12RegistrationBean.setValid(false);
}else if(isUserRegisterd)
{
e12RegistrationBean.setUserName(rs.getString("USER_NAME"));
e12RegistrationBean.setValid(true);
}
}catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Log In failed: An Exception has occurred! In :getLoginActionDetail() : " + d.getMessage());
}
}
return e12RegistrationBean;
}
/**
* From Registration Page check the user already registered or not if user not registered then create new user
* @Author: Dhanendra
* */
@Override
public E12RegistrationBean getUserExist(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
System.out.println(" In E12LoginRegistration Method getLoginActionDetail ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
String emailId = "";
String userName = "";
String lastName = "";
String mobileNo = "";
String dataSourceName = "";
String tranID = "";
boolean isEmailRegisterd;
boolean isContactNoRegisterd;
try
{
authConn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName()); //"Driver"
connDriver = null;
emailId = e12RegistrationBean.getEmailId();
userName = e12RegistrationBean.getUserName();
lastName = e12RegistrationBean.getLastName();
mobileNo = e12RegistrationBean.getContactNo();
dataSourceName = e12RegistrationBean.getDataSourceName();
tranID = e12RegistrationBean.getTranID();
System.out.println("emailId :"+emailId);
sql = "SELECT EMAIL_ID FROM USER_REGISTRATION WHERE EMAIL_ID = ? ";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, emailId);
rs = pstmt.executeQuery();
isEmailRegisterd = rs.next();
sql = "SELECT CONTACT_NO FROM USER_REGISTRATION WHERE CONTACT_NO = ? ";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, mobileNo);
rs = pstmt.executeQuery();
isContactNoRegisterd = rs.next();
if (isEmailRegisterd || isContactNoRegisterd)
{
System.out.println("Registered user!");
e12RegistrationBean.setValid(false);
}else if(!isEmailRegisterd || !isContactNoRegisterd)
{
/*System.out.println("get seq start in isUserRegistered Method");
String seq = getNextSequence("user_reg_seq", dataSourceName );
System.out.println("get seq"+seq);
System.out.println("get seq for genartion"+seq);
e12RegistrationBean.setTranID(seq);
System.out.println("get seq End in isUserRegistered Method");*/
//Changes done By Kamal P to get user_registration value on basis of verification type Start on 11 dec 2018
System.out.println("Create New User if user is not registered");
String verificationType = createNewUserRegistration(userName, lastName, mobileNo, emailId, dataSourceName, tranID);
System.out.println("verification type of User which doing new registration"+verificationType);
//Changes done By Kamal P to get user_registration value on basis of verification type END on 11 dec 2018
e12RegistrationBean.setValid(true);
e12RegistrationBean.setVerificationType(verificationType);
System.out.println("E12LoginRegistration===>"+e12RegistrationBean);
e12RegistrationBean.setUserName(userName);
}
}catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Log In failed: An Exception has occurred! In :getUserExist() : " + d.getMessage());
}
}
return e12RegistrationBean;
}
/**
* This method is use for create New user and send verification mail
* @Author: Dhanendra
* */
@Override
public String createNewUserRegistration(String userName, String lastName, String mobileNo, String emailId, String dataSourceName, String tranID) throws RemoteException, ITMException
{
System.out.println("in createNewUserRegistration ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
ArrayList<String> mailInfo = null;
String password = "";
String status = "1";
int count = 0;
String uri = "";
String otpValue = null;
String verificationType = null;
CommonDBAccessEJB commonDBAcess = new CommonDBAccessEJB();
try
{
System.out.println("dataSourceName :"+dataSourceName+ "=== emailId :"+emailId+"==== userName :"+userName+"---- LastName :"+lastName);
if(checkNull(mobileNo).length() > 0)
{
System.out.println("emailId in E12Login to check length"+emailId);
//Changed By Pankaj T. on 18-09-19 for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml
otpValue = commonDBAcess.generateOTP(userName) ;//TODO: Call commonDBAcess method generateOTP //TODO: Pass userId instead of userName for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml
System.out.println("OTP Value For user registration"+otpValue);
}
System.out.println("dataSourceName :"+dataSourceName+ "=== emailId :"+emailId+"==== userName :"+userName+"---- LastName :"+lastName+ "===otpVlaue:"+otpValue+ "==mobileNo:"+mobileNo);
authConn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
System.out.println("currentDate :"+currentDate);
// Changed by Sneha on 19-08-2016, for generating random no as password [Start]
//Changed By Pankaj T. on 18-09-19 for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml
password = getNewPwd(userName);//TODO: Pass userId instead of userName for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml
//System.out.println("password =====>> "+password);
// Changed by Sneha on 19-08-2016, for generating random no as password [End]
sql = "INSERT INTO USER_REGISTRATION (EMAIL_ID,USER_NAME,STATUS,PASS_WD_SHA,LAST_NAME,CREATE_DATE,VERIFY_DATE,REG_DATE, CONTACT_NO, OTP, TRAN_ID)"
+ " VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
System.out.println("sql to insert otp value"+sql);
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, emailId);
pstmt.setString(2, userName);
pstmt.setString(3, status);
pstmt.setString(4, password);
pstmt.setString(5, lastName);
pstmt.setDate(6, currentDate);
pstmt.setDate(7, currentDate);
pstmt.setDate(8, currentDate);
pstmt.setString(9, mobileNo);
pstmt.setString(10, otpValue);
pstmt.setString(11, tranID);
System.out.println("pstmt in userRegister"+pstmt);
UserInfoBean userInfo = new UserInfoBean();
if( checkNull(dataSourceName).trim().length() > 0 )
{
userInfo.setTransDB(dataSourceName);//Set dataSourceName As TranDB
System.out.println("datasourcename in if=="+userInfo);
}
else
{
userInfo.setTransDB("Driver");//Set DriverITM As TranDB
System.out.println("datasourcename in else=="+userInfo);
}
count = pstmt.executeUpdate();
System.out.println("count :"+count);
if (count > 0)
{
authConn.commit();
//Changes done By Kamal P to get user_registration value on basis of verification type Start on 11 dec 2018
if(checkNull(otpValue).length() > 0)
{
verificationType = "OTP";
System.out.println("In verification type OTP function"+otpValue);
System.out.println("OTP vlaue in if "+otpValue);
E12SMSComp e12smsComp = new E12SMSComp();
System.out.println("e12smsComp==>"+e12smsComp);
String formatCode="USER_FORMAT";
String xtraParams = "loginCode="+"userCode"+"~~loginEmpCode"+"userCode";
StringBuffer valueXmlString = new StringBuffer( "<?xml version=\"1.0\"?>\r\n<Root>\r\n<Header></Header>\r\n<Errors></Errors>\r\n" );
valueXmlString.append( "<Detail1 objName = 'user_authenticate'>\r\n" );
valueXmlString.append( "<code><![CDATA[" ).append("entityCode").append( "]]></code>\r\n" );
valueXmlString.append( "<verfnCode><![CDATA[" ).append(otpValue).append( "]]></verfnCode>\r\n" );
valueXmlString.append( "</Detail1>\r\n" );
valueXmlString.append( "</Root>\r\n" );
String smsresp = "";//e12smsComp.sendSMS(valueXmlString.toString(), formatCode, xtraParams, userInfo);
//BaseLogger.log("3",null,null,"sms response::::"+smsresp);
}
/*if(emailId!= null )
{
mailInfo = new ArrayList<String>();
mailInfo.add(emailId);
mailInfo.add("E12Registration verify your email address");
//Changed by Santosh on 09/01/17 to send users fname and last name in verification link
//uri = CommonConstants.TOMCAT_HOME +"/ibase/E12Registration/jsp/verification.jsp?mailid=" + emailId + "&token=" + password;
uri = CommonConstants.TOMCAT_HOME +"/ibase/E12Registration/jsp/Verification.jsp?mailid=" + emailId + "&token=" + password+"&fName="+userName+"&lName="+lastName+"";
uri = "<a href="+uri+" style=\" background-color: #555;color: #fff;padding: 5px 10px;text-align: center;text-decoration: none;display: inline-block;\">Verify Email</a>";
//Changed by Santosh on 09/01/17
//mailInfo.add(" Welcome " +userName+ ", \n \n Please click on below link to verify your email address: \n \n" + uri + "\n \n Thanks, \n \n The Base Team ");
mailInfo.add("<p>Welcome " +userName+ ",</p> <p>Please click on below button to verify your email address.</p>" + uri + "<p>Thanks, <br></br> Proteus Team </p>");
this.sendMail(mailInfo);
if(verificationType!= null) {
verificationType = verificationType + ",";
System.out.println("comma=====>"+verificationType);
}
verificationType = verificationType + "EMAIL";
System.out.println("verification value using comma seperated"+verificationType);
}*/
if(checkNull(emailId).length() > 0)
{
verificationType = "EMAIL";
System.out.println("In verification type Email function"+emailId);
mailInfo = new ArrayList<String>();
mailInfo.add(emailId);
mailInfo.add("E12Registration verify your email address");
//Changed by Santosh on 09/01/17 to send users fname and last name in verification link
//uri = CommonConstants.TOMCAT_HOME +"/ibase/E12Registration/jsp/verification.jsp?mailid=" + emailId + "&token=" + password;
uri = CommonConstants.TOMCAT_HOME +"/ibase/E12Registration/jsp/Verification.jsp?mailid=" + emailId + "&token=" + password+"&fName="+userName+"&lName="+lastName+"&verificationType="+verificationType+"";
System.out.println("In uri of e12Loginregistration for redirect in Verification"+uri);
uri = "<a href="+uri+" style=\" background-color: #555;color: #fff;padding: 5px 10px;text-align: center;text-decoration: none;display: inline-block;\">Verify Email</a>";
//Changed by Santosh on 09/01/17
//mailInfo.add(" Welcome " +userName+ ", \n \n Please click on below link to verify your email address: \n \n" + uri + "\n \n Thanks, \n \n The Base Team ");
mailInfo.add("<p>Welcome " +userName+ ",</p> <p>Please click on below button to verify your email address.</p>" + uri + "<p>Thanks, <br></br> Proteus Team </p>");
this.sendMail(mailInfo);
}
if(checkNull(otpValue).length() > 0 && checkNull(emailId).length() > 0) {
System.out.println("In verification type all function OTPValue==>"+otpValue+"emailId==>"+emailId);
verificationType = "ALL";
}
//Changes done By Kamal P to get user_registration value on basis of verification type End on 11 dec 2018
System.out.println(" user insertated Succefully in EJB");
}else
{
authConn.rollback();
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :E12LoginRegistration: createNewUserRegistration():" + d.getMessage());
}
}
return verificationType;
}
// Changed by Sneha on 19-08-2016, for generating random no [Start]
private String getNewPwd(String user) throws BaseException
{
String newPwd = new String();
try
{
//If PASSWORDCOMPLEXITY == 1 then 4 digit randaom will be generate.
//Changed By Pankaj T. on 18-09-19 for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml - start
//String passWdComplexity = CommonConstants.PASSWORDCOMPLEXITY;
String passWdComplexity = "";
BaseLogger.log("3", null, null, "In E12LoginRegistration getNewPwd CODE:["+user+"]");
CommonDBAccessEJB commonDBAccessEJB = new CommonDBAccessEJB();
String transDB = commonDBAccessEJB.getDBColumnValue("USERS", "TRANS_DB", "WHERE CODE = '"+user+"'");
BaseLogger.log("3", null, null, "In E12LoginRegistration getNewPwd TRANS_DB:["+transDB+"]");
String enterprise = commonDBAccessEJB.getDBColumnValue("USERS", "ENTERPRISE", "WHERE CODE = '"+user+"'");
BaseLogger.log("3", null, null, "In E12LoginRegistration getNewPwd ENTERPRISE against CODE:["+enterprise+"]");
if( "".equals(E12GenericUtility.checkNull(enterprise)) )
{
String siteCode = commonDBAccessEJB.getDBColumnValue("USERS", "SITE_CODE__DEF", "WHERE CODE = '"+user+"'");
BaseLogger.log("3", null, null, "In E12LoginRegistration getNewPwd SITE_CODE against CODE:["+siteCode+"]");
enterprise = commonDBAccessEJB.getDBColumnValue("SITE", "ENTERPRISE", "WHERE SITE_CODE = '"+siteCode+"'", transDB);
BaseLogger.log("3", null, null, "In E12LoginRegistration getNewPwd ENTERPRISE against SITE_CODE:["+enterprise+"]");
}
passWdComplexity = commonDBAccessEJB.getDBColumnValue("ENTERPRISE", "PASSWORD_COMPLEXITY", "WHERE ENTERPRISE = '"+enterprise+"'", transDB);
BaseLogger.log("3",null,null,"In getNewPwd E12LoginRegistration PASSWORD_COMPLEXITY against ENTERPRISE:["+passWdComplexity+"]");
//Changed By Pankaj T. on 18-09-19 for getting PASSWORD_COMPLEXITY against user defined ENTERPRISE instead of ibase.xml - end
if("1".equals(passWdComplexity))
{
newPwd = ""+(new Random().nextInt(9000)+1000);
}
else
{
newPwd = user.substring((user.length()/2)).toUpperCase();
newPwd += user.substring(0,(user.length()/2)).toLowerCase();
newPwd += Math.random();
}
System.out.println("newPwd =["+newPwd+"]");
newPwd = newPwd.replaceAll(" ","");//changed by Chitranga tandel on 20/07/2017 to remove spaces from password
if (newPwd.length() > 16)
{
newPwd = newPwd.substring(0, 15);
}
}
catch(Exception e)
{
System.out.println("Exception :CommonDBAccessEJB :getNewPwd :==>\n"+e); //$NON-NLS-1$
throw new BaseException( e );
}
return newPwd;
}
// Changed by Sneha on 19-08-2016, for generating random no [Start]
/**
* This method is used for sendMail
* @Author: Dhanendra
* */
public void sendMail(ArrayList<String> mailInfo)
{
StringBuffer commInfo = new StringBuffer();
commInfo.append("<ROOT>");
commInfo.append("<MAILINFO>");
System.out.println("Mail information....");
//commInfo.append("<EMAIL_TYPE>").append("page").append("</EMAIL_TYPE>");//Added by PriyankaC on 24/10/2017.
commInfo.append("<TO_ADD>").append("<![CDATA[" + mailInfo.get(0) + "]]>").append("</TO_ADD>");
commInfo.append("<SUBJECT>").append("<![CDATA[" + mailInfo.get(1) + "]]>").append("</SUBJECT>");
commInfo.append("<BODY_TEXT>").append("<![CDATA[" +mailInfo.get(2) + "]]>").append("</BODY_TEXT>");
//Added by Santosh on 10/01/17 to send message type
commInfo.append("<MESSAGE_TYPE>").append("<![CDATA[text/html]]>").append("</MESSAGE_TYPE>");
commInfo.append("</MAILINFO>");
commInfo.append("</ROOT>");
//EMail email = new EMail();
ibase.utility.EMail email = new ibase.utility.EMail();
try
{
System.out.println(" calling sendMail method() form E12LoginRegistration.createNewUserRegistration");
//email.sendMail(commInfo.toString(), "ITM", "");
email.sendMail(commInfo.toString(), "ITM");
System.out.println(" ******** Email send succesfully for E12Registration. createNewUserRegistration ***********");
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :E12LoginRegistration " + e.getMessage());
}
finally
{
}
email = null;
}
/**
* This Method is used for update/confirm password in Database
* @Author: Dhanendra
* */
@Override
public E12RegistrationBean updatePassordUsingEmail(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
System.out.println("in updatePassord Using EMAIL ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
int count =0;
String emailId = "";
String password = "";
String userName = "";
String tranId = "";
try
{
System.out.println("in try field of updatePassord Using Email");
emailId = e12RegistrationBean.getEmailId();
password = e12RegistrationBean.getPassWdSha();
userName = e12RegistrationBean.getUserName();
authConn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
RegistrationProcess regstProcces = new RegistrationProcess();
sql = "Select * from USER_REGISTRATION where EMAIL_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, emailId);
rs = pstmt.executeQuery();
if (rs.next())
{
tranId = checkNull(rs.getString("TRAN_ID")).trim();
}
pstmt.close();
rs.close();
//Changed by samadhan to update user id
//sql = "UPDATE USER_REGISTRATION SET PASS_WD_SHA= ? WHERE EMAIL_ID= ?";
sql = "UPDATE USER_REGISTRATION SET PASS_WD_SHA= ? , USER_ID = ? WHERE EMAIL_ID= ?";
pstmt = authConn.prepareStatement(sql);
String usrId = regstProcces.generateTranId("w_registration", userName.toUpperCase(), "", authConn);
usrId = usrId.toUpperCase();
pstmt.setString(1, password);
pstmt.setString(2, usrId);
pstmt.setString(3, emailId);
System.out.println("pstmt updatePassord Using Email");
count = pstmt.executeUpdate();
System.out.println("count :"+count);
if (count != 0)
{
authConn.commit();
e12RegistrationBean.setValid(true);
System.out.println("Update Password Successfully");
}else
{
authConn.rollback();
e12RegistrationBean.setValid(false);
System.out.println("RollBack Update Password");
}
e12RegistrationBean.setTranID(tranId);
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :E12LoginRegistration : updatePassord():" + d.getMessage());
}
}
return e12RegistrationBean;
}
@Override
public E12RegistrationBean updatePassordUsingOTP(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
System.out.println("in updatePassord Using OTP");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
int count =0;
String contactNo = "";
String password = "";
String userName = "";
String otpValue = "";
String tranId = "";
try
{
System.out.println("in try field of updatePassord Using OTP");
contactNo = e12RegistrationBean.getContactNo();
password = e12RegistrationBean.getPassWdSha();
userName = e12RegistrationBean.getUserName();
System.out.println("in updatePassword Using OTP getting contactNo==>"+contactNo+", password==>"+password+", userName===>"+userName);
authConn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
RegistrationProcess regstProcces = new RegistrationProcess();
sql = "Select * from USER_REGISTRATION where CONTACT_NO= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, contactNo);
rs = pstmt.executeQuery();
if (rs.next())
{
otpValue = checkNull(rs.getString("OTP")).trim();
tranId = checkNull(rs.getString("TRAN_ID")).trim();
}
pstmt.close();
rs.close();
System.out.println("in updatePassword Using OTP getting otpValue==>"+otpValue);
e12RegistrationBean.setOtpValue(otpValue);
e12RegistrationBean.setTranID(tranId);
//Changed by samadhan to update user id
//sql = "UPDATE USER_REGISTRATION SET PASS_WD_SHA= ? WHERE EMAIL_ID= ?";
sql = "UPDATE USER_REGISTRATION SET PASS_WD_SHA= ? , USER_ID = ? WHERE CONTACT_NO= ?";
pstmt = authConn.prepareStatement(sql);
String usrId = regstProcces.generateTranId("w_registration", userName.toUpperCase(), "", authConn);
usrId = usrId.toUpperCase();
pstmt.setString(1, password);
pstmt.setString(2, usrId);
pstmt.setString(3, contactNo);
System.out.println("pstmt OF OTP==>"+pstmt);
count = pstmt.executeUpdate();
System.out.println("count :"+count);
if (count != 0)
{
System.out.println("In if Of Update Password Using OTP");
authConn.commit();
e12RegistrationBean.setValid(true);
System.out.println("Update Password Successfully Using OTP");
}else
{
System.out.println("In Else Of Update Password Using OTP");
authConn.rollback();
e12RegistrationBean.setValid(false);
System.out.println("RollBack Update Password Using OTP");
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :E12LoginRegistration : updatePassord():" + d.getMessage());
}
}
return e12RegistrationBean;
}
/**
* This method is update Business Detail into database against email address
* @Author: Dhanendra
* */
@Override
public E12RegistrationBean updateBusinessDetail(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
System.out.println(" ******* In updateBusinessDetail ******** ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
int count =0;
String emailId = "";
String country = "";
String currency = "";
String typesOfOrg = "";
String displayName = "";
String legalName = "";
String lineOfBusiness = "";
String addr1 = "";
String addr2 = "";
String addr3 = "";
String mobileNum = "";
String contEmailId = "";
try
{
emailId = e12RegistrationBean.getEmailId();
typesOfOrg = e12RegistrationBean.getOrgType();
country = e12RegistrationBean.getCountryCode();
currency = e12RegistrationBean.getCurrCode();
displayName = e12RegistrationBean.getDisplayName();
legalName = e12RegistrationBean.getLegalName();
lineOfBusiness = e12RegistrationBean.getLineOfBusiness();
addr1 = e12RegistrationBean.getAddr1();
addr2 = e12RegistrationBean.getAddr2();
addr3 = e12RegistrationBean.getAddr3();
mobileNum = e12RegistrationBean.getContactNo();
contEmailId = e12RegistrationBean.getContactEmailId();
System.out.println("emailId :"+emailId);
System.out.println("country :"+country);
System.out.println("currency :"+currency);
System.out.println("typesOfOrg :"+typesOfOrg);
System.out.println("displayName :"+displayName);
System.out.println("legalName :"+legalName);
System.out.println("lineOfBusiness :"+lineOfBusiness);
System.out.println("addr1 :"+addr1);
System.out.println("addr2 :"+addr2);
System.out.println("addr3 :"+addr3);
System.out.println("mobileNum :"+mobileNum);
System.out.println("contEmailId :"+contEmailId);
conn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
sql = "UPDATE USER_REGISTRATION SET ORG_TYPE=? , COUNTRY_CODE = ?, CURR_CODE = ? , DISPLAY_NAME =? ,LEGAL_NAME =? ,LINE_OF_BUSINESS =? ,ADDR1 =? ,ADDR2 =? ,ADDR3 = ? ,CONTACT_NO = ? , CONTACT_EMAIL=? Where EMAIL_ID = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, typesOfOrg);
pstmt.setString(2, country);
pstmt.setString(3, currency);
pstmt.setString(4, displayName);
pstmt.setString(5, legalName);
pstmt.setString(6, lineOfBusiness);
pstmt.setString(7, addr1);
pstmt.setString(8, addr2);
pstmt.setString(9, addr3);
pstmt.setString(10, mobileNum);
pstmt.setString(11, contEmailId);
pstmt.setString(12, emailId);
count = pstmt.executeUpdate();
System.out.println("count :"+count);
if (count != 0)
{
conn.commit();
e12RegistrationBean.setValid(true);
System.out.println(" ******** Update Business Detail Successfully ********** ");
}else
{
conn.rollback();
e12RegistrationBean.setValid(false);
System.out.println(" ******** RollBack Update Business Detail ******** ");
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in : updateBusinessDetail : updateBusinessDetail():" + d.getMessage());
}
}
return e12RegistrationBean;
}
//Added by Samadhan on 28/04/17 to send organization detail form after setting password[Start]
@Override
public void sendOrganisationFormLink(String emailAddress, E12RegistrationBean e12RegistrationBean,String mailFormat) throws ITMException
{
ArrayList<String> mailInfo = null;
String uri = "";
ResultSet rs = null;
String sql = "";
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
JSONObject jsonObj = new JSONObject();
String to="",cc="",bcc="",sub="",body="";
EMail email = new EMail();
try
{
authConn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
String userSql = "SELECT SEND_TO,COPY_TO,BLIND_COPY,SUBJECT,BODY_TEXT FROM MAIL_FORMAT WHERE FORMAT_CODE = ? ";
pstmt = authConn.prepareStatement(userSql);
//pstmt.setString(1, "E12_REGST_USER");
pstmt.setString(1, mailFormat);
rs = pstmt.executeQuery();
if(rs.next())
{
to = rs.getString("SEND_TO");
cc = rs.getString("COPY_TO");
bcc = rs.getString("BLIND_COPY");
sub = rs.getString("SUBJECT");
body = rs.getString("BODY_TEXT");
}
pstmt.close();
rs.close();
sql = "SELECT * FROM USER_REGISTRATION WHERE EMAIL_ID = ? ";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, emailAddress);
rs = pstmt.executeQuery();
if(rs.next())
{
int total_rows = rs.getMetaData().getColumnCount();
for (int i = 0; i < total_rows; i++) {
jsonObj.put(rs.getMetaData().getColumnLabel(i+1)
.toLowerCase(), rs.getObject(i + 1));
}
}
System.out.println("jsonObj:"+jsonObj);
String mailXmlData = "<root>"
+ "<TO_ADD><![CDATA["+jsonObj.get(to)+"]]></TO_ADD>";
if(cc != null && cc.trim().length() > 0)
{
mailXmlData = mailXmlData + "<CC_ADD><![CDATA["+cc+"]]></CC_ADD>";
}
if(cc != null && cc.trim().length() > 0)
{
mailXmlData = mailXmlData + "<BCC_ADD><![CDATA["+bcc+"]]></BCC_ADD>";
}
mailXmlData = mailXmlData + "<SUBJECT><![CDATA["+sub+"]]></SUBJECT>"
+ "<MESSAGE><![CDATA["+getFormatedEmailBody(body,jsonObj)+"]]></MESSAGE>"
+ "<MESSAGE_TYPE><![CDATA[text/html]]></MESSAGE_TYPE>"
//email type teg remove..by PriyankaC on 24/10/2017..[START]
//+ "<EMAIL_TYPE><![CDATA[page]]></EMAIL_TYPE>"
//email type teg remove..by PriyankaC on 24/10/2017..[END]
+ "</root>";
System.out.println("Email type tag remove...");
System.out.println("sendOrganisationFormLink:mailXmlData:" + mailXmlData);
System.out.println(email.sendMail(mailXmlData, null));
pstmt.close();
rs.close();
}
catch(Exception e)
{
System.out.println("E12LoginRegistration.sendOrganisationFormLink()");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in : sendOrganisationFormLink : sendOrganisationFormLink():" + d.getMessage());
}
}
}
private String getFormatedEmailBody(String bodyTextData, JSONObject jsonObj ) throws ITMException
{
String startFindStr = "#:";
String endFindStr = ":#";
String colFullName = "";
String colName="";
String currColVal = "";
int currentIndex = 0;
int nextSearchIndex = 0;
try
{
if(bodyTextData != null)
{
while(bodyTextData.indexOf(startFindStr,nextSearchIndex) != -1)
{
System.out.println(nextSearchIndex);
currColVal = "";
currentIndex = bodyTextData.indexOf(startFindStr,nextSearchIndex);
String firstPart = bodyTextData.substring(0,currentIndex);
String lastPart = bodyTextData.substring(currentIndex,bodyTextData.length());
colFullName = lastPart.substring(0,lastPart.indexOf(endFindStr)+2);
System.out.println("colFullName:"+colFullName);
colName = colFullName.substring(startFindStr.length(),colFullName.lastIndexOf(endFindStr));
System.out.println("colName:"+colName);
currColVal = jsonObj.get(colName).toString();
bodyTextData = firstPart + lastPart.replaceFirst(colFullName, currColVal);
nextSearchIndex = currentIndex+currColVal.length();
System.out.println("bodyTextData:"+bodyTextData);
}
//Added by Chitranga Tandel ,request id S16HBAS020 on 21/07/2017 to convert url into local host start
bodyTextData = bodyTextData.replaceAll("#TOMCATE_HOME#",CommonConstants.TOMCAT_HOME);
System.out.println("Formatted bodyTextData"+bodyTextData);
//Added by Chitranga Tandel ,request id S16HBAS020 on 21/07/2017 to convert url into local host end
}
}catch(Exception e)
{
throw new ITMException(e);
}
return bodyTextData;
}
public E12RegistrationBean updateInvitedUsrPassord(E12RegistrationBean e12RegistrationBean) throws RemoteException, ITMException
{
System.out.println("in updateInvitedUsrPassord ");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
int count =0;
String emailId = "";
String password = "";
try
{
emailId = e12RegistrationBean.getEmailId();
password = e12RegistrationBean.getPassWdSha();
//conn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
authConn = connDriver.getConnectDB("Driver");
connDriver = null;
sql = "UPDATE USER_REGISTRATION SET PASS_WD_SHA= ? WHERE EMAIL_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, checkNull(password) );
pstmt.setString(2, checkNull(emailId) );
count = pstmt.executeUpdate();
System.out.println("count :"+count);
if (count != 0)
{
authConn.commit();
e12RegistrationBean.setValid(true);
System.out.println("Update Password Successfully");
}else
{
authConn.rollback();
e12RegistrationBean.setValid(false);
System.out.println("RollBack Update Password");
}
} catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (authConn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
authConn.close();
authConn = null;
}
authConn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("Exception in :E12LoginRegistration : updatePassord():" + d.getMessage());
}
}
return e12RegistrationBean;
}
//Added by Samadhan on 28/04/17 to send organization detail form after setting password[End]
//Added by Chitranga Tandel on 3 OCT 2018 to create new user , employee and user_site START
/*
public E12RegistrationBean CreateNewUser(E12RegistrationBean e12RegistrationBean)
{
System.out.println("***** In CreateNewUser Method ***** ");
String userName = "";
ResultSet rs = null;
String emailId = "";
String lastName = "";
String contactNo = "";
String empCode = "";
String passWdSha = "";
int count = 0;
boolean isError = false;
String userLvl = "0";
String profileId = "";
String user_id = "";
String site_code = "";
String trans_db ="";
String enterprise = "";
String chgTerm = "SYSTEM";
String sql = "";
String lob = "";
//String userLicType;
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pstmt =null;
try
{
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
String email_id = e12RegistrationBean.getEmailId();
conn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
connDriver = null;
sql = "Select * from user_registration where email_id= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, email_id);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
passWdSha = checkNull(rs.getString("PASS_WD_SHA")).trim();
user_id = checkNull(rs.getString("USER_ID")).trim();
site_code = checkNull(rs.getString("SITE_CODE")).trim();
empCode = user_id.toUpperCase();
contactNo = checkNull(rs.getString("CONTACT_NO")).trim();
lob = checkNull(rs.getString("LINE_OF_BUSINESS")).trim();
}
pstmt.close();
rs.close();
System.out.println("user_registration **Invited User*** site_code ***** :"+site_code + " *** LINE_OF_BUSINESS *** " + lob);
sql = "Select * from user_invite where code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, user_id);
rs = pstmt.executeQuery();
if (rs.next())
{
userLvl = checkNull(rs.getString("USR_LEV")).trim();
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
trans_db = checkNull(rs.getString("TRANS_DB")).trim();
enterprise = checkNull(rs.getString("ENTERPRISE")).trim();
}
pstmt.close();
rs.close();
System.out.println("***** userLvl ***** :"+userLvl);
System.out.println("***** profileId ***** :"+profileId);
System.out.println("***** site_code ***** :"+site_code);
System.out.println("***** trans_db ***** :"+trans_db);
System.out.println("***** enterprise ***** :"+enterprise);
sql = "Select * from users where code= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, user_id);
rs = pstmt.executeQuery();
if (rs.next())
{
emailId = checkNull(rs.getString("EMAIL_ID")).trim();
}
System.out.println("<---- emailId ---- >[" +emailId +"]");
pstmt.close();
rs.close();
if(emailId == "")
{
sql = "insert into employee (EMP_CODE, EMP_FNAME, EMP_MNAME, EMP_LNAME, CHG_DATE, CHG_USER, CHG_TERM, DATE_JOIN ,EMP_FNAME_LONG , EMP_MNAME_LONG , EMP_LNAME_LONG) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, empCode); //pending
pstmt.setString(2, userName);
pstmt.setString(3, "-");
pstmt.setString(4, lastName);
pstmt.setDate(5, currentDate);
pstmt.setString(6, empCode); //pending
pstmt.setString(7, empCode); //pending
pstmt.setDate(8, currentDate);
pstmt.setString(9, userName);
pstmt.setString(10, "-");
pstmt.setString(11, lastName);
count = pstmt.executeUpdate();
pstmt = null;
System.out.println("count :"+count);
//sql = "insert into users (CODE, NAME, PASS_WD, USR_LEV, EMP_CODE, CHG_DATE,CHG_USER,CHG_TERM,MOBILE_NO,NO_SESSION_ALLOW,PASS_WD_SHA,SITE_CODE__DEF,USER_THEME,PROFILE_ID,ENTITY_CODE,EMAIL_ID , USER_TYPE, PASSWD_FREQ, LOGIN_FIRST, GRACE_LOGIN_CNT, WRONG_LOGIN_CNT, TRANS_DB, ENTERPRISE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
sql = "UPDATE users SET NAME= ?, PASS_WD= ?, USR_LEV= ?, EMP_CODE= ?, CHG_DATE= ?,CHG_USER= ?,CHG_TERM= ?,MOBILE_NO= ?,NO_SESSION_ALLOW= ?,PASS_WD_SHA= ?,SITE_CODE__DEF= ?,USER_THEME= ?,PROFILE_ID= ?,ENTITY_CODE= ?,EMAIL_ID = ?, USER_TYPE= ?, PASSWD_FREQ= ?, LOGIN_FIRST= ?, GRACE_LOGIN_CNT= ?, WRONG_LOGIN_CNT= ?, TRANS_DB= ?, ENTERPRISE =? WHERE CODE=?";
System.out.println("*****Update users ***** :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userName);
pstmt.setString(2, empCode);
pstmt.setString(3, userLvl);
pstmt.setString(4, empCode);
pstmt.setDate(5, currentDate);
pstmt.setString(6, empCode);
pstmt.setString(7, empCode);
pstmt.setString(8, contactNo);
pstmt.setString(9, "9");
pstmt.setString(10, passWdSha);
pstmt.setString(11, site_code);
pstmt.setString(12, "galaxy");
pstmt.setString(13, profileId);
pstmt.setString(14, empCode);
pstmt.setString(15, email_id);
pstmt.setString(16, "E");
pstmt.setString(17, "60");
pstmt.setString(18, "0");
pstmt.setString(19, "5");
pstmt.setString(20, "0");
pstmt.setString(21, trans_db);
pstmt.setString(22, enterprise);
//pstmt.setString(23, userLicType);
pstmt.setString(23, empCode);
count = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("count Users :"+count);
}
else
{
System.out.println("in else :==>\n" + passWdSha);
String userSql = "UPDATE USERS SET PASS_WD_SHA = ? WHERE CODE = ?";
pstmt = conn.prepareStatement(userSql);
pstmt.setString(1, passWdSha);
pstmt.setString(2, empCode);
pstmt.executeQuery();
pstmt.close();
}
String userSql = "UPDATE USER_INVITE SET REGST_STAT = ? WHERE CODE = ?";
pstmt = conn.prepareStatement(userSql);
pstmt.setString(1, "R");
pstmt.setString(2, empCode);
pstmt.executeQuery();
pstmt.close();
if(lob.trim() == "SFA")
{
updatesForSalesPers(e12RegistrationBean);
}
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :RegistrationProcess CreateNewUser method: :==>\n" + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if( !isError )
{
System.out.println("commmit");
conn.commit();
}
else if ( isError )
{
System.out.println("rollback");
conn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
System.out.println("Exception :RegistrationProcess : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
conn.rollback();
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
return e12RegistrationBean;
}
*/
//Added by Chitranga Tandel on 3 OCT 2018 to create new user , employee and user_site END
//Added by Chitranga Tandel on 24 OCT 2018 to get xml for sales_pers START
private E12RegistrationBean updatesForSalesPers(E12RegistrationBean e12RegistrationBean)
{
String userName = "";
ResultSet rs = null;
String lastName = "";
String contactNo = "";
String empCode = "";
String passWdSha = "";
int count = 0;
String userLvl = "0";
String profileId = "";
String user_id = "";
String site_code = "";
String sql = "";
String addr1 = "";
String addr2 = "";
String addr3 = "";
String city = "";
String stateCode = "";
String tele1 = "";
String tele2 = "";
String tele3 = "";
String pin = "";
String inviteeEmailId = "";
String mobileNo = "";
String code="";
boolean isError = false;
Connection authConn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pstmt =null;
try
{
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
String email_id = e12RegistrationBean.getEmailId();
System.out.println("currentDate :"+currentDate);
System.out.println("email id :"+ email_id);
authConn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName()); //"Driver" for table user_registration and user_invite
connDriver = null;
E12EmpUsrSp e12EmpUsrSp = new E12EmpUsrSp();
sql = "Select * from user_registration where email_id= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, email_id);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
passWdSha = checkNull(rs.getString("PASS_WD_SHA")).trim();
user_id = checkNull(rs.getString("USER_ID")).trim();
site_code = checkNull(rs.getString("SITE_CODE")).trim();
empCode = user_id.toUpperCase();
contactNo = checkNull(rs.getString("CONTACT_NO")).trim();
addr1 = checkNull(rs.getString("ADDR1")).trim();
addr2 = checkNull(rs.getString("ADDR2")).trim();
addr3 = checkNull(rs.getString("ADDR3")).trim();
city = checkNull(rs.getString("CITY")).trim();//CITY
stateCode = checkNull(rs.getString("STATE_CODE")).trim(); //STATE_CODE
pin = checkNull(rs.getString("PIN")).trim();//pin
tele1 = checkNull(rs.getString("TELE1")).trim();
tele2 = checkNull(rs.getString("TELE2")).trim();
tele3 = checkNull(rs.getString("TELE3")).trim();
e12EmpUsrSp.setShort_name(userName);
e12EmpUsrSp.setEmp_fname(userName);
e12EmpUsrSp.setEmp_mname("-");
e12EmpUsrSp.setEmp_lname(lastName);
e12EmpUsrSp.setEmp_code( empCode);
e12EmpUsrSp.setCur_add1(addr1);
e12EmpUsrSp.setCur_add2(addr2);
e12EmpUsrSp.setCur_add3(addr3);
e12EmpUsrSp.setCur_city(city);
e12EmpUsrSp.setCur_state(stateCode);
e12EmpUsrSp.setCur_pin(pin);
e12EmpUsrSp.setCur_tel1(tele1);
e12EmpUsrSp.setCur_tel2(tele2);
e12EmpUsrSp.setCur_tel3(tele3);
e12EmpUsrSp.setBirth_date("");
e12EmpUsrSp.setStan_code__hq("");
e12EmpUsrSp.setHol_tblno("");
e12EmpUsrSp.setName_prefix("");
e12EmpUsrSp.setSex("");
e12EmpUsrSp.setEmp_type("");
e12EmpUsrSp.setDesign_code("MR");
e12EmpUsrSp.setDesignation("EX SCIENTIFIC INFORMATION");
e12EmpUsrSp.setDept_code("SLS");
e12EmpUsrSp.setGrade("6");
e12EmpUsrSp.setCadre("EX");
e12EmpUsrSp.setReport_to("Vac1");
}
pstmt.close();
rs.close();
System.out.println("user_registration ***** site_code ***** :"+site_code);
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, user_id);
rs = pstmt.executeQuery();
if (rs.next())
{
userLvl = checkNull(rs.getString("USR_LEV")).trim();
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
inviteeEmailId = checkNull(rs.getString("EMAIL_ID")).trim();
code = checkNull(rs.getString("CODE")).trim();
e12EmpUsrSp.setMobile_no(mobileNo);
e12EmpUsrSp.setEmp_site(site_code);
e12EmpUsrSp.setEmail_id_off(inviteeEmailId);
e12EmpUsrSp.setEmail_id_per(inviteeEmailId);
e12EmpUsrSp.setSales_pers(empCode);
e12EmpUsrSp.setItem_ser(profileId);
e12EmpUsrSp.setUser_code(code);
e12EmpUsrSp.setProfile_id(profileId);
e12EmpUsrSp.setProfile_id__disp(profileId);
e12EmpUsrSp.setProfile_id__res(profileId);
e12EmpUsrSp.setDate_join(new Date().toString());
e12EmpUsrSp.setSp_type("P");
e12EmpUsrSp.setLock_status("N");
e12EmpUsrSp.setActive("Y");
e12EmpUsrSp.setAuto_conf("N");
e12EmpUsrSp.setUser_type("P");
e12EmpUsrSp.setUsr_lev("2");
e12EmpUsrSp.setDelay_prd("");
e12EmpUsrSp.setPasswd_freq("999");
e12EmpUsrSp.setLast_pwd_chgdate("");
e12EmpUsrSp.setAscertain_attendance("N");
e12EmpUsrSp.setAcct_lock("N");
e12EmpUsrSp.setLogin_first("0");
e12EmpUsrSp.setWrong_login_cnt("3");
}
pstmt.close();
rs.close();
String xmlString = e12EmpUsrSp.toXml();
System.out.println("xmlString :: \n" + xmlString);
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :e12loginRegistration : :==>\n" + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch (Exception e)
{
System.out.println("Exception :e12loginRegistration : :==>\n" + e.getMessage());
}
}
return e12RegistrationBean;
}
//Added by Chitranga Tandel on 24 OCT 2018 to get xml for sales_pers END
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str.trim() ;
}
}
//Invited User Password and Other fields updation
public E12RegistrationBean CreateNewUser(E12RegistrationBean e12RegistrationBean)
{
System.out.println("***** In CreateNewUser Method ***** ");
String userName = "";
ResultSet rs = null;
String emailId = "";
String lastName = "";
String contactNo = "";
String invitedUserId_U = "";
String empCode = "";
String passWdSha = "";
int count = 0;
boolean isError = false;
String userLvl = "0";
String profileId = "";
String invitedUserId = "";
String inviteeUserId = "";
String site_code = "";
String trans_db ="";
String enterprise = "";
String chgTerm = "SYSTEM";
String sql = "";
String lob = "";
String userLicType = "E";
String acc_lock = "";
String ascertion_attentdence = "";
String pass_freq = "";
String wrong_login_cnt ="";
String userType = "";
String entityCode = "";
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
Connection usrConn = null;
PreparedStatement pstmt =null;
boolean createNewEntity = false;
try
{
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
String invitedEmailId = e12RegistrationBean.getEmailId();
System.out.println("email_id ==>" +invitedEmailId + " transDB " +e12RegistrationBean.getDataSourceName());
//conn = connDriver.getConnectDB(e12RegistrationBean.getDataSourceName());
authConn = connDriver.getConnectDB("Driver");
String transDB = e12RegistrationBean.getDataSourceName();
System.out.println("transDB ==>" +transDB );
usrConn = connDriver.getConnectDB(transDB);
//conn = connDriver.getConnectDB("Driver");
connDriver = null;
sql = "Select * from user_registration where email_id= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, invitedEmailId);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
passWdSha = checkNull(rs.getString("PASS_WD_SHA")).trim();
invitedUserId = checkNull(rs.getString("USER_ID")).trim();
invitedUserId_U = invitedUserId.toUpperCase();
empCode = invitedUserId_U;
contactNo = checkNull(rs.getString("CONTACT_NO")).trim();
lob = checkNull(rs.getString("LINE_OF_BUSINESS")).trim();
}
System.out.println("empCode ==>" +empCode);
pstmt.close();
rs.close();
System.out.println("user_registration **Invited User*** site_code ***** :"+site_code + " *** LINE_OF_BUSINESS *** " + lob);
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, invitedUserId);
rs = pstmt.executeQuery();
if (rs.next())
{
userLvl = checkNull(rs.getString("USR_LEV")).trim();
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
trans_db = checkNull(rs.getString("TRANS_DB")).trim();
enterprise = checkNull(rs.getString("ENTERPRISE")).trim();
acc_lock = checkNull(rs.getString("ACCT_LOCK")).trim();
ascertion_attentdence = checkNull(rs.getString("ASCERTAIN_ATTENDANCE")).trim();
pass_freq = checkNull(rs.getString("PASSWD_FREQ")).trim();
wrong_login_cnt = checkNull(rs.getString("WRONG_LOGIN_CNT")).trim();
inviteeUserId = checkNull(rs.getString("CHG_USER")).trim();
userType = checkNull(rs.getString("USER_TYPE")).trim();
entityCode = checkNull(rs.getString("ENTITY_CODE")).trim();
}
pstmt.close();
rs.close();
System.out.println("***** userLvl ***** :"+userLvl);
System.out.println("***** profileId ***** :"+profileId);
System.out.println("***** site_code ***** :"+site_code);
System.out.println("***** trans_db ***** :"+trans_db);
System.out.println("***** enterprise ***** :"+enterprise);
System.out.println("***** userType ***** :"+userType);
System.out.println("<---- emailId ---- >[" +emailId +"]");
System.out.println("***** acc_lock ***** :"+acc_lock);
System.out.println("***** ascertion_attentdence ***** :"+ascertion_attentdence);
System.out.println("***** pass_freq ***** :"+pass_freq);
System.out.println("***** wrong_login_cnt ***** :"+wrong_login_cnt);
//sql = "insert into users (CODE, NAME, PASS_WD, USR_LEV, EMP_CODE, CHG_DATE,CHG_USER,CHG_TERM,MOBILE_NO,NO_SESSION_ALLOW,PASS_WD_SHA,SITE_CODE__DEF,USER_THEME,PROFILE_ID,ENTITY_CODE,EMAIL_ID , USER_TYPE, PASSWD_FREQ, LOGIN_FIRST, GRACE_LOGIN_CNT, WRONG_LOGIN_CNT, TRANS_DB, ENTERPRISE) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
sql = "UPDATE users SET NAME= ?, PASS_WD= ?, USR_LEV= ?, EMP_CODE= ?, CHG_DATE= ?,CHG_USER= ?,CHG_TERM= ?,MOBILE_NO= ?,NO_SESSION_ALLOW= ?,PASS_WD_SHA= ?,SITE_CODE__DEF= ?,USER_THEME= ?,PROFILE_ID= ?,ENTITY_CODE= ?,EMAIL_ID = ?, USER_TYPE= ?, PASSWD_FREQ= ?, LOGIN_FIRST= ?, GRACE_LOGIN_CNT= ?, WRONG_LOGIN_CNT= ?, TRANS_DB= ?, ENTERPRISE =? , USER_LIC_TYPE=? ,ASCERTAIN_ATTENDANCE=? ,ACCT_LOCK=? WHERE CODE=?";
System.out.println("*****Update users ***** :"+sql);
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, userName);
pstmt.setString(2, invitedUserId_U);
pstmt.setString(3, userLvl);
//pstmt.setString(4, invitedUserId_U);
pstmt.setDate(5, currentDate);
pstmt.setString(6, inviteeUserId);
pstmt.setString(7, "SYSTEM");
pstmt.setString(8, contactNo);
pstmt.setString(9, "9");
pstmt.setString(10, passWdSha);
pstmt.setString(11, site_code);
pstmt.setString(12, "galaxy");
pstmt.setString(13, profileId);
System.out.println("entityCode --> ["+ entityCode + "]");
//Added by Prajyot on 30-NOV-19 [Setting Default Employee Code for usertype other than 'E' ] Starts
String _emp_code = "E999999";
if( "E".equals(userType))
{
_emp_code = ( "1".equals(entityCode.trim()) ) ? invitedUserId_U : entityCode;
}
else
{
System.out.println("Setting default Employee code for User Type["+userType+"]");
}
System.out.println("_emp_code --> ["+ _emp_code + "]");
pstmt.setString(4, _emp_code);
// Updated By Saitej D [On 16 APR 2019] [To set EMP_CODE & ENTITY_CODE as new generated USER_ID.]
if( "1".equals(entityCode.trim()))
{
//pstmt.setString(4, invitedUserId_U);
pstmt.setString(14, invitedUserId_U);
createNewEntity = true;
}
else
{
//pstmt.setString(4, entityCode);
pstmt.setString(14, entityCode);
}
//Added by Prajyot on 30-NOV-19 [Setting Default Employee Code for usertype other than 'E'] End
pstmt.setString(15, invitedEmailId);
pstmt.setString(16, userType);
pstmt.setString(17, pass_freq);
pstmt.setString(18, "0");
pstmt.setString(19, "5");
pstmt.setString(20, wrong_login_cnt);
pstmt.setString(21, trans_db);
pstmt.setString(22, enterprise);
pstmt.setString(23, userLicType);
pstmt.setString(24, ascertion_attentdence);
pstmt.setString(25,acc_lock );
pstmt.setString(26, invitedUserId_U);
count = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("count Users :"+count);
//Commented by Prajyot on 24-OCT-19 [PASS_WD_SHA is getting updated in above SQL]
/*
System.out.println("in else :==>\n" + passWdSha);
String userSql = "UPDATE USERS SET PASS_WD_SHA = ? WHERE CODE = ?";
pstmt = authConn.prepareStatement(userSql);
pstmt.setString(1, passWdSha);
pstmt.setString(2, invitedUserId_U);
pstmt.executeQuery();
pstmt.close();
*/
System.out.println("createNewEntity updating in user_invite table and transDB 070119:==>\n" + createNewEntity +" empCode "+ empCode + "userType ["+ userType +"] userType.trim() [" +userType.trim() + "]" + "transDB" + transDB);
if( createNewEntity )
{
switch( userType.trim())
{
case "E" : //Employee
createEmployee(empCode, usrConn);
System.out.println("createNewEntity call :==> createEmployee");
break;
case "P" : // Sales Person & Employee
System.out.println("createNewEntity call :==> createEmployee createSalesPers");
createEmployee(empCode, usrConn);
createSalesPers(empCode , usrConn);
break;
case "S" : //Supplier
createSupplier(empCode, usrConn);
System.out.println("createNewEntity call :==> Supplier");
break;
case "C" : //Customer
System.out.println("createNewEntity call :==> Customer");
createCustomer(empCode , usrConn);
break;
}
}
//Changes by Prajyot R. on 30NOV19 [ Entity Code Update not required ]
//Update User Registration Status in User Invite table
//String userSql = "UPDATE USER_INVITE SET REGST_STAT = ? , ENTITY_CODE = ? WHERE CODE = ?";
String userSql = "UPDATE USER_INVITE SET REGST_STAT = ? WHERE CODE = ?";
pstmt = authConn.prepareStatement(userSql);
pstmt.setString(1, "R");
pstmt.setString(2, invitedUserId_U);
//pstmt.setString(3, invitedUserId_U);
pstmt.executeQuery();
pstmt.close();
// if(lob.trim() == "SFA")
// {
// updatesForSalesPers(e12RegistrationBean);
// }
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration CreateNewUser method: :==>\n" + e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if( !isError )
{
System.out.println("Auth Connection Commmited inside CreateNewUser!");
authConn.commit();
//createUserOnTransDb(invitedUserId_U , usrConn);
createUserOnTransDb(invitedUserId_U, trans_db, usrConn);
System.out.println("User Connection Commmited inside CreateNewUser!");
usrConn.commit();
}
else if ( isError )
{
System.out.println("Auth Connection Rollback inside CreateNewUser!");
authConn.rollback();
System.out.println("User Connection Rollback inside CreateNewUser!");
usrConn.rollback();
e12RegistrationBean.setValid(false);
pstmt = null;
rs = null;
String userSql = "UPDATE USER_INVITE SET REGST_STAT = ? WHERE CODE = ?";
pstmt = authConn.prepareStatement(userSql);
pstmt.setString(1, "P");
pstmt.setString(2, invitedUserId_U);
System.out.println("Auth after connection");
//pstmt.setString(3, invitedUserId_U);
pstmt.executeQuery();
authConn.commit();
pstmt.close();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
if(usrConn != null)
usrConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
return e12RegistrationBean;
}
public void createEmployee(String empCode , Connection usrConn) throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
// Connection usrConn = null;
PreparedStatement pstmt =null;
ResultSet rs = null;
int count = 0;
boolean isError = false;
String userName = "";
String lastName = "";
String addr1 = "";
String addr2 = "";
String addr3 = "";
String city = "";
String stateCode = "";
String tele1 = "";
String tele2 = "";
String tele3 = "";
String pin = "";
String chngUser= "";
String mobileNo = "";
String inviteeEmailId = "";
String accParam = "";
String grade = "";
String dept = "";
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[START]
String ediAddr = "";
String reportTo = "";
String stanCodeHq = "";
String designCode = "";
String designation = "";
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[END]
try
{
//System.out.println("trandb in createEmployee" + transDB );
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
authConn = connDriver.getConnectDB("Driver");
// usrConn = connDriver.getConnectDB(transDB);
String sql = "Select * from user_registration where USER_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
addr1 = checkNull(rs.getString("ADDR1")).trim();
addr2 = checkNull(rs.getString("ADDR2")).trim();
addr3 = checkNull(rs.getString("ADDR3")).trim();
city = checkNull(rs.getString("CITY")).trim();//CITY
stateCode = checkNull(rs.getString("STATE_CODE")).trim(); //STATE_CODE
pin = checkNull(rs.getString("PIN")).trim();//pin
tele1 = checkNull(rs.getString("TELE1")).trim();
tele2 = checkNull(rs.getString("TELE2")).trim();
tele3 = checkNull(rs.getString("TELE3")).trim();
}
System.out.println("empCode ==>" +empCode);
pstmt.close();
rs.close();
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
chngUser = checkNull(rs.getString("CHG_USER")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
inviteeEmailId = checkNull(rs.getString("EMAIL_ID")).trim();
accParam = checkNull(rs.getString("ACC_PARM1")).trim();
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[START]
ediAddr = checkNull(rs.getString("EDI_ADDR")).trim();
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[END]
}
pstmt.close();
rs.close();
if(accParam != null && !accParam.isEmpty())
{
String [] getDeptGrade = accParam.split("\\$");
dept = getDeptGrade[0];
grade = getDeptGrade[1];
dept = dept.substring(dept.lastIndexOf(":") + 1);
grade = grade.substring(grade.lastIndexOf(":") + 1);
}
System.out.println("dept ==>" +dept);
System.out.println("grade ==>" +grade);
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[START]
if(ediAddr != null && !ediAddr.isEmpty())
{
String [] reportToDesCodeHq = ediAddr.split("\\$");
designCode = reportToDesCodeHq[0];
reportTo = reportToDesCodeHq[1];
stanCodeHq = reportToDesCodeHq[2];
designCode = designCode.substring(designCode.lastIndexOf(":") + 1);
reportTo = reportTo.substring(reportTo.lastIndexOf(":") + 1);
stanCodeHq = stanCodeHq.substring(stanCodeHq.lastIndexOf(":") + 1);
}
System.out.println("designCode ==>" +designCode);
System.out.println("reportTo ==>" +reportTo);
System.out.println("stanCodeHq ==>" +stanCodeHq);
if(designCode != null && designCode.trim().length() > 0)
{
designCode = designCode.trim();
sql = "SELECT DESIGNATION FROM DESIGNATION WHERE DESIGN_CODE = ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1,designCode);
rs = pstmt.executeQuery();
if(rs.next())
{
designation = checkNull(rs.getString("DESIGNATION")).trim();
}
pstmt.close();
rs.close();
}
System.out.println("designation ==>" +designation);
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[END]
sql = "insert into employee (EMP_CODE, EMP_FNAME, EMP_MNAME, EMP_LNAME, CHG_DATE, CHG_USER, CHG_TERM, DATE_JOIN ,EMP_FNAME_LONG , EMP_MNAME_LONG , EMP_LNAME_LONG ,CUR_ADD1, CUR_ADD2, CUR_ADD3 ,CUR_CITY, CUR_STATE, CUR_PIN, CUR_TEL1, CUR_TEL2, CUR_TEL3 ,EMAIL_ID_OFF , MOBILE_NO ,DEPT_CODE ,GRADE, REPORT_TO, DESIGN_CODE, STAN_CODE__HQ, DESIGNATION ) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ";
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24
pstmt = usrConn.prepareStatement(sql);
pstmt.setString(1, empCode);
pstmt.setString(2, userName);
pstmt.setString(3, "-");
pstmt.setString(4, lastName);
pstmt.setDate(5, currentDate);
pstmt.setString(6, chngUser);
pstmt.setString(7, "SYSTEM");
pstmt.setDate(8, currentDate);
pstmt.setString(9, userName);
pstmt.setString(10, "-");
pstmt.setString(11, lastName);
pstmt.setString(12, addr1);//CUR_ADD1
pstmt.setString(13, addr2);//CUR_ADD2
pstmt.setString(14, addr3);//CUR_ADD3
pstmt.setString(15, city);//CUR_CITY
pstmt.setString(16, stateCode);// CUR_STATE
pstmt.setString(17, pin); // CUR_PIN
pstmt.setString(18, tele1); // CUR_TEL1
pstmt.setString(19, tele2);//CUR_TEL2,
pstmt.setString(20, tele3);// CUR_TEL3
pstmt.setString(21, inviteeEmailId);//CUR_TEL2,
pstmt.setString(22, mobileNo);// CUR_TEL3
pstmt.setString(23, dept);//CUR_TEL2,
pstmt.setString(24, grade);// CUR_TEL3
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[START]
pstmt.setString(25, reportTo);//REPORT_TO
pstmt.setString(26, designCode);//DESIGN_CODE
pstmt.setString(27, stanCodeHq);//STAN_CODE__HQ
pstmt.setString(28, designation);//DESIGNATION
//Changes added to get values for designation,reportTo,headquarter on 27-MAR-24[END]
pstmt.executeQuery();
pstmt.close();
// authConn.commit();
System.out.println("count Users exceuted656565:"+count);
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration createEmployee method: :==>\n" + e.getMessage());
e.printStackTrace();
throw new Exception(e);
}
finally
{
try
{
if( !isError )
{
System.out.println("commmit");
authConn.commit();
//usrConn.commit();
}
else if ( isError )
{
System.out.println("rollback");
authConn.rollback();
//usrConn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
}
public void createSalesPers(String empCode ,Connection usrConn) throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
// Connection usrConn = null;
PreparedStatement pstmt =null;
ResultSet rs = null;
int count = 0;
boolean isError = false;
String userName = "";
String lastName = "";
String profileId = "";
String chngUser = "";
String site_code = "";
String mobileNo = "";
String inviteeEmailId = "";
String accParam = "";
String itmSer="";
String shortName = "";
String transDB = "";
try
{
System.out.println("trandb in createSalesPers" + transDB );
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
authConn = connDriver.getConnectDB("Driver");
// usrConn = connDriver.getConnectDB(transDB);
String sql = "Select * from user_registration where USER_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
}
if (userName.length() > 20)
{
shortName = userName.substring(0,20);
}
System.out.println("empCode ==>" +empCode);
pstmt.close();
rs.close();
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
chngUser = checkNull(rs.getString("CHG_USER")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
inviteeEmailId = checkNull(rs.getString("EMAIL_ID")).trim();
accParam = checkNull(rs.getString("ACC_PARM1")).trim();
}
pstmt.close();
rs.close();
if(accParam != null && !accParam.isEmpty())
{
String [] getItmSer = accParam.split("\\$");
itmSer = getItmSer[2];
itmSer = itmSer.substring(itmSer.lastIndexOf(":") + 1);
}
System.out.println("itmSer ==>" +itmSer);
sql = "INSERT INTO SALES_PERS(SALES_PERS ,SP_TYPE ,ITEM_SER ,LOCK_STATUS,ACTIVE ,AUTO_CONF,CHG_DATE,CHG_USER,CHG_TERM,EMP_CODE,SP_NAME,SH_NAME , SITE_CODE__PAY , MOBILE_NO_TAX_REG, EMAIL_ID_TAX_REG, ACCT_CODE__AP , CCTR_CODE__AP , ADD_DATE, ADD_USER , ADD_TERM ) VALUES(?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = usrConn.prepareStatement(sql);
pstmt.setString(1, empCode); //SALES_PERS
pstmt.setString(2, "C"); //SP_TYPE
pstmt.setString(3, itmSer); //,ITEM_SER - profileId-USER-INVITE
pstmt.setString(4, "N"); //,LOCK_STATUS,
pstmt.setString(5, "Y");//ACTIVE
pstmt.setString(6, "N"); //,AUTO_CONF,
pstmt.setDate(7,currentDate ); //CHG_DATE,
pstmt.setString(8, chngUser);//CHG_USER,
pstmt.setString(9, "SYSTEM");//CHG_TERM,
pstmt.setString(10, empCode);//EMP_CODE
pstmt.setString(11, userName); //SP_NAME,
pstmt.setString(12,shortName);//SH_NAME
pstmt.setString(13,site_code);//SITE_CODE__PAY
pstmt.setString(14,mobileNo);//MOBILE_NO_TAX_REG
pstmt.setString(15,inviteeEmailId);//EMAIL_ID_TAX_REG
pstmt.setString(16,"10200003");//ACCT_CODE__AP
pstmt.setString(17,"0000");//CCTR_CODE__AP
pstmt.setDate(18,currentDate);//ADD_DATE
pstmt.setString(19,chngUser);//ADD_USER
pstmt.setString(20,"SYSTEM");//ADD_TERM
pstmt.executeQuery();
pstmt.close();
// authConn.commit();
System.out.println("count Users :"+count);
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration createSalesPers method: :==>\n" + e.getMessage());
e.printStackTrace();
throw new Exception(e);
}
finally
{
try
{
if( !isError )
{
System.out.println("commmit");
authConn.commit();
//usrConn.commit();
}
else if ( isError )
{
System.out.println("rollback");
authConn.rollback();
//usrConn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
}
public void createSupplier(String empCode , Connection usrConn) throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
// Connection usrConn = null;
PreparedStatement pstmt =null;
ResultSet rs = null;
int count = 0;
boolean isError = false;
String userName = "";
String lastName = "";
String profileId = "";
String chngUser = "";
String site_code = "";
String mobileNo = "";
String inviteeEmailId = "";
String addr1 = "";
String addr2 = "";
String addr3 = "";
String city = "";
String stateCode = "";
String tele1 = "";
String tele2 = "";
String tele3 = "";
String pin = "";
try
{
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
authConn = connDriver.getConnectDB("Driver");
// usrConn = connDriver.getConnectDB(transDB);
String sql = "Select * from user_registration where USER_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
addr1 = checkNull(rs.getString("ADDR1")).trim();
addr2 = checkNull(rs.getString("ADDR2")).trim();
addr3 = checkNull(rs.getString("ADDR3")).trim();
city = checkNull(rs.getString("CITY")).trim();//CITY
stateCode = checkNull(rs.getString("STATE_CODE")).trim(); //STATE_CODE
pin = checkNull(rs.getString("PIN")).trim();//pin
tele1 = checkNull(rs.getString("TELE1")).trim();
tele2 = checkNull(rs.getString("TELE2")).trim();
tele3 = checkNull(rs.getString("TELE3")).trim();
}
System.out.println("empCode ==>" +empCode);
pstmt.close();
rs.close();
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
chngUser = checkNull(rs.getString("CHG_USER")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
inviteeEmailId = checkNull(rs.getString("EMAIL_ID")).trim();
}
pstmt.close();
rs.close();
sql = "INSERT INTO SUPPLIER(SUPP_CODE, SUPP_TYPE, SH_NAME, TELE1, TELE2, TELE3, CHG_DATE ,CHG_USER ,CHG_TERM ,ADD_TERM ,ADD_USER, ADD_DATE, SITE_CODE, FULL_NAME, MOBILE_NO_TAX_REG, EMAIL_ID_TAX_REG, GROUP_CODE, CR_TERM , SUPP_NAME ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?)";
pstmt = usrConn.prepareStatement(sql);
pstmt.setString(1, empCode); //SUPP_CODE
pstmt.setString(2, "S" ); //SUPP_TYPE//pending
pstmt.setString(3,userName);// SH_NAME
pstmt.setString(4,tele1);// TELE1
pstmt.setString(5,tele2);// TELE2
pstmt.setString(6,tele3);//TELE3
pstmt.setDate(7,currentDate);//CHG_DATE
pstmt.setString(8,chngUser);//,CHG_USER ,
pstmt.setString(9,"SYSTEM");//CHG_TERM
pstmt.setString(10,"SYSTEM");// ADD_TERM
pstmt.setString(11, chngUser);//,ADD_USER,
pstmt.setDate(12,currentDate);// ADD_DATE,
pstmt.setString(13, site_code ); // SITE_CODE,
pstmt.setString(14, userName +" "+ lastName ); // FULL_NAME,
pstmt.setString(15, mobileNo); // MOBILE_NO_TAX_REG,
pstmt.setString(16, inviteeEmailId);// EMAIL_ID_TAX_RE,
pstmt.setString(17, "DUMMY"); // GROUP_CODE
pstmt.setString(18, "CR007");// CR_TERM
pstmt.setString(19, userName);// CR_TERM
pstmt.executeQuery();
pstmt.close();
// authConn.close();
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration createSupplier method: :==>\n" + e.getMessage());
e.printStackTrace();
throw new Exception(e);
}
finally
{
try
{
if( !isError )
{
System.out.println("commmit");
authConn.commit();
// usrConn.commit();
}
else if ( isError )
{
System.out.println("rollback");
authConn.rollback();
// usrConn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
}
//completed
public void createCustomer(String empCode , Connection usrConn) throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
// Connection usrConn = null;
PreparedStatement pstmt =null;
ResultSet rs = null;
int count = 0;
boolean isError = false;
String userName = "";
String lastName = "";
String profileId = "";
String chngUser = "";
String site_code = "";
String mobileNo = "";
String inviteeEmailId = "";
String addr1 = "";
String addr2 = "";
String addr3 = "";
String city = "";
String stateCode = "";
String tele1 = "";
String tele2 = "";
String tele3 = "";
String pin = "";
String transDB = "";
try
{
System.out.println("trandb in createCustomer" + transDB );
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
authConn = connDriver.getConnectDB("Driver");
// usrConn = connDriver.getConnectDB(transDB);
String sql = "Select * from user_registration where USER_ID= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("USER_NAME")).trim();
lastName = checkNull(rs.getString("LAST_NAME")).trim();
addr1 = checkNull(rs.getString("ADDR1")).trim();
addr2 = checkNull(rs.getString("ADDR2")).trim();
addr3 = checkNull(rs.getString("ADDR3")).trim();
city = checkNull(rs.getString("CITY")).trim();//CITY
stateCode = checkNull(rs.getString("STATE_CODE")).trim(); //STATE_CODE
pin = checkNull(rs.getString("PIN")).trim();//pin
tele1 = checkNull(rs.getString("TELE1")).trim();
tele2 = checkNull(rs.getString("TELE2")).trim();
tele3 = checkNull(rs.getString("TELE3")).trim();
}
System.out.println("empCode ==>" +empCode);
pstmt.close();
rs.close();
sql = "Select * from user_invite where code= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, empCode);
rs = pstmt.executeQuery();
if (rs.next())
{
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
chngUser = checkNull(rs.getString("CHG_USER")).trim();
site_code = checkNull(rs.getString("SITE_CODE__DEF")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
inviteeEmailId = checkNull(rs.getString("EMAIL_ID")).trim();
}
pstmt.close();
rs.close();
sql = "INSERT INTO CUSTOMER(CUST_CODE, CUST_TYPE, CUST_NAME, SH_NAME, TELE1, TELE2, TELE3, SALES_PERS, CONTACT_CODE, CHG_DATE, CHG_USER , CHG_TERM , ADD_DATE, ADD_USER , ADD_TERM, GROUP_CODE , STAN_CODE , CUST_CODE__BIL , CREDIT_LMT , ROUND , ROUND_TO , CURR_CODE__FRT ,CURR_CODE__INS) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?)";
pstmt = usrConn.prepareStatement(sql);
pstmt.setString(1, empCode); //CUST_CODE,
pstmt.setString(2, "C" ); // CUST_TYPE, //pending
pstmt.setString(3, userName); //CUST_NAME
pstmt.setString(4, userName); // SH_NAME
pstmt.setString(5,tele1);// TELE1
pstmt.setString(6,tele2);//TELE2
pstmt.setString(7,tele3);// TELE3
pstmt.setString(8,"DUMMY");//SALES_PERS
pstmt.setString(9,"DUMMY");//CONTACT_CODE
pstmt.setDate(10,currentDate);//CHG_DATE
pstmt.setString(11,chngUser);// CHG_USER
pstmt.setString(12,"SYSTEM");//CHG_TERM
pstmt.setDate(13,currentDate);//ADD_DATE
pstmt.setString(14,chngUser);// ADD_USER
pstmt.setString(15,"SYSTEM");// ADD_TERM
pstmt.setString(16,"ABC");// GROUP_CODE
pstmt.setString(17,"DUMMY");// STAN_CODE
pstmt.setString(18,empCode);// CUST_CODE__BIL
pstmt.setString(19,"50");// CREDIT_LMT
pstmt.setString(20,"N");// ROUND
pstmt.setString(21,"0");// ROUND_TO
pstmt.setString(22,"INR");// CURR_CODE__FRT
pstmt.setString(23,"INR");// CURR_CODE__INS
pstmt.executeQuery();
pstmt.close();
//authConn.close();
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration createCustomer method: :==>\n" + e.getMessage());
e.printStackTrace();
throw new Exception( e );
}
finally
{
try
{
if( !isError )
{
System.out.println("commmit");
authConn.commit();
//usrConn.commit();
}
else if ( isError )
{
System.out.println("rollback");
authConn.rollback();
// usrConn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
}
//Changes by Prajyot on 30-NOV-19 [Check for AuthConn and UserConn are same or not] Starts
//public void createUserOnTransDb(String userCode , Connection usrConn) throws Exception
public void createUserOnTransDb(String userCode , String trans_db, Connection usrConn) throws Exception
{
ConnDriver connDriver = new ConnDriver();
Connection authConn = null;
// Connection usrConn = null;
PreparedStatement pstmt =null;
ResultSet rs = null;
int count = 0;
boolean isError = false;
String userName = "";
String passWd = "";
String entityCode = "";
String profileId = "";
String site_code = "";
String userTheme = "";
String siteCodeDef = "";
String passHha = "";
String noSeesionAllow = "";
String mobileNo = "";
String chgTerm = "";
String chgUser = "";
//Date chgDate = "";
String empCode = "";
String usrLevel = "";
String enterprise = "";
String wronLoginCnt = "";
String graceCount = "";
String loginFirst = "";
String passFreq = "";
String userType = "";
String emailId = "";
String userLicType = "";
String ascertionAttendenec = "";
String acctLock = "";
String transDB = "";
String activationCode = "";
String status = "";
try
{
ConnParams autvisParams = CommonConstants.connParamsMap.get("Driver");
ConnParams usrvisParams = CommonConstants.connParamsMap.get(trans_db);
if( autvisParams != null && autvisParams.getDataSourceName() != null && usrvisParams != null)
{
if( autvisParams.getDataSourceName().equalsIgnoreCase(usrvisParams.getDataSourceName()))
{
System.out.println("While creating user on TransDB - " + trans_db +
" - Authentication schema : [" + autvisParams.getDataSourceName() + "]" +
" and Users schema : [" + autvisParams.getDataSourceName() + "] both are same." ) ;
return ;
}
}
System.out.println("trandb in createUser" + transDB + "------- CODE ----" +userCode);
java.sql.Date currentDate = new java.sql.Date(new java.util.Date().getTime());
authConn = connDriver.getConnectDB("Driver");
// usrConn = connDriver.getConnectDB(transDB);
String sql = "Select * from USERS where CODE= ?";
pstmt = authConn.prepareStatement(sql);
pstmt.setString(1, userCode);
rs = pstmt.executeQuery();
if (rs.next())
{
userName = checkNull(rs.getString("NAME")).trim();
passWd = checkNull(rs.getString("PASS_WD")).trim();
usrLevel = checkNull(rs.getString("USR_LEV")).trim();
empCode = checkNull(rs.getString("EMP_CODE")).trim();
// chgDate = rs.getDate("CHG_DATE");
chgUser = checkNull(rs.getString("CHG_USER")).trim();
chgTerm = checkNull(rs.getString("CHG_TERM")).trim();
mobileNo = checkNull(rs.getString("MOBILE_NO")).trim();
noSeesionAllow = checkNull(rs.getString("NO_SESSION_ALLOW")).trim();
passHha = checkNull(rs.getString("PASS_WD_SHA")).trim();
siteCodeDef = checkNull(rs.getString("SITE_CODE__DEF")).trim();
userTheme = checkNull(rs.getString("USER_THEME")).trim();
profileId = checkNull(rs.getString("PROFILE_ID")).trim();
entityCode = checkNull(rs.getString("ENTITY_CODE")).trim();
emailId = checkNull(rs.getString("EMAIL_ID")).trim();
userType = checkNull(rs.getString("USER_TYPE")).trim();
passFreq = checkNull(rs.getString("PASSWD_FREQ")).trim();
loginFirst = checkNull(rs.getString("LOGIN_FIRST")).trim();
graceCount = checkNull(rs.getString("GRACE_LOGIN_CNT")).trim();
wronLoginCnt = checkNull(rs.getString("WRONG_LOGIN_CNT")).trim();
transDB = checkNull(rs.getString("TRANS_DB")).trim();
enterprise = checkNull(rs.getString("ENTERPRISE")).trim();
userLicType = checkNull(rs.getString("USER_LIC_TYPE")).trim();
ascertionAttendenec = checkNull(rs.getString("ASCERTAIN_ATTENDANCE")).trim();
acctLock = checkNull(rs.getString("ACCT_LOCK")).trim();
//Bugfixing Due to trigger entries getting disturbed - by Prajyot on 21-JAN-2018
activationCode = checkNull(rs.getString("ACTIVATION_CODE")).trim();
status = checkNull(rs.getString("STATUS")).trim();
}
pstmt.close();
rs.close();
System.out.println("usrLevel " + usrLevel );
System.out.println("profileId " + profileId );
System.out.println("entityCode " + entityCode );
System.out.println("loginFirst " + loginFirst );
System.out.println("graceCount " + graceCount );
System.out.println("siteCodeDef " +siteCodeDef);
//Bugfixing Due to trigger entries getting disturbed - by Prajyot on 21-JAN-2018
//sql = "INSERT INTO USERS(CODE, NAME, PASS_WD, USR_LEV, EMP_CODE, CHG_DATE, CHG_USER, CHG_TERM, MOBILE_NO, NO_SESSION_ALLOW, PASS_WD_SHA, SITE_CODE__DEF, USER_THEME, PROFILE_ID, ENTITY_CODE, EMAIL_ID, USER_TYPE, PASSWD_FREQ, LOGIN_FIRST, GRACE_LOGIN_CNT, WRONG_LOGIN_CNT, TRANS_DB, ENTERPRISE, USER_LIC_TYPE, ASCERTAIN_ATTENDANCE, ACCT_LOCK) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?)";
sql = "INSERT INTO USERS(CODE, NAME, PASS_WD, USR_LEV, EMP_CODE, CHG_DATE, CHG_USER, CHG_TERM, MOBILE_NO, NO_SESSION_ALLOW, PASS_WD_SHA, SITE_CODE__DEF, USER_THEME, PROFILE_ID, ENTITY_CODE, EMAIL_ID, USER_TYPE, PASSWD_FREQ, LOGIN_FIRST, GRACE_LOGIN_CNT, WRONG_LOGIN_CNT, TRANS_DB, ENTERPRISE, USER_LIC_TYPE, ASCERTAIN_ATTENDANCE, ACCT_LOCK, ACTIVATION_CODE, STATUS) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstmt = usrConn.prepareStatement(sql);
pstmt.setString(1, userCode); //NAME
pstmt.setString(2, userName); //NAME
pstmt.setString(3, passWd ); // PASS_WD
pstmt.setString(4, usrLevel); // USR_LEV
pstmt.setString(5, empCode); // EMP_CODE
pstmt.setDate(6,currentDate);// , CHG_DATE
pstmt.setString(7,chgUser);//CHG_USER
pstmt.setString(8, chgTerm);// ,CHG_TERM
pstmt.setString(9,mobileNo );//MOBILE_NO
pstmt.setString(10,noSeesionAllow);//NO_SESSION_ALLOW
pstmt.setString(11,passHha);//PASS_WD_SHA
pstmt.setString(12,siteCodeDef);//SITE_CODE__DEF
pstmt.setString(13 ,userTheme);//USER_THEME
pstmt.setString(14,profileId);// PROFILE_ID
pstmt.setString(15,entityCode);// ENTITY_CODE
pstmt.setString(16, emailId);// EMAIL_ID
pstmt.setString(17,userType);// USER_TYPE
pstmt.setString(18,passFreq);// PASSWD_FREQ
pstmt.setString(19,loginFirst);// LOGIN_FIRST
pstmt.setString(20,graceCount);// GRACE_LOGIN_CNT
pstmt.setString(21,wronLoginCnt);// WRONG_LOGIN_CNT
pstmt.setString(22,transDB);// TRANS_DB
pstmt.setString(23,enterprise);// ENTERPRISE
pstmt.setString(24,userLicType);// USER_LIC_TYPE,
pstmt.setString(25,ascertionAttendenec);// ASCERTAIN_ATTENDANCE
pstmt.setString(26,acctLock);// ACCT_LOCK
//Bugfixing Due to trigger entries getting disturbed - by Prajyot on 21-JAN-2018
pstmt.setString(27,activationCode);// ACTIVATION_CODE
pstmt.setString(28,status);// STATUS
pstmt.executeQuery();
pstmt.close();
//usrConn.close();
}
catch (Exception e)
{
isError = true;
System.out.println("Exception :E12LoginRegistration createUserOnTransDb method: :==>\n" + e.getMessage());
e.printStackTrace();
throw new Exception( e );
}
finally
{
try
{
if( !isError )
{
System.out.println("User Connection Commmited inside createUserOnTransDb !");
usrConn.commit();
}
else if ( isError )
{
System.out.println("User Connection Rollback inside createUserOnTransDb !");
usrConn.rollback();
}
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Added By Saitej D [On 26 April 2019] [To close connections]
if(authConn != null)
authConn.close();
//Added By Saitej D [On 26 April 2019] [To close connections]
}
catch (Exception e)
{
System.out.println("Exception :E12LoginRegistration : :==>\n" + e.getMessage());
try
{
System.out.println("Before rollback");
authConn.rollback();
authConn.close(); //Added By Saitej D [On 26 April 2019] [To close connections]
} catch (SQLException sqle)
{
System.out.println(sqle);
}
}
}
}
//Changes by Prajyot on 30-NOV-19 [Check for AuthConn and UserConn are same or not] End
//Added By Kamal P to get seq_no for tran_id Start on 11 dec 2018
public String getNextSequence(String seqName, String datasourceName)
{
String sequence = "";
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
/*// 1. Get Session object
Session session = HibernateUtil.getSessionFactory(siteTranDB).openSession();
// 2. Create Query
Query query = session.createSQLQuery("SELECT " +seqName+".nextVal FROM DUAL");*/
conn = connDriver.getConnectDB(datasourceName);
sql = "SELECT " +seqName+".nextVal FROM DUAL";
System.out.println("sql querry for inserting value in tranID"+sql);
/*List seqList = query.getResultList();
System.out.println("sequence list in getNextSequence==>"+seqList);*/
pstmt = conn.prepareStatement(sql);
System.out.println("pstmt querry for inserting value in tranID"+pstmt);
rs = pstmt.executeQuery();
System.out.println("rs result value"+rs);
if(rs.next())
{
System.out.println("Inside If Condition After rs.nxt call");
/*List seqList = (List) rs.getArray(seqName);*/
//String seqList = rs.getString(seqName);
long seqNumber = rs.getLong(1);
System.out.println("Seql in array form"+seqNumber);
int seq = (int) seqNumber;
System.out.println("seq if rs next"+seq);
sequence = String.format(String.format("%%0%dd", 10), seq);
System.out.println("sequence in getNextSequence==>"+sequence);
}
}
catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception d)
{
d.printStackTrace();
System.out.println("SEQ NUMBER GENERATE ERROR : " + d.getMessage());
}
}
return sequence;
}
//Added By Kamal P to get seq_no for tran_id End on 11 dec 2018
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment