private void lstConnections_SelectedIndexChanged(object sender, EventArgs e) { try { if (lstConnections.SelectedIndex >= 0) { ConnectionItem ci = lstConnections.SelectedItem as ConnectionItem; lblTestResult.Visible = false; if (ci != null) { TDSettings.ConnectionRow conn = _connSettings.GetConnectionById(ci.ConnectionID); if (conn != null) { txtUrl.Text = conn.URL; txtConnectionName.Text = conn.ConnectionName; txtUserName.Text = conn.UserName; txtPassword.Text = conn.Password; chkActiveUser.Checked = conn.ActiveUser; //chkRemember.Checked = conn.RememberPassword; } else { if (this._addConnection == true) { txtConnectionName.Text = Messages.NewConnection; txtUrl.Text = string.Empty; txtUserName.Text = string.Empty; txtPassword.Text = string.Empty; chkActiveUser.Checked = false; //chkRemember.Checked = false; } } } } } catch (Exception ex) { MyLogger.Write(ex, "lstConnections_SelectedIndexChanged", LoggingCategory.Exception); MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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(); } } }
// TO DO load catalogues for connection public void LoadCataloguesForUser(int connectionId) { TDSettings.ConnectionRow connection = _appSettings.GetConnectionById(connectionId); if (String.IsNullOrEmpty(connection.Charset)) { IUtilities utilities = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionId); connection.Charset = utilities.GetBugzillaCharset(connection.URL); _appSettings.EditConnection(connection); } SavingData data = new SavingData(OperationType.EditConnection, connection); this.LoadCataloguesForUser(data); }
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); } }
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); } }
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); }
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; } }
/// <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); }