void bkgBugLastUpdated_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; string bugLastUpdated = null; ArrayList al = e.Argument as ArrayList; int bugNo = int.Parse(al[0].ToString()); try { worker.ReportProgress(0); // start thread. worker.ReportProgress(10); IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId); bugLastUpdated = bugInterface.GetBugLastUpdated(bugNo); worker.ReportProgress(60); e.Result = bugLastUpdated; worker.ReportProgress(100); //completed } catch (Exception ex) { MyLogger.Write(ex, "bkgBugDetails_DoWork", LoggingCategory.Exception); worker.ReportProgress(100); //completed throw; } }
void bkgVersion_DoWork(object sender, DoWorkEventArgs e) { try { ArrayList al = e.Argument as ArrayList; int connectionID = int.Parse(al[0].ToString()); string url = al[1].ToString(); IUtilities utilities = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionID); string version = utilities.GetBugzillaVersion(url); ArrayList alResult = new ArrayList(); alResult.Add(version); alResult.Add(connectionID); e.Result = alResult; } catch (Exception ex) { MyLogger.Write(ex, "bkgVersion_DoWork", LoggingCategory.Exception); throw; } }
private void bkgTestCredentials_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; try { worker.ReportProgress(0); worker.ReportProgress(10); IUser user = (IUser)BLControllerFactory.GetRegisteredConcreteFactory(Utils.ConnectionId); worker.ReportProgress(50); ArrayList al = e.Argument as ArrayList; bool result = user.TestLogOnToBugzilla(al[0].ToString(), al[1].ToString(), al[2].ToString()); worker.ReportProgress(100); e.Result = result; } catch (Exception ex) { MyLogger.Write(ex, "bkgTestCredentials_DoWork", LoggingCategory.Exception); worker.ReportProgress(100); throw; } }
private void btnAddAttachment_Click(object sender, EventArgs e) { try { bool isValid = CheckConditions(); if (isValid == true) { this.Cursor = Cursors.WaitCursor; string contentType = Utils.GetFileContentType(txtFile.Text); this.NewAttachment = new Attachment(_bugID, txtFile.Text, txtDescription.Text, contentType, txtComment.Text); System.IO.FileInfo fileInfo = new System.IO.FileInfo(txtFile.Text); this.NewAttachment.Size = fileInfo.Length; if (_postWhenAdding == true) { string errorMessage = string.Empty; // post attachment IBugBSI bugProvider = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId); bugProvider.PostAttachment(this.NewAttachment, out errorMessage); if (!String.IsNullOrEmpty(errorMessage)) { string strMessage = string.Format(Messages.ErrPostFile, txtFile.Text); MessageBox.Show(this, strMessage + Environment.NewLine + errorMessage, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); this.NewAttachment = null; } else { this.Close(); } } else { // no code here. this.Close(); } } } catch (Exception ex) { MyLogger.Write(ex, "btnAddAttachment_Click", LoggingCategory.Exception); this.NewAttachment = null; MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
void bkgDepCatalogues1_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bkgWork = sender as BackgroundWorker; try { #if DEBUG System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); #endif Interlocked.Increment(ref activeThreads); bkgWork.ReportProgress(0); bkgWork.ReportProgress(10); // component and version catalogues Catalogues cataloguesPerUser = e.Argument as Catalogues; IUtilities catalogue = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(cataloguesPerUser.ConnectionId); bkgWork.ReportProgress(60); // request ArrayList al = catalogue.GetValuesForDependentCatalogues(0, cataloguesPerUser.catalogueProduct); cataloguesPerUser.catalogueComponent = al[0] as NameValueCollection; cataloguesPerUser.catalogueVersion = al[1] as NameValueCollection; cataloguesPerUser.catalogueTargetMilestone = al[2] as NameValueCollection; bkgWork.ReportProgress(100); e.Result = cataloguesPerUser; #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), "bkgDepCatalogues1_DoWork", LoggingCategory.Debug); #endif } catch (Exception ex) { MyLogger.Write(ex, "bkgDepCatalogues1_DoWork", LoggingCategory.Exception); bkgWork.ReportProgress(100); throw; } }
void bkgDepCatalogues2_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker bkgWork = sender as BackgroundWorker; try { bkgWork.ReportProgress(0); bkgWork.ReportProgress(10); Interlocked.Increment(ref activeThreads); ArrayList argument = e.Argument as ArrayList; //get connection id from the event arguments int connectionID = int.Parse(argument[0].ToString()); //get product name from the event arguments string product = argument[1].ToString(); Catalogues cataloguesPerUser = this.GetCataloguesForConnection(connectionID); IUtilities catalogue = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionID); bkgWork.ReportProgress(60); // al[0] = AssignTo; al[1] = CC // request ArrayList alSpecificCatalogues = catalogue.GetSpecificCataloguesWhenManageBug(product, cataloguesPerUser.catalogueComponent); NameValueCollection assignToColl = alSpecificCatalogues[0] as NameValueCollection; cataloguesPerUser.catalogueAssignedTo = assignToColl; NameValueCollection ccColl = alSpecificCatalogues[1] as NameValueCollection; cataloguesPerUser.catalogueCC = ccColl; NameValueCollection ccPriority = alSpecificCatalogues[2] as NameValueCollection; cataloguesPerUser.catalogueDefaultPriority = ccPriority; bkgWork.ReportProgress(100); } catch (Exception ex) { MyLogger.Write(ex, "bkgDepCatalogues2_DoWork", LoggingCategory.Exception); bkgWork.ReportProgress(100); throw; } }
void bkgSearch_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; worker.ReportProgress(0); // start thread. IBugBSI bugProvider = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(_userID); worker.ReportProgress(60); //intermediate state List <BSI.BusinessEntities.Bug> bugsFound = bugProvider.SearchBugs(_searchParam); worker.ReportProgress(100); //completed e.Result = bugsFound; }
// 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 bkgBugDetails_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; Bug bugDetail = null; ArrayList al = e.Argument as ArrayList; int bugNo = int.Parse(al[0].ToString()); bool useCachedBugIfExits = bool.Parse(al[1].ToString()); try { worker.ReportProgress(0); // start thread. worker.ReportProgress(10); // check if bug was previously loaded if (bugToUpdate == null || !useCachedBugIfExits) { IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId); bugDetail = bugInterface.GetBug(bugNo); bugDetail.Id = bugNo; } else { bugDetail = bugToUpdate; } worker.ReportProgress(60); e.Result = bugDetail; worker.ReportProgress(100); //completed } catch (Exception ex) { MyLogger.Write(ex, "bkgBugDetails_DoWork", LoggingCategory.Exception); worker.ReportProgress(100); //completed throw; } }
private void bkgBugUpdate_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 errorMessage = string.Empty; string result = bugInterface.UpdateBug(bugToUpdate, out errorMessage); ArrayList al = new ArrayList(); al.Add(errorMessage); al.Add(result); e.Result = al; worker.ReportProgress(100); //completed } catch (Exception ex) { MyLogger.Write(ex, "bkgBugUpdate_DoWork", LoggingCategory.Exception); worker.ReportProgress(100); //completed throw; } }
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; } }
private static Catalogues GetCataloguesForUser(TDSettings.ConnectionRow currentConnection, BackgroundWorker bkgWork) { MyZilla.BusinessEntities.Catalogues cataloguesPerUser = null; string connInfo = _appSettings.GetConnectionInfo(currentConnection.ConnectionId); try { #if DEBUG System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); #endif bkgWork.ReportProgress(0, connInfo); bkgWork.ReportProgress(10, connInfo); // when refresh catalogues, it is no need to verify login. IUser user = (IUser)BLControllerFactory.GetRegisteredConcreteFactory(currentConnection.ConnectionId); // TO DO: eliminate the last param. string loggedUser = user.LogOnToBugzilla(currentConnection.UserName, currentConnection.Password); if (loggedUser.Length > 0) { // this could happen if a wrong password was saved. bkgWork.ReportProgress(100, connInfo); throw new Exception(loggedUser); } IUtilities catalogue = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(currentConnection.ConnectionId); string[] catalogNames = new string[] { "classification", "product", "bug_status", "resolution", "bug_severity", "priority", "rep_platform", "op_sys", "short_desc_type", "field0-0-0", "type0-0-0" }; // get all the main catalogues (catalogues without dependencies) used in the application // request ArrayList collCatalogues = catalogue.GetCatalogues(catalogNames); // get the connection/user information cataloguesPerUser = new MyZilla.BusinessEntities.Catalogues(currentConnection.ConnectionId); #region Main Catalogues // get the product catalogue List <string> lstProduct = collCatalogues[1] as List <string>; cataloguesPerUser.catalogueProduct = new NameValueCollection(); foreach (string strProduct in lstProduct) { cataloguesPerUser.catalogueProduct.Add(strProduct, string.Empty); } // get the rest of the main catalogues and populate the corresponding controls. // string[] catalogNames = new string[] {"product", // "bug_status", // "resolution", // "bug_severity", // "priority", // "rep_platform", // "op_sys", // "short_desc_type"}; cataloguesPerUser.catalogueStatus = collCatalogues[2] as List <string>; cataloguesPerUser.catalogueResolution = collCatalogues[3] as List <string>; cataloguesPerUser.catalogueSeverity = collCatalogues[4] as List <string>; cataloguesPerUser.cataloguePriority = collCatalogues[5] as List <string>; cataloguesPerUser.catalogueHardware = collCatalogues[6] as List <string>; cataloguesPerUser.catalogueOS = collCatalogues[7] as List <string>; cataloguesPerUser.catalogueStringOperators = collCatalogues[8] as List <string>; cataloguesPerUser.catalogueFields = collCatalogues[9] as List <string>; cataloguesPerUser.catalogueOperators = collCatalogues[10] as List <string>; #endregion bkgWork.ReportProgress(40, connInfo); #region Dependent catalogues // component and version catalogues // request ArrayList al = catalogue.GetValuesForDependentCatalogues(0, cataloguesPerUser.catalogueProduct); cataloguesPerUser.catalogueComponent = al[0] as NameValueCollection; cataloguesPerUser.catalogueVersion = al[1] as NameValueCollection; cataloguesPerUser.catalogueTargetMilestone = al[2] as NameValueCollection; #endregion bkgWork.ReportProgress(80, connInfo); #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), "GetCataloguesForUser", LoggingCategory.Debug); #endif } catch (Exception ex) { MyLogger.Write(ex, "GetCataloguesForUser", LoggingCategory.Exception); throw; } finally { bkgWork.ReportProgress(100, connInfo); } return(cataloguesPerUser); }
private static Catalogues LoadMainCatalogues(TDSettings.ConnectionRow connectionRow, BackgroundWorker backgroudWorker) { #if DEBUG string methodName = "LoadMainCatalogues"; #endif #if DEBUG System.Diagnostics.Stopwatch watch = System.Diagnostics.Stopwatch.StartNew(); #endif backgroudWorker.ReportProgress(0); backgroudWorker.ReportProgress(10); // when refresh catalogues, it is no need to verify login. IUser user = (IUser)BLControllerFactory.GetRegisteredConcreteFactory(connectionRow.ConnectionId); string userIsLogged = user.LogOnToBugzilla(connectionRow.UserName, connectionRow.Password); #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), methodName, LoggingCategory.Debug); watch.Start(); #endif if (userIsLogged.Length > 0) { // this could happen because a wrong password was saved. backgroudWorker.ReportProgress(100); return(null); } IUtilities catalogue = (IUtilities)BLControllerFactory.GetRegisteredConcreteFactory(connectionRow.ConnectionId); string[] catalogNames = new string[] { "classification", "product", "bug_status", "resolution", "bug_severity", "priority", "rep_platform", "op_sys", "short_desc_type", "field0-0-0", "type0-0-0" }; // get all the main catalogues (catalogues without dependencies) used in the application // request ArrayList collCatalogues = catalogue.GetCatalogues(catalogNames); #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), methodName, LoggingCategory.Debug); watch.Start(); #endif // get the connection/user information MyZilla.BusinessEntities.Catalogues cataloguesPerUser = new MyZilla.BusinessEntities.Catalogues(connectionRow.ConnectionId); #region Main Catalogues // get the product catalogue List <string> lstProduct = collCatalogues[1] as List <string>; cataloguesPerUser.catalogueProduct = new NameValueCollection(); foreach (string strProduct in lstProduct) { cataloguesPerUser.catalogueProduct.Add(strProduct, string.Empty); } backgroudWorker.ReportProgress(80); // get the rest of the main catalogues and populate the corresponding controls. // string[] catalogNames = new string[] {"product", // "bug_status", // "resolution", // "bug_severity", // "priority", // "rep_platform", // "op_sys", // "short_desc_type"}; cataloguesPerUser.catalogueStatus = collCatalogues[2] as List <string>; cataloguesPerUser.catalogueResolution = collCatalogues[3] as List <string>; cataloguesPerUser.catalogueSeverity = collCatalogues[4] as List <string>; cataloguesPerUser.cataloguePriority = collCatalogues[5] as List <string>; cataloguesPerUser.catalogueHardware = collCatalogues[6] as List <string>; cataloguesPerUser.catalogueOS = collCatalogues[7] as List <string>; cataloguesPerUser.catalogueStringOperators = collCatalogues[8] as List <string>; cataloguesPerUser.catalogueFields = collCatalogues[9] as List <string>; cataloguesPerUser.catalogueOperators = collCatalogues[10] as List <string>; #endregion backgroudWorker.ReportProgress(100); #if DEBUG watch.Stop(); MyLogger.Write(watch.ElapsedMilliseconds.ToString(), methodName, LoggingCategory.Debug); #endif return(cataloguesPerUser); }