public static TfsTeamProjectCollection GetTeamProjectCollection(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { TfsTeamProjectCollection result; TfsClientCredentials credential = null; if (tfsCredentials != null) { credential = tfsCredentials.GetCredentials(); } else { if (Defaults.GetDefaultCredentials(tfsCollectionUri) != null) { credential = Defaults.GetDefaultCredentials(tfsCollectionUri).GetCredentials(); } } if (credential != null) { result = new TfsTeamProjectCollection(tfsCollectionUri, credential); result.Connect(ConnectOptions.IncludeServices); } else { result = new TfsTeamProjectCollection(tfsCollectionUri); } return result; }
private void BtnGetInformation_Click(object sender, EventArgs e) { TfsTeamProjectCollection ProjectCollection = new TfsTeamProjectCollection(new Uri("http://example.com:8080/tfs/ProjectCollection")); ProjectCollection.Connect(ConnectOptions.None); var vcs = ProjectCollection.GetService <VersionControlServer>(); VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C529", null); VersionSpec versionTo = VersionSpec.Latest; string serverPath = @"$/"; List <Changeset> Changesets = vcs.QueryHistory(serverPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, Int32.MaxValue, true, false ).Cast <Changeset>().ToList <Changeset>(); BaseChangesets = Changesets; if (BaseChangesets != null) { GrpDateFilter.Enabled = true; } }
private TfsTeamProjectCollection ConnectAndCacheCredentials() { Uri serverUri = null; try { serverUri = new Uri(tbServer.Text); } catch (FormatException ex) { MessageBox.Show(this, "Invalid server URL: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } TfsClientCredentials cred = GetCredentials(serverUri); TfsTeamProjectCollection cfgServer = new TfsTeamProjectCollection(serverUri, cred); try { cfgServer.Connect(ConnectOptions.IncludeServices); return(cfgServer); } catch (Exception ex) { MessageBox.Show(this, "Cannot login: "******"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } }
public void Save() { Uri collectionUri = null; TfsTeamProjectCollection collection = null; try { collectionUri = new Uri(Uri); collection = new TfsTeamProjectCollection(collectionUri); } catch (Exception) { throw new Exception("Invalid URL, please enter a valid URL to a TFS Project Collection."); } try { collection.Connect(ConnectOptions.IncludeServices); if (!ClientConfiguration.Current.Sources.Contains(this)) { ClientConfiguration.Current.Sources.Add(this); } ClientConfiguration.Current.Save(); } catch (Exception ex) { throw new Exception(string.Format("Unable to connect to TFS, error message was:\n\n{0}", ex.Message)); } }
public static TfsTeamProjectCollection GetTeamProjectCollection(Uri tfsCollectionUri, ITfsCredentials tfsCredentials) { TfsTeamProjectCollection result; TfsClientCredentials credential = null; if (tfsCredentials != null) { credential = tfsCredentials.GetCredentials(); } else { if (Defaults.GetDefaultCredentials(tfsCollectionUri) != null) { credential = Defaults.GetDefaultCredentials(tfsCollectionUri).GetCredentials(); } } if (credential != null) { result = new TfsTeamProjectCollection(tfsCollectionUri, credential); result.Connect(ConnectOptions.IncludeServices); } else { result = new TfsTeamProjectCollection(tfsCollectionUri); } return(result); }
private TfsTeamProjectCollection ConnectToTfs() { var tfsServer = new TfsTeamProjectCollection(new Uri(Properties.Settings.Default.TfsAddress)); tfsServer.ClientCredentials = new TfsClientCredentials(new WindowsCredential()); tfsServer.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.None); return tfsServer; }
public TfsTeamProjectCollection GenerateTfsConnection() { var tfs= new TfsTeamProjectCollection(GetTfsUri(), GetNetworkCredential()); tfs.Authenticate(); tfs.Connect(new ConnectOptions()); return tfs; }
public TfsTeamProjectCollection GenerateTfsConnection() { var tfs = new TfsTeamProjectCollection(GetTfsUri(), GetNetworkCredential()); tfs.Authenticate(); tfs.Connect(new ConnectOptions()); return(tfs); }
/// <summary> /// Create a new instance of TFSAPI Class /// </summary> /// <param name="TfsCollectionURI">URI to access the TFS Server and project collection</param> /// <param name="ProjectName">Default project</param> public TFSAPI(Uri TfsCollectionURI, string ProjectName) { teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(TfsCollectionURI); teamProjectCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices); teamProjectCollection.EnsureAuthenticated(); wiStore = new WorkItemStore(teamProjectCollection); workItemTypeCollection = wiStore.Projects[ProjectName].WorkItemTypes; }
private TfsTeamProjectCollection Connect(ServiceContext context) { var token = new Microsoft.TeamFoundation.Client.SimpleWebTokenCredential(Username, Password); var clientCreds = new Microsoft.TeamFoundation.Client.TfsClientCredentials(token); projectCollection = new TfsTeamProjectCollection(new Uri(ConnectionString), clientCreds); projectCollection.EnsureAuthenticated(); projectCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.None); return(projectCollection); }
/// <summary> /// Create a new instance of TFSAPI Class /// </summary> /// <param name="TfsCollectionURI">URI to access the TFS Server and project collection</param> /// <param name="ProjectName">Default project</param> public TFSAPI(Uri TfsCollectionURI, string ProjectName) { teamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(TfsCollectionURI); teamProjectCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices); teamProjectCollection.EnsureAuthenticated(); wiStore = new WorkItemStore(teamProjectCollection); workItemTypeCollection = wiStore.Projects[ProjectName].WorkItemTypes; }
public static void MyClassInitialize(TestContext testContext) { NetworkCredential networkCredential = new NetworkCredential(@"*****@*****.**","zippyd00da"); BasicAuthToken basicAuthToken = new BasicAuthToken(networkCredential); BasicAuthCredential basicAuthCredential = new BasicAuthCredential(basicAuthToken); TfsClientCredentials tfsClientCredentials = new TfsClientCredentials(basicAuthCredential); tfsClientCredentials.AllowInteractive = false; server2 = new TfsTeamProjectCollection(new Uri("https://rdavis.visualstudio.com/DefaultCollection"), tfsClientCredentials); server2.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.None); server2.EnsureAuthenticated(); server2.Authenticate(); if (!server2.HasAuthenticated) throw new InvalidOperationException("Not authenticated"); store = new WorkItemStore(server2); }
public Server(Uri tfsUrl, string projectName, System.Net.ICredentials credentials) { this.ResetDetails(); try { teamUri = tfsUrl; this.projectName = projectName; tpc = new TfsTeamProjectCollection(teamUri, credentials); tpc.Connect(ConnectOptions.IncludeServices); workItemStore = tpc.GetService <WorkItemStore>(); linkTypes = new List <WorkItemLinkType>(workItemStore.WorkItemLinkTypes); this.executor = new TFS.Execution.Executor(); this.isValid = true; css4 = tpc.GetService <ICommonStructureService4>(); } catch { this.ResetDetails(); } }
public static bool AddAADGroupToTPCustomGroup(string teamProject, string tpCustomGroupName, string aadGroupName, string organizationUrl) { VssCredentials creds = new VssClientCredentials(); creds.Storage = new VssClientCredentialStorage(); var tpc = new TfsTeamProjectCollection(new Uri(organizationUrl), creds); tpc.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices); IIdentityManagementService ims = tpc.GetService <IIdentityManagementService>(); string tpCustomGroupNameFull = "[" + teamProject + "]" + "\\" + tpCustomGroupName; string aadGroupNameFull = "[TEAM FOUNDATION]" + "\\" + aadGroupName; //for AAD Groups try { var tfsGroupIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, tpCustomGroupNameFull, MembershipQuery.None, ReadIdentityOptions.IncludeReadFromSource); var aadGroupIdentity = ims.ReadIdentity(IdentitySearchFactor.AccountName, aadGroupNameFull, MembershipQuery.None, ReadIdentityOptions.IncludeReadFromSource); ims.AddMemberToApplicationGroup(tfsGroupIdentity.Descriptor, aadGroupIdentity.Descriptor); Console.WriteLine("Group added: " + aadGroupName + " to " + tpCustomGroupName); return(true); } catch (Exception ex) { Console.WriteLine("Group cannot be added: " + aadGroupName + ", " + tpCustomGroupName); return(false); } }
/// <summary> /// The connect. /// </summary> /// <param name="uri"> /// The uri. /// </param> /// <param name="credentials"> /// The credentials. /// </param> /// <returns> /// is connected /// </returns> public bool Connect(Uri uri, ICredentials credentials, bool anotherUser) { List <CatalogNode> catalogNodes = GetCatalogNodes(uri, credentials, anotherUser); if (catalogNodes != null) { nodes = new List <CatalogNode>(); foreach (CatalogNode node in catalogNodes) { try { bool _isvsservice = uri.ToString().Contains("visualstudio.com"); using (TfsTeamProjectCollection projCollection = new TfsTeamProjectCollection(new Uri(string.Format(@"{0}/{1}", uri, (_isvsservice)? "" : node.Resource.DisplayName)), Credential)) { projCollection.EnsureAuthenticated(); projCollection.Connect(ConnectOptions.None); nodes.Add(node); } } catch (TeamFoundationServiceUnavailableException ex) { } catch (Exception ex) { //MessageBox.Show(ex.Message); } } if (nodes.Count > 0) { ChangeCollection(nodes[0].Resource.DisplayName); tfsVersion = collection.GetVersion(); return(true); } } return(false); }
/// <summary> /// Opens the Common TFS Project Selection Form. /// </summary> /// <returns></returns> public static ITestManagementTeamProject SelectTfsProject(bool isDestinationProject) { TeamProjectPicker teamProjectPicker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); DialogResult result = teamProjectPicker.ShowDialog(); if (result == DialogResult.OK && teamProjectPicker.SelectedTeamProjectCollection != null) { if (isDestinationProject && teamProjectPicker.SelectedTeamProjectCollection != null) { TfsTeamProjectCollection destinationTeamProjectCollection = teamProjectPicker.SelectedTeamProjectCollection; destinationTeamProjectCollection.Connect(ConnectOptions.IncludeServices); _destinationStructureService = destinationTeamProjectCollection.GetService(typeof(ICommonStructureService)) as ICommonStructureService; } TfsTeamProjectCollection teamProjectCollection = teamProjectPicker.SelectedTeamProjectCollection; ITestManagementService testManagementService = (ITestManagementService)teamProjectCollection.GetService(typeof(ITestManagementService)); ITestManagementTeamProject project = testManagementService.GetTeamProject(teamProjectPicker.SelectedProjects[0].Name); return(project); } return(null); }
public bool Connect() { try { if (teamFoundationServerExt.ActiveProjectContext == null) { return(false); } if (tfsCollection == null || !tfsConnectionUrl.Equals(teamFoundationServerExt.ActiveProjectContext.DomainUri, StringComparison.CurrentCultureIgnoreCase)) { tfsConnectionUrl = teamFoundationServerExt.ActiveProjectContext.DomainUri; if (string.IsNullOrWhiteSpace(tfsConnectionUrl)) { return(false); } if (ConnectionChanged != null) { ConnectionChanged(this, null); } logger.Log(string.Format("Connecting to TFS server '{0}'", tfsConnectionUrl), LogLevel.Info); tfsCollection = new TfsTeamProjectCollection(new Uri(tfsConnectionUrl)); tfsCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.None); return(true); } else { return(true); } } catch (Exception ex) { logger.Log(string.Format("Error trying to connect to tfs server\n {0}", ex.ToString()), LogLevel.Error); return(false); } }
public bool Connect() { try { if (teamFoundationServerExt.ActiveProjectContext == null) { return false; } if (tfsCollection == null || !tfsConnectionUrl.Equals(teamFoundationServerExt.ActiveProjectContext.DomainUri, StringComparison.CurrentCultureIgnoreCase)) { tfsConnectionUrl = teamFoundationServerExt.ActiveProjectContext.DomainUri; if (string.IsNullOrWhiteSpace(tfsConnectionUrl)) { return false; } if(ConnectionChanged != null) { ConnectionChanged(this, null); } logger.Log(string.Format("Connecting to TFS server '{0}'", tfsConnectionUrl), LogLevel.Info); tfsCollection = new TfsTeamProjectCollection(new Uri(tfsConnectionUrl)); tfsCollection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.None); return true; } else { return true; } } catch (Exception ex) { logger.Log(string.Format("Error trying to connect to tfs server\n {0}", ex.ToString()), LogLevel.Error); return false; } }
private void BtnRefresh_Click(object sender, EventArgs e) { DateTime DateFrom = DateTime.Parse(TxtDateFrom.Text); DateTime DateTo = DateTime.Parse(TxtDateTo.Text); DataTable dt = new DataTable(); dt.Columns.Add("folder_path"); dt.Columns.Add("filename"); dt.Columns.Add("username"); dt.Columns.Add("datetime_entered"); dt.Columns.Add("message"); TfsTeamProjectCollection ProjectCollection = new TfsTeamProjectCollection(new Uri("http://example.com:8080/tfs/defaultcollection")); ProjectCollection.Connect(ConnectOptions.None); var vcs = ProjectCollection.GetService <VersionControlServer>(); VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C529", null); VersionSpec versionTo = VersionSpec.Latest; string serverPath = @"$/"; List <Changeset> Changesets = vcs.QueryHistory(serverPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, Int32.MaxValue, true, false ).Cast <Changeset>().ToList <Changeset>(); List <Changeset> FilteredChangesets = new List <Changeset>(); foreach (Changeset c in Changesets) { if (c.CreationDate > DateFrom && c.CreationDate < DateTo) { FilteredChangesets.Add(c); } } foreach (Changeset c in FilteredChangesets) { List <Change> Changes = c.Changes.ToList <Change>(); if (Changes != null && Changes.Count > 0) { foreach (Change ch in Changes) { if (ch.Item.ItemType == ItemType.File) { DataRow dr = dt.NewRow(); dr["folder_path"] = ch.Item.ServerItem; dr["filename"] = ch.Item.ServerItem; dr["username"] = c.Committer; dr["datetime_entered"] = c.CreationDate.ToString("dd/MM/yyyy HH:mm"); dr["message"] = c.Comment; dt.Rows.Add(dr); } } } } DgvResults.DataSource = dt; }
private void ApplyUserServerPreferences() { if (_userPreferences.TfsUri.Value == null || String.IsNullOrEmpty(_userPreferences.TestProject)) { return; } _logger.Info("Apply server preferences. TFS URI: {0}; TestProject: {1}", _userPreferences.TfsUri.Value, _userPreferences.TestProject); _tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_userPreferences.TfsUri); _tfs.Connect(ConnectOptions.IncludeServices); _testProject = _tfs.GetService<ITestManagementService>().GetTeamProject(_userPreferences.TestProject); _changeProjectToolStripButton.Text = _userPreferences.TestProject; }
/// <summary> /// The connect. /// </summary> /// <param name="uri"> /// The uri. /// </param> /// <param name="credentials"> /// The credentials. /// </param> /// <returns> /// is connected /// </returns> public bool Connect(Uri uri, ICredentials credentials, bool anotherUser) { List<CatalogNode> catalogNodes = GetCatalogNodes(uri, credentials, anotherUser); if (catalogNodes != null) { nodes = new List<CatalogNode>(); foreach (CatalogNode node in catalogNodes) { try { using (TfsTeamProjectCollection projCollection = new TfsTeamProjectCollection(new Uri(string.Format(@"{0}/{1}", uri, node.Resource.DisplayName)), Credential)) { projCollection.Connect(ConnectOptions.None); nodes.Add(node); } } catch (TeamFoundationServiceUnavailableException) { } catch (Exception ex) { //MessageBox.Show(ex.Message); } } if (nodes.Count > 0) { ChangeCollection(nodes[0].Resource.DisplayName); tfsVersion = collection.GetVersion(); return true; } } return false; }
private static void GetTeamProjectCollection() { _collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tpcUri)); _collection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices); }
static void Main(string[] args) { try { Console.WriteLine("please Enter the TFS Server IP : "); String TfsServerIp = Console.ReadLine(); String TfsServerPort = "8080"; String TfsServerVirtualPath = "tfs"; String TfsServerUriString = string.Format("http://{0}:{1}/{2}", TfsServerIp, TfsServerPort, TfsServerVirtualPath); Uri TfsServerUri = new Uri(TfsServerUriString); TfsConfigurationServer TfsServerconfiguration = TfsConfigurationServerFactory.GetConfigurationServer(TfsServerUri); ReadOnlyCollection<CatalogNode> ProjectCollectionNodes = TfsServerconfiguration.CatalogNode.QueryChildren( new[] { CatalogResourceTypes.ProjectCollection }, false, CatalogQueryOptions.None); Console.WriteLine("please enter the ProjectCollection name : "); string ProjectCollectionName = Console.ReadLine(); foreach (CatalogNode ProjectCollectionNode in ProjectCollectionNodes) { if (ProjectCollectionNode.Resource.DisplayName == ProjectCollectionName) { Guid collectionId = new Guid(ProjectCollectionNode.Resource.Properties["InstanceId"]); TfsTeamProjectCollection TeamProjectCollection = TfsServerconfiguration.GetTeamProjectCollection(collectionId); TeamProjectCollection.Connect(ConnectOptions.None); VersionControlServer Vcs = TeamProjectCollection.GetService<VersionControlServer>(); ReadOnlyCollection<CatalogNode> TeamProjectNodes = ProjectCollectionNode.QueryChildren( new[] { CatalogResourceTypes.TeamProject }, false, CatalogQueryOptions.None); Console.WriteLine("please enter the Team Project name : "); String TeamProjectName = Console.ReadLine(); Console.WriteLine("Please enter the Branch name : "); String BranchName = Console.ReadLine(); foreach (CatalogNode TeamProjectNode in TeamProjectNodes) { if (TeamProjectNode.Resource.DisplayName == TeamProjectName) { var tp = Vcs.GetTeamProject(TeamProjectNode.Resource.DisplayName); var ServerPath = String.Format("{0}/Branches/{1}", tp.ServerItem, BranchName); VersionSpec versionFrom = null; VersionSpec versionTo = VersionSpec.Latest; var ChangeSetList = Vcs.QueryHistory( ServerPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, Int32.MaxValue, true, true ).Cast<Changeset>().ToList(); Changeset Lastchangeset = null; Lastchangeset = ChangeSetList.First(); Console.WriteLine(".....last Changest Report....."); Console.WriteLine(); Console.WriteLine(string.Format("ID : {0} , Date: {1} , Comment : {2} , by : {3} ", Lastchangeset.ChangesetId, Lastchangeset.CreationDate, Lastchangeset.Comment, Lastchangeset.OwnerDisplayName)); Console.WriteLine(); Console.WriteLine(".....End The Report....."); } } } } Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(" Warnining "); Console.WriteLine("-----------please check your TFS Server IP-----------"); Console.ReadLine(); } }
protected override void OnCheckConnection(PluginProfileErrorCollection errors, TfsPluginProfile settings) { settings.ValidateStartRevision(errors); settings.ValidateUri(errors); if (!errors.Any()) { TfsTeamProjectCollection collection = null; try { TfsConnectionParameters parameters = TfsConnectionHelper.GetTfsConnectionParameters(settings); switch (parameters.SegmentsCount) { case UriTfsProjectCollection: { collection = new TfsTeamProjectCollection(parameters.TfsCollectionUri, parameters.Credential); collection.EnsureAuthenticated(); collection.Connect(ConnectOptions.None); var vcs = collection.GetService <VersionControlServer>(); CheckChangeset(settings, vcs); break; } case UriTfsTeamProject: { collection = new TfsTeamProjectCollection(parameters.TfsCollectionUri, parameters.Credential); collection.EnsureAuthenticated(); collection.Connect(ConnectOptions.None); var vcs = collection.GetService <VersionControlServer>(); TeamProject teamProject = vcs.GetTeamProject(parameters.TeamProjectName); CheckChangeset(settings, vcs, teamProject); break; } default: errors.Add(new PluginProfileError { FieldName = "Uri", Message = "Could not connect to server." }); break; } } catch (TeamFoundationServerUnauthorizedException e) { errors.Add( new PluginProfileError { Status = PluginProfileErrorStatus.WrongCredentialsError, FieldName = "Login", Message = "Authorization failed.", AdditionalInfo = e.Message }); errors.Add( new PluginProfileError { Status = PluginProfileErrorStatus.WrongCredentialsError, FieldName = "Password", Message = "Authorization failed.", AdditionalInfo = e.Message }); } catch (ResourceAccessException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "Uri", Message = "Resource access denied", Status = PluginProfileErrorStatus.Error }); } catch (ChangesetNotFoundException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "StartRevision", Message = "There’s no such revision.", Status = PluginProfileErrorStatus.UnexistedRevisionWarning }); } catch (TeamFoundationServiceUnavailableException e) { errors.Add(new PluginProfileError { AdditionalInfo = e.Message, FieldName = "Uri", Message = "Could not connect to server.", }); } finally { if (collection != null) { collection.Dispose(); } } } }
private static void GetTeamProjectCollection() { _collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(tpcUri)); _collection.Connect(Microsoft.TeamFoundation.Framework.Common.ConnectOptions.IncludeServices); }
private void BtnRefresh_Click(object sender, EventArgs e) { DateTime DateFrom = DateTime.Parse(TxtDateFrom.Text); DateTime DateTo = DateTime.Parse(TxtDateTo.Text); DataTable dt = new DataTable(); dt.Columns.Add("folder_path"); dt.Columns.Add("filename"); dt.Columns.Add("username"); dt.Columns.Add("datetime_entered"); dt.Columns.Add("message"); TeamProjectPicker ProjectPicker = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, false); ProjectPicker.ShowDialog(); TfsTeamProjectCollection ProjectCollection = ProjectPicker.SelectedTeamProjectCollection; ProjectCollection.Connect(ConnectOptions.None); var vcs = ProjectCollection.GetService <VersionControlServer>(); VersionSpec versionFrom = VersionSpec.ParseSingleSpec("C529", null); VersionSpec versionTo = VersionSpec.Latest; string serverPath = @"$/"; List <Changeset> Changesets = vcs.QueryHistory(serverPath, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, Int32.MaxValue, true, false ).Cast <Changeset>().ToList <Changeset>(); List <Changeset> FilteredChangesets = new List <Changeset>(); foreach (Changeset c in Changesets) { if (c.CreationDate > DateFrom && c.CreationDate < DateTo) { FilteredChangesets.Add(c); } } foreach (Changeset c in FilteredChangesets) { DataRow dr = dt.NewRow(); dr["folder_path"] = ""; dr["filename"] = ""; dr["username"] = c.Committer; dr["datetime_entered"] = c.CreationDate.ToString("dd/MM/yyyy HH:mm"); dr["message"] = c.Comment; dt.Rows.Add(dr); } DgvResults.DataSource = dt; }