Beispiel #1
0
        public FormEditBug(int connectionId, int bugNo, Bug cachedBug)
        {
            InitializeComponent();

            _connectionId = connectionId;

            bool isValid = CheckConditionsForLoading();

            this.DialogResult = isValid ? DialogResult.OK : DialogResult.Cancel;

            if (this.DialogResult == DialogResult.OK)
            {

                _bugNo = bugNo;

                ucEditBug.BugNumber = bugNo;

                ucEditBug.ConnectionId = _connectionId;

                if (cachedBug != null)
                {
                    ucEditBug.BugToUpdate = cachedBug;
                }

                ucEditBug.CancelEvent += new EventHandler(ucEditBug_CancelEvent);

                this.KeyPreview = true;

                this.Text = string.Format(Messages.EditBugTitle, _bugNo);

            }
        }
Beispiel #2
0
        /// <summary>
        /// Get the details of the specified bug.
        /// </summary>
        /// <param name="bugzillaURL"></param>
        /// <param name="bugId"></param>
        /// <returns></returns>
        public MyZilla.BusinessEntities.Bug GetBug(int bugId)
        {
            TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId);

            string urlEnding = String.Format(BUG_DETAILS_URL, bugId);

            MyZilla.BusinessEntities.Bug bugBSI = GetBugDetailsFromXml(connection.URL, urlEnding, connection.Charset);

            return(bugBSI);
        }
Beispiel #3
0
        public UCBugStatus(List <string> resolutionList, MyZilla.BusinessEntities.Bug bugToUpdate, List <string> assignedToList, UCEditBug ucEditBug)
        {
            InitializeComponent();

            _catResolution = resolutionList.GetRange(0, resolutionList.Count);

            _bugToUpd = bugToUpdate;

            this.Size = ucSize;

            this.assignedTo = assignedToList;

            _ucEditBug = ucEditBug;
        }
Beispiel #4
0
        public UCBugStatus(List<string> resolutionList, MyZilla.BusinessEntities.Bug bugToUpdate, List<string >  assignedToList , UCEditBug ucEditBug   )
        {
            InitializeComponent();

            _catResolution = resolutionList.GetRange(0, resolutionList.Count);

            _bugToUpd = bugToUpdate;

            this.Size = ucSize;

            this.assignedTo = assignedToList;

            _ucEditBug = ucEditBug;
        }
Beispiel #5
0
        public string PostHttpRequest_AddBug(MyZilla.BusinessEntities.Bug bug)
        {
            StringBuilder sb = new StringBuilder();

            //Encoding bugzillaEncoding = Encoding.GetEncoding("utf-8");
            Encoding bugzillaEncoding = Encoding.GetEncoding(this._charset);

            #region Build data to be posted

            sb.AppendFormat("product={0}", HttpUtility.UrlEncode(bug.Product, bugzillaEncoding));
            sb.AppendFormat("&version={0}", HttpUtility.UrlEncode(bug.Version, bugzillaEncoding));
            sb.AppendFormat("&component={0}", HttpUtility.UrlEncode(bug.Component, bugzillaEncoding));
            sb.AppendFormat("&rep_platform={0}", HttpUtility.UrlEncode(bug.Hardware, bugzillaEncoding));
            sb.AppendFormat("&op_sys={0}", HttpUtility.UrlEncode(bug.OS, bugzillaEncoding));
            sb.AppendFormat("&priority={0}", HttpUtility.UrlEncode(bug.Priority, bugzillaEncoding));
            sb.AppendFormat("&bug_severity={0}", HttpUtility.UrlEncode(bug.Severity, bugzillaEncoding));
            if (String.IsNullOrEmpty(bug.Milestone))
            {
                sb.AppendFormat("&target_milestone={0}", "---");
            }
            else
            {
                sb.AppendFormat("&target_milestone={0}", HttpUtility.UrlEncode(bug.Milestone, bugzillaEncoding));
            }
            sb.AppendFormat("&bug_status={0}", HttpUtility.UrlEncode(bug.Status, bugzillaEncoding));
            sb.AppendFormat("&assigned_to={0}", HttpUtility.UrlEncode(bug.AssignedTo, bugzillaEncoding));
            if (bug.CC != null && bug.CC.Count != 0)
            {
                foreach (string cc in bug.CC)
                {
                    sb.AppendFormat("&cc={0}", HttpUtility.UrlEncode(cc, bugzillaEncoding));
                }
            }
            sb.AppendFormat("&bug_file_loc={0}", HttpUtility.UrlEncode(bug.Url, bugzillaEncoding));
            sb.AppendFormat("&short_desc={0}", HttpUtility.UrlEncode(bug.Summary, bugzillaEncoding));
            if (bug.Comment != null && bug.Comment.Count > 0)
            {
                sb.AppendFormat("&comment={0}", HttpUtility.UrlEncode(bug.Comment[0], bugzillaEncoding));
            }

            sb.AppendFormat("&dependson={0}", bug.DependsOn);
            sb.AppendFormat("&blocked={0}", bug.Blocks);

            #endregion

            // blanks have to be replaced with "+"
            return(sb.Replace(' ', '+').ToString());;
        }
Beispiel #6
0
        private string AddBugForVersion_3_0(MyZilla.BusinessEntities.Bug bug, string myZillaUrl, string charset)
        {
            string result = string.Empty;

            MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, charset);

            string htmlContent = httpDialog.PostMultipartWhenAddingBug(bug, myZillaUrl);

#if DEBUG
            MyZilla.BL.Interfaces.Utils.htmlContents = htmlContent;
#endif

            result = ValidateAddBug(htmlContent);

            return(result);
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bugDetail"></param>
        private void CompleteCcList(MyZilla.BusinessEntities.Bug bug)
        {
            if (allowAddingPersonsToCcList && !txtCC.Visible)
            {
                lstCC.Top       += txtCC.Height + 5;
                lstCC.Height    -= (txtCC.Height + 5);
                txtCC.Visible    = true;
                btnAddCC.Visible = true;
            }

            if (bug.CC != null && bug.CC.Count > 0)
            {
                if (lstCC.Items.Count > 1)
                {
                    // check the proper items in chklistbox
                    for (int i = 0; i < lstCC.Items.Count; i++)
                    {
                        string item = lstCC.Items[i] as string; // name <email>

                        if (CcListContainsItem(item))
                        {
                            lstCC.SetItemChecked(i, true);
                        }
                    }
                }
                else
                {
                    //cc catalog contains only default value
                    if (lstCC.Items.Count == 1)
                    {
                        lstCC.Items.Clear();
                    }

                    int prevCount = lstCC.Items.Count;

                    for (int i = 0; i < bug.CC.Count; i++)
                    {
                        lstCC.Items.Add(bug.CC[i]);
                        lstCC.SetItemChecked(i + prevCount, true);
                    }
                }
            }
        }
Beispiel #8
0
        private string AddBugForVersion_2_0(MyZilla.BusinessEntities.Bug bug, string myZillaUrl, string charset)
        {
            string result = string.Empty;

            string url = myZillaUrl + UPDATE_BUG_2_0_PAGE;

            MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, charset);

            string dataToPost = httpDialog.PostHttpRequest_AddBug(bug);

            string htmlContent = httpDialog.PostToUrl(url, dataToPost, false);

#if DEBUG
            MyZilla.BL.Interfaces.Utils.htmlContents = htmlContent;
#endif

            result = ValidateAddBug(htmlContent);

            return(result);
        }
Beispiel #9
0
        public string AddBug(MyZilla.BusinessEntities.Bug newBug)
        {
            string result = string.Empty;

            int versionINT = -1;

            TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId);

            // get version for connection
            MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance();

            string version = _appSettings.GetConnectionById(_connectionId).Version;

            try
            {
                versionINT = int.Parse(version.Substring(0, version.IndexOf(".")));
            }
            catch (FormatException ex)
            {
                result = ex.Message;

                return(result);
            }

            switch (versionINT)
            {
            case 2:
                result = this.AddBugForVersion_2_0(newBug, connection.URL, connection.Charset);
                break;

            case 3:
                result = this.AddBugForVersion_3_0(newBug, connection.URL, connection.Charset);
                break;
            }

            return(result);
        }
