当前位置: 首页>>代码示例>>C#>>正文


C# TfsTeamProjectCollection.Dispose方法代码示例

本文整理汇总了C#中TfsTeamProjectCollection.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TfsTeamProjectCollection.Dispose方法的具体用法?C# TfsTeamProjectCollection.Dispose怎么用?C# TfsTeamProjectCollection.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TfsTeamProjectCollection的用法示例。


在下文中一共展示了TfsTeamProjectCollection.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLastButOneRevision

		public string GetLastButOneRevision()
		{
			var collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);

			var changesets = vcs.QueryHistory(
					tp.ServerItem,
					VersionSpec.Latest,
					0,
					RecursionType.Full,
					null,
					null,
					null,
					Int32.MaxValue,
					true,
					true).Cast<Changeset>().ToArray();

			collection.Dispose();

			if (changesets.Count() == 1)
				return changesets.First().ChangesetId.ToString();

			int lastButOneChangeset = changesets.Where(x => x.ChangesetId < changesets.Max(m => m.ChangesetId)).Max(x => x.ChangesetId);

			return lastButOneChangeset.ToString(CultureInfo.InvariantCulture);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:27,代码来源:TfsFuncTestRepository.cs

示例2: CollectionExists

        public static bool CollectionExists(Uri collectionUri, ICredentials credentials, out bool isAuthorized)
        {
            TfsTeamProjectCollection collection = null;

            try
            {
                collection = new TfsTeamProjectCollection(collectionUri, credentials);
                collection.EnsureAuthenticated();
                isAuthorized = true;

                return true;
            }
            catch (TeamFoundationServerUnauthorizedException)
            {
                isAuthorized = false;

                return true;
            }
            catch
            {
                isAuthorized = false;

                return false;
            }
            finally
            {
                collection.Dispose();
                collection = null;
            }
        }
开发者ID:wullemsb,项目名称:TFS-Monitor,代码行数:30,代码来源:TFSBaseProxy.cs

示例3: GetLatestRevision

        public string GetLatestRevision()
        {
            TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.TestCollection));
            var vcs = collection.GetService<VersionControlServer>();
            TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.TestCollectionProject);
            var maxChangeset = vcs.QueryHistory(
                        tp.ServerItem,
                        VersionSpec.Latest,
                        0,
                        RecursionType.Full,
                        null,
                        null,
                        null,
                        Int32.MaxValue,
                        true,
                        true).Cast<Changeset>().Max(x => x.ChangesetId);

            collection.Dispose();

            return maxChangeset.ToString();
        }
开发者ID:sbcfwebdev,项目名称:Target-Process-Plugins,代码行数:21,代码来源:TfsTestRepository.cs

示例4: ClearFileContent

		public void ClearFileContent()
		{
			TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);
			ItemSet itemSet = vcs.GetItems(tp.ServerItem, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.File);
			Item item = itemSet.Items.FirstOrDefault(x => x.ServerItem == string.Concat("$/", ConfigHelper.Instance.FuncTestsProject + "/testFile.txt"));

			string localItem = _workspace.GetLocalItemForServerItem(item.ServerItem);
			_workspace.PendEdit(localItem);

			using (var file = File.Open(localItem, FileMode.Truncate)) { }

			PendingChange[] pendingChanges = _workspace.GetPendingChanges().Where(x => x.ChangeType == ChangeType.Edit).ToArray();
			_workspace.CheckIn(pendingChanges, ConfigHelper.Instance.Login, string.Empty, null, null, null);

			collection.Dispose();
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:18,代码来源:TfsFuncTestRepository.cs

示例5: Commit

		public string Commit(string serverItemPath, string changedContent, string commitComment)
		{
			TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri(ConfigHelper.Instance.FuncTestCollection));
			var vcs = collection.GetService<VersionControlServer>();
			TeamProject tp = vcs.GetTeamProject(ConfigHelper.Instance.FuncTestsProject);
			ItemSet itemSet = vcs.GetItems(tp.ServerItem, VersionSpec.Latest, RecursionType.Full, DeletedState.NonDeleted, ItemType.File);
			Item item = itemSet.Items.FirstOrDefault(x => x.ServerItem == serverItemPath);

			string localItem = _workspace.GetLocalItemForServerItem(item.ServerItem);
			int changesetId = _workspace.PendEdit(localItem);

			using (var file = File.OpenWrite(localItem))
			{
				var changes = new UTF8Encoding(true).GetBytes(changedContent);
				file.Seek(0, SeekOrigin.End);
				file.Write(changes, 0, changes.Length);
			}

			PendingChange[] pendingChanges = _workspace.GetPendingChanges().Where(x => x.ChangeType == ChangeType.Edit).ToArray();
			int changeset = _workspace.CheckIn(pendingChanges, ConfigHelper.Instance.Login, commitComment, null, null, null);

			Changeset latestChangeset = vcs.GetChangeset(changeset);

			collection.Dispose();

			return latestChangeset.ChangesetId.ToString(CultureInfo.InvariantCulture);
		}
