static void Main(string[] args)
        {
            string instrukey = ConfigurationManager.AppSettings["AppInsightsInstruKey"];    //path to the query
            var    log       = new LoggerConfiguration()
                               .WriteTo
                               .ApplicationInsightsEvents(instrukey)
                               .CreateLogger();

            log.Information("Sending Email");
            try
            {
                WorkItemQuery wq = new WorkItemQuery();
                // get list of pending work items
                WorkItemList wlist = wq.GetWorkItemsByQuery().Result;

                // send email if list is not null
                if (wlist != null)
                {
                    EmailClient ec = new EmailClient();
                    String      emailMessageBody = ec.getEmailBodyContent(wlist);
                    ec.sendEmail(emailMessageBody);
                    log.Information("Email sent successfully");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message);
                log.Error("Exception {e}", e.Message);
            }
        }
Ejemplo n.º 2
0
 private void SelectWorkItem()
 {
     if (this.dataGridView1.CurrentRow != null)
     {
         this.DialogResult = DialogResult.OK;
         this.workItem     = this.dataGridView1.CurrentRow.DataBoundItem as WorkItemList;
     }
     else
     {
         MessageBox.Show("Select a WorkItem!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Standard constructor for the tool window.
        /// </summary>
        public QueryResultsPane()
            : base(null)
        {
            // Set the window title reading it from the resources.
            this.Caption = Resources.ToolWindowTitle;
            // Set the image that will appear on the tab of the window frame
            // when docked with an other window
            // The resource ID correspond to the one defined in the resx file
            // while the Index is the offset in the bitmap strip. Each image in
            // the strip being 16x16.
            this.BitmapResourceID = 301;
            this.BitmapIndex      = 1;

            // This is the user control hosted by the tool window; Note that, even if this class implements IDisposable,
            // we are not calling Dispose on this object. This is because ToolWindowPane calls Dispose on
            // the object returned by the Content property.
            _view = new WorkItemList();

            var items = new List <object>()
            {
                new { Title = "Title One", Closed = false },
                new { Title = "Title Two", Closed = true },
                new { Title = "Title Three", Closed = false }
            };

            foreach (var eachItem in items)
            {
                var itemView = new WorkItem();
                itemView.Status.Source = "\uf12a".ToFontAwesomeIcon(Brushes.Red);
                //itemView.Status.Source = "\uf00c".ToFontAwesomeIcon();

                var checkbox = new CheckBox();

                var listItem = new ListBoxItem();
                listItem.Selected         += listItem_Selected;
                listItem.MouseDoubleClick += listItem_MouseDoubleClick;

                var panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                panel.Children.Add(checkbox);
                panel.Children.Add(itemView);

                listItem.Content = panel;
                _view.WorkItems.Items.Add(listItem);
            }
            //view.Sample.Source = FontAwesome.GetIcon("\uf046");


            base.Content = _view;

            _preview = new WorkItemEditor();
        }
Ejemplo n.º 4
0
        private void SetContent(ObservableCollection <TfsWorkItemWrapper> workItems)
        {
            if (Repository.Instance.TfsConnectionInfo.Uri == null)
            {
                ResetWorkItems();
                return;
            }

            WorkItems = workItems;
            WorkItemList.SetContent(WorkItems);
            foreach (var item in TfsItemCache.WorkItemCache)
            {
                item.IsVisible = WorkItems.Contains(item);
            }
        }
        public string getEmailBodyContent(WorkItemList wlist)
        {
            StringBuilder email       = new StringBuilder();
            string        baseAddress = ConfigurationManager.AppSettings["BaseAddress"];
            string        projectName = ConfigurationManager.AppSettings["ProjectName"];
            string        workItemUrl = baseAddress + "/" + projectName + "/_workitems?id=";

            email.Append("<html><style>table{ border-collapse: collapse;}table, td, th{border: 1px solid black;}</style><body>");
            email.Append("<p>Hi User,</p>");
            email.Append("<p>Number of Pending queries : " + wlist.count + "</p>");
            email.Append("<p>Following is the list of queries : </p>");
            email.Append("<table>");

            email.Append("<tr>");
            email.Append("<th>Id</th><th>Title</th><th>Work Item Type</th><th>State</th><th>Reason</th><th>Assigned To</th><th>Iteration Path</th>");
            email.Append("</tr>");
            foreach (var item in wlist.value)
            {
                email.Append("<tr bgcolor=\"#f2f2f2\">");
                email.Append("<td><a href='" + workItemUrl + item.id + "'>");
                email.Append(item.id);
                email.Append("</a></td>");
                email.Append("<td>");
                email.Append(item.fields.title);
                email.Append("</td>");
                email.Append("<td>");
                email.Append(item.fields.workItemType);
                email.Append("</td>");
                email.Append("<td>");
                email.Append(item.fields.state);
                email.Append("</td>");
                email.Append("<td>");
                email.Append(item.fields.reason);
                email.Append("</td>");
                email.Append("<td>");
                email.Append(item.fields.assignedTo);
                email.Append("</td>");
                email.Append("<td>");
                email.Append(item.fields.iterationPath);
                email.Append("</td>");
                email.Append("</tr>");
            }
            email.Append("</table>");
            email.Append("<p>Thank you,</p><p>BlueMetal Team</p>");
            email.Append("</body></html>");
            return(email.ToString());
        }
Ejemplo n.º 6
0
        private void SelectWorkItem(WorkItemList workItemList = null)
        {
            if (CounterRunning)
            {
                MessageBox.Show("Stop The Work Tracking before select other WorkItem!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (workItemList == null)
            {
                var fm = new fmSelectQuery();
                if (fm.ShowDialog() == DialogResult.OK)
                {
                    WorkItemSelected = fm.workItem;
                }
            }
            else
            {
                WorkItemSelected = workItemList;
            }

            if (WorkItemSelected == null)
            {
                return;
            }

            labelTaskValue.Text       = WorkItemSelected.Id + " - " + WorkItemSelected.Title;
            labelEstimativeValue.Text = WorkItemSelected.OriginalEstimate.ToString();

            TimeSpan interval = DateTime.Now.Subtract(DateTime.Now);

            interval = interval.Add(TimeSpan.FromHours(WorkItemSelected.CompletedWork));

            labelStatus.Text = string.Format("{0:00}:{1:00}:{2:00}",
                                             (int)interval.TotalHours,
                                             interval.Minutes,
                                             interval.Seconds);

            buttonStartStop.Visible = true;
            buttonLink.Visible      = true;
        }
        public async Task <WorkItemList> GetWorkItemsByQuery()
        {
            string personalAccessToken = ConfigurationManager.AppSettings["PersonalAccessToken"];
            string credentials         = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "", personalAccessToken)));
            string baseAddress         = ConfigurationManager.AppSettings["BaseAddress"];
            string project             = ConfigurationManager.AppSettings["ProjectName"];
            string path = ConfigurationManager.AppSettings["QueryPath"];    //path to the query

            try
            {
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("https://bluemetal.visualstudio.com");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", credentials);

                    //if you already know the query id, then you can skip this step
                    HttpResponseMessage queryHttpResponseMessage = client.GetAsync(project + "/_apis/wit/queries/" + path + "?api-version=2.2").Result;

                    if (queryHttpResponseMessage.IsSuccessStatusCode)
                    {
                        string responseBody = await queryHttpResponseMessage.Content.ReadAsStringAsync();

                        //bind the response content to the queryResult object
                        QueryResult queryResult = queryHttpResponseMessage.Content.ReadAsAsync <QueryResult>().Result;
                        string      queryId     = queryResult.id;

                        //using the queryId in the url, we can execute the query
                        HttpResponseMessage httpResponseMessage = client.GetAsync(project + "/_apis/wit/wiql/" + queryId + "?api-version=2.2").Result;

                        if (httpResponseMessage.IsSuccessStatusCode)
                        {
                            //string responseBody1 = await httpResponseMessage.Content.ReadAsStringAsync();
                            WorkItemQueryResult workItemQueryResult = httpResponseMessage.Content.ReadAsAsync <WorkItemQueryResult>().Result;

                            //now that we have a bunch of work items, build a list of id's so we can get details
                            var builder = new System.Text.StringBuilder();
                            foreach (var item in workItemQueryResult.workItems)
                            {
                                builder.Append(item.id.ToString()).Append(",");
                            }

                            //clean up string of id's
                            string ids = builder.ToString().TrimEnd(new char[] { ',' });

                            //get the work items list
                            HttpResponseMessage getWorkItemsHttpResponse = client.GetAsync("_apis/wit/workitems?ids=" + ids + "&fields=System.Id,System.Title,System.WorkItemType,System.State,System.Reason,System.AssignedTo,System.IterationPath&asOf=" + workItemQueryResult.asOf + "&api-version=2.2").Result;

                            if (getWorkItemsHttpResponse.IsSuccessStatusCode)
                            {
                                //  string responseBody2 = await getWorkItemsHttpResponse.Content.ReadAsStringAsync();
                                var          result = getWorkItemsHttpResponse.Content.ReadAsStringAsync().Result;
                                WorkItemList list   = getWorkItemsHttpResponse.Content.ReadAsAsync <WorkItemList>().Result;
                                return(list);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception " + e.Message);
            }
            return(null);
        }
Ejemplo n.º 8
0
 protected override void UpdateColumns(ObservableCollection <FieldMapperGridColumn> columns)
 {
     WorkItemList.SetColumns(columns);
     Columns = columns;
 }