Beispiel #10
0
        /// <summary>
        /// Get the details of a bug, reading a xml structure.
        /// </summary>
        /// <param name="htmlContent"></param>
        /// <returns></returns>
        private MyZilla.BusinessEntities.Bug GetBugDetailsFromXml(string urlBase,  string urlEnding, string charset)
        {
            MyZilla.BusinessEntities.Bug result = new MyZilla.BusinessEntities.Bug();

            try
            {

                HttpHelper httpDialog = new HttpHelper(_connectionId, charset);

                string strContent =  httpDialog.GetFromUrl(urlBase + urlEnding, false);

            #if DEBUG
                //string bugDetailsFile = @"C:\Documents and Settings\Marius Zavoi\Desktop\LogFiles\show_bug.xml";
                //if (File.Exists(bugDetailsFile)){
                //    TextReader reader = new StreamReader(bugDetailsFile);
                //    using (reader) {
                //        strContent = reader.ReadToEnd();
                //    }
                //}
            #endif

                XmlDocument doc = new XmlDocument();

                string toFind = "urlbase=\"";

                int startIndex = strContent.IndexOf(toFind);

                int endIndex = strContent.IndexOf('"', startIndex + toFind.Length);

                string[] list = strContent.Substring(startIndex + toFind.Length, endIndex - startIndex - toFind.Length).Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries);

                if (list != null && list.GetLength(0)>0)
                    strContent = strContent.Replace(list[0], urlBase);
                else
                    strContent = strContent.Replace(toFind + "\"", toFind + urlBase + "\"");

                startIndex = strContent.IndexOf("<!DOCTYPE");
                if (startIndex >= 0)
                {
                    endIndex = strContent.IndexOf(">", startIndex);

                    string xmlType = strContent.Substring(startIndex, endIndex - startIndex + 1);

                    strContent = strContent.Replace(xmlType, string.Empty);
                }

                doc.LoadXml(CleanInvalidXmlChars(strContent));

                XmlNodeList bugDetail = doc.GetElementsByTagName("bug");

                result = GetBug(bugDetail[0]);

            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "GetBugDetailsFromXml", LoggingCategory.Exception);

                result.ErrorMessage = ex.Message;
            }

            return result;
        }
Beispiel #11
0
        public string PostHttpRequest_UpdateBug(MyZilla.BusinessEntities.Bug bug, string bugzillaVersion)
        {
            StringBuilder sb = new StringBuilder();

            //Encoding bugzillaEncoding = Encoding.GetEncoding("utf-8");
            Encoding bugzillaEncoding = Encoding.GetEncoding(this._charset);

            #region Build data to be posted

            if (bugzillaVersion.StartsWith("2.18"))
            {
                sb.AppendFormat("&delta_ts={0}", bug.Changed.ToString("yyyyMMddHHmmss"));
            }
            else
            {
                sb.AppendFormat("&delta_ts={0}", HttpUtility.UrlEncode(bug.Changed.ToString("yyyy-MM-dd HH:mm:ss"), bugzillaEncoding));
            }

            sb.AppendFormat("&longdesclength={0}", 1); // mmi
            sb.AppendFormat("&id={0}", bug.Id);
            sb.AppendFormat("&token={0}", bug.Token);
            sb.AppendFormat("&alias={0}", "");
            sb.AppendFormat("&short_desc={0}", HttpUtility.UrlEncode(bug.Summary, bugzillaEncoding));
            sb.AppendFormat("&product={0}", HttpUtility.UrlEncode(bug.Product, bugzillaEncoding));
            sb.AppendFormat("&component={0}", HttpUtility.UrlEncode(bug.Component, bugzillaEncoding));
            sb.AppendFormat("&rep_platform={0}", HttpUtility.UrlEncode(bug.Hardware, bugzillaEncoding));
            sb.AppendFormat("&op_sys={0}", HttpUtility.UrlEncode(bug.OS, bugzillaEncoding));
            sb.AppendFormat("&version={0}", HttpUtility.UrlEncode(bug.Version, bugzillaEncoding));
            sb.AppendFormat("&priority={0}", HttpUtility.UrlEncode(bug.Priority, bugzillaEncoding));
            sb.AppendFormat("&bug_severity={0}", HttpUtility.UrlEncode(bug.Severity, bugzillaEncoding));
            sb.AppendFormat("&assigned_to={0}", HttpUtility.UrlEncode(bug.AssignedTo, bugzillaEncoding));
            sb.AppendFormat("&qa_contact={0}", HttpUtility.UrlEncode("", bugzillaEncoding));
            sb.AppendFormat("&target_milestone={0}", HttpUtility.UrlEncode(bug.Milestone, bugzillaEncoding));
            sb.AppendFormat("&bug_file_loc={0}", HttpUtility.UrlEncode(bug.Url, bugzillaEncoding));
            sb.AppendFormat("&status_whiteboard={0}", HttpUtility.UrlEncode(bug.StatusWhiteboard, bugzillaEncoding));
            sb.AppendFormat("&keywords={0}", HttpUtility.UrlEncode("", bugzillaEncoding));
            sb.AppendFormat("&dependson={0}", bug.DependsOn);
            sb.AppendFormat("&blocked={0}", bug.Blocks);
            sb.AppendFormat("&newcc={0}", HttpUtility.UrlEncode("", bugzillaEncoding));
            sb.AppendFormat("&cf_custom_field={0}", HttpUtility.UrlEncode("", bugzillaEncoding));
            sb.AppendFormat("&defined_cf_colo={0}", HttpUtility.UrlEncode("", bugzillaEncoding));
            sb.AppendFormat("&cf_color={0}", HttpUtility.UrlEncode("---", bugzillaEncoding));
            sb.AppendFormat("&cf_datetime={0}", HttpUtility.UrlEncode("", bugzillaEncoding));

            sb.AppendFormat("&flag_type-8={0}", HttpUtility.UrlEncode("X", bugzillaEncoding));
            sb.AppendFormat("&flag_type-9={0}", HttpUtility.UrlEncode("X", bugzillaEncoding));
            sb.AppendFormat("&flag_type-11={0}", HttpUtility.UrlEncode("X", bugzillaEncoding));
            sb.AppendFormat("&flag_type-10={0}", HttpUtility.UrlEncode("X", bugzillaEncoding));
            sb.AppendFormat("&flag_type-6={0}", HttpUtility.UrlEncode("X", bugzillaEncoding));

            sb.AppendFormat("&estimated_time={0}", HttpUtility.UrlEncode("0.0", bugzillaEncoding));
            sb.AppendFormat("&work_time={0}", HttpUtility.UrlEncode("0", bugzillaEncoding));
            sb.AppendFormat("&remaining_time={0}", HttpUtility.UrlEncode("0.0", bugzillaEncoding));

            sb.AppendFormat("&deadline={0}", HttpUtility.UrlEncode("", bugzillaEncoding));

            sb.AppendFormat("&comment={0}", HttpUtility.UrlEncode(bug.Comment[bug.Comment.Count - 1], bugzillaEncoding));

            sb.AppendFormat("&knob={0}", bug.Knob);  // mmi
            sb.AppendFormat("&resolution={0}", HttpUtility.UrlEncode(bug.Resolution, bugzillaEncoding));

            sb.AppendFormat("&bug_status={0}", HttpUtility.UrlEncode(bug.Status, bugzillaEncoding));

            sb.AppendFormat("&addtonewgroup={0}", "yesifinold");

            //&estimated_time=0.0
            //&work_time=0
            //&remaining_time=0.0
            //&deadline=
            //&comment=ddd
            //&bug_status=NEW

            //&dup_id=
            //&defined_isprivate_13662=1
            //&defined_isprivate_13724=1

            if (bug.DuplicateBug != null)
            {
                sb.AppendFormat("&dup_id={0}", bug.DuplicateBug);
            }

            #region CC
            if (bug.CC != null && bug.CC.Count > 0)
            {
                for (int i = 0; i < bug.CC.Count; i++)
                {
                    string itemCC = bug.CC[i];

                    string[] elements = itemCC.Split(',');

                    if (elements.Length == 2)
                    {
                        switch (elements[1])
                        {
                        case "removecc":
                            // cc=mzavoi%40tremend.ro&removecc=on
                            sb.AppendFormat("&cc={0}&removecc=on", HttpUtility.UrlEncode(elements[0], bugzillaEncoding));
                            break;

                        case "newcc":
                            sb.AppendFormat("&newcc={0}", HttpUtility.UrlEncode(elements[0], bugzillaEncoding));
                            break;
                        }
                    }
                    else
                    {
                        // no code here.
                    }
                }
            }
            #endregion



            #endregion

            // spaces have to be replaced bu "+"
            string dataToPost = sb.Replace(" ", "+").ToString();

            return(dataToPost);
        }
