/// <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>
        ///	Set A_Asset_ID
        /// </summary>
        /// <param name="issue"></param>
        public void SetA_Asset_ID(MIssue issue)
        {
            int A_Asset_ID = 0;

            //String sql = "SELECT * FROM A_Asset a "
            //    + "WHERE EXISTS (SELECT * FROM A_Asset_Group ag "	//	Tracking Assets
            //        + "WHERE a.A_Asset_Group_ID=ag.A_Asset_Group_ID AND ag.IsTrackIssues='Y')"
            //    + " AND EXISTS (SELECT * FROM AD_User u "
            //        + "WHERE (a.C_BPartner_ID=u.C_BPartner_ID OR a.C_BPartnerSR_ID=u.C_BPartner_ID)"
            //        + " AND u.EMail=@param1)"					//	#1 EMail
            //    + " AND (SerNo IS NULL OR SerNo=@param2)";	//	#2 Name



            base.SetA_Asset_ID(A_Asset_ID);
        }       //	setA_Asset_ID
Exemple #4
0
        /// <summary>
        /// Create and report issue SessionEndAll
        /// </summary>
        /// <param name="record">log record</param>
        /// <returns>reported issue or null</returns>
        public static MIssue Create(LogRecord record)
        {
            _log.Config(record.message);
            MSystem system = MSystem.Get(Env.GetCtx());

            if (!DataBase.DB.IsConnected() ||
                system == null ||
                !system.IsAutoErrorReport())
            {
                return(null);
            }
            //
            MIssue issue = new MIssue(record);
            String error = issue.Report();

            issue.Save();
            if (error != null)
            {
                return(null);
            }
            return(issue);
        }       //	create
Exemple #5
0
        }       //	create

        /// <summary>
        ///	Create from decoded hash map string
        /// </summary>
        /// <param name="ctx">context</param>
        /// <param name="hexInput">hex string</param>
        /// <returns>issue</returns>
        //@SuppressWarnings("unchecked")

        public static MIssue Create(Ctx ctx, String hexInput)
        {
            Dictionary <String, String> hmIn = null;

            try                 //	encode inn report
            {
                byte[] byteArray = Secure.ConvertHexString(hexInput);
                java.io.ByteArrayInputStream bIn = new java.io.ByteArrayInputStream(byteArray);
                //MemoryStream bln = new MemoryStream(byteArray);

                java.io.ObjectInputStream oIn = new java.io.ObjectInputStream(bIn);
                //BufferedStream oIn = new BufferedStream(bln);
                hmIn = (Dictionary <String, String>)oIn.readObject();
            }
            catch (Exception e)
            {
                _log.Log(Level.SEVERE, "", e);
                return(null);
            }

            MIssue issue = new MIssue(ctx, (Dictionary <String, String>)hmIn);

            return(issue);
        }       //	create
        /// <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