开发者ID:TargetProcess,项目名称:Target-Process-Plugins,代码行数:27,代码来源:TfsFuncTestRepository.cs

示例6: button_save_Click


//.........这里部分代码省略.........
                    }
                    else
                    {
                        workItem.Fields[fieldSystenInfo].Value = textbox_SystemInfo.Text;
                    }

                }

                string fieldsReproStreps = "Microsoft.VSTS.TCM.ReproSteps";
                if (workItem.Fields.Contains(fieldsReproStreps))
                {
                    workItem.Fields[fieldsReproStreps].Value = textbox_ReproStep.Text;
                    if (string.IsNullOrEmpty(textbox_ReproStep.Text))
                    {
                        workItem.Fields[fieldsReproStreps].Value = workItem.Description;
                    }
                }

                // add image
                string tempFile = Path.Combine(Environment.CurrentDirectory, this.Filename);
                File.WriteAllBytes(tempFile, this.ImageData);

                workItem.Attachments.Add(new Attachment(tempFile));

                // Link the failed test case to the Bug
                // workItem.Links.Add(new RelatedLink(testcaseID));

                // Check for validation errors before saving the Bug
                ArrayList validationErrors = workItem.Validate();

                if (validationErrors.Count == 0)
                {
                    workItem.Save();

                    if (this.TFSInfo == null)
                    {
                        this.TFSInfo = new TFSInfo();
                    }

                    this.TFSInfo.ID = workItem.Id.ToString();
                    this.TFSInfo.Title = workItem.Title;
                    this.TFSInfo.Description = workItem.Description;

                    // http://stackoverflow.com/questions/6466441/how-to-map-a-tfs-item-url-to-something-viewable
                    var testManagementService = tfs.GetService<ILinking>();
                    this.TFSInfo.WebDetailUrl = testManagementService.GetArtifactUrlExternal(workItem.Uri.ToString());

                    var myService = tfs.GetService<TswaClientHyperlinkService>();
                   this.TFSInfo.WebEditUrl = myService.GetWorkItemEditorUrl(workItem.Id).ToString();

                    if (checkbox_description_addImage.Checked)
                    {
                        if (workItem.Fields["System.Description"].FieldDefinition.FieldType == FieldType.Html)
                        {
                            workItem.Description += string.Format("<br/><a href=\"{0}\"><img src=\"{0}\" /></a>", workItem.Attachments[0].Uri.ToString());
                        }
                        else
                        {
                            workItem.Description += System.Environment.NewLine + workItem.Attachments[0].Uri.ToString();
                        }
                    }

                    if (checkbox_reproStep_AddImage.Checked && (workItem.Fields.Contains(fieldsReproStreps)))
                    {
                        if (workItem.Fields[fieldsReproStreps].FieldDefinition.FieldType == FieldType.Html)
                        {
                            workItem.Fields[fieldsReproStreps].Value += string.Format("<br/><a href=\"{0}\"><img src=\"{0}\" /></a>", workItem.Attachments[0].Uri.ToString());
                        }
                        else
                        {
                            workItem.Fields[fieldsReproStreps].Value += System.Environment.NewLine + workItem.Attachments[0].Uri.ToString();
                        }
                    }

                    workItem.Save();

                    this.SetLastValue();
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    string errrorMsg = "Validation Error in field\n";
                    foreach (Field field in validationErrors)
                    {
                        errrorMsg += field.Name + "\n";
                    }

                    MessageBox.Show(errrorMsg);
                }

                tfs.Dispose();

                // delete temps images
                System.IO.File.Delete(tempFile);
            }
            catch (Exception eError)
            {
                MessageBox.Show(eError.ToString());
            }
        }
开发者ID:ploufs,项目名称:Greenshot-TFS-Plugin,代码行数:101,代码来源:AddForm.cs


注:本文中的TfsTeamProjectCollection.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。