Beispiel #12
0
        public MyZilla.BusinessEntities.Bug GetBugDetails()
        {
            ep.Clear();

            MyZilla.BusinessEntities.Bug result = new Bug();

            try
            {

                result.Reporter = txtReporter.Text;

                result.Product = cmbProduct.SelectedValue.ToString();

                result.Component = cmbComponent.SelectedValue.ToString();

                result.Version = cmbVersion.SelectedValue.ToString();

                if (cmbMilestone.SelectedValue != null)
                {
                    result.Milestone = cmbMilestone.SelectedValue.ToString();
                }

                result.Priority = cmbPriority.SelectedValue.ToString();

                if (cmbAssignedTo.SelectedValue != null)
                    result.AssignedTo = cmbAssignedTo.SelectedValue.ToString().TrimStart('<').TrimEnd('>');
                else
                    result.AssignedTo = cmbAssignedTo.Text;

                result.Status = cmbStatus.SelectedValue.ToString();

                result.OS = cmbOS.SelectedValue.ToString();

                result.Severity = cmbSeverity.SelectedValue.ToString();

                result.Hardware = cmbHardware.SelectedValue.ToString();

                result.DependsOn = txtDependsOn.Text;

                result.Blocks = txtBlock.Text;

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

                        result.CC.Add(item);

                    }
                }

                result.Url = txtURL.Text;

                result.Summary = txtSummary.Text;

                result.Comment.Add(txtComment.Text);

                // attachment

                result.Attachments = addedBug.Attachments;

            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "GetBugDetails", LoggingCategory.Exception);

                throw;

            }

            return result;
        }
Beispiel #13
0
        /// <summary>
        /// Get the details of a bug, reading a xml structure.
        /// </summary>
        /// <param name="htmlContent"></param>
        /// <returns></returns>
        private MyZilla.BusinessEntities.Bug GetBugDetailsFromXml(string urlBase, string urlEnding, string charset)
        {
            MyZilla.BusinessEntities.Bug result = new MyZilla.BusinessEntities.Bug();

            try
            {
                HttpHelper httpDialog = new HttpHelper(_connectionId, charset);

                string strContent = httpDialog.GetFromUrl(urlBase + urlEnding, false);

#if DEBUG
                //string bugDetailsFile = @"C:\Documents and Settings\Marius Zavoi\Desktop\LogFiles\show_bug.xml";
                //if (File.Exists(bugDetailsFile)){
                //    TextReader reader = new StreamReader(bugDetailsFile);
                //    using (reader) {
                //        strContent = reader.ReadToEnd();
                //    }
                //}
#endif

                XmlDocument doc = new XmlDocument();

                string toFind = "urlbase=\"";

                int startIndex = strContent.IndexOf(toFind);

                int endIndex = strContent.IndexOf('"', startIndex + toFind.Length);

                string[] list = strContent.Substring(startIndex + toFind.Length, endIndex - startIndex - toFind.Length).Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries);

                if (list != null && list.GetLength(0) > 0)
                {
                    strContent = strContent.Replace(list[0], urlBase);
                }
                else
                {
                    strContent = strContent.Replace(toFind + "\"", toFind + urlBase + "\"");
                }

                startIndex = strContent.IndexOf("<!DOCTYPE");
                if (startIndex >= 0)
                {
                    endIndex = strContent.IndexOf(">", startIndex);

                    string xmlType = strContent.Substring(startIndex, endIndex - startIndex + 1);

                    strContent = strContent.Replace(xmlType, string.Empty);
                }

                doc.LoadXml(CleanInvalidXmlChars(strContent));

                XmlNodeList bugDetail = doc.GetElementsByTagName("bug");

                result = GetBug(bugDetail[0]);
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "GetBugDetailsFromXml", LoggingCategory.Exception);

                result.ErrorMessage = ex.Message;
            }

            return(result);
        }
Beispiel #14
0
        public string PostMultipartWhenAddingBug(Bug addedBug, string myzillaUrl)
        {
            string result = string.Empty;

            try
            {
                string url = String.Concat(myzillaUrl, UPDATE_BUG_PAGE);

                MultipartForm mPost = new MultipartForm(url, _userID );

                mPost.SetField("product", HttpUtility.UrlEncode(addedBug.Product));
                mPost.SetField("version", HttpUtility.UrlEncode(addedBug.Version));
                mPost.SetField("component", HttpUtility.UrlEncode(addedBug.Component));
                mPost.SetField("bug_severity", HttpUtility.UrlEncode(addedBug.Severity));
                mPost.SetField("rep_platform", HttpUtility.UrlEncode(addedBug.Hardware));
                mPost.SetField("priority", HttpUtility.UrlEncode(addedBug.Priority));
                mPost.SetField("op_sys", HttpUtility.UrlEncode(addedBug.OS));

                if (!string.IsNullOrEmpty(addedBug.Milestone))
                    mPost.SetField("target_milestone", HttpUtility.UrlEncode(addedBug.Milestone));

                mPost.SetField("bug_status", HttpUtility.UrlEncode(addedBug.Status));
                mPost.SetField("assigned_to", HttpUtility.UrlEncode(addedBug.AssignedTo));

                // can be 1 cc
                if (addedBug.CC != null && addedBug.CC.Count == 1)
                {
                    mPost.SetField("cc", HttpUtility.UrlEncode(addedBug.CC[0]));
                }
                mPost.SetField("bug_file_loc", HttpUtility.UrlEncode(addedBug.Url));
                mPost.SetField("short_desc", HttpUtility.UrlEncode(addedBug.Summary));
                if (addedBug.Comment != null && addedBug.Comment.Count >= 1)
                {
                    mPost.SetField("comment", HttpUtility.UrlEncode(addedBug.Comment[0]) );
                }

                mPost.SetField("dependson", HttpUtility.UrlEncode(addedBug.DependsOn));
                mPost.SetField("blocked", HttpUtility.UrlEncode(addedBug.Blocks));
                mPost.SetField("form_name", "enter_bug");

                if (addedBug.Attachments.Count > 0)
                {
                    mPost.SetField("contenttypemethod", "autodetect");
                    mPost.SetField("contenttypeselection", "text/plain");
                    mPost.SetField("contenttypeentry", String.Empty);
                    mPost.SetField("description", HttpUtility.UrlEncode(addedBug.Attachments[0].Description));
                    mPost.FileContentType = addedBug.Attachments[0].ContentType;
                    mPost.SendFile(addedBug.Attachments[0].FileName);

                }
                else
                {
                    mPost.SendFile(String.Empty);
                }

                result = mPost.ResponseText.ToString();

            }
            catch (Exception ex)
            {
                MyLogger.WriteWithStack(ex.Message, "PostMultipartWhenAddingBug", LoggingCategory.Exception);

                throw;

            }

            return result;
        }
