void bgWorker_DoWork(object sender, DoWorkEventArgs e) { try { ITrac trac = TracCommon.GetTrac((ServerDetails)e.Argument); //TODO: Multicall List <MulticallItem> attributes = new List <MulticallItem>(); attributes.Add(new MulticallItem("ticket.component.getAll", new string[] { })); attributes.Add(new MulticallItem("ticket.milestone.getAll", new string[] {})); attributes.Add(new MulticallItem("ticket.severity.getAll", new string[] {})); attributes.Add(new MulticallItem("ticket.type.getAll", new string[] {})); attributes.Add(new MulticallItem("ticket.priority.getAll", new string[] { })); attributes.Add(new MulticallItem("ticket.status.getAll", new string[] { })); attributes.Add(new MulticallItem("ticket.resolution.getAll", new string[] { })); attributes.Add(new MulticallItem("ticket.version.getAll", new string[] { })); object[] result = trac.multicall(attributes.ToArray()); e.Result = result; } catch (Exception ex) { e.Result = ex; } }
/// <summary> /// Returns an <see cref="ITrac"/> instance which is connected to a <see cref="ServerDetails"/> object. /// </summary> /// <param name="serverDetails"></param> /// <returns></returns> public static ITrac GetTrac(ServerDetails serverDetails) { ITrac trac = XmlRpcProxyGen.Create <ITrac>(); trac.Proxy = WebRequest.DefaultWebProxy; trac.Url = serverDetails.XmlRpcUrl(); switch (serverDetails.RequiredAuthentication) { case AuthenticationTypes.BasicAuthentication: trac.Credentials = new NetworkCredential(serverDetails.Username, serverDetails.Password); break; case AuthenticationTypes.IntegratedAuthentication: trac.Credentials = CredentialCache.DefaultNetworkCredentials; break; case AuthenticationTypes.ClientCertAuthentication: try { X509Store s = new X509Store(StoreName.My, StoreLocation.CurrentUser); X509Certificate2Collection col; s.Open(OpenFlags.ReadOnly); col = s.Certificates.Find(X509FindType.FindBySubjectName, serverDetails.Username, true); if (col.Count == 1) { trac.ClientCertificates.Add(col[0]); } else { System.Windows.Forms.MessageBox.Show("No or multiple (" + col.Count + ") certificate with name [" + serverDetails.Username + "] found."); } s.Close(); } catch (System.Security.Cryptography.CryptographicException s) { System.Windows.Forms.MessageBox.Show("CryptographicException: " + s.ToString()); } catch (System.Security.SecurityException s) { System.Windows.Forms.MessageBox.Show("SecurityException: " + s.ToString()); } catch (System.ArgumentException s) { System.Windows.Forms.MessageBox.Show("ArgumentException: " + s.ToString()); } break; case AuthenticationTypes.None: trac.Credentials = null; break; } return(trac); }
void bgWorker_DoWork(object sender, DoWorkEventArgs e) { try { ITrac trac = TracCommon.GetTrac((ServerDetails)e.Argument); string[] pages = trac.getAllPages(); List <string> wikiPages = new List <string>(pages); wikiPages.Sort(); e.Result = wikiPages; } catch (Exception ex) { e.Result = ex; } }
public static void Init(TestContext context) { ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error) { // just accept any ssl connection for the unit tests return(true); }; //List<ServerDetails> servers = ServerDetails.LoadAll(); SetAllowUnsafeHeaderParsing(); //trac = TracCommon.GetTrac(servers[1]); // get the first server from the registry var server = new ServerDetails("https://gtsoftware.xp-dev.com/trac/TracExplorer/", "buildserver", "e5Yz6w4X4MFQmDUgEndK"); trac = TracCommon.GetTrac(server); xmlrpc.Tracer tracer = new xmlrpc.Tracer(); tracer.Attach(trac); //call a method just to get exception here is there is a problem. Then no tests will run. object result = trac.getAPIVersion(); }
/// <summary> /// Start the background thread and disable all control while it works /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void wizardPage2_ShowFromNext(object sender, EventArgs e) { this.Cursor = Cursors.WaitCursor; wizard1.NextEnabled = wizard1.BackEnabled = wizard1.CancelEnabled = false; pictureBox1.Visible = true; lblStatus.Text = Properties.Resources.LabelChecking; lblError.Text = string.Empty; UpdateServerDetails(); ITrac trac = TracCommon.GetTrac(_server); IAsyncResult asr = trac.BeginGetAPIVersion(); while (asr.IsCompleted == false) { Application.DoEvents(); } try { object[] ret = trac.EndGetAPIVersion(asr); lblStatus.Text = Properties.Resources.LabelCheckingSuccess; } catch (Exception ex) { lblStatus.Text = Properties.Resources.LabelCheckingFailure; lblError.Text = ex.Message; } wizard1.BackEnabled = wizard1.CancelEnabled = true; wizard1.NextEnabled = (lblError.Text == string.Empty); pictureBox1.Visible = false; this.Cursor = Cursors.Default; }
private void bgwTickets_DoWork(object sender, DoWorkEventArgs e) { try { ITrac trac = TracCommon.GetTrac(ServerDetails); List <int> tickets = new List <int>(); try { for (int i = 1; i < 1000; i++)///TODO: replace 1000 by number of tickets/100 { tickets.AddRange(trac.queryTickets(string.Format("{0}&page={1}", TicketDefinition.Filter, i))); } } catch (XmlRpcFaultException) { //There are no more pages left to fetch } List <MulticallItem> ticketItems = new List <MulticallItem>(); foreach (int id in tickets) { ticketItems.Add(new MulticallItem("ticket.get", new string[] { id.ToString() })); } object[] results = trac.multicall(ticketItems.ToArray()); // convert SortableBindingList <Ticket> ticketArr = new SortableBindingList <Ticket>(); foreach (object[] result in results) { object[] items = result[0] as object[]; XmlRpcStruct attributes = items[3] as XmlRpcStruct; Ticket t = new Ticket(); t.Id = int.Parse(items[0].ToString()); t.Created = ParseDate(items[1]); t.LastModified = ParseDate(items[2]); t.Status = (string)attributes["status"]; t.Description = (string)attributes["description"]; t.Reporter = (string)attributes["reporter"]; t.CC = (string)attributes["cc"]; t.Resolution = (string)attributes["resolution"]; t.Component = (string)attributes["component"]; t.Summary = (string)attributes["summary"]; t.Priority = (string)attributes["priority"]; t.Keywords = (string)attributes["keywords"]; t.Version = (string)attributes["version"]; t.Milestone = (string)attributes["milestone"]; t.Owner = (string)attributes["owner"]; t.TicketType = (string)attributes["type"]; t.Severity = (string)attributes["severity"]; t.Icon = string.IsNullOrEmpty(t.Resolution) ? Resources.newticket : Resources.closedticket; ticketArr.Add(t); } e.Result = ticketArr; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void Init(TestContext context) { ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error) { // just accept any ssl connection for the unit tests return true; }; //List<ServerDetails> servers = ServerDetails.LoadAll(); SetAllowUnsafeHeaderParsing(); //trac = TracCommon.GetTrac(servers[1]); // get the first server from the registry trac = TracCommon.GetTrac(new ServerDetails("http://tracexplorer.devjavu.com/", "*****@*****.**", "testing")); xmlrpc.Tracer tracer = new xmlrpc.Tracer(); tracer.Attach(trac); //call a method just to get exception here is there is a problem. Then no tests will run. object result = trac.getAPIVersion(); }