Example #1
0
        /// <summary>
        /// Populate bug object with the values from controls.
        /// </summary>
        /// <returns></returns>
        public MyZilla.BusinessEntities.Bug GetUpdatedBug()
        {
            try
            {
                // resolution, knob... values form ucBugStatus
                bugToUpdate.Resolution   = _bugResolution;
                bugToUpdate.Knob         = _bugKnob;
                bugToUpdate.DuplicateBug = _bugDuplicateBug;
                bugToUpdate.ReassignTo   = _bugReassignTo;


                bugToUpdate.Summary  = txtSummary.Text;
                bugToUpdate.Changed  = DateTime.Parse(txtLastModified.Text);
                bugToUpdate.Id       = int.Parse(txtBugNo.Text);
                bugToUpdate.Reporter = txtReporter.Text;

                if (string.IsNullOrEmpty(bugToUpdate.ReassignTo))
                {
                    bugToUpdate.AssignedTo = txtAssignedTo.Text;
                }
                else
                {
                    bugToUpdate.AssignedTo = bugToUpdate.ReassignTo;
                }

                bugToUpdate.Product   = cmbProduct.SelectedValue.ToString();
                bugToUpdate.Component = cmbComponent.SelectedValue.ToString();
                bugToUpdate.Version   = cmbVersion.SelectedValue.ToString();
                if (cmbMilestone.SelectedValue != null)
                {
                    bugToUpdate.Milestone = cmbMilestone.SelectedValue.ToString();
                }
                if (cmbPriority.SelectedValue != null)
                {
                    bugToUpdate.Priority = cmbPriority.SelectedValue.ToString();
                }

                bugToUpdate.Status = txtStatus.Text;

                if (cmbOS.SelectedValue != null)
                {
                    bugToUpdate.OS = cmbOS.SelectedValue.ToString();
                }

                bugToUpdate.Severity         = cmbSeverity.SelectedValue.ToString();
                bugToUpdate.Hardware         = cmbHardware.SelectedValue.ToString();
                bugToUpdate.DependsOn        = txtDependsOn.Text;
                bugToUpdate.Blocks           = txtBlock.Text;
                bugToUpdate.Url              = txtURL.Text;
                bugToUpdate.StatusWhiteboard = txtStWhiteboard.Text;


                #region CC

                List <string> oldCC = new List <string>();
                foreach (string strCC in bugToUpdate.CC)
                {
                    oldCC.Add(strCC);
                }

                List <string> newCC = new List <string>();

                if (lstCC.CheckedItems.Count > 0)
                {
                    foreach (string item in lstCC.CheckedItems)
                    {
                        // item = name <email>

                        newCC.Add(item);
                    }
                }

                // build the CC list
                // the items will have the pattern: item,attribute ( newcc, removecc)

                // check if any item has been added
                foreach (string item in newCC)
                {
                    bool isContained = oldCC.Contains(item);

                    if (isContained)
                    {
                        // no code here
                    }
                    else
                    {
                        string ccItem = item + ",newcc";
                        bugToUpdate.AddCC(ccItem);
                    }
                }

                // check if any item has been removed.
                foreach (string item in oldCC)
                {
                    bool isContained = newCC.Contains(item);

                    if (isContained)
                    {
                        // no code here
                    }
                    else
                    {
                        string ccItem = item + ",removecc";
                        bugToUpdate.CC.Add(ccItem);
                    }
                }


                #endregion

                #region Comment
//                if (txtComment.Text != string.Empty)
//                {
                bugToUpdate.Comment.Add(txtComment.Text);
//                }
                #endregion
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "GetUpdatedBug", LoggingCategory.Exception);

                throw;
            }


            return(bugToUpdate);
        }