Beispiel #15
0
        /// <summary>
        /// Walks through the node element and fills a bug object
        /// </summary>
        /// <param name="BugNode"></param>
        /// <returns></returns>
        private static Bug GetBug(XmlNode BugNode)
        {
            Bug bugResult = new Bug();

            XmlElement bugElement = (XmlElement)BugNode;

            try{

                if (bugElement.HasAttributes)
                {
                    string errorMessage = bugElement.Attributes["error"].InnerText;

                    if (!string.IsNullOrEmpty(errorMessage))
                    {
                        bugResult.ErrorMessage = errorMessage;

                        return bugResult;
                    }
                }

                string comment = string.Empty;

                #region Get object properties

                if (bugElement.GetElementsByTagName("alias").Count == 1)
                {
                    bugResult.Alias = bugElement.GetElementsByTagName("alias")[0].InnerText;
                }

                bugResult.Id = int.Parse(bugElement.GetElementsByTagName("bug_id")[0].InnerText);

                bugResult.Product = bugElement.GetElementsByTagName("product")[0].InnerText;

                bugResult.Component = bugElement.GetElementsByTagName("component")[0].InnerText;

                bugResult.Status = bugElement.GetElementsByTagName("bug_status")[0].InnerText;

                bugResult.AssignedTo = bugElement.GetElementsByTagName("assigned_to")[0].InnerText;

                if (bugElement.GetElementsByTagName("bug_file_loc").Count == 1)
                {

                    bugResult.Url = bugElement.GetElementsByTagName("bug_file_loc")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("short_desc").Count == 1)
                {

                    bugResult.FullSummary = bugElement.GetElementsByTagName("short_desc")[0].InnerText;

                    bugResult.Summary = bugResult.FullSummary.Substring(0, Math.Min(bugResult.FullSummary.Length, 60));
                }

                if (bugElement.GetElementsByTagName("rep_platform").Count == 1)
                {

                    bugResult.Hardware = bugElement.GetElementsByTagName("rep_platform")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("op_sys").Count == 1)
                {

                    bugResult.OS = bugElement.GetElementsByTagName("op_sys")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("version").Count == 1)
                {

                    bugResult.Version = bugElement.GetElementsByTagName("version")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("priority").Count == 1)
                {

                    bugResult.Priority = bugElement.GetElementsByTagName("priority")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("bug_severity").Count == 1)
                {

                    bugResult.Severity = bugElement.GetElementsByTagName("bug_severity")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("reporter").Count == 1)
                {

                    bugResult.Reporter = bugElement.GetElementsByTagName("reporter")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("clasification").Count == 1)
                {

                    bugResult.Classification = bugElement.GetElementsByTagName("clasification")[0].InnerText;
                }

                //result.Created
                string dateAsString = bugElement.GetElementsByTagName("creation_ts")[0].InnerText;
                DateTime value;

                //prevent wrond date parsing by removing PST, PDT, CET ...
                //(some database datetime values particularity) with  empty string
                Regex dateFieldEnding = new Regex(@" [A-Z]+", RegexOptions.IgnoreCase);

                dateAsString = dateFieldEnding.Replace(dateAsString, string.Empty);

                bool success = DateTime.TryParse(dateAsString, out value);

                if (success)
                    bugResult.Created = value;

                //read bug CHANGED date
                dateAsString = bugElement.GetElementsByTagName("delta_ts")[0].InnerText;

                dateAsString = dateFieldEnding.Replace(dateAsString, string.Empty);

                success = DateTime.TryParse(dateAsString, out value);

                if (success)
                {
                    bugResult.Changed = value;
                }

                if (bugElement.GetElementsByTagName("resolution").Count == 1)
                {

                    bugResult.Resolution = bugElement.GetElementsByTagName("resolution")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("target_milestone").Count == 1)
                {

                    bugResult.Milestone = bugElement.GetElementsByTagName("target_milestone")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("status_whiteboard").Count == 1)
                {

                    bugResult.StatusWhiteboard = bugElement.GetElementsByTagName("status_whiteboard")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("dependson").Count == 1)
                {

                    bugResult.DependsOn = bugElement.GetElementsByTagName("dependson")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("token").Count >= 1)
                {

                    bugResult.Token = bugElement.GetElementsByTagName("token")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("blocked").Count == 1)
                {

                    bugResult.Blocks = bugElement.GetElementsByTagName("blocked")[0].InnerText;
                }

                if (bugElement.GetElementsByTagName("cc").Count >= 1)
                {
                    for (int i = 0; i < bugElement.GetElementsByTagName("cc").Count; i++)
                    {
                        string strCC = bugElement.GetElementsByTagName("cc")[i].InnerText;

                        if (!string.IsNullOrEmpty(strCC))
                        {
                            bugResult.CC.Add(strCC);

                        }
                    }

                }

                //getting comments (first comment is the long description): "Description" is the label from the web interface
                int nrOfComments = bugElement.GetElementsByTagName("who").Count;
                for (int i = 0; i < nrOfComments; i++)
                {
                    comment = String.Empty;
                    comment = bugElement.GetElementsByTagName("who")[i].InnerText;
                    comment += " , " + bugElement.GetElementsByTagName("bug_when")[i].InnerText;
                    comment += " , " + bugElement.GetElementsByTagName("thetext")[i].InnerText.Replace("System.Collections.Generic.List`1[System.String]", String.Empty);

                    bugResult.Comment.Add(comment);
                }

                //getting comments (first comment is the long description): "Description" is the label from the web interface
                int nrOfAttachments = bugElement.GetElementsByTagName("attachment").Count;
                for (int i = 0; i < nrOfAttachments; i++)
                {
                    Attachment newAttachment = new Attachment();

                    newAttachment.AttachmentId = int.Parse(bugElement.GetElementsByTagName("attachid")[i].InnerText);

                    //replace PST(some database datetime values particularity) with  empty string
                    string attachmentCreatedOn = bugElement.GetElementsByTagName("date")[i].InnerText;

                    attachmentCreatedOn = dateFieldEnding.Replace(attachmentCreatedOn, string.Empty);

                    success = DateTime.TryParse(attachmentCreatedOn, out value);

                    if (success)
                        newAttachment.Created = DateTime.Parse(attachmentCreatedOn);

                    newAttachment.Description = bugElement.GetElementsByTagName("desc")[i].InnerText;
                    if (bugElement.GetElementsByTagName("ctype")[i] != null)
                    {
                        newAttachment.ContentType = bugElement.GetElementsByTagName("ctype")[i].InnerText;
                    }
                    if (bugElement.GetElementsByTagName("type")[i] != null)
                    {
                        newAttachment.ContentType = bugElement.GetElementsByTagName("type")[i].InnerText;
                    }
                    if (bugElement.GetElementsByTagName("size")[i] != null)
                    {
                        newAttachment.Size = long.Parse(bugElement.GetElementsByTagName("size")[i].InnerText);
                    }
                    if (bugElement.GetElementsByTagName("filename")[i] != null)
                    {
                        newAttachment.FileName = bugElement.GetElementsByTagName("filename")[i].InnerText;
                    }

                    newAttachment.Operation = AttachmentOperation.Unchanged;

                    bugResult.Attachments.Add(newAttachment);
                }

                #endregion
            }catch(Exception ex){
                bugResult.ErrorMessage = ex.Message;

                MyLogger.WriteWithStack(ex.Message, "GetBug", LoggingCategory.Exception);
            }

            return bugResult;
        }
Beispiel #16
0
        public void Submit()
        {
            try
            {
                bool isValid = this.CheckConditionsForSaving();

                if (isValid == true)
                {
                    bugToUpdate = GetUpdatedBug();

                    if (bugToUpdate == null)
                    {
                        return;
                    }

                    if (bugLastUpdatedSeconds != null)
                        bugToUpdate.Changed = bugToUpdate.Changed.AddSeconds(bugLastUpdatedSeconds);

                    //// check for modifications
                    //if (bugToUpdate.isDirty == false)
                    //{
                    //    Messages.UpdBugOK

                    //}
                    BackgroundWorker bkgBugUpdate = new BackgroundWorker();

                    bkgBugUpdate.DoWork += new DoWorkEventHandler(bkgBugUpdate_DoWork);

                    bkgBugUpdate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bkgBugUpdate_RunWorkerCompleted);

                    bkgBugUpdate.ProgressChanged += new ProgressChangedEventHandler(bkgBugUpdate_ProgressChanged);

                    bkgBugUpdate.WorkerReportsProgress = true;

                    bkgBugUpdate.WorkerSupportsCancellation = true;

                    // start run async thread.
                    bkgBugUpdate.RunWorkerAsync();

                    btnSave.Enabled = false;
                }
                else
                {
                    // no code here
                }
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "Submit", LoggingCategory.Exception);

                MessageBox.Show("Update bug failed" + Environment.NewLine + ex.Message);
            }
        }
Beispiel #17
0
        public static bool ValidateBugStateTransition(Bug bug, Bug bugValuesToBeChanged)
        {
            bool result = false;

            string bugStatus = bug.Status.ToUpper();

            string knob = bugValuesToBeChanged.Knob.ToLower();

            result = ((bugStatus == BugStatus.UNCONFIRMED && (knob == BugKnob.CONFIRM
                                                                || knob == BugKnob.ACCEPT
                                                                || knob == BugKnob.RESOLVE
                                                                || knob == BugKnob.DUPLICATE
                                                                || knob == BugKnob.REASSIGN))

                    || (bugStatus == BugStatus.NEW && (knob == BugKnob.ACCEPT
                                                        || knob == BugKnob.RESOLVE
                                                        || knob == BugKnob.DUPLICATE
                                                        || knob == BugKnob.REASSIGN))

                    || (bugStatus == BugStatus.ASSIGNED && (knob == BugKnob.RESOLVE
                                                            || knob == BugKnob.DUPLICATE
                                                            || knob == BugKnob.REASSIGN))

                    || (bugStatus == BugStatus.RESOLVED && (knob == BugKnob.CHANGE_RESOLUTION
                                                            || knob == BugKnob.REOPEN
                                                            || knob == BugKnob.DUPLICATE
                                                            || knob == BugKnob.VERIFY
                                                            || knob == BugKnob.REASSIGN  //?
                                                            || knob == BugKnob.CLOSE))

                    || (bugStatus == BugStatus.REOPENED && (knob == BugKnob.RESOLVE
                                                        || knob == BugKnob.DUPLICATE
                                                        || knob == BugKnob.REASSIGN))

                    || (bugStatus == BugStatus.VERIFIED && (knob == BugKnob.CHANGE_RESOLUTION
                                                            || knob == BugKnob.REOPEN
                                                            || knob == BugKnob.DUPLICATE
                                                            || knob == BugKnob.REASSIGN //?
                                                            || knob == BugKnob.CLOSE))

                    || (bugStatus == BugStatus.CLOSED && (knob == BugKnob.CHANGE_RESOLUTION
                                                            || knob == BugKnob.REOPEN
                                                            || knob == BugKnob.DUPLICATE))
                    || (knob == BugKnob.NONE && (!String.IsNullOrEmpty(bugValuesToBeChanged.Severity) || !String.IsNullOrEmpty(bugValuesToBeChanged.Priority)))
                    );
            //|| (true));

            return result;
        }
Beispiel #18
0
        void ResolvedOtherItem_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                string resolution = sender.ToString();

                Bug bugsPropToBeChanged = new Bug();
                bugsPropToBeChanged.Knob = BugKnob.RESOLVE;
                bugsPropToBeChanged.Resolution = resolution;

                this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);

            }
        }
Beispiel #19
0
        void PriorityItem_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                string priority = sender.ToString();

                Bug bugsPropToBeChanged = new Bug();
                bugsPropToBeChanged.Knob = BugKnob.NONE;
                bugsPropToBeChanged.Priority = priority;

                this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);

            }
        }
Beispiel #20
0
        private void miReopenBugs(object sender, EventArgs e)
        {
            Bug bugsPropToBeChanged = new Bug();
            bugsPropToBeChanged.Knob = BugKnob.REOPEN;
            bugsPropToBeChanged.Resolution = String.Empty;

            this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);
        }
Beispiel #21
0
        private void fixedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bug bugsPropToBeChanged = new Bug();
            bugsPropToBeChanged.Knob = BugKnob.RESOLVE;
            bugsPropToBeChanged.Resolution = BugResolution.FIXED;

            StartAsyncBulkUpdateBugs(bugsPropToBeChanged);
        }
Beispiel #22
0
        private BulkUpdateResult BulkUpdateBugs(Bug bugValuesToBeChanged)
        {
            BulkUpdateResult result = new BulkUpdateResult();

            // get the selected bugs
            SortedList bugs = new SortedList(dgvResults.SelectedRows.Count);
            //string result = string.Empty;

            DataGridViewSelectedRowCollection selRows = dgvResults.SelectedRows;

            int countSelectedBugs = 0;

            if (selRows != null)
            {
                countSelectedBugs = selRows.Count;

                for (int i = 0; i < selRows.Count; i++)
                {
                    DataGridViewRow row = selRows[i];

                    int bugID = int.Parse(row.Cells[BUG_ID_COL_NAME].Value.ToString());

                    Bug bug = GetBugFromCache(bugID);

                    if (bug != null)
                    {
                        if (Utils.ValidateBugStateTransition(bug, bugValuesToBeChanged))
                            bugs.Add(bugID, bugID);
                    }
                    else {
                        //MessageBox.Show("Bug(s) details not loaded yet!");
                        result.CountBugs = 0;
                        result.Message = "Bug(s) details not loaded yet!";

                        return result;
                    }
                }
            }

            result.CountBugs = bugs.Count;
            result.BugsList = (SortedList)bugs.Clone();

            if (bugs.Count > 0)
            {

                IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(_connectionId);
                string strError = null;

                result.Message = bugInterface.UpdateBugs(bugs, bugValuesToBeChanged, out strError);

                if (!string.IsNullOrEmpty(strError))
                {
                    throw new Exception(strError);
                }
                else {
                    if(countSelectedBugs > bugs.Count){
                        result.Message = "Only bugs that have a valid bug status transition have been updated!" + Environment.NewLine + "Bugs updated: " + result.ListOfBugs;
                    }
                }
            }
            else
            {
                result.Message = Messages.NoBugWithValidStatusTransition;
            }

            #if DEBUG
            (Utils.FormContainer as MainForm).wb.DocumentText = MyZilla.BL.Interfaces.Utils.htmlContents;
            #endif

            return result;
        }
Beispiel #23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="htmlContent"></param>
        public void ParseCsvGettingBugs(object htmlContent)
        {
            ArrayList alResult;
            string[] contentLines = ((String)htmlContent).Split('\n');
            //using (StreamReader objReader = new StreamReader(txtCSVPath.Text.Trim()))
            //{
            int lineIndex = 0;
            const int headerIndex = 0;
            ArrayList Cols = new ArrayList();
            MyZilla.BusinessEntities.Bug newBug;

            DateTime result;

            char csvSeparator = ',';

            if (contentLines.GetLength(0) > 0)
            {
                alResult = CsvParser.Parse(contentLines[0], csvSeparator);

                if (alResult == null || alResult.Count == 0) {
                    csvSeparator = ';';
                }

                foreach (string strLineText in contentLines)
                {
                    alResult = CsvParser.Parse(strLineText, csvSeparator);

                    if (alResult == null || alResult.Count == 0)
                    {
                        MyLogger.Write(" Parsing cvs bugs list failed.", "ParseCsvGettingBugs", LoggingCategory.Exception);
                        continue;
                    }

                    if (lineIndex == headerIndex)
                        Cols = alResult;
                    else
                    {
                        bool success;
                        newBug = new Bug();
                        for (int s = 0; s < alResult.Count; s++)
                        {
                            string currentTDValue = alResult[s].ToString();
                            #region set properties of the bug
                            switch (Cols[s].ToString())
                            {
                                case "bug_id":
                                    newBug.Id = Int32.Parse(currentTDValue);
                                    break;

                                case "alias":
                                    newBug.Alias = currentTDValue;
                                    break;

                                case "opendate":
                                    result = new DateTime();
                                    success = DateTime.TryParse(currentTDValue, out result);
                                    if (success)
                                        newBug.Created = result;
                                    else
                                        newBug.Created = new DateTime();
                                    break;

                                case "changeddate":
                                    result = new DateTime();
                                    success = DateTime.TryParse(currentTDValue, out result);
                                    if (success)
                                        newBug.Changed = result;
                                    else
                                        newBug.Changed = new DateTime();
                                    break;

                                case "bug_severity":
                                    newBug.Severity = currentTDValue;
                                    break;

                                case "priority":
                                    newBug.Priority = currentTDValue;
                                    break;

                                case "rep_platform":
                                    newBug.Hardware = currentTDValue;
                                    break;

                                case "assigned_to":
                                    newBug.AssignedTo = currentTDValue;
                                    break;

                                case "assigned_to_realname":
                                    newBug.AssignedToRealName = currentTDValue;
                                    break;

                                case "reporter":
                                    newBug.Reporter = currentTDValue;
                                    break;

                                case "reporter_realname":
                                    newBug.ReporterRealName = currentTDValue;
                                    break;

                                case "bug_status":
                                    newBug.Status = currentTDValue;
                                    break;

                                case "resolution":
                                    newBug.Resolution = currentTDValue;
                                    break;

                                case "classification":
                                    newBug.Classification = currentTDValue;
                                    break;

                                case "product":
                                    newBug.Product = currentTDValue;
                                    break;

                                case "component":
                                    newBug.Component = currentTDValue;
                                    break;

                                case "version":
                                    newBug.Version = currentTDValue;
                                    break;

                                case "op_sys":
                                    newBug.OS = currentTDValue;
                                    break;

                                case "votes":
                                    newBug.Votes = currentTDValue;
                                    break;

                                case "target_milestone":
                                    newBug.TargetMilestone = currentTDValue;
                                    break;

                                case "qa_contact":
                                    newBug.QAContact = currentTDValue;
                                    break;

                                case "qa_contact_realname":
                                    newBug.QAContact = currentTDValue;
                                    break;

                                case "status_whiteboard":
                                    newBug.StatusWhiteboard = currentTDValue;
                                    break;

                                case "keywords":
                                    newBug.Keywords = currentTDValue;
                                    break;

                                case "estimated_time":
                                    newBug.EstimatedTime = currentTDValue;
                                    break;

                                case "remaining_time":
                                    newBug.RemainingTime = currentTDValue;
                                    break;

                                case "actual_time":
                                    newBug.ActualTime = currentTDValue;
                                    break;

                                case "percentage_complete":
                                    newBug.PercentageComplete = currentTDValue;
                                    break;

                                case "deadline":
                                    result = new DateTime();
                                    success = DateTime.TryParse(currentTDValue, out result);
                                    if (success)
                                        newBug.Deadline = result;
                                    break;

                                case "short_desc":
                                    newBug.FullSummary = currentTDValue;
                                    break;

                                case "short_short_desc":
                                    newBug.Summary = currentTDValue;
                                    break;

                                case "cf_custom_field":
                                    newBug.CustomField = currentTDValue;
                                    break;

                                default:
                                    break;
                            }

                            #endregion
                        }

                        this.bugs.Add(newBug);
                    }

                    lineIndex++;
                }
            }
            //}

            #region old way (parse pure html)
            //string[] Cols = GetColumnsToBeDisplayedFromCookie();

            //WebBrowser wbHTMLDoc = new WebBrowser();

            //wbHTMLDoc.ScriptErrorsSuppressed = true;

            //wbHTMLDoc.Navigate("about:blank");

            //HtmlDocument doc = wbHTMLDoc.Document;

            //doc.Write(string.Empty);

            ////set the response HTML in the web browser control
            //wbHTMLDoc.DocumentText = htmlContent.ToString();

            ////associate complete event
            //wbHTMLDoc.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wbHTMLDoc_DocumentCompleted);

            ////forces events to execute
            ////(wihtout this, property Document of the web browser control is null)

            //Thread.Sleep(200);

            //Application.DoEvents();

            //HtmlDocument htmlDoc = wbHTMLDoc.Document;

            //HtmlElementCollection htmlElemCollection = htmlDoc.GetElementsByTagName("Table");

            //int nrOfBugs;

            //BSI.BusinessEntities.Bug newBug;
            //bugs = new List<BSI.BusinessEntities.Bug>();

            //foreach (HtmlElement htmlElem in htmlElemCollection)
            //{
            //    HtmlElementCollection htmlElem2 = htmlElem.GetElementsByTagName("colgroup");
            //    if (htmlElem2 != null)
            //    {
            //        HtmlElementCollection htmlTRCollection = htmlElem.GetElementsByTagName("tr");
            //        if (htmlTRCollection != null)
            //        {

            //            nrOfBugs = htmlTRCollection.Count - 1;

            //            string currentTDValue = String.Empty;

            //            //start from 1 (first tr contains the header)
            //            for (int bugIndex = 0; bugIndex < nrOfBugs; bugIndex++)
            //            {
            //                newBug = new BSI.BusinessEntities.Bug();

            //                //GetBug columns collections
            //                //(each columns contains a value for a field of the bug)
            //                HtmlElementCollection htmlTDCollection = htmlTRCollection[bugIndex+1].GetElementsByTagName("td");

            //                //bug id is always in the first column in "a href"
            //                currentTDValue = htmlTDCollection[0].GetElementsByTagName("a")[0].OuterText;

            //                //set the ID of the bug
            //                newBug.ID = Int32.Parse(currentTDValue);

            //                DateTime result;
            //                bool success;

            //                for (int s = 0; s < htmlTDCollection.Count - 1; s++)
            //                {
            //                    //get value from the current column
            //                    currentTDValue = htmlTDCollection[s + 1].OuterText;

            //                    #region set properties of the bug
            //                    switch (Cols[s].ToString())
            //                    {
            //                        case "opendate":
            //                            result = new DateTime();
            //                            success = DateTime.TryParse(currentTDValue, out result);
            //                            newBug.Created = result;
            //                            break;
            //                        case "changeddate":
            //                            result = new DateTime();
            //                            success = DateTime.TryParse(currentTDValue, out result);
            //                            newBug.Changed = result;
            //                            break;
            //                        case "bug_severity":
            //                            newBug.Severity = currentTDValue;
            //                            break;
            //                        case "priority":
            //                            newBug.Priority = currentTDValue;
            //                            break;
            //                        case "rep_platform":
            //                            newBug.Hardware = currentTDValue;
            //                            break;
            //                        case "assigned_to":
            //                            newBug.AssignedTo = currentTDValue;
            //                            break;
            //                        case "assigned_to_realname":
            //                            newBug.AssignedToRealName = currentTDValue;
            //                            break;
            //                        case "reporter":
            //                            newBug.Reporter = currentTDValue;
            //                            break;
            //                        case "reporter_realname":
            //                            newBug.ReporterRealName = currentTDValue;
            //                            break;
            //                        case "bug_status":
            //                            newBug.Status = currentTDValue;
            //                            break;
            //                        case "resolution":
            //                            newBug.Resolution = currentTDValue;
            //                            break;
            //                        case "product":
            //                            newBug.Product = currentTDValue;
            //                            break;
            //                        case "component":
            //                            newBug.Component = currentTDValue;
            //                            break;
            //                        case "version":
            //                            newBug.Version = currentTDValue;
            //                            break;
            //                        case "op_sys":
            //                            newBug.OS = currentTDValue;
            //                            break;
            //                        case "votes":
            //                            newBug.Votes = currentTDValue;
            //                            break;
            //                        case "status_whiteboard":
            //                            newBug.StatusWhiteboard = currentTDValue;
            //                            break;
            //                        case "short_desc":
            //                            newBug.FullSummary = currentTDValue;
            //                            break;
            //                        case "short_short_desc":
            //                            newBug.Summary = currentTDValue;
            //                            break;
            //                    }

            //                    #endregion
            //                }

            //                bugs.Add(newBug);
            //            }

            //            //return bugs;
            //        }

            //    }
            //}

            ////return null;

            //#region old way of getting bugs from a search operation
            ////htmlContent = httpDialog.GetHTML(htmlContent, @"<table class=""bz_buglist""", @"</table>");
            ////int Pos = 0;
            ////string htmlRow = String.Empty;
            ////string[] values;

            ////string htmlHeaderRow = httpDialog.GetNextRowInTable(htmlContent, ref Pos);
            //////for each th in htmlHeaderRow

            ////string[] headerColumns = httpDialog.GetValuesFromTableRow(htmlHeaderRow, "th");

            ////while ((htmlRow = httpDialog.GetNextRowInTable(htmlContent, ref Pos)).Length>0)
            ////{
            ////    //contains the values of the bug fields
            ////    values = httpDialog.GetValuesFromTableRow(htmlRow, "td");
            ////}

            ////return new BSI.BusinessEntities.Bug[1];
            //#endregion
            #endregion
        }
