Esempio n. 1
0
        public async Task <ActionResult <IEnumerable <TaskViewModel> > > getTasks(Guid projectId, Guid dataSetId, [FromQuery] QueryStringParameters parameters)
        {
            try
            {
                var userId           = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                var convertProjectId = projectId.ToString().ToUpper();
                var convertDataSetId = dataSetId.ToString().ToUpper();
                var role             = await AzureService.FindUserRole(userId);

                if (role != "admin" && !await AzureService.FindUserIsProjectManager(userId, convertProjectId))
                {
                    var res = await AzureService.CheckUserHasThisDataset(userId, convertProjectId, convertDataSetId);

                    if (!res && role != "labeler")
                    {
                        return(StatusCode(403));
                    }
                    // for labels,get tasks from another func
                    //var taskList = await AzureService.getDatasetTaskList(userId, convertProjectId, convertDataSetId);
                    //return Ok(new Response().GetJObject("taskList", taskList));
                }
                var adminTaskList = await AzureService.getTasks(convertProjectId, convertDataSetId);

                var list = PageOps.GetPageRange(adminTaskList, parameters.page, parameters.size, adminTaskList.Count);
                return(Ok(new Response().GetJObject("taskList", list, "totalCount", adminTaskList.Count)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult <IEnumerable <ProjectViewModel> > > GetProjects([FromQuery] QueryStringParameters parameters)
        {
            try
            {
                var userId = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                List <ProjectViewModel> accounts = await AzureService.FindUserRoleDetail(userId);

                if (!string.IsNullOrWhiteSpace(parameters.orderBy) && parameters.orderBy == "name")
                {
                    accounts = accounts.OrderBy(o => o.Name).ToList();
                    if (!string.IsNullOrWhiteSpace(parameters.order) && parameters.order == "desc")
                    {
                        accounts.Reverse();
                    }
                }
                else
                {
                    accounts.Reverse();
                }
                if (!string.IsNullOrWhiteSpace(parameters.name))
                {
                    accounts = accounts.FindAll(p => p.Name.Contains(parameters.name));
                }

                var list = PageOps.GetPageRange(accounts, parameters.page, parameters.size, accounts.Count);
                return(Ok(new Response().GetJObject("projects", list, "totalCount", accounts.Count)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 3
0
        public async Task <ActionResult <Response> > GetDataSetByLabels(Guid projectId, Guid dataSetId, [FromQuery] QueryStringParameters parameters)
        {
            var            convertProjectId            = projectId.ToString().ToUpper();
            var            convertDataSetId            = dataSetId.ToString().ToUpper();
            List <JObject> annotationViewModels        = new List <JObject>();
            List <JObject> predictAnnotationViewModels = new List <JObject>();
            List <string>  taskIds = await AzureService.GetDataSetBySearch(convertProjectId, convertDataSetId, parameters);

            taskIds = await AzureService.FilterTasksByIOU(taskIds, parameters, convertProjectId, convertDataSetId);

            var list = PageOps.GetPageRange(taskIds, parameters.page, parameters.size, taskIds.Count);

            foreach (var taskId in list)
            {
                annotationViewModels.Add(await AzureService.GetOneTask(convertProjectId, convertDataSetId, taskId));
                predictAnnotationViewModels.Add(await AzureService.SelectAnnoByIouRange(convertProjectId, convertDataSetId, taskId, parameters));
            }
            return(Ok(new Response().GetJObject("taskIds", annotationViewModels, "totalCount", taskIds.Count, "prediction", predictAnnotationViewModels)));
        }
Esempio n. 4
0
        public async Task <ActionResult <IEnumerable <UserInfoViewModel> > > GetDataSetUsers(Guid projectId, Guid dataSetId, [FromQuery] QueryStringParameters parameters)
        {
            try
            {
                var convertProjectId = projectId.ToString().ToUpper();
                var convertDataSetId = dataSetId.ToString().ToUpper();
                var currentUserId    = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                var role             = await AzureService.FindUserRole(currentUserId);

                if (role != "admin" && !await AzureService.FindUserIsProjectManager(currentUserId, convertProjectId))
                {
                    return(StatusCode(403));
                }
                var userList = await AzureService.GetDataSetUsers(convertProjectId, convertDataSetId);

                var list = PageOps.GetPageRange(userList, parameters.page, parameters.size, userList.Count);
                return(Ok(new Response().GetJObject("users", list, "totalCount", userList.Count)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 5
0
        public async Task <ActionResult <IEnumerable <DatasetViewModel> > > ListDatasets([FromQuery] QueryStringParameters parameters)
        {
            try
            {
                List <DatasetViewModel> datasetList = new List <DatasetViewModel>();
                var userId = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                List <ProjectViewModel> accounts = await AzureService.FindUserRoleDetail(userId);

                var role = await AzureService.FindUserRole(userId);

                foreach (var one in accounts)
                {
                    datasetList.AddRange(await AzureService.getDatasets(userId, one.ProjectId, role));
                }
                datasetList.Reverse();
                var list = PageOps.GetPageRange(datasetList, parameters.page, parameters.size, datasetList.Count);
                return(Ok(new Response().GetJObject("datasets", list, "totalCount", datasetList.Count)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 6
0
        public async Task <ActionResult <IEnumerable <DatasetViewModel> > > GetDatasets(Guid projectId, [FromQuery] QueryStringParameters parameters)
        {
            try
            {
                var convertProjectId = projectId.ToString().ToUpper();
                var userId           = HttpContext.User.Claims.First(c => c.Type == "uid").Value.ToString();
                var role             = await AzureService.FindUserRole(userId);

                List <DatasetViewModel> datasetList = await AzureService.getDatasets(userId, convertProjectId, role);

                if (!string.IsNullOrWhiteSpace(parameters.orderBy) && parameters.orderBy == "name")
                {
                    datasetList = datasetList.OrderBy(o => o.name).ToList();
                    if (!string.IsNullOrWhiteSpace(parameters.order) && parameters.order == "desc")
                    {
                        datasetList.Reverse();
                    }
                }
                else
                {
                    datasetList.Reverse();
                }

                if (!string.IsNullOrWhiteSpace(parameters.name))
                {
                    datasetList = datasetList.FindAll(p => p.name.Contains(parameters.name));
                }

                var list = PageOps.GetPageRange(datasetList, parameters.page, parameters.size, datasetList.Count);
                return(Ok(new Response().GetJObject("datasets", list, "totalCount", datasetList.Count)));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex.Message));
            }
        }
Esempio n. 7
0
        public async Task <ActionResult <Response> > GetDataSetMap(Guid projectId, Guid dataSetId, [FromQuery] QueryStringParameters parameters)
        {
            var convertProjectId = projectId.ToString().ToUpper();
            var convertDataSetId = dataSetId.ToString().ToUpper();
            var array            = await AzureService.GetDatasetMap(convertProjectId, convertDataSetId);

            JArray newArray = new JArray();

            if (!object.ReferenceEquals(array, null))
            {
                foreach (var oneThr in array)
                {
                    var oneThrObj  = oneThr as JObject;
                    var oneThrData = Json.GetJToken("data", oneThrObj) as JArray;
                    newArray.Add(new JObject()
                    {
                        { "iouThr", Json.GetJToken("iouThr", oneThrObj) }, { "data", JToken.FromObject(PageOps.GetPageRange(oneThrData.ToList(), parameters.page, parameters.size, oneThrData.Count)) }, { "mean_ap", Json.GetJToken("mean_ap", oneThrObj) }
                    });
                }
            }

            return(Ok(new Response().GetJObject("data", newArray, "totalCount", array != null?array[0]["data"].Count():0)));
        }