/// <summary> /// Get/Set Project /// </summary> /// <param name="issue">issue</param> /// <returns>project</returns> static public MIssueProject Get(MIssue issue) { if (issue.GetName() == null) { return(null); } MIssueProject pj = null; String sql = "SELECT * FROM R_IssueProject WHERE Name=@param"; SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; try { //pstmt = DataBase.prepareStatement (sql, null); //pstmt.setString (1, issue.getName()); param[0] = new SqlParameter("@param", issue.GetName()); idr = DataBase.DB.ExecuteReader(sql, param, null); if (idr.Read()) { pj = new MIssueProject(issue.GetCtx(), idr, null); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } // New if (pj == null) { pj = new MIssueProject(issue.GetCtx(), 0, null); pj.SetName(issue.GetName()); pj.SetA_Asset_ID(issue); } pj.SetSystemStatus(issue.GetSystemStatus()); pj.SetStatisticsInfo(issue.GetStatisticsInfo()); pj.SetProfileInfo(issue.GetProfileInfo()); if (!pj.Save()) { return(null); } // Set issue.SetR_IssueProject_ID(pj.GetR_IssueProject_ID()); if (pj.GetA_Asset_ID() != 0) { issue.SetA_Asset_ID(pj.GetA_Asset_ID()); } return(pj); } // get
/// <summary> /// Get/Set User for Issue /// </summary> /// <param name="issue">issue</param> /// <returns>user</returns> static public MIssueUser Get(MIssue issue) { if (issue.GetUserName() == null) { return(null); } MIssueUser user = null; // Find Issue User String sql = "SELECT * FROM R_IssueUser WHERE UserName=@param"; SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; try { //pstmt = DataBase.prepareStatement (sql, null); //pstmt.setString (1, issue.getUserName()); param[0] = new SqlParameter("@param", issue.GetUserName()); idr = DataBase.DB.ExecuteReader(sql, param, null); if (idr.Read()) { user = new MIssueUser(issue.GetCtx(), idr, null); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } // New if (user == null) { user = new MIssueUser(issue.GetCtx(), 0, null); user.SetUserName(issue.GetUserName()); user.SetAD_User_ID(); if (!user.Save()) { return(null); } } issue.SetR_IssueUser_ID(user.GetR_IssueUser_ID()); return(user); } // MIssueUser
/// <summary> /// Get/Set System /// </summary> /// <param name="issue">issue</param> /// <returns>system</returns> static public MIssueSystem Get(MIssue issue) { if (issue.GetDBAddress() == null) { return(null); } MIssueSystem system = null; SqlParameter[] param = new SqlParameter[1]; IDataReader idr = null; String sql = "SELECT * FROM R_IssueSystem WHERE DBAddress=@param"; try { //pstmt = DataBase.prepareStatement (sql, null); //pstmt.setString (1, issue.getDBAddress()); param[0] = new SqlParameter("@param", issue.GetDBAddress()); idr = DataBase.DB.ExecuteReader(sql, param, null); if (idr.Read()) { system = new MIssueSystem(issue.GetCtx(), idr, null); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } // New if (system == null) { system = new MIssueSystem(issue.GetCtx(), 0, null); system.SetDBAddress(issue.GetDBAddress()); system.SetA_Asset_ID(issue.GetA_Asset_ID()); } system.SetSystemStatus(issue.GetSystemStatus()); system.SetStatisticsInfo(issue.GetStatisticsInfo()); system.SetProfileInfo(issue.GetProfileInfo()); if (issue.GetA_Asset_ID() != 0 && system.GetA_Asset_ID() != issue.GetA_Asset_ID()) { system.SetA_Asset_ID(issue.GetA_Asset_ID()); } // if (!system.Save()) { return(null); } // Set issue.SetR_IssueSystem_ID(system.GetR_IssueSystem_ID()); if (system.GetA_Asset_ID() != 0) { issue.SetA_Asset_ID(system.GetA_Asset_ID()); } return(system); } // get