Beispiel #24
0
        public string UpdateBugs(SortedList bugsIdList, Bug bugPropetriesToBeChanged, out string errorMessage)
        {
            errorMessage = string.Empty;

            TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId);

            string strResult = string.Empty;

            string url = String.Concat(connection.URL, UPDATE_BUG_PAGE);

            MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset);

            string dataToPost = httpDialog.PostHttpRequest_UpdateBugsBulk ( bugsIdList, bugPropetriesToBeChanged  );

            string htmlContent = httpDialog.PostToUrl(url, dataToPost, false);

            errorMessage = HttpEngine.GetStringBetween(htmlContent, "<title>", "</title>", 0, false);

            if (errorMessage.Contains("processed")) {
                //message is not from an error
                errorMessage = String.Empty;

                string updBugs = String.Empty;

                foreach (object key in bugsIdList.Keys)
                {
                    if (String.IsNullOrEmpty(updBugs))
                    {
                        updBugs = key.ToString();
                    }
                    else
                    {
                        updBugs += "," + key.ToString();
                    }
                }

                if (updBugs.Length > 0)
                {
                    strResult = string.Format(Resource.MsgUpdBunchBugsSuccessfully, updBugs);
                }

            }
            #if DEBUG
            MyZilla.BL.Interfaces.Utils.htmlContents = htmlContent;
            #endif

            return strResult;
        }
Beispiel #25
0
        private void DisplayBugDetails(MyZilla.BusinessEntities.Bug bugDetail)
        {
            try
            {
                #region Simple properties

                txtSummary.Text = bugDetail.FullSummary;

                txtOpenedOn.Text = bugDetail.Created.ToString();

                txtLastModified.Text = bugDetail.Changed.ToString();

                txtBugNo.Text = bugDetail.Id.ToString();

                txtReporter.Text = bugDetail.Reporter;

                txtAssignedTo.Text = bugDetail.AssignedTo;

                cmbProduct.SelectedValue = bugDetail.Product;

                cmbComponent.SelectedValue = bugDetail.Component;

                cmbVersion.SelectedValue = bugDetail.Version;

                cmbMilestone.SelectedValue = bugDetail.Milestone;

                cmbPriority.SelectedValue = bugDetail.Priority;

                txtStatus.Text = bugDetail.Status;

                cmbOS.SelectedValue = bugDetail.OS;

                cmbSeverity.SelectedValue = bugDetail.Severity;

                cmbHardware.SelectedValue = bugDetail.Hardware;

                txtDependsOn.Text = bugDetail.DependsOn;

                txtBlock.Text = bugDetail.Blocks;

                txtURL.Text = bugDetail.Url;

                txtStWhiteboard.Text = bugDetail.StatusWhiteboard;

                txtResolution.Text = bugDetail.Resolution;

                _bugKnob = bugDetail.Knob;

                _bugReassignTo = bugDetail.ReassignTo;

                _bugDuplicateBug = bugDetail.DuplicateBug;

                _bugResolution = bugDetail.Resolution;

                #endregion

                #region CC

                if (this.ccCatalogListCompleted && !this.ccCompleted)
                {
                    this.ccCompleted = true;
                    //complete cc list with ccBugList

                    this.CompleteCcList(bugDetail);

                    this.ccCatalogListCompleted = false;
                }

                #endregion

                #region Description & Comments

                //load Comments
                ucComments1.LoadComments(bugDetail.Comment);

                //load description
                if (bugDetail.Comment != null && bugDetail.Comment.Count > 0)
                {
                    // who, bug_when, thetext

                    StringBuilder sb = new StringBuilder();


                    string strComment = bugDetail.Comment[0].Replace("\n", Environment.NewLine);

                    string[] elements = strComment.Split(',');

                    if (elements.GetLength(0) >= 3)
                    {
                        string Date = elements[1].ToString();

                        sb.Append(strComment.Substring(strComment.IndexOf(Date) + Date.Length + 2));
                    }

                    txtDescriptionValue.Text = sb.ToString();
                }


                #endregion

                if (txtResolution.Text == "DUPLICATE")
                {
                    // search in comment text the bug to duplicate
                    Regex duplicateBug = new Regex(@"This bug has been marked as a duplicate of (?<bug_number>[(0-9)]+)", RegexOptions.IgnoreCase);

                    foreach (string strComment in bugDetail.Comment)
                    {
                        Match match = duplicateBug.Match(strComment.ToString());

                        if (match.Success == true)
                        {
                            string bugNo = match.Groups["bug_number"].ToString();

                            txtResolution.Text = "DUPLICATE of bug " + bugNo;

                            break;
                        }
                    }
                }


                #region Attachments

                this.PopulateAttachmentList();

                #endregion
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "DisplayBugDetails", LoggingCategory.Exception);

                throw;
            }
        }
Beispiel #26
0
        /// <summary>
        /// Build POST data for updating priority, severity or Reassign to
        /// </summary>
        /// <param name="lstBugs"></param>
        /// <param name="propBugsToUpdate"></param>
        /// <returns></returns>
        public string PostHttpRequest_UpdateBugsBulk(SortedList bugsIdList, Bug bugValuesToUpdate)
        {
            StringBuilder sb = new StringBuilder();
            string strUpdate = string.Empty;
            string strToPost = string.Empty;

            foreach (object key in bugsIdList.Keys) {
                sb.Append("id_" + key.ToString() + "=on&");
            }

            //for (int i = 0; i < bugsIdList.Count;i++ )
            //{
            //    //sb.Append("id_" + bugsIdList[i].ToString() + "=on&");
            //}

            strUpdate = "dontchange=--do_not_change--&product=--do_not_change--&version=--do_not_change--&rep_platform=--do_not_change--&priority={0}&component=--do_not_change--&bug_severity={3}&masscc=&ccaction=add&comment=&bit-14=-1&bit-17=-1&bit-16=-1&bit-18=-1&bit-15=-1&bit-12=-1&bit-13=-1&bit-19=-1&knob={1}&resolution={2}&assigned_to={4}";

            if (String.IsNullOrEmpty(bugValuesToUpdate.Priority))
            {
                bugValuesToUpdate.Priority = "--do_not_change--";
            }

            if (String.IsNullOrEmpty(bugValuesToUpdate.Severity))
            {
                bugValuesToUpdate.Severity = "--do_not_change--";
            }

            if (String.IsNullOrEmpty(bugValuesToUpdate.ReassignTo))
            {
                bugValuesToUpdate.ReassignTo  = "--do_not_change--";
            }

            strToPost = string.Format(strUpdate, bugValuesToUpdate.Priority, bugValuesToUpdate.Knob, bugValuesToUpdate.Resolution, bugValuesToUpdate.Severity, bugValuesToUpdate.ReassignTo  );

            string dataToPost = sb.Append(strToPost).ToString() ;

            return dataToPost;
        }
