示例#1
0
        public IEnumerable <Participant> InferParticipantsFromWorkItems(IEnumerable <WorkItem> workItems,
                                                                        Func <WorkItem, bool> workItemPredicate, Func <Revision, bool> workItemRevisionPredicate)
        {
            List <Participant> participants = new List <Participant>();

            if (workItemPredicate != null)
            {
                workItems = workItems.Where(workItemPredicate);
            }

            foreach (WorkItem workItem in workItems)
            {
                foreach (Revision revision in workItem.Revisions)
                {
                    if (workItemRevisionPredicate != null)
                    {
                        if (!workItemRevisionPredicate(revision))
                        {
                            continue;
                        }
                    }

                    participants.Add(IdentityUtility.Create((string)revision.Fields["Changed by"].Value));
                }
            }

            return(participants.Distinct());
        }
示例#2
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime endDateTime, Func <Event, bool> predicate)
        {
            var dp = new YammerDataProvider();

            var retval = dp.PullData(startDateTime, endDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.CreatedAt,
                    EventType = "Yammer.SentMessages",
                    Text      = p.Body
                };
                e.Participants.Add(IdentityUtility.Create(p.Sender));
                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#3
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var cdp = new ConnectDataProvider();

            var retval = cdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.SubmittedUtcDate,
                    EventType = "Connect.Submission",
                    Text      = p.Title
                };

                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#4
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var source = new TeamFoundationServerChangesetDataProvider(TeamFoundationServer, Project);
            var data   = source.PullData(startDateTime, stopDateTime);

            var retval = data.Select(
                p =>
            {
                var e = new Event
                {
                    Text      = p.Comment,
                    Date      = p.CreationDate,
                    Duration  = TimeSpan.Zero,
                    Context   = p.ChangesetId,
                    EventType = "TeamFoundationServer.Changeset"
                };
                e.Participants.Add(IdentityUtility.Create(p.Committer));
                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#5
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var m = new ManicTimeDataProvider(m_settings[ManicTimeSettingConstants.ActivitiesDatabaseFile].Value);

            var retval = m.PullData(startDateTime, stopDateTime).Select(p =>
            {
                var e = new Event
                {
                    Date      = p.StartUtcTime,
                    Duration  = p.EndUtcTime - p.StartUtcTime,
                    EventType = "ManicTime.Activity",
                    Context   = p.DisplayName,
                    Text      = p.GroupDisplayName
                };

                // "Utilities" and other "helpers" should be injected via the plugin runtime
                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#6
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime, Func <Event, bool> predicate)
        {
            var kdp = new KudosDataProvider();

            var retval = kdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date      = p.CreatedUtcTime,
                    EventType = "Kudos.Received",
                    Context   = p.SenderAlias,
                    Text      = p.Message
                };

                e.Participants.Add(IdentityUtility.Create(p.SenderAlias));
                e.Participants.Add(IdentityUtility.Create(Environment.UserName));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#7
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime stopDateTime,
                                                       Func <Event, bool> predicate)
        {
            var cfdp = new CodeFlowDataProvider();

            var retval = cfdp.PullData(startDateTime, stopDateTime)
                         .Select(p =>
            {
                var e = new Event
                {
                    Date         = p.PublishedUtcDate,
                    Duration     = p.ClosedUtcDate - p.PublishedUtcDate,
                    Text         = p.Name,
                    Participants = p.Reviewers.ToGraph(),
                    EventType    = "CodeFlow.Author"
                };

                e.Participants.Add(IdentityUtility.Create(p.AuthorLogin));

                return(e);
            }).ToList();

            return((predicate != null) ? retval.Where(predicate) : retval);
        }
示例#8
0
        public IEnumerable <CodeFlowReview> PullData(DateTime startUtcTime, DateTime endUtcTime)
        {
            using (var codeFlowReviewClient = new ReviewDashboardServiceClient())
            {
                var alias = Environment.UserName.Split('\\').Last(); // REVIEW cheap inaccurate way to get user alias

                Console.WriteLine("Pulling reviews authored by " + alias);

                var result = codeFlowReviewClient.QueryReviewSummaries(new CodeReviewQuery
                {
                    CreatedBeforeDate = endUtcTime,
                    CreatedAfterDate  = startUtcTime,
                    Authors           = new[] { alias },
                    UserAgent         = "EECTES/WorkSummarizer 1.0"
                });

                if (result.Reviews == null)
                {
                    return(Enumerable.Empty <CodeFlowReview>());
                }

                return(result.Reviews
                       .Select(p =>
                {
                    return new CodeFlowReview
                    {
                        AuthorLogin = p.AuthorLogin,
                        PublishedUtcDate = p.CreatedOn.ToUniversalTime(),
                        ClosedUtcDate = p.CompletedOn.ToUniversalTime(),
                        Name = p.Name,
                        Reviewers = p.Reviewers.Select(s => IdentityUtility.Create(s.Name))
                    };
                })
                       .ToList());
            }
        }
示例#9
0
        public override IEnumerable <Event> PullEvents(DateTime startDateTime, DateTime endDateTime, Func <Event, bool> predicate)
        {
            var source = new TeamFoundationServerWorkItemDataProvider(TeamFoundationServer, Project);
            var wis    = source.PullData(startDateTime, endDateTime);

            // Convert WI to Event
            var retval = new List <Event>();

            foreach (var wi in wis)
            {
                foreach (Revision r in wi.Revisions)
                {
                    var e = new Event();

                    e.Date      = (DateTime)r.Fields["Changed date"].Value;
                    e.Duration  = TimeSpan.Zero;
                    e.Text      = (string)r.Fields["History"].Value;
                    e.EventType = r.Index == 0 ? "TeamFoundationServer.WorkItem.Created" : "TeamFoundationServer.WorkItem.Revision";

                    if (r.Fields.Contains("State"))
                    {
                        var stateValue = r.Fields["State"].Value as string;
                        if (!string.IsNullOrWhiteSpace(stateValue))
                        {
                            if (
                                !string.Equals((string)r.Fields["State"].OriginalValue, (string)r.Fields["State"].Value,
                                               StringComparison.OrdinalIgnoreCase))
                            {
                                if (stateValue.Equals("Resolved", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Resolved";
                                }
                                else if (stateValue.Equals("Closed", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Closed";
                                }
                                else if (stateValue.Equals("Active", StringComparison.OrdinalIgnoreCase))
                                {
                                    e.EventType = "TeamFoundationServer.WorkItem.Activated";
                                }
                            }
                        }
                    }

                    e.Context = wi.Id;

                    if (e.Text.Contains(m_skipWorkItemWhenHistoryContainsText))
                    {
                        continue;
                    }

                    if (e.Date.Ticks > startDateTime.Ticks && e.Date.Ticks < endDateTime.Ticks)
                    {
                        var p = IdentityUtility.Create((string)r.Fields["Changed by"].Value);
                        e.Participants = new Graph <Participant> {
                            p
                        };

                        retval.Add(e);
                    }
                }
            }

            return((predicate != null) ? retval.Where(predicate) : retval);
        }