Exemplo n.º 1
0
    protected void btnCheckIn_Click(object sender, EventArgs e)
    {
        using (CrackerEntities myEntity = new CrackerEntities())
        {
            ITransactionRepository transactionRepo = new TransactionRepository();
            IBugRepository bugRepo = new BugRepository();

            string bugName = Request.QueryString.Get("BugID");

            var bugId = bugRepo.GetBugIdByTitle(bugName);

            Transaction myTransaction = new Transaction
            {
                BugId = (int)bugId,
                ChangedBy = HttpContext.Current.User.Identity.Name,
                ChangedOn = DateTime.Now,
                StatusId = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlResolution")).SelectedValue),
                TimeSpent = Int32.Parse(((TextBox)LoginView1.FindControl("txtTime")).Text),
                LanguageId = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlLanguages")).SelectedValue),
                Note = HttpUtility.HtmlEncode(((TextBox)LoginView1.FindControl("txtNote")).Text)
            };

            transactionRepo.InsertTransaction(myTransaction);
            transactionRepo.Save();

        }
        Response.Redirect("~/Default.aspx");
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string bugName = Request.QueryString.Get("BugID");
        ((Label)LoginView1.FindControl("lblBugID")).Text = bugName;

        string checkedOutBy;
        DateTime changedOn;
        string status;

        ITransactionRepository transactionRepo = new TransactionRepository();
        IBugRepository bugRepo = new BugRepository();

        //Verify that the bug we are going to check in can be checked in
        //Get bug ID
        var result = bugRepo.GetBugIdByTitle(bugName);

        if (result != null)
        {
            //check if the bug is checked out & if it's checked by current user
            var check = transactionRepo.GetLastTransactionForBug((int)result);

            status = Convert.ToString(check.Status.StatusName);
            changedOn = Convert.ToDateTime(check.ChangedOn);
            checkedOutBy = Convert.ToString(check.ChangedBy);

            if (checkedOutBy != HttpContext.Current.User.Identity.Name)
            {
                ((Label)LoginView1.FindControl("lblWarning")).ForeColor = System.Drawing.Color.Red;
                ((Label)LoginView1.FindControl("lblWarning")).Text = "You're about to undo a bug that was not checked out by you!";
            }

            //get how long has the bug been checked out
            ((TextBox)LoginView1.FindControl("txtTime")).Text = Math.Round(DateTime.Now.Subtract(changedOn).TotalMinutes, 0).ToString();

            ((Label)LoginView1.FindControl("lblBugID")).Text = bugName;
        }
        else
        {
            ((Label)LoginView1.FindControl("lblBugID")).ForeColor = System.Drawing.Color.Red;
            ((Label)LoginView1.FindControl("lblBugID")).Text = bugName + " does not exist!";
            ((Button)LoginView1.FindControl("btnUNdo")).Enabled = false;

        }
    }
Exemplo n.º 3
0
    protected void btnUndo_Click(object sender, EventArgs e)
    {
        ITransactionRepository transactionRepo = new TransactionRepository();
        IBugRepository bugRepo = new BugRepository();

        string bugName = Request.QueryString.Get("BugID");
        var bugId = bugRepo.GetBugIdByTitle(bugName);

        Transaction myTransaction = new Transaction
        {
            ChangedBy = HttpContext.Current.User.Identity.Name,
            ChangedOn = DateTime.Now,
            BugId = (int)bugId,
            StatusId = 9,
            TimeSpent = Int32.Parse(((TextBox)LoginView1.FindControl("txtTime")).Text),
            LanguageId = 14
        };

        transactionRepo.InsertTransaction(myTransaction);
        transactionRepo.Save();

        Response.Redirect("~/Default.aspx");
    }
Exemplo n.º 4
0
    protected void btnCheckOut_Click(object sender, EventArgs e)
    {
        string bug = ((TextBox)LoginView1.FindControl("txtBugId")).Text;
        int bugId;

        try
        {
                ITransactionRepository transactionRepo = new TransactionRepository();
                IBugRepository bugRepo = new BugRepository();

                var result = bugRepo.GetBugIdByTitle(bug);

                if (result == 0)
                {
                    Bug newBug = new Bug()
                    {
                        Bug1 = bug

                    };

                    bugRepo.InsertBug(newBug);
                    bugRepo.Save();
                }

                bugId = (int)bugRepo.GetBugIdByTitle(bug);

                //check if bug was not checked out previously (check if there is any transaction for this bug)
                var testCheckout = transactionRepo.GetLastTransactionForBug(bugId);

                //if there is an transaction
                if (testCheckout != null)
                {
                    //check if bug is not checked out now
                    if (testCheckout.StatusId != 8)
                    {
                        //check out bug
                        CheckoutBug(bugId, transactionRepo);

                        ((Label)LoginView1.FindControl("lblAlreadyCheckedOut")).Visible = false;

                        setGridView(gridIdBugsMe, true);
                        setGridView(gridIdBugsOthers, false);
                    }
                    else
                    {
                        ((Label)LoginView1.FindControl("lblAlreadyCheckedOut")).Visible = true;
                    }
                }
                else
                {
                    CheckoutBug(bugId, transactionRepo);

                    ((Label)LoginView1.FindControl("lblAlreadyCheckedOut")).Visible = false;

                    setGridView(gridIdBugsMe, true);
                    setGridView(gridIdBugsOthers, false);
                }
        }
        catch (DataException ex)
        {
            ((Label)LoginView1.FindControl("lblException")).Visible = true;
            ((Label)LoginView1.FindControl("lblException")).Text = "Data not available, please try again later (" + ex.Message + ex.InnerException.Message + ").";
        }
    }