⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forgetcihper.java

📁 电信的网厅的整站代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	private String[] getEmailAndCity(String account) {
		try {
			Object[] _object = new Object[1];
			_object[0] = account;
			dt = _dac.executeQuery(S_INVALIACC, _object);
			if (dt != null && dt.getRows().getCount() > 0){
			   String[] strings = new String[2];
			   strings[0] = dt.getRow(0).getString("email");
			   strings[1] = dt.getRow(0).getString("citycode");
	           return strings;
			}
		} catch (Exception e) {
			_logger.warn("获取email出错:" + e.getMessage());
		}
		return null;
	}

	/**
	 * 跟据地市获取账号
	 * 
	 * @param account
	 * @return
	 */
	public DataTable getAccountC(String city, String statu) {

		try {
			String sql = S_COMPARATIVE;
			Object[] _object = new Object[2];
			_object[0] = city;
			_object[1] = statu;
			return _dac.executeQuery(sql, _object);

		} catch (Exception ex) {
			_logger.warn("数据库查询出错!", ex);
		} finally {
			dt = null;
		}
		return null;
	}

	/**
	 * <p>
	 * 跟据Email获取accountid
	 * </p>
	 * 
	 * @param email
	 * @return
	 */
	public DataTable getAccountE(String email) {
		try {
			String sql = S_EMAIL;
			Object[] _object = new Object[1];
			_object[0] = email;

			dt = _dac.executeQuery(sql, _object);
			return dt;
		} catch (Exception rex) {
			_logger.warn("没有你要的用户!", rex);
		} finally {
			dt = null;
		}
		return null;
	}

	/**
	 * <p>
	 * <em>密码更新</em>
	 * </p>
	 * 
	 * @param account
	 * @param servername
	 * @param serverport
	 * @param contentpath
	 * @return
	 */
	public String setCihper(String account) {
		try {
			if (account == null && account.equals(""))
				return "0";
			/** 生成随机密码 */
			String newPwd = SendMail.getRandomNumber(8);
			String pwd = UserFactory.getEncryptPassword(newPwd);
			String sql = S_SETCIHER;
			Object[] _object = new Object[2];
			_object[0] = pwd;
			_object[1] = account;
			/** 更新成功 */
			int row = _dac.executeUpdate(sql, 10, _object);
			if (row > 0) {
				return sendPwdMail(account, newPwd);
			}

		} catch (Exception ex) {
			ex.printStackTrace();
			_logger.warn("数据库更新出错!", ex);
		} finally {
			dt = null;
		}
		return "0";
	}

	public void onLineUserLogoff(String account){
		try {
			String onLineSQL = "delete from tf_custonline where staffid=?";
			_dac.executeUpdate(onLineSQL, 10, new Object[]{account});
		} catch (Exception e) {
			_logger.info(e.getMessage(), e);
		} finally {
		}
		

	}
	
	
	/**
	 * 找回密码邮件.
	 * @param account
	 * @param pwd
	 * @return
	 * @throws UnsupportedEncodingException
	 */
	public String sendPwdMail(String account, String pwd) {
		String flag = "0";
		try {
			TemplateMail impl = new TemplcateMailImpl();
			FormBody body = new FormBody();
			body.append("ACCOUNTID", account);
			body.append("TEMPLATENAME", TemplateMail.PASSWORD_MAIL);
			body.append("PARAMTER", pwd);
			EMessage message = new EMessage((String)impl.sendLoginMail(body));
			flag = message.getBody();
		} catch (Exception ex) {
			_logger.warn("邮件失败: "+ex.getMessage(), ex);
			flag = "0";
		}
		
		String[] result = this.getEmailAndCity(account);
		if (flag.equals("1")) {
			return result[0] + "成功";
		}
		return result[0] + "失败";
	}

	/**
	 * 
	 * @param cityCode
	 * @return
	 */
	public static int getActiveAccountTime(String cityCode) {
		try {
			String sql = "select paravalue from ts_configsub where paraname='LockAccountTimes' and citycode=?";
			DacClient client = new DacClient() ;
			DataTable dt = client.executeQuery(sql, new Object[] { cityCode });
			if (dt != null && dt.getRows().getCount() > 0) {
				return dt.getRow(0).getInt("paravalue");
			}
		} catch (Exception ex) {}
		return 5;
	}


	/**
	 * 根据输入的accountid查询到该帐号下的所有关联产品清单
	 * 
	 * @param accountid
	 * @param state
	 * @return DataTable
	 * @version v1.0.0
	 * @author zengzc
	 * @date 2006-1-5
	 */
	public DataTable getRelaListByAcct(String accountid, String state) {
		try {
			Object[] _object = new Object[2];
			_object[0] = accountid;
			_object[1] = state;
			dt = _dac.executeQuery(RelaListSQL, _object);
			return dt;
		} catch (Exception ex) {
			_logger.warn("getRelaListByAcct:" + ex.getMessage(), ex);
		}
		return null;
	}

	/**
	 * 撤销产品关联,后台撤销产品关联。
	 * 
	 * @param cancelResu
	 *            撤销原因
	 * @param userid
	 *            帐号
	 * @param phonenum
	 *            电话号码
	 * @param cancelor
	 *            撤销人,如果是内部管理平台,那么写入操作人员的工号
	 * @return
	 */
	public String unRelaProdByUserid(String cancelResu, String userid,
			String phonenum, String cancelor) {
		int row = 0;
		try {
			Object[] _object = new Object[3];
			Date now = new Date();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

			_object[0] = sdf.format(now) + "," + cancelor + "," + cancelResu;
			_object[1] = userid;
			_object[2] = phonenum;
			row = _dac.executeUpdate(UnRelaProdSQL, 10, _object);

		} catch (Exception ex) {
			_logger.warn("unRelaProdByUserid:" + ex.getMessage(), ex);
		}
		return String.valueOf(row);
	}

	/**
	 * 根据输入的userid取得所有的关联产品清单。
	 * 
	 * @param userid
	 *            用户唯一标识id
	 * @return 所有的产品清单
	 */
	public DataTable getRelaInfoByUserid(String userid) {
		try {
			Object[] _object = new Object[1];
			_object[0] = userid;
			dt = _dac.executeQuery(getPhoneNum, _object);
			return dt;
		} catch (Exception ex) {
			_logger.warn("getRelaInfoByUserid:" + ex.getMessage(), ex);
		}
		return null;
	}

	/**
	 * <code>获取过期账号总数</code>
	 * 
	 * @param cityCode
	 * @return
	 */
	public int getOverDueAccountCount(String cityCode) {
		
		try {
			java.util.Map _map = new java.util.HashMap();
			_map.put("CITY",cityCode);
			return Register.getOrderListCount(_map,"L");
		} catch (Exception rux) {
			_logger.warn("getOverDueAccountCount:" + rux.getMessage(), rux);
			throw new RuntimeException(rux.getMessage());
		}
		
	}

	public DataTable activeOverDueAccountD(String cityCode) {
		String sql = "";
		String error = "";
		try {
			if (cityCode != null && !cityCode.equals("0590")) {
				sql = "SELECT accountid,PWD,EMAIL  FROM tf_custinfoweb c WHERE c.state='D' AND c.custtypeid='2' AND c.userstate='L' AND c.citycode=?";
				return _dac.executeQuery(sql, new Object[] { cityCode });
			} else {
				sql = "SELECT accountid,PWD,EMAIL  FROM tf_custinfoweb c WHERE c.state='D' AND c.custtypeid='2' AND c.userstate='L'";
				return _dac.executeQuery(sql);
			}

		} catch (Exception ex) {
			_logger.warn("activeOverDueAccountD:" + ex.getMessage(), ex);
			error = ex.getMessage();
		}
		throw new RuntimeException(error);
	}

	public void activeOverDueAccount(String cityCode) {
		String sql = "SELECT accountid,PWD,EMAIL  FROM tf_custinfoweb c WHERE c.state='D' AND c.custtypeid='2' AND c.userstate='L' AND c.citycode=?";
		String error = "";
		try {
			dt = _dac.executeQuery(sql, new Object[] { cityCode });

			if (dt != null && dt.getRows().getCount() > 0) {
				for (int i = dt.getRows().getCount(); --i >= 0;) {
					try {
						String accountid = dt.getRow(i).getString("accountid");
//						String pwd = dt.getRow(i).getString("pwd");
						String email = dt.getRow(i).getString("email");
						setChanged();
						notifyObservers("执行账号: " + accountid + " Email: "
								+ email);

						setCihper(accountid);
					} catch (RuntimeException ruxs) {
					}
				}
				updateOverDueAccount(cityCode);
			}

		} catch (Exception rux) {
			_logger.warn("activeOverDueAccount:" + rux.getMessage(), rux);
			error = rux.getMessage();
		}
		throw new RuntimeException(error);
	}

	/** 当前执行的账号 */
	private String processAccount = "";

	public void update(Observable o, Object arg) {
		if (arg instanceof String) {
			processAccount = (String) arg;
		}
	}

	public String getProcessAccount() {
		return this.processAccount;
	}

	/**
	 * <code>更新过期账号为未激活账号</code>
	 * 
	 * @param cityCode
	 * @return
	 */
	public void updateOverDueAccount(String cityCode) {
		StringBuffer sql = new StringBuffer();
		String error = "";
		try {
			if (cityCode != null && !cityCode.equals("0590")) {
				sql.append("UPDATE tf_custinfoweb c SET c.state='E',c.userstate='N',c.createtime=sysdate ");
				sql.append("WHERE c.state='D' AND c.custtypeid='2' AND c.userstate='L' AND c.citycode=?");
				_dac.executeUpdate(sql.toString(), 10,new Object[] { cityCode });
			} else {
				sql.append("UPDATE tf_custinfoweb c SET c.state='E',c.userstate='N',c.createtime=sysdate ");
				sql.append("WHERE c.state='D' AND c.custtypeid='2' AND c.userstate='L'");
				_dac.executeUpdate(sql.toString(), 10, null);
			}

		} catch (Exception rux) {
			_logger.warn("updateOverDueAccount:" + rux.getMessage(), rux);
			error = rux.getMessage();
		}
		throw new RuntimeException(error);
	}

	/**
	 * <code>解锁单个过期账号</code>
	 * 
	 * @param accountid
	 * @return
	 */
	public boolean unLockDueAccount(String accountid) {
		StringBuffer sql = new StringBuffer();
		sql.append("UPDATE tf_custinfoweb c SET c.state='E',c.userstate='N',c.createtime=sysdate ");
		sql.append("WHERE c.accountid=?");

		try {
			int i = _dac.executeUpdate(sql.toString(), 10, new Object[] { accountid });
			if (i > 0) {
				setCihper(accountid);
				return true;
			}
			return false;
		} catch (Exception rux) {
			_logger.warn("updateOverDueAccount:" + rux.getMessage(), rux);
		}
		return false;
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -