private void btnAddAttachment_Click(object sender, EventArgs e) { // not allowed many attachments for Bugzilla 3.0 // get the version of this connection MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); string version = _appSettings.GetConnectionById(this.connectionId).Version; int versionINT = int.Parse(version.Substring(0, version.IndexOf("."))); if (versionINT >= 3 && addedBug.Attachments.Count == 1) { MessageBox.Show(this, string.Format(Messages.MsgAttNotAllowed, Environment.NewLine), Messages.Info, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { FormAttachment frm = new FormAttachment(this.connectionId, -1, false); frm.ShowDialog(); Attachment newAtt = frm.NewAttachment; if (newAtt != null) { addedBug.Attachments.Add(newAtt); PopulateAttachmentList(); } } }
public void AddNewCookie(string CookieName, string CookieValue) { string myZillaUrl = MyZillaSettingsDataSet.GetInstance().GetUrlForConnection(_connectionId); string domain = myZillaUrl.Substring(myZillaUrl.IndexOf("://") + 3).TrimEnd('/'); CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie(CookieName, CookieValue, "", domain)); }
public string GetAttachment(int attID, bool isPicture, out Bitmap bitmap, out string errorMessage) { bitmap = null; string result = string.Empty; errorMessage = string.Empty; TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string url = String.Concat(connection.URL, ATTACHMENT_PAGE, attID); MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); if (isPicture) { bitmap = httpDialog.GetPictureFromUrl(url, false); } else { string getResult = httpDialog.GetFromUrl(url, false); if (result.ToLower().IndexOf("error") >= 0) { errorMessage = getResult; } else { result = getResult; } } return(result); }
/// <summary> /// This method parses the buglist.cgi response html and retrives the bugs found /// </summary> /// <param name="BugzillaUrl">Url of the bugzilla system where the user is connected</param> /// <param name="Params">Hash containing the columns that must be loaded and later on, displayed</param> /// <returns></returns> public List <MyZilla.BusinessEntities.Bug> SearchBugs(NameValueCollection Params) { TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); myZillaUrl += SEARCH_BUGS_PAGE;// "buglist.cgi?"; StringBuilder criterias = new StringBuilder(); string paramFormat = "{0}={1}&"; for (int i = 0; i < Params.Count; i++) { //compose QueryString based on the criteria selected in the interface for (int j = 0; j < Params.GetValues(i).Length; j++) { criterias.Append(String.Format(paramFormat, Params.GetKey(i), Params.GetValues(i)[j])); } } myZillaUrl += criterias.ToString(); string htmlContent = httpDialog.GetFromUrl(myZillaUrl + "ctype=csv", false); this.ParseCsvGettingBugs(htmlContent); return(bugs); }
/// <summary> /// Get the LAST_UPDATED (delta_ts) of the specified bug. /// Used only for bugzilla 2.18 /// </summary> /// <param name="bugzillaURL"></param> /// <param name="bugId"></param> /// <returns></returns> public string GetBugLastUpdated(int bugId) { string result = null; TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; string urlEnding = String.Format(BUG_LAST_UPDATED_URL, bugId); try { HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); string strContent = httpDialog.GetFromUrl(myZillaUrl + urlEnding, false); if (String.IsNullOrEmpty(strContent)) { } else { result = GetStringBetween(strContent, "value=\"", "\"", strContent.IndexOf("delta_ts"), false); } } catch { } return(result); }
public ArrayList GetValuesForDependentCatalogues(int classificationsCount, NameValueCollection products) { ArrayList result = new ArrayList(); NameValueCollection resCPTS = new NameValueCollection(); NameValueCollection resVERS = new NameValueCollection(); NameValueCollection resTMS = new NameValueCollection(); // get the content of the page TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); myZillaUrl += ADVANCED_SEARCH_BUGS_PAGE; string htmlContent = httpDialog.GetFromUrl(myZillaUrl, false); if (classificationsCount == 0) { for (int i = 0; i < products.Count; i++) { string catalogItemName = products.GetKey(i); Dictionary <string, string> res = GetSubstringForCriteria(htmlContent, "cpts[" + i.ToString() + "] = ", "];", catalogItemName); foreach (KeyValuePair <string, string> entry in res) { resCPTS.Add(entry.Value, entry.Key); } res = GetSubstringForCriteria(htmlContent, "vers[" + i.ToString() + "] = ", "];", catalogItemName); foreach (KeyValuePair <string, string> entry in res) { resVERS.Add(entry.Value, entry.Key); } res = GetSubstringForCriteria(htmlContent, "tms[" + i.ToString() + "] = ", "];", catalogItemName); foreach (KeyValuePair <string, string> entry in res) { resTMS.Add(entry.Value, entry.Key); } } result.Add(resCPTS); result.Add(resVERS); result.Add(resTMS); } return(result); }
public FormGlobalSettings() { InitializeComponent(); _appSettings = MyZillaSettingsDataSet.GetInstance(); LoadGlobalSettings(); }
private void EditBug_Load(object sender, EventArgs e) { try { if (!this.DesignMode) { _appSettings = MyZillaSettingsDataSet.GetInstance(); _asyncOpManager = AsyncOperationManagerList.GetInstance(); // disable the control until de bug details are loaded and // all the controls are populated accordingly. ShowConnectionInfo(); this.Enabled = false; _catalogues = CatalogueManager.Instance(); //if (_catalogues.DependentCataloguesLoadedCompleted!=null) _catalogues.DependentCataloguesLoadedCompleted += new EventHandler(this._catalogues_DependentCataloguesLoadedCompleted); cataloguesPerUser = _catalogues.GetCataloguesForConnection(this.connectionId); if (cataloguesPerUser.catalogueComponent == null || cataloguesPerUser.catalogueVersion == null || cataloguesPerUser.catalogueTargetMilestone == null) { cmbComponent.Enabled = false; cmbVersion.Enabled = false; cmbMilestone.Enabled = false; _catalogues.CompAndVersionCataloguesLoadedCompleted += new EventHandler(_catalogues_CompAndVersionCataloguesLoadedCompleted); _catalogues.LoadCompAndVersionCatalogues(cataloguesPerUser); } else { PopulateControls(); // asyn op GetBugDetailsAndSetControls(this.bugId, true); } if (_appSettings.GetConnectionById(connectionId).Version.StartsWith("2.18")) { GetLastUpdated(); } } } catch (Exception ex) { MyLogger.Write(ex, "EditBug_Load", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void PostAttachment(Attachment attachment, out string errorMessage) { errorMessage = string.Empty; TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); try { string result = httpDialog.PostAttachment(attachment, myZillaUrl); string token = ""; int startToken = result.IndexOf("token"); if (startToken > 0) { int stopTokenEntry = result.Substring(startToken).IndexOf(">"); if (stopTokenEntry > 0) { string res = result.Substring(startToken, stopTokenEntry); if (!string.IsNullOrEmpty(res)) { if (res.Contains("value=")) { token = res.Substring(res.IndexOf("value=") + "value=".Length); token = token.Replace("\"", ""); } } } } if (!string.IsNullOrEmpty(token)) { attachment.Token = token; } if (result.IndexOf("Changes Submitted") >= 0) { errorMessage = string.Empty; } else { int pos1 = result.IndexOf("<title>"); int pos2 = result.IndexOf("</title>"); errorMessage = result.Substring(pos1 + "<title>".Length, pos2 - (pos1 - 1 + "</title>".Length)); } } catch (Exception ex) { errorMessage = ex.Message; } }
private void InsertBug_Load(object sender, EventArgs e) { try { if (!this.DesignMode) { MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); _catalogues = CatalogueManager.Instance(); this.txtReporter.Text = _appSettings.GetConnectionById(this.connectionId).UserName; asyncOpManager = AsyncOperationManagerList.GetInstance(); cmbConnections.SelectedValueChanged -= new EventHandler(cmbConnections_SelectedValueChanged); LoadConnectionInfo(); cmbConnections.Text = _appSettings.GetConnectionInfo(this.connectionId); cmbConnections.SelectedValueChanged += new EventHandler(cmbConnections_SelectedValueChanged); // verify if all catalogues have been added and populate the controls properly cataloguesPerUser = _catalogues.GetCataloguesForConnection(this.connectionId); if (cataloguesPerUser.catalogueComponent == null || cataloguesPerUser.catalogueVersion == null || cataloguesPerUser.catalogueTargetMilestone == null) { cmbComponent.Enabled = false; cmbVersion.Enabled = false; cmbMilestone.Enabled = false; btnInsertBug.Enabled = false; _catalogues.CompAndVersionCataloguesLoadedCompleted += new EventHandler(_catalogues_CompAndVersionCataloguesLoadedCompleted); _catalogues.LoadCompAndVersionCatalogues(cataloguesPerUser); } else { _catalogues.DependentCataloguesLoadedCompleted += new EventHandler(this._catalogues_DependentCataloguesLoadedCompletedInsertBug); PopulateControls(); } } } catch (Exception ex) { MyLogger.Write(ex, "InsertBug_Load", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void InitializeData() { InitializeComponent(); _connSettings = MyZillaSettingsDataSet.GetInstance(); this.queryTree = ConfigItems.TDSQueriesTree.Instance(); _asyncOpManager = AsyncOperationManagerList.GetInstance(); }
/// <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); }
private CatalogueManager( ) { _appSettings = MyZillaSettingsDataSet.GetInstance(); _appSettings.SaveSettings += new EventHandler <MyZillaSettingsEventArgs>(_appSettings_SaveSettings); if (_appSettings.ConnectionType.Rows.Count == 0) { _appSettings.AddConnectionType("Bugzilla"); } }
public string GetBugzillaVersion(string url) { string version = String.Empty; TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string urlBase = connection.URL; HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); string httpContent = httpDialog.GetFromUrl(String.Concat(urlBase, String.Format(BUG_DETAILS_URL, -1)), false); this.bugzillaCharset = httpDialog.BugzillaCharset; XmlDocument doc = new XmlDocument(); string toFind = "urlbase=\""; int startIndex = httpContent.IndexOf(toFind); if (startIndex >= 0) { int endIndex = httpContent.IndexOf('"', startIndex + toFind.Length); if (endIndex > startIndex) { string[] list = httpContent.Substring(startIndex + toFind.Length, endIndex - startIndex - toFind.Length).Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries); httpContent = httpContent.Replace(list[0], urlBase); } } //WARNING //if login cookies are not generated //, xml is not returned and getting bugzilla version fails try { doc.LoadXml(httpContent); XmlNodeList bugVersion = doc.GetElementsByTagName("bugzilla"); XmlNode versionNode = bugVersion[0]; XmlElement versionElement = (XmlElement)versionNode; if (versionElement.HasAttributes) { version = versionElement.Attributes["version"].InnerText; } } catch { //generic version number for cases when getting bugzilla version fails version = "2.0"; } return(version); }
public string GetAttachment(int attID, out string errorMessage) { TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string url = String.Concat(connection.URL, ATTACHMENT_PAGE, attID); MyZilla.BL.Utils.HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); string strFullPath = httpDialog.GetStreamFormUrl(url, out errorMessage); return(strFullPath); }
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); }
public string GetBugzillaCharset(string url) { string version = String.Empty; TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string urlBase = connection.URL; HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); string httpContent = httpDialog.GetFromUrl(urlBase, false); this.bugzillaCharset = httpDialog.BugzillaCharset; return(this.bugzillaCharset); }
/// <summary> /// Gets the columns to be displayed from Bugzilla - colchange.cgi /// /// </summary> /// <param name="BugzillaUrl">Url of the bugzilla system</param> /// <returns>Hashtable (key is column name, value is the index in the array of columns)</returns> public Hashtable GenerateColumnsToBeDisplayed(System.ComponentModel.BackgroundWorker backgroundWorker) { TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); HttpHelper httpRequest = new HttpHelper(_connectionId, connection.Charset); //GET HTML content for the page provided string htmlContent = httpRequest.GetFromUrl(String.Concat(connection.URL, DISPLAYED_COLUMNS_PAGE), false); ParseHtmlForColumnListValues(htmlContent); if (backgroundWorker != null) { backgroundWorker.ReportProgress(100); } return(cols); }
private static FormEditBug LoadForm(int bugId, int connectionId, Bug cachedBug) { // load form FormEditBug frmEditBug = null; try { frmEditBug = new FormEditBug(connectionId, bugId, cachedBug); if (frmEditBug.DialogResult == DialogResult.OK) { //frmEditBug.Show(); } if (frmEditBug.DialogResult == DialogResult.Cancel) { MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); string connInfo = _appSettings.GetConnectionInfo(connectionId); string strMessage = string.Format(Messages.NoActiveConnection, connInfo); MessageBox.Show(Utils.FormContainer, strMessage, Messages.Warning, MessageBoxButtons.OK, MessageBoxIcon.Warning); frmEditBug = null; } } catch (Exception ex) { MyLogger.Write(ex, "LoadForm", LoggingCategory.Exception); MessageBox.Show(Utils.FormContainer, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); if (frmEditBug != null) { frmEditBug = null; frmEditBug.Dispose(); } } return(frmEditBug); }
public void LoadDefaultData(string applicationPath) { _appPath = applicationPath; string fileName = applicationPath + Path.DirectorySeparatorChar + _fileName; string defaultFileName = Application.StartupPath + Path.DirectorySeparatorChar + _defaultFileName; try { if (File.Exists(fileName)) { _instance.ReadXml(fileName); } //if QueriesTree does not exist in the windows user application data folder //load the default values from the application folder else if (File.Exists(defaultFileName)) { TDSQueriesTree t = new TDSQueriesTree(); t.ReadXml(defaultFileName); _instance.QueryTypes.Merge(t.QueryTypes); _instance.QueryParameters.Merge(t.QueryParameters); MyZillaSettingsDataSet settings = MyZillaSettingsDataSet.GetInstance(); TDSettings.ConnectionDataTable connections = settings.GetActiveConnections(); foreach (TDSettings.ConnectionRow connection in connections) { CatalogueManager catalogues = CatalogueManager.Instance(); if (catalogues.GetCataloguesForConnection(connection.ConnectionId) != null) { BuildTreeStructureForUserId(t, connection); } } } else { throw (new IOException("Default queries configuration [" + fileName + "] is missing!")); } } catch (IOException) { throw (new IOException("File " + fileName + " not exist.")); } }
public ArrayList GetSpecificCataloguesWhenManageBug(string productName, NameValueCollection Components) { MyLogger.Write("Start getting bug specific catalogs!", "GetSpecificCataloguesWhenManageBug", LoggingCategory.General); TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; HttpHelper httpHelper = new HttpHelper(_connectionId, connection.Charset); myZillaUrl = myZillaUrl + String.Format(ADD_BUG_PAGE, productName); //get html content string htmlContent = httpHelper.GetFromUrl(myZillaUrl, false); ParseHtmlForDependentCatalogues(new DataContainer(productName, htmlContent, Components)); MyLogger.Write("Complete getting bug specific catalogs!", "GetSpecificCataloguesWhenManageBug", LoggingCategory.General); return(resultSpecificCatalogues); }
/// <summary> /// Get the details of the specified bug. /// </summary> /// <param name="bugzillaURL"></param> /// <param name="bugId"></param> /// <returns></returns> public List <MyZilla.BusinessEntities.Bug> GetBugs(string bugIdList) { TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string urlEnding = String.Format(BUGS_DETAILS_URL, bugIdList); XmlNodeList bugsAsXMLNodes = GetBugsAsXML(connection.URL, urlEnding, connection.Charset); List <MyZilla.BusinessEntities.Bug> bugs = new List <MyZilla.BusinessEntities.Bug>(); if (bugsAsXMLNodes != null) { foreach (XmlNode node in bugsAsXMLNodes) { bugs.Add(GetBug(node)); } } else { } return(bugs); }
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); }
private void LoadConnectionInfo() { MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); txtConnection.Text = _appSettings.GetConnectionInfo(_connectionID); }
/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns>empty string when ok, err message when an error was raised</returns> public string LogOnToBugzilla(string username, string password) { HttpWebResponse respLogin = null; HttpHelper httpDialog = null; #if DEBUG Stopwatch watch = Stopwatch.StartNew(); #endif MyLogger.Write("Starting LogOn!", "LogOnToBugzilla", LoggingCategory.General); try { TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); string myZillaUrl = connection.URL; string url = String.Concat(myZillaUrl, INDEX_PAGE); httpDialog = new HttpHelper(_connectionId, connection.Charset); httpDialog.BugzillaCharset = connection.Charset; string dataToPost = httpDialog.BuildBugzillaLogOnData(username, password); // POST respLogin = httpDialog.PostToUrlWhenLogOn(url, dataToPost, false); #if DEBUG watch.Stop(); MyLogger.Write("LogOn took: " + watch.ElapsedMilliseconds, "LogOnToBugzilla", LoggingCategory.Debug); #endif if (respLogin != null && respLogin.Cookies != null && respLogin.Cookies.Count == 2) { // user is logged. CookieManager.AddNewCookieContainer(_connectionId, respLogin.Cookies); return(String.Empty); } else { // log failed. if (respLogin != null && respLogin.Cookies != null) { MyLogger.Write(String.Format("LogOn failed! Cookies.Count: {0}", respLogin.Cookies.Count), "LogOnToBugzilla", LoggingCategory.Warning); } else if (respLogin.Cookies == null) { MyLogger.Write("LogOn failed! Cookie collection is NULL", "LogOnToBugzilla", LoggingCategory.Warning); } CookieManager.DeleteCookiesForUser(_connectionId); return("Invalid user or password"); } } catch (Exception ex) { if (httpDialog != null) { CookieManager.DeleteCookiesForUser(_connectionId); } return(ex.Message); } finally { if (respLogin != null) { respLogin.Close(); } MyLogger.Write("LogOn completed!", "LogOnToBugzilla", LoggingCategory.General); } }
void bkgAddBug_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; try { worker.ReportProgress(0); // start thread. worker.ReportProgress(10); IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId); worker.ReportProgress(60); //intermediate state string strResult = bugInterface.AddBug(addedBug); if (addedBug.Attachments.Count > 0) { // get bug ID Regex addBug = new Regex(@"(?<bug_number>[(0-9)]+) was added to the database", RegexOptions.IgnoreCase); Match match = addBug.Match(strResult); int bugNo = 0; if (match.Success == true) { bugNo = int.Parse(match.Groups["bug_number"].ToString()); } string strAtt = string.Empty; string errorMessage = string.Empty; // get version for current connection MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); string version = _appSettings.GetConnectionById(this.connectionId).Version; int versionINT = int.Parse(version.Substring(0, version.IndexOf("."))); switch (versionINT) { case 2: foreach (Attachment att in addedBug.Attachments) { att.BugId = bugNo; bugInterface.PostAttachment(att, out errorMessage); if (!String.IsNullOrEmpty(errorMessage)) { strAtt = string.Format(Messages.ErrPostFile, att.FileName); strResult += Environment.NewLine + strAtt + " [" + errorMessage + "]"; } } break; case 3: break; } } e.Result = strResult; worker.ReportProgress(100); //completed } catch (Exception ex) { MyLogger.Write(ex, "bkgAddBug_DoWork", LoggingCategory.Exception); worker.ReportProgress(100); //completed throw; } }
void bkgAddBug_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { bool continueBugEdit = false; try { // check the status of the async operation. if (e.Error != null) { //display error message from bugzilla string errorMessage = e.Error.Message; DialogResult dr = MessageBox.Show(Utils.FormContainer, errorMessage, Messages.Error, MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation); continueBugEdit = (dr == DialogResult.Retry); #if DEBUG (Utils.FormContainer as MainForm).wb.DocumentText = MyZilla.BL.Interfaces.Utils.htmlContents; #endif } else { // status OK if (!e.Cancelled && e.Error == null) { string strResult = e.Result.ToString(); #if DEBUG (Utils.FormContainer as MainForm).wb.DocumentText = MyZilla.BL.Interfaces.Utils.htmlContents; #endif // set the last selected item for some properties Utils.lastSelectedHardware = cmbHardware.Text; Utils.lastSelectedOS = cmbOS.Text; Utils.lastSelectedProduct = cmbProduct.Text; Utils.lastSelectedVersion = cmbVersion.Text; Utils.lastSelectedMilestone = cmbMilestone.Text; // confirmation message MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); TDSettings.GlobalSettingsRow globalSettings = _appSettings.GetGlobalSettings(); if (globalSettings.ConfirmSuccessfullyEditBug) { DialogResult dr = MessageBox.Show(this, strResult, Messages.Info, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } if (!continueBugEdit) { btnCancel_Click(this, null); } btnInsertBug.Enabled = true; } 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, "bkgAddBug_RunWorkerCompleted", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// /// </summary> /// <param name="htmlContent"></param> public void ParseHtmlForColumnListValues(object htmlContent) { string content = htmlContent.ToString(); int startFormIndex = content.IndexOf("<form action=\"colchange.cgi\""); if (startFormIndex >= 0) { int endFormIndex = content.IndexOf("</form>", startFormIndex); string formXML = content.Substring(startFormIndex, endFormIndex + "</form>".Length - startFormIndex - 1); Hashtable labels = new Hashtable(); string cookieValue = String.Empty; string cookieValueAll = String.Empty; string delim = String.Empty; int index = formXML.IndexOf("<input type=\"checkbox\""); while (index > 0) { int endIndex = formXML.IndexOf(">", index); string input = GetStringBetween(formXML, "<input type=\"checkbox\"", ">", index, true);//formXML.Substring(index, endIndex - index + 1); string nameAttributeValue = GetStringBetween(input, "name=\"", "\"", 0, false); string isChecked = GetStringBetween(input, "checked=\'", "\'", 0, false); nameAttributeValue = nameAttributeValue.Replace("column_", String.Empty); if (isChecked != null && isChecked.Length > 0) { //isChecked can have values: 0-not used, 1-used and visible, 2-used but invisible isChecked = "1"; cookieValue += delim + nameAttributeValue; if (cookieValue.Length > 0) { delim = "%20"; } } else { if (nameAttributeValue == "bug_severity") { cookieValue += delim + nameAttributeValue; isChecked = "2"; } else { isChecked = "0"; } } index = formXML.IndexOf("<label for=", endIndex); string forAttributeValue = GetStringBetween(formXML, "for=\"", "\"", index, false); string forText = GetStringBetween(formXML, "\">", "</label>", index, false); labels.Add(forAttributeValue, forText.TrimEnd(new char[] { ' ', '\n' })); cookieValueAll += labels[nameAttributeValue] + "&" + nameAttributeValue; cookieValueAll += "&" + isChecked + "@"; index = formXML.IndexOf("<input type=\"checkbox\"", index); } bool bugSeverityIsVisible = (cookieValue.IndexOf("bug_severity") >= 0); if (!bugSeverityIsVisible) { cookieValue += "bug_severity"; } string myZillaUrl = MyZillaSettingsDataSet.GetInstance().GetUrlForConnection(_connectionId); string domain = myZillaUrl.Substring(myZillaUrl.IndexOf("://") + 3).TrimEnd('/'); if (!CookieManager.Instance().CookieCollectionContainsCookieByUserId("COLUMNLIST", _connectionId)) { CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie("COLUMNLIST", cookieValue, "", domain)); } CookieManager.Instance().AddNewCookieToCookieCollection(_connectionId, new Cookie("COLUMNLISTALL", cookieValueAll, "", domain)); } return; }
public ArrayList GetCatalogues(string[] catalogIdList) { int pos = 0; int posBegin = 0; int posEnd = 0; List <string> lstOptions = null; string strSelect = string.Empty; ArrayList lstCatalogues = new ArrayList(); TDSettings.ConnectionRow connection = MyZillaSettingsDataSet.GetInstance().GetConnectionById(_connectionId); HttpHelper httpDialog = new HttpHelper(_connectionId, connection.Charset); string myZillaUrl = connection.URL; // get the content of the page myZillaUrl += ADVANCED_SEARCH_BUGS_PAGE; MyLogger.Write("Start getting main catalogs! Url = " + myZillaUrl, "GetCatalogues", LoggingCategory.General); string htmlContent = httpDialog.GetFromUrl(myZillaUrl, false); #if DEBUG MyZilla.BL.Interfaces.Utils.htmlContents = htmlContent; #endif // find the select TAG in html content. for (int catalogNumber = 0; catalogNumber < catalogIdList.Length; catalogNumber++) { pos = 0; lstOptions = new List <string>(); while (pos < htmlContent.Length) { posBegin = htmlContent.IndexOf("<select", pos); if (posBegin == -1) { break; } else { posEnd = htmlContent.IndexOf("</select>", posBegin); strSelect = htmlContent.Substring(posBegin, posEnd - posBegin); if (strSelect.IndexOf("name=\"" + catalogIdList [catalogNumber]) >= 0) { // the catalogue was found lstOptions = HttpHelper.GetOptionsFormSelection(strSelect); break; } else { pos = posEnd + 1; } } } lstCatalogues.Add(lstOptions); } MyLogger.Write("Complete getting main catalogs!", "GetCatalogues", LoggingCategory.General); return(lstCatalogues); }
private void ShowConnectionInfo() { MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance(); txtConnInfo.Text = _appSettings.GetConnectionInfo(this.connectionId); }