static void Main(string[] args) { CommandLineArgs command = new CommandLineArgs(args); if (command.IsDownload && string.IsNullOrWhiteSpace(command.BuildNumber)) { ConsoleWriter.Write("Cannot download build. Enter a valid build ID to download.", MessageType.Error); Console.ForegroundColor = ConsoleColor.Gray; return; } if (string.IsNullOrWhiteSpace(command.ProjectName) && !string.IsNullOrWhiteSpace(command.BuildNumber)) { ConsoleWriter.Write("No project name specified.", MessageType.Error); Console.ForegroundColor = ConsoleColor.Gray; return; } TFS _tfs = new TFS(command.UserName, command.Password, command.CollectionURL, command.ProjectName, command.BuildNumber); TFSBuild.RootObject obj = _tfs.GetBuilds().Result; if (obj != null) { List <TFSBuild.Value> v = obj.value; if (command.IsDownload) { TFSBuild.Value buildDef = v.Single(x => x.buildNumber == command.BuildNumber); if (!string.IsNullOrEmpty(command.OutputFile)) { ConsoleWriter.Write("Download destination: " + command.OutputFile, MessageType.Information); ConsoleWriter.Write("Initiating download..." + command.OutputFile, MessageType.Information); DownloadBuild _buildDownloader = new DownloadBuild(buildDef.drop.downloadUrl, command.OutputFile + command.BuildNumber + ".zip"); _buildDownloader.Download(); ConsoleWriter.Write("Download Successfull!!" + command.OutputFile, MessageType.Information); } else { ConsoleWriter.Write("Download destination: " + command.OutputFile, MessageType.Information); DownloadBuild _buildDownloader = new DownloadBuild(buildDef.drop.downloadUrl, command.BuildNumber + ".zip"); _buildDownloader.Download(); ConsoleWriter.Write("Download Successfull!!" + command.OutputFile, MessageType.Information); } } else { foreach (var _value in v) { ConsoleWriter.Write("Build Number: " + _value.buildNumber, MessageType.Success); ConsoleWriter.Write("Download URL: " + _value.drop.downloadUrl, MessageType.Success); ConsoleWriter.Write("------------------------------------------------------------------", MessageType.Success); } } } //restore the original console foreground color ConsoleWriter.Write("Press any key to exit..." + command.OutputFile, MessageType.Information); Console.ForegroundColor = ConsoleColor.Gray; Console.ReadLine(); }
public BuildScheduleViewModel(TFS.Common.WorkflowConfig.MultiEnvironmentWorkflowDefinition multiEnvironmentWorkflowDefinition) { // TODO: Complete member initialization this.Item = multiEnvironmentWorkflowDefinition; this.Item.MainLabWorkflowDefinition.LabBuildDefinitionDetails.PropertyChanged += (sender, args) => { if (args.PropertyName.Equals("ContinuousIntegrationType")) { this.RaisePropertyChanged(() => this.QuietPeriodVisible); this.RaisePropertyChanged(() => this.ScheduledDaysVisible); } }; }
private void LoadProjects(Uri uri) { IsProjectsWorking = true; try { Tfs = new TFS(uri); Projects = Tfs.GetTeamProjects(); if (!Servers.Select(server => server.ToLowerInvariant()).ToList().Contains(uri.AbsoluteUri.ToLowerInvariant())) { Servers.Add(uri.AbsoluteUri.TrimEnd('/')); RaisePropertyChanged(nameof(Servers)); } using (var sqliteConnection = new SqliteConnection("Data Source=" + System.IO.Path.Combine(appPath, "servers.sqlite"))) { sqliteConnection.Open(); var db = DB.DBBase.GetDBInstance(sqliteConnection, 0); db.SaveServer(uri.AbsoluteUri.TrimEnd('/')); sqliteConnection.Close(); } RaisePropertyChanged(nameof(Projects)); } catch (Exception e) { Projects = new List <TeamProject>(); RaisePropertyChanged(nameof(Projects)); MessageBox.Show(e.Message, "TFSMonkey", MessageBoxButton.OK, MessageBoxImage.Error); Tfs = null; } IsProjectsWorking = false; }
public void ShowProject(TFS tfs, TeamProject teamProject) { Tfs = tfs; TeamProject = teamProject; Title = teamProject.Name + "- TFSMonkey"; RaisePropertyChanged(nameof(Title)); SqliteConnection = new SqliteConnection("Data Source=" + System.IO.Path.Combine(appPath, $"{AppData.SanitizePath(Tfs.Url)}-{AppData.SanitizePath(TeamProject.ServerItem)}.sqlite")); Settings = Settings.LoadSettings(SqliteConnection); DataSource = new DataSource(SqliteConnection, tfs, TeamProject, Settings); Page = new Uri("/Views/CombinedPage.xaml", UriKind.Relative); RaisePropertyChanged(nameof(Page)); Task.Factory.StartNew(() => { DataSource.GetData(); new Timer(state => { DataSource.RefreshData(); }).Change(1000 * 60 * 10, 1000 * 60 * 10); }); }
public BacklogManagmenetApp(string tfsUrl, string pat, Action <string> verbose) { this.TfsUrl = tfsUrl; this.PAT = pat; this.TFS = new BacklogManagement(this.TfsUrl, this.PAT, verbose); this.TFS2 = new TFS(this.TfsUrl, this.PAT); this.Verbose = verbose; }
// POST: api/TFS/5 public HttpResponseMessage Post(int id, [FromBody] TFSCredentials credentials) { try { //Get the latest suites for a team with the given credentials TFS.GetLatestTestSuites(id, credentials); return(Request.CreateResponse(HttpStatusCode.OK, true)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.BadRequest, false)); } }
public DataSource(SqliteConnection sqliteConnection, TFS tfs, TeamProject teamProject, Settings settings) { SqliteConnection = sqliteConnection; Tfs = tfs; TeamProject = teamProject; Settings = settings; HistoryItemFactory = new HistoryItemFactory(); WorkItemFactory = new WorkItemFactory(settings); HistoryItems = new ObservableCollectionEx <HistoryItem>(CancellationTokenSource.Token); WorkItems = new ObservableCollectionEx <WorkItem>(CancellationTokenSource.Token); Tfs.HistoryItemFactory = HistoryItemFactory; Tfs.WorkItemFactory = WorkItemFactory; DBLoader = DB.DBBase.GetDBInstance(sqliteConnection); DBSaver = DB.DBBase.GetDBInstance(sqliteConnection, 0); }
public Engine(SVN svn, TFS tfs) { _svn = svn; _tfs = tfs; }
public TimeTrackingApp(string tfsUrl, string pat) { this.TfsUrl = tfsUrl; this.PAT = pat; this.TFS = new TFS(this.TfsUrl, this.PAT); }
/// <summary> /// Based on a list of ids, this copies each TFS TC with matching id to RF /// </summary> /// <param name="testCaseIds">List of TFS testcase IDs.</param> /// <param name="browsers">List of browser names as defined by RF.</param> /// <returns></returns> public Task <List <Core.ServiceException> > CopyTestToRainforest(List <int> testCaseIds, List <string> browsers, Site site) { return(Task.Factory.StartNew(() => { ViewModelLocator.MainWindowViewModel.TaskManager.AddTask(); // store failures, to be returned to UI layer for displaying List <Core.ServiceException> failedPush = new List <Core.ServiceException>(); foreach (int id in testCaseIds) { // Get the required tc data from TFS Services.TFS.TestCaseCopyData tfsCopyData = null; try { tfsCopyData = TFS.GetCopyData(id, site); } catch (Core.ServiceException e) { failedPush.Add(e); continue; } Test rfTestCase = null; // extract the RFID tag from the tfs tc string rfIdTag = null; try { rfIdTag = Parse.ExtractIdFromTags("RFID", tfsCopyData.Tags); } catch (InvalidOperationException) { // somehow has too many tags and it can't be determined which is correct Core.ServiceException e = new Core.ServiceException(Core.Error.TFSTestTooManyTags, id.ToString()); failedPush.Add(e); continue; } // create new RF tc or update if (rfIdTag == null) { // create new in RF rfTestCase = Services.Rainforest.Tests.Create(tfsCopyData.Title); TFS.AddTag(id, $"RFID{rfTestCase.id}"); } else { // get existing string rfID = rfIdTag; try { rfTestCase = Services.Rainforest.Tests.GetSingle(rfID); } catch (Core.HttpException) { failedPush.Add(new Core.ServiceException(Core.Error.RFTestDoesNotExist, id.ToString())); } } // assign title from TFS to RF in case there were updates rfTestCase.title = tfsCopyData.Title; // assign description from TFS to RF rfTestCase.description = tfsCopyData.Description; // assign the test steps from TFS testStepData to RF Elements rfTestCase.elements = new List <TestElement>(); try { // redirect bool values in RF API are stored somewhat awkwardly // if the step is an embedded step at the start of a test case then it is auto redirected // to its start url, but the redirect bool is set to false // otherwise an embedded step will hold the bool and it will reflect the value of the // checkbox presented before the step in the UI on RF // each test case also has a start url, which problematically appears as a redirect box // in the UI after ANY sized chain of embedded steps at the start of the test // // the tool will look for "redirect" TAGS in TFS in order to set these redirect values in RF // this means that two versions may exist for the same embedded test, one redirecting and one not // the reverse logic for this issue for RF -> VSTS is in TS.TestSteps.cs bool redirect = false; bool haveProcessedNormalStep = false; bool isFirstStep = true; // replace the rfTestCase object's steps with the steps from TestCaseCopyData foreach (Services.TFS.TestStepData teststep in tfsCopyData.Steps) { // this is awful logic by design of Rainforest if (isFirstStep) { // by default the first step is always false redirect = false; isFirstStep = false; } else if ((!haveProcessedNormalStep) && (teststep.TFSSharedId == null)) { // if first normal step after some number of embedded steps redirect = TFS.ContainsTag(id, "redirect"); } else if (teststep.TFSSharedId != null) { // if an embedded step, but not the first step redirect = TFS.ContainsTag((int)teststep.TFSSharedId, "redirect"); } else { // if just a normal step at some point other than the first redirect = false; } ElementDocumentation elementDoc = new ElementDocumentation(teststep.RFEmbeddedId, teststep.Title, teststep.ExpectedResult); TestElement element = new TestElement(elementDoc, redirect); rfTestCase.elements.Add(element); // determine if this is first normal step processed haveProcessedNormalStep = haveProcessedNormalStep || (teststep.TFSSharedId == null); } } catch (Core.ServiceException e) { e.AffectedId = id.ToString(); failedPush.Add(e); continue; } // copy the tags from TFS data to RF tc, leave out RFID tag List <string> tags = (from tag in tfsCopyData.Tags where (!tag.Contains("RFID")) select tag).ToList(); rfTestCase.tags = tags; rfTestCase.tags.Add($"TFSID{id}"); // update with the provided browser set from the UI into RF Browsers (if needed) rfTestCase.browsers = browsers; // set the start_uri (aka the redirect url) rfTestCase.start_uri = tfsCopyData.RedirectUrl; // set the site to test this case on rfTestCase.extras["site_id"] = (site == null) ? null : site.id; var response = Services.Rainforest.Tests.UpdateSingle(rfTestCase); } ViewModelLocator.MainWindowViewModel.TaskManager.RemoveTask(); return failedPush; })); }