Beispiel #27
0
        public UCInsertBug()
        {
            InitializeComponent();

            addedBug = new Bug ();
        }
Beispiel #28
0
        void SeverityItem_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                string newSeverityValue = sender.ToString();

                Bug bugsPropToBeChanged = new Bug();
                bugsPropToBeChanged.Knob = BugKnob.NONE;
                bugsPropToBeChanged.Severity  = newSeverityValue ;

                this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);

            }
        }
Beispiel #29
0
        /// <summary>
        /// Update a bug.
        /// </summary>
        /// <param name="bug"></param>
        public string UpdateBug(MyZilla.BusinessEntities.Bug bug, out string errorMessage)
        {
            errorMessage = string.Empty;

            // get version for connection
            MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance();

            TDSettings.ConnectionRow connection = _appSettings.GetConnectionById(_connectionId);

            string myZillaUrl = connection.URL;

            string bugzillaVersion = _appSettings.GetConnectionById(_connectionId).Version;

            string strResult = string.Empty;

            string url = String.Concat(myZillaUrl, UPDATE_BUG_PAGE);

            MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset);

            string dataToPost = httpDialog.PostHttpRequest_UpdateBug(bug, bugzillaVersion);

            string htmlContent = httpDialog.PostToUrl(url, dataToPost, false);

            // verify if confirmation string exits in response
            int pos = htmlContent.IndexOf("Changes submitted");

            if (pos >= 0)
            {
                strResult = string.Format(Resource.MsgUpdBugSuccessfully, bug.Id);
            }
            else
            {
                int pos1 = htmlContent.IndexOf("<title>");
                int pos2 = htmlContent.IndexOf("</title>");


                string strTitle = errorMessage = htmlContent.Substring(pos1 + "<title>".Length, pos2 - (pos1 - 1 + "</title>".Length));

                strResult = string.Format(Resource.MsgUpdBugFailed, bug.Id) + Environment.NewLine + strTitle;

                if (strTitle.Contains("collision"))
                {
                    strResult += Environment.NewLine + "Bug details will be reloaded!";
                }
            }

#if DEBUG
            MyZilla.BL.Interfaces.Utils.htmlContents = htmlContent;
#endif

            if (strResult.IndexOf("failed") >= 0)
            {
                // search in htmlContent the error
                // check if assignee was properly assigned
                //bool errIdentified = false;

                if (htmlContent.ToLower().IndexOf("assignee") >= 0)
                {
                    errorMessage = string.Format(Resource.ErrAssigneeNotMatch, bug.AssignedTo);

                    //errIdentified = true;
                }
                if (htmlContent.ToLower().IndexOf("invalid bug id") >= 0)
                {
                    errorMessage = Resource.ErrInvalidBugID;

                    // errIdentified = true;
                }
                //if (!errIdentified)
                //{
                //    errorMessage = Resource.ErrNotIdentifiedFail;
                //}
            }

            return(strResult);
        }
Beispiel #30
0
 public UpdatedBugEventArgs( Bug updatedBug)
 {
     this.updatedBug = updatedBug;
 }
Beispiel #31
0
        private void StartAsyncBulkUpdateBugs(Bug bugValuesToBeChanged)
        {
            dgvResults.UseWaitCursor = true;

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += new DoWorkEventHandler(BulkUpdateBugs_DoWork);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BulkUpdateBugs_RunWorkerCompleted);
            bw.ProgressChanged += new ProgressChangedEventHandler(BulkUpdateBugs_ProgressChanged);

            bw.RunWorkerAsync(bugValuesToBeChanged);
        }
Beispiel #32
0
        private void bkgBugDetails_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.ccBugListCompleted = true;
            // check the status of the async operation.

            try
            {
                if (e.Error != null)
                {

                    string errorMessage = Messages.ErrUpdBug + Environment.NewLine + e.Error.Message;

                    MessageBox.Show(Utils.FormContainer, errorMessage, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                }

                // status OK
                if (!e.Cancelled && e.Error == null)
                {
                    bugToUpdate = e.Result as MyZilla.BusinessEntities.Bug;

                    if (!String.IsNullOrEmpty(bugToUpdate.ErrorMessage))
                    {
                        this.Enabled = false;

                        if ((bugToUpdate.ErrorMessage == GettingBugErrorMessages.InvalidBugId) || (bugToUpdate.ErrorMessage == GettingBugErrorMessages.BugIdNotFound))
                            bugToUpdate.ErrorMessage = String.Format(Properties.Messages.BugIdDoesNotExists, bugToUpdate.Id);

                        DialogResult dr = MessageBox.Show(bugToUpdate.ErrorMessage);

                        if (dr == DialogResult.OK)
                        {
                            btnCancel_Click(null, null);
                        }
                    }
                    else
                    {
                        DisplayBugDetails(bugToUpdate);

                        bugToUpdate.IsDirty = false;

                        btnSave.Enabled = true;

                        Utils.LoadingFormInBackground();

                        this.Enabled = true;
                    }
                }

            #if DEBUG
                (Utils.FormContainer as MainForm).wb.DocumentText = MyZilla.BL.Interfaces.Utils.htmlContents;
            #endif

            }

            catch (Exception ex)
            {
                // The thread could continue to execute after the form was closed.
                // In this case, an exception is generated. It is no need to be logged or be shown those type of exceptions.
                if (!_formClosed)
                {

                    MyLogger.Write(ex, "bkgBugDetails_RunWorkerCompleted", LoggingCategory.Exception);

                    MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #33
0
        private void verifiedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bug bugsPropToBeChanged = new Bug();
            bugsPropToBeChanged.Knob = BugKnob.VERIFY;
            //keep bug resolution the same

            this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);
        }
Beispiel #34
0
        void AssignToItem_Click(object sender, EventArgs e)
        {
            if (sender != null)
            {
                string assignTo = sender.ToString();

                Bug bugsPropToBeChanged = new Bug();
                bugsPropToBeChanged.Knob = BugKnob.REASSIGN;
                bugsPropToBeChanged.ReassignTo = assignTo ;

                this.StartAsyncBulkUpdateBugs(bugsPropToBeChanged);

            }
        }
Beispiel #35
0
        public void Submit()
        {
            try
            {
                bool isValid = this.CheckConditionsForSaving();

                if (isValid == true)
                {

                    addedBug = GetBugDetails();

                    if (addedBug != null)
                    {
                        btnInsertBug.Enabled = false;

                        BackgroundWorker bkgAddBug = new BackgroundWorker();

                        bkgAddBug.DoWork += new DoWorkEventHandler(bkgAddBug_DoWork);

                        bkgAddBug.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bkgAddBug_RunWorkerCompleted);

                        bkgAddBug.ProgressChanged += new ProgressChangedEventHandler(bkgAddBug_ProgressChanged);

                        bkgAddBug.WorkerReportsProgress = true;

                        bkgAddBug.WorkerSupportsCancellation = true;

                        bkgAddBug.RunWorkerAsync();
                    }
                }
                else
                {
                    // no code here.
                }
            }

            catch (Exception ex)
            {
                MyLogger.Write(ex, "UCInsertBug.Submit", LoggingCategory.Exception);

                MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }