protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider) { TrackerService.WorkItem workItem = (TrackerService.WorkItem)objectProvider.GetObject(); _behavior = new ObjectDumperBehavior(workItem); StringBuilder builder = new StringBuilder(); Form form = new Form(); form.FormBorderStyle = FormBorderStyle.SizableToolWindow; SplitContainer splitContainer = new SplitContainer(); FastColoredTextBox textBox = new FastColoredTextBox(); textBox.ReadOnly = true; textBox.Text = _behavior.Text; textBox.Dock = DockStyle.Fill; splitContainer.Panel1.Controls.Add(textBox); PropertyGrid propertyGrid = new PropertyGrid(); propertyGrid.SelectedObject = workItem; propertyGrid.Dock = DockStyle.Fill; splitContainer.Panel2.Controls.Add(propertyGrid); splitContainer.Dock = DockStyle.Fill; splitContainer.Parent = form; windowService.ShowDialog(form); }
/// <summary> /// Sets a custom field value. /// </summary> /// <param name="workItem"></param> /// <param name="key"></param> /// <param name="value"></param> public static void SetCustomFieldValue(TrackerService.WorkItem workItem, string key, object value) { CustomField customField = new CustomField(); customField.key = key; customField.value = value; Connection.Tracker.setCustomField(customField); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="index"></param> /// <param name="downloadedFileName"></param> /// <returns></returns> public static FileInfo DownloadAttachment(this TrackerService.WorkItem workItem, int index, string password, string downloadedFileName) { TrackerService.Attachment attachment = API.ExtractAttachment(workItem)[index]; WebClient webClient = new WebClient(); webClient.Credentials = new NetworkCredential(API.Connection.UserName, password); webClient.DownloadFile(attachment.url, downloadedFileName); return(new FileInfo(downloadedFileName)); }
/// <summary> /// /// </summary> /// <param name="id"></param> public PolarionItem(string id = null) { if (string.IsNullOrEmpty(id)) { return; } _workItem = API.GetWorkItemById(id); }
/// <summary> /// Sets the custom field values. /// </summary> /// <param name="workItem"></param> /// <param name="fieldValueAssociation"></param> public static void SetCustomFieldValues(TrackerService.WorkItem workItem, Dictionary <string, object> fieldValueAssociation) { foreach (KeyValuePair <string, object> keyValuePair in fieldValueAssociation) { TrackerService.Custom custom = workItem.customFields.Where(x => x.key == keyValuePair.Key).FirstOrDefault(); if (custom != null) { custom.value = keyValuePair.Value; } } }
/// <summary> /// Creates a work Item /// </summary> /// <param name="workItemType"></param> /// <param name="title"></param> /// <returns></returns> public static TrackerService.WorkItem CreateWorkItem(string workItemType, string title = "Test Run", Dictionary <string, object> customFields = null) { // create a new WorkItem instance TrackerService.WorkItem newWorkItem = new TrackerService.WorkItem(); // set project newWorkItem.project = new TrackerService.Project(); newWorkItem.project.uri = Connection.Project.getProject(polarionProject).uri; // set the work item type TrackerService.EnumOptionId enumId = new TrackerService.EnumOptionId(); enumId.id = workItemType; newWorkItem.type = enumId; // set the title newWorkItem.title = title; // create the work item string newWorkItemUri = Connection.Tracker.createWorkItem(newWorkItem); newWorkItem.uri = newWorkItemUri; // set the custom fields if (customFields != null) { foreach (KeyValuePair <string, object> currentCustomField in customFields) { TrackerService.CustomField customField = new TrackerService.CustomField(); customField.key = "targetVersion"; customField.parentItemURI = newWorkItemUri; // set the value, it is of type EnumOptionId[] enumId = new TrackerService.EnumOptionId(); enumId.id = "Version_1_0"; customField.value = new TrackerService.EnumOptionId[] { enumId }; Connection.Tracker.setCustomField(customField); } } //the regex expression matches the term: SW-<multipledigits> Match idMatch = Regex.Match(newWorkItemUri, @"SW-\d+"); //Already set id, so it is not needed to reread the id beforehand. if (idMatch.Success) { newWorkItem.id = idMatch.ToString(); } return(newWorkItem); }
public static PolarionItem[] CreateItems(string type, string text) { string[] lines = Regex.Split(text, "\n"); List <PolarionItem> polarionItems = new List <PolarionItem>(); foreach (string line in lines) { string changedLine = line.Replace("/", "").TrimStart(' '); TrackerService.WorkItem workItem = API.CreateWorkItem("type", changedLine); PolarionItem polarionItem = new PolarionItem(workItem.id); polarionItems.Add(polarionItem); } return(polarionItems.ToArray()); }
/// <summary> /// Get all work items by id using the given fields. /// </summary> /// <param name="fields">Fields and custom fields</param> /// <param name="ids">The WorkItem ids.</param> /// <returns></returns> public static TrackerService.WorkItem[] GetEachWorkItemByID(List <string> fields, params string[] ids) { List <TrackerService.WorkItem> workItems = new List <TrackerService.WorkItem>(); foreach (string id in ids) { TrackerService.WorkItem workItem = API.GetWorkItemById(id, fields.ToArray()); if (workItem == null) { continue; } workItems.Add(workItem); } return(workItems.ToArray()); }
/// <summary> /// Get the custom fields of a WorkItem as Dictionary. /// Eeasier to access that way. /// </summary> /// <param name="workItem"></param> /// <returns></returns> public static Dictionary <string, object> GetCustomFieldValues(TrackerService.WorkItem workItem) { Dictionary <string, object> fieldValueAssociation = new Dictionary <string, object>(); TrackerService.Custom[] customFields = workItem.customFields; if (customFields == null) { return(fieldValueAssociation); } foreach (TrackerService.Custom customField in customFields) { fieldValueAssociation.Add(customField.key, customField.value); } return(fieldValueAssociation); }
/// <summary> /// Gets all the custom fields as a plain object. /// </summary> /// <param name="workItem"></param> /// <returns></returns> public static TrackerService.Custom[] GetCustomFields(TrackerService.WorkItem workItem) { return(workItem.customFields); }
/// <summary> /// Creates an attachment. /// </summary> /// <param name="workItem">WorkItem to upload the attachment to.</param> /// <param name="fileName">The FileName to upload.</param> /// <param name="title">How the item should be called.</param> /// <param name="content">The content to upload.</param> public static void CreateAttachment(TrackerService.WorkItem workItem, string fileName, string title, byte[] content) { Connection.Tracker.createAttachment(workItem.uri, fileName, title, content); }
/// <summary> /// Creates an attachment. /// </summary> /// <param name="workItem">The WorkItem to upload the attachment to.</param> /// <param name="title">The title for the attachment.</param> /// <param name="filePath">Full qualified filepath of the file to upload.</param> public static void CreateAttachment(TrackerService.WorkItem workItem, string title, string filePath) { TrackerService.Attachment newWorkItem = new TrackerService.Attachment(); byte[] content = File.ReadAllBytes(filePath); Connection.Tracker.createAttachment(workItem.uri, filePath, title, content); }
/// <summary> /// Creates an attachment. /// </summary> /// <param name="workItem">The WorkItem to upload the attachment to.</param> /// <param name="fileName"></param> /// <param name="title"></param> /// <param name="content"></param> public static void CreateAttachment(TrackerService.WorkItem workItem, string fileName, string title, string content) { Connection.Tracker.createAttachment(workItem.uri, fileName, title, Encoding.ASCII.GetBytes(content)); }
public Behavior(TrackerService.WorkItem workItem) { _workItem = workItem; }
/// <summary> /// Uses workitem and reads the custom field values using the dictionary method from the Polarion API. /// </summary> /// <param name="workItem"></param> public TestCase(TrackerService.WorkItem workItem) { this._workItem = workItem; this._fieldValues = API.GetCustomFieldValues(workItem); }
public DefaultBehavior(TrackerService.WorkItem workItem) : base(workItem) { }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="customFields"></param> public static void SetCustomFieldValues(this TrackerService.WorkItem workItem, Dictionary <string, object> customFields) { API.SetCustomFieldValues(workItem, customFields); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="key"></param> /// <param name="value"></param> public static void SetCustomFieldValue(this TrackerService.WorkItem workItem, string key, string value) { API.SetCustomFieldValue(workItem, key, value); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="fileName"></param> /// <param name="title"></param> /// <param name="content"></param> public static void CreateAttachment(this TrackerService.WorkItem workItem, string fileName, string title, string content) { API.CreateAttachment(workItem, fileName, title, Encoding.ASCII.GetBytes(content)); }
/// <summary> /// Test if workItem is really valid. /// </summary> /// <param name="workItem"></param> /// <returns></returns> public static bool IsValidItem(this TrackerService.WorkItem workItem) { return((workItem.id != null) && (workItem.title != null)); }
/// <summary> /// Creates a new Work Item /// </summary> /// <returns></returns> public static TrackerService.WorkItem CreateWorkItem() { TrackerService.WorkItem newWorkItem = new TrackerService.WorkItem(); Connection.Tracker.createWorkItem(newWorkItem); return(newWorkItem); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <returns></returns> public static TrackerService.Attachment[] ExtractAttachment(this TrackerService.WorkItem workItem) { return(API.ExtractAttachment(workItem)); }
public ObjectDumperBehavior(TrackerService.WorkItem workItem) : base(workItem) { }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="title"></param> /// <param name="filePath"></param> public static void CreateAttachment(this TrackerService.WorkItem workItem, string title, string filePath) { API.CreateAttachment(workItem, title, filePath); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> private PolarionItem(TrackerService.WorkItem workItem) { _workItem = workItem; }
/// <summary> /// Gets the attachment of the WorkItem as a plain object. /// </summary> /// <param name="workItem">THe WorkItem to read the attachment from.</param> /// <returns></returns> public static TrackerService.Attachment[] ExtractAttachment(TrackerService.WorkItem workItem) { return(workItem.attachments); }
/// <summary> /// /// </summary> /// <param name="workItem"></param> /// <param name="fileName"></param> /// <param name="title"></param> /// <param name="content"></param> public static void CreateAttachment(this TrackerService.WorkItem workItem, string fileName, string title, byte[] content) { API.CreateAttachment(workItem, fileName, title, content); }