コード例 #1
0
ファイル: userTable.java プロジェクト: Ningning-Xia/Calendar
  public static int updateOneUser(User user) {
    int uid = user.getUid();
    String userName = user.getUserName();
    String email = user.getEmail();
    String password = user.getPassword();
    try {
      conn = RDSManagement.getConnection();
      st = (Statement) conn.createStatement();
      String sql =
          "update User set email ='"
              + email
              + "', password ='******' where uid = "
              + uid
              + ";";
      System.out.println(sql);
      st.executeUpdate(sql);
      System.out.println("Update user: " + uid);

    } catch (SQLException e) {
      System.out.println(e.getMessage());
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } finally {
      try {
        st.close();
        conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return uid;
  }
コード例 #2
0
  @Test
  public void test() {
    Paper q = null;
    User v = null;

    try {
      q = (Paper) FileWriter.deSerializable("P_" + p.getFileSerialName());
      v = (User) FileWriter.deSerializable("U_" + u.getFileSerialName());
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    assert (u.getUserName().equals(v.getUserName()));
    assert (q.getAuthor().equals(p.getAuthor()));
    assert (q.getPaper().equals(p.getPaper()));
  }
コード例 #3
0
  /**
   * 生成日志
   *
   * @param logType 1 为系统管理日志 2为登录日志 3为业务日志
   * @param logContent 日志内容
   * @param result 操作结果
   * @return
   */
  public boolean insertSystemLog(String logType, String logContent, boolean result) {
    DbContextHolder.setDbType(DbContextHolder.DATA_SOURCE_COMMON);
    Systemdiary systemLog = new Systemdiary();
    systemLog.setDiaryCode(GenUUID.generateUUID());
    systemLog.setOperContent(logContent);
    systemLog.setDiaryType(logType);
    systemLog.setOperTime(CurrentDate.getCurrentDate());
    if (result) {
      systemLog.setOperResult("操作成功");
    } else {
      systemLog.setOperResult("操作失败");
    }
    Map<String, Object> session = (Map<String, Object>) ActionContext.getContext().getSession();
    User nowuser = (User) session.get("currentUser");
    if (nowuser != null) {
      systemLog.setOperPerson(nowuser.getUserName());
    }

    if (logType != null) {
      if (logType.equals("1")) {
        systemLog.setDiaryName("系统管理日志");
      } else if (logType.equals("2")) {
        systemLog.setDiaryName("系统登录日志");
      } else {
        systemLog.setDiaryName("系统业务日志");
      }
    }
    return systemLogDao.executeInsertEntity(systemLog);
  }
コード例 #4
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public PostIt updatePostIt(String name, String token, int id) throws RemoteException {
   for (User user : users) {
     if (user.getUserName().equals(name)) {
       return user.getPostIt(token, id);
     }
   }
   return null;
 }
コード例 #5
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public List<PostIt> getAllPostIts(String name, String Token) throws RemoteException {
   // retorna todos os postits do usuario
   for (User user : users) {
     if (user.getUserName().equals(name)) {
       return user.getAllPostIt(Token);
     }
   }
   return null;
 }
コード例 #6
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public boolean addNewUser(String name, String pass) throws RemoteException {
   for (User user : users) {
     if (user.getUserName().equals(name)) return false;
   }
   users.add(new User(name, pass));
   System.out.println("Usuario " + name + " criado! Senha " + pass);
   saveData();
   return true;
 }
コード例 #7
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public boolean editPostIt(String name, String Token, int id, String text) throws RemoteException {
   for (User user : users) {
     if (user.getUserName().equals(name)) {
       user.editPostIt(Token, id, text);
       saveData();
       return true;
     }
   }
   return false;
 }
コード例 #8
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public boolean removePostIt(String name, String token, int id) throws RemoteException {
   for (User user : users) {
     if (user.getUserName().equals(name)) {
       boolean aux = user.removePostIt(token, id);
       saveData();
       return aux;
     }
   }
   return false;
 }
コード例 #9
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public int addPostIt(String name, String Token, String textOfPostIt) throws RemoteException {
   // usuario adiciona postIt
   for (User user : users) {
     if (user.getUserName().equals(name)) {
       int aux = user.addPostIt(Token, textOfPostIt);
       saveData();
       return aux;
     }
   }
   return 0;
 }
コード例 #10
0
ファイル: Server.java プロジェクト: UlyssesRocha/EngCompStuff
 @Override
 public String login(String name, String pass) throws RemoteException {
   System.out.println("Usuario Solicitando login" + name + " criado! Senha " + pass);
   // Pesquisa usuarios e retorna token de acesso caso o login / senha esteja correto
   for (User user : users) {
     if (user.getUserName().equals(name) && user.checkTheUserPass(pass)) {
       return user.getUserToken();
     }
   }
   saveData();
   return null;
 }
コード例 #11
0
ファイル: userTable.java プロジェクト: Ningning-Xia/Calendar
  public static int insertOneUser(User user) {
    int uid = getMaxUserID() + 1;
    String userName = user.getUserName();
    String email = user.getEmail();
    String password = user.getPassword();
    try {
      conn = RDSManagement.getConnection();
      st = (Statement) conn.createStatement();
      String sql =
          "insert into User values("
              + uid
              + ",'"
              + userName
              + "', '"
              + email
              + "','"
              + password
              + "');";
      System.out.println(sql);
      int count = st.executeUpdate(sql);
      System.out.println("Inserted " + count + " items into Event");

    } catch (SQLException e) {
      System.out.println(e.getMessage());
    } catch (Exception e) {
      System.out.println(e.getMessage());
    } finally {
      try {
        st.close();
        conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    return uid;
  }
コード例 #12
0
 /**
  * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  *
  * @param request servlet request
  * @param response servlet response
  * @throws ServletException if a servlet-specific error occurs
  * @throws IOException if an I/O error occurs
  */
 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   response.setContentType("text/html;charset=UTF-8");
   SimpleDateFormat sf = new SimpleDateFormat("yyyy, M, d");
   HttpSession session = request.getSession(false);
   User u = (User) session.getAttribute("user");
   List<AppointmentLog> req = AppointmentLog.getDocRequest(u.getUserID());
   List<User> allP = User.showAccPatientList(u.getUserID());
   String poption = "";
   for (int i = 0; i < allP.size(); i++) {
     poption =
         poption.concat(
             "<option value=\""
                 + allP.get(i).getUserID()
                 + "\">"
                 + allP.get(i).getFirstname()
                 + " "
                 + allP.get(i).getLastname()
                 + "</option>");
   }
   request.setAttribute("poption", poption);
   if (!req.isEmpty()) {
     String sreq = "";
     for (int i = 0; i < req.size(); i++) {
       sreq =
           sreq.concat(
               "<div class=\"alert alert-info col-sm-12 alert-dismissable animation-slideRight\">\n"
                   + "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button><p>คุณมีคำขอนัดใหม่</p><p><strong>วันที่ "
                   + req.get(i).getChecktime().toString()
                   + " พบกับคนไข้ "
                   + User.getUserName(req.get(i).getPatientId())
                   + "<br />รายละเอียด "
                   + req.get(i).getDetail()
                   + "<a href=\"calAcc?id="
                   + req.get(i).getLogId()
                   + "\"><br /><button class=\"btn btn-sm btn-effect-ripple btn-success\">เพิ่ม</button></a><a href=\"calDec?id="
                   + req.get(i).getLogId()
                   + "\"> <button class=\"btn btn-sm btn-effect-ripple btn-danger\">ลบ</button></a></div>");
     }
     System.out.println(sreq);
     request.setAttribute("req", sreq);
   }
   List<AppointmentLog> all = AppointmentLog.getDocCalendar(u.getUserID());
   if (!all.isEmpty()) {
     String json = "[ ";
     int siz = all.size();
     for (int i = 0; i < all.size(); i++) {
       json =
           json.concat(
               "{ title: \'"
                   + all.get(i).getDetail()
                   + "\', start: new Date("
                   + sf.format(all.get(i).getChecktime())
                   + ") } ");
       if (i != (siz - 1)) {
         json = json.concat(" , ");
       }
     }
     json = json.concat(" ] ");
     request.setAttribute("cal", json);
   } else {
     String json = "[]";
     request.setAttribute("cal", json);
   }
   getServletContext().getRequestDispatcher("/doccalendar.jsp").forward(request, response);
   /*[
   {
       title: 'Cinema',
       start: new Date(4, 8, 2014),
       allDay: true,
       color: '#de815c'
   },*/
 }