Exemplo n.º 1
0
        public async Task <ActionResult <WorkItemResponse> > FindWork([FromBody] ViewWorkRequest request)
        {
            WorkItemResponse workItem = new WorkItemResponse();

            workItem.totalpage = 0;
            workItem.pagenum   = request.pagenum;
            workItem.worklist  = new List <WorkResponse>();

            var start = (request.pagenum - 1) * request.pagesize;
            var end   = request.pagenum * request.pagesize - 1;

            //取得存在cookie的当前账户id
            var    stu_id = Int32.Parse(User.Identity.Name);
            string search = '%' + request.query + '%';
            var    temp   = await WorkAccessor.FindWork(search);

            if (temp != null)
            {
                for (int i = 0; i < temp.total; i++)
                {
                    workItem.totalpage++;
                    if (i >= start && i <= end)
                    {
                        WorkResponse a = _mapper.Map <WorkResponse>(temp.workItem[i]);
                        workItem.worklist.Add(a);
                    }
                }

                return(Ok(workItem));
            }
            return(Ok(-1));
        }
Exemplo n.º 2
0
        private WorkItemModel WorkItemModelFromResponse(WorkItemResponse response)
        {
            WorkItemModel model = new WorkItemModel();

            FillOutWorkItemModel(model, response);

            return(model);
        }
Exemplo n.º 3
0
 private void FillOutWorkItemModel(WorkItemModel model, WorkItemResponse response)
 {
     model.Activity         = response.Fields.Activity;
     model.CompletedWork    = response.Fields.CompletedWork;
     model.IterationPath    = response.Fields.IterationPath;
     model.OriginalEstimate = response.Fields.OriginalEstimate;
     model.RemainingWork    = response.Fields.RemainingWork;
     model.State            = response.Fields.State;
     model.Title            = response.Fields.Title;
     model.WorkItemType     = response.Fields.WorkItemType;
     model.ID = response.ID;
 }
Exemplo n.º 4
0
        public async Task <ActionResult <WorkItemResponse> > ViewOwnWork([FromBody] ViewWorkRequest request)
        {
            WorkItemResponse workItem = new WorkItemResponse();

            workItem.totalpage = 0;
            workItem.pagenum   = request.pagenum;
            workItem.worklist  = new List <WorkResponse>();

            var start = (request.pagenum - 1) * request.pagesize;
            var end   = request.pagenum * request.pagesize - 1;

            //取得存在cookie的当前账户id
            var stu_id = Int32.Parse(User.Identity.Name);

            var temp = await WorkAccessor.FindOwnWork(stu_id);

            if (temp != null)
            {
                for (int i = 0; i < temp.total; i++)
                {
                    var work_info = await WorkAccessor.FindWorkInfo(temp.TakesItem[i].work_id);

                    var status = await TakesAccessor.FindInfo(stu_id, temp.TakesItem[i].work_id);

                    workItem.totalpage++;
                    if (i >= start && i <= end && work_info != null)
                    {
                        WorkResponse a = _mapper.Map <WorkResponse>(work_info);
                        a.status = status.status;
                        workItem.worklist.Add(a);
                    }
                }

                return(Ok(workItem));
            }
            return(Ok(-1));
        }
Exemplo n.º 5
0
        public async Task <ActionResult <WorkItemResponse> > GetFavoriteInfo([FromBody] InfoFavoriteRequest request)
        {
            WorkItemResponse workItem = new WorkItemResponse();

            workItem.totalpage = 0;
            workItem.pagenum   = 0;
            workItem.worklist  = new List <WorkResponse>();

            var temp = await FavoriteAccessor.ViewInfo(request.favorite_id);

            if (temp != null)
            {
                for (int i = 0; i < temp.total; i++)
                {
                    workItem.totalpage++;

                    WorkResponse a = _mapper.Map <WorkResponse>(temp.workItem[i]);
                    workItem.worklist.Add(a);
                }

                return(Ok(workItem));
            }
            return(Ok(-1));
        }
Exemplo n.º 6
0
        private static async Task <Pie> GeneratPie(ReportChartModel item, int position)
        {
            var workItemData = await GetWorkItemData(item.QueryId, null);

            WorkItems workItemsData = workItemData.Item1;

            var ids = workItemsData.GetAllIds();
            WorkItemResponse response    = null;
            bool             aggregation = false;

            foreach (var id in ids)
            {
                string aggregationFiled = "";
                if (!string.IsNullOrEmpty(item.aggregationColumnReferenceName))
                {
                    aggregationFiled = "," + item.aggregationColumnReferenceName;
                    aggregation      = true;
                }
                var chartData = await HttpProvider.GetHttpRequest(StaticParams.TfsUrl, "_apis/wit/workItems?ids=" + id + "&fields=" + item.ColumnReferenceName + aggregationFiled);

                var currentItem = JsonConvert.DeserializeObject <WorkItemResponse>(chartData);
                if (response == null)
                {
                    response = currentItem;
                }
                else
                {
                    response.value.AddRange(currentItem.value);
                }
            }

            var propName = item.ColumnReferenceName.Replace(".", "");

            var groupedData = response.value.GroupBy(p => p.fields.GetType().GetProperty(propName).GetValue(p.fields)).Select(g => new
            {
                titel = g.Key,
                value = (double)g.Count()
            });

            if (aggregation)
            {
                var aggregationPropName = item.aggregationColumnReferenceName.Replace(".", "");
                groupedData = response.value.GroupBy(p => p.fields.GetType().GetProperty(propName).GetValue(p.fields)).Select(g => new
                {
                    titel = g.Key,
                    value = g.Sum(f => (double)f.fields.GetType().GetProperty(aggregationPropName).GetValue(f.fields))
                });
            }

            List <Datum> PieLabels = new List <Datum>();
            int          total     = response.value.Count;

            foreach (var PieData in groupedData)
            {
                PieLabels.Add(new Datum
                {
                    Label = PieData.titel == null ? "No data" : PieData.titel.ToString(),
                    Value = PieData.value,
                });
            }

            var pie = new Pie
            {
                Name         = item.ChartName,
                Element      = "pie-chart" + position,
                Type         = item.ChartType.ToString().ToLower(),
                Data         = PieLabels.ToArray(),
                TotalData    = total.ToString(),
                DataShowType = item.DataShowType.ToString().ToLower()
            };

            return(pie);
        }