Пример #1
0
        /// <summary>
        /// gets the previous bug in the chain
        /// </summary>
        /// <returns>NoPreviousBugException is thrown if no previous bug is found, else return object of type type Bug</returns>
        private DeveloperBug GetPreviousBug()
        {
            DeveloperBug previousBug = DeveloperBug.Get(PreviousBugID);

            //if bug
            if (PreviousBugID != 0 && previousBug != null)
            {
                return(previousBug);
            }
            else
            {
                throw new NoPreviousBugException(string.Format("no previous Bug. Bug by id {0} is the first bug in the chain", Id));
            }
        }
Пример #2
0
        /// <summary>
        /// gets All newer and older records of Bug
        /// </summary>
        /// <param name="developerBugID"> Bug from Chain of Developer bugs</param>
        /// <returns>List<DeveloperBug></returns>
        public static List <DeveloperBug> getBugHistory(long developerBugID)
        {
            List <DeveloperBug> developerBugs = new List <DeveloperBug>();

            List <DeveloperBug> nextDeveloperBugs = new List <DeveloperBug>();

            //gets bug which can be at top, middle or bottum of the chain
            DeveloperBug firstBug = DeveloperBug.Get(developerBugID);

            //checks to see if bug has previous
            Boolean hasPreviousBugID = (firstBug.PreviousBugID != 0);

            //checks to see if bug has next
            Boolean      hasNextBugID = (firstBug.NextBugId != 0);
            DeveloperBug nextBug      = firstBug;
            DeveloperBug PreviousBug  = firstBug;

            //if bug has next, add to bug list
            while (hasNextBugID)
            {
                nextBug = DeveloperBug.Get(nextBug.NextBugId);
                nextDeveloperBugs.Add(nextBug);
                hasNextBugID = (nextBug.NextBugId != 0);
            }

            //add next bugs in correct order
            developerBugs.AddRange(nextDeveloperBugs.Reverse <DeveloperBug>());
            developerBugs.Add(firstBug);

            //if has previous bug, add to bug list
            while (hasPreviousBugID)
            {
                PreviousBug = DeveloperBug.Get(PreviousBug.PreviousBugID);
                if (PreviousBug != null)
                {
                    developerBugs.Add(PreviousBug);
                    hasPreviousBugID = (PreviousBug.PreviousBugID != 0);
                }
                else
                {
                    hasPreviousBugID = false;
                }
            }



            return(developerBugs);
        }
Пример #3
0
        /// <summary>
        /// gets latest bugs in chains
        /// </summary>
        /// <param name="DeveloperID"></param>
        /// <param name="openOnly">parameter to show only open if true, else show open and close</param>
        /// <returns>list of bugs that Assigned user's ID = Developer ID</returns>
        public static new List <DeveloperBug> GetAssignedDevloperBugs(long DeveloperID, Boolean openOnly)
        {
            List <DeveloperBug> BugList = new List <DeveloperBug>();
            DataSet             ds      = new DataSet();
            SqlConnection       sqlCon  = new SqlConnection(Settings.AzureBugTrackingConnectionString);
            SqlCommand          sqlCom  = new SqlCommand("SELECT dbo.Bugs.id, dbo.Bugs.Title, dbo.Bugs.Comment, dbo.Bugs.LocationID, dbo.DeveloperBug.BugOpen,dbo.Bugs.CreatedDate,dbo.DeveloperBug.Code, dbo.Bugs.Archived, dbo.DeveloperBug.NextBugId, dbo.Bugs.CreatedById, dbo.DeveloperBug.previousBugID, dbo.DeveloperBug.Priority, dbo.Bugs.AssignedUserID FROM dbo.DeveloperBug LEFT OUTER JOIN dbo.Bugs ON dbo.DeveloperBug.BugID = dbo.Bugs.id where (AssignedUserID = @Id or CreatedByID = @Id ) and dbo.DeveloperBug.NextBugId is null", sqlCon);

            sqlCom.Parameters.Add(new SqlParameter("@Id", DeveloperID));
            if (openOnly == true)
            {
                sqlCom.Parameters.Add(new SqlParameter("@open", true));
                sqlCom.CommandText += " AND BugOpen = @open";
            }



            try
            {
                sqlCon.Open();

                SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCom);

                sqlDa.Fill(ds);
            }
            finally
            {
                sqlCon.Close();
            }


            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    long        Id            = (long)row["Id"];
                    String      Title         = (String)row["Title"];
                    String      Comment       = (String)row["Comment"];
                    long        previousBugId = (long)Settings.iif(Convert.IsDBNull(row["previousBugId"]), 0, (long)row["previousBugId"]);
                    long        locationID    = (long)Settings.iif(Convert.IsDBNull(row["locationID"]), (long)row["locationID"], (long)0);
                    BugLocation bugLocation   = new BugLocation(locationID);


                    DateTime CreatedDate = (DateTime)row["CreatedDate"];
                    bool     BugOpen;

                    if ((bool)row["BugOpen"] == true)
                    {
                        BugOpen = true;
                    }
                    else
                    {
                        BugOpen = false;
                    }
                    bugLocation.Get();

                    long priority = (long)row["priority"];



                    String code = "";

                    if (row["Code"] != DBNull.Value)
                    {
                        code = (String)row["Code"];
                    }



                    DeveloperBug newBug = new DeveloperBug(Id, Title, Comment, bugLocation, previousBugId, priority, BugOpen, code);

                    newBug.CreatedDate = CreatedDate;
                    Developer developer = Developer.Get((long)row["CreatedById"]);



                    BugList.Add(newBug);
                }
            }
            else
            {
                //throw exeption
                return(null);
            }

            return(BugList);
        }
Пример #4
0
        /// <summary>
        /// Get single developer Bug details
        /// </summary>
        /// <param name="id">Id of developer bug</param>
        /// <returns>returns bug</returns>
        public static new DeveloperBug Get(long id)
        {
            //retreives information about bug with ID
            DataSet       ds     = new DataSet();
            SqlConnection sqlCon = new SqlConnection(Settings.AzureBugTrackingConnectionString);
            SqlCommand    sqlCom = new SqlCommand("SELECT dbo.Bugs.id, dbo.Bugs.Title, dbo.Bugs.Comment, dbo.Bugs.LocationID, dbo.Bugs.CreatedDate, dbo.DeveloperBug.BugOpen,dbo.DeveloperBug.Code, dbo.Bugs.Archived, dbo.DeveloperBug.NextBugId, dbo.Bugs.CreatedById, dbo.DeveloperBug.previousBugID, dbo.DeveloperBug.Priority, dbo.Bugs.AssignedUserID FROM dbo.DeveloperBug LEFT OUTER JOIN dbo.Bugs ON dbo.DeveloperBug.BugID = dbo.Bugs.id where Id = @ID", sqlCon);

            sqlCom.Parameters.Add(new SqlParameter("@ID", id));
            try
            {
                sqlCon.Open();

                SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCom);

                sqlDa.Fill(ds);
            }
            finally
            {
                sqlCon.Close();
            }

            if (ds.Tables[0].Rows.Count > 0)
            {
                long Id = id;

                String Title = (String)ds.Tables[0].Rows[0]["Title"];

                String Comment = (String)ds.Tables[0].Rows[0]["Comment"];

                BugLocation Location = new BugLocation((long)ds.Tables[0].Rows[0]["LocationID"]);


                DateTime CreatedDate = (DateTime)ds.Tables[0].Rows[0]["CreatedDate"];


                long PreviousBugId = 0;
                if (ds.Tables[0].Rows[0]["PreviousBugID"] != DBNull.Value)
                {
                    PreviousBugId = (long)ds.Tables[0].Rows[0]["PreviousBugID"];
                }

                long NextBugID = 0;
                if (ds.Tables[0].Rows[0]["NextBugId"] != DBNull.Value)
                {
                    NextBugID = (long)ds.Tables[0].Rows[0]["NextBugId"];
                }


                List <Bug> UserBugs;


                long Priority = (long)ds.Tables[0].Rows[0]["Priority"];


                Boolean BugOpen = (Boolean)ds.Tables[0].Rows[0]["BugOpen"];

                String code = "";
                if (ds.Tables[0].Rows[0]["Code"] != DBNull.Value)
                {
                    code = (String)ds.Tables[0].Rows[0]["Code"];
                }

                long assignedUserID = 0;

                if (ds.Tables[0].Rows[0]["Code"] != DBNull.Value)
                {
                    assignedUserID = (long)ds.Tables[0].Rows[0]["AssignedUserID"];
                }



                DeveloperBug bug = new DeveloperBug(Id, Title, Comment, Location, PreviousBugId, Priority, BugOpen, code);
                bug.CreatedDate    = CreatedDate;
                bug.NextBugId      = NextBugID;
                bug.AssignedUserID = assignedUserID;



                return(bug);
            }
            else
            {
                return(null);
            }
        }
Пример #5
0
        /// <summary>
        /// Lists all Developer Bugs
        /// </summary>
        /// <returns>List of Developer Bugs</returns>
        public static new List <DeveloperBug> Get()
        {
            List <DeveloperBug> BugList = new List <DeveloperBug>();
            DataSet             ds      = new DataSet();
            SqlConnection       sqlCon  = new SqlConnection(Settings.AzureBugTrackingConnectionString);
            SqlCommand          sqlCom  = new SqlCommand("SELECT dbo.Bugs.id, dbo.Bugs.Title, dbo.Bugs.Comment, dbo.Bugs.LocationID, dbo.DeveloperBug.BugOpen, dbo.Bugs.Archived, dbo.DeveloperBug.NextBugId, dbo.Bugs.CreatedById, dbo.Bugs.previousBugID, dbo.Bugs.Priority, dbo.Bugs.AssignedUserID FROM dbo.DeveloperBug LEFT OUTER JOIN dbo.Bugs ON dbo.DeveloperBug.BugID = dbo.Bugs.id", sqlCon);

            try
            {
                sqlCon.Open();

                SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCom);

                sqlDa.Fill(ds);
            }
            finally
            {
                sqlCon.Close();
            }


            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    long   Id            = (long)row["Id"];
                    String Title         = (String)row["Title"];
                    String Comment       = (String)row["Comment"];
                    long   previousBugId = (long)Settings.iif(Convert.IsDBNull(row["previousBugId"]), 0, (long)row["previousBugId"]);
                    String code          = (String)row["Code"];

                    Boolean isNull    = Convert.IsDBNull(row["NextBugID"]);
                    long    NextBugId = (long)0;
                    if (!isNull)
                    {
                        NextBugId = (long)row["NextBugID"];
                    }


                    long        locationID  = (long)Settings.iif(Convert.IsDBNull(row["locationID"]), (long)row["locationID"], (long)0);
                    BugLocation bugLocation = new BugLocation(locationID);


                    bool BugOpen;

                    if ((bool)row["BugOpen"] == true)
                    {
                        BugOpen = true;
                    }
                    else
                    {
                        BugOpen = false;
                    }
                    bugLocation.Get();

                    long priority = (long)row["priority"];


                    DeveloperBug newBug = new DeveloperBug(Id, Title, Comment, bugLocation, previousBugId, priority, BugOpen, code);

                    Developer developer = Developer.Get((long)row["CreatedById"]);



                    BugList.Add(newBug);
                }
            }
            else
            {
                //throw exeption
                return(null);
            }

            return(BugList);
        }