public async Task <int> SyncTimeRecordsV2(string userid, string token, DateTime startDate, DateTime endDate)
        {
            // 先到clockify获取数据
            var ls = await _clockifyService.GetTimeEntriesV2(userid, token, startDate, endDate);

            _logger.LogDebug(JsonConvert.SerializeObject(ls));
            var list = new List <TimeEntry>();

            //_projectService.ListAsync(a=>a.)
            var projectIdList = (await _projectService.ListAllAsync()).Select(a => a.Gid).ToList();
            var taskIdList    = (await _projectTaskService.ListAllAsync()).Select(a => a.Gid).ToList();
            var tasksToAdd    = new List <ProjectTask>();
            var projectsToAdd = new List <Project>();

            foreach (var l in ls)
            {
                try
                {
                    list.Add(new TimeEntry()
                    {
                        Gid    = l._id,
                        UserId = l.userId,
                        //WorkspaceId = l.workspaceId,
                        Description = l.description,
                        //IsBillable =
                        IsLocked        = l.isLocked,
                        ProjectId       = l.projectId,
                        TaskId          = l.taskId,
                        TotalHours      = (decimal)(l.timeInterval.duration / 3600.0f),
                        Date            = l.timeInterval.start.Date.AddHours(8),
                        CreatedDate     = DateTime.Now,
                        CreatedUserID   = userid,
                        CreatedUserName = userid,
                        IsDeleted       = false,
                        UpdatedDate     = DateTime.Now,
                        UpdatedUserID   = userid,
                        UpdatedUserName = userid
                    });

                    // 检查TaskGID是不是已经存在,如果不存在,同时在Task表里增加对应的空task的项目记录。
                    if (!taskIdList.Contains(l.taskId))
                    {
                        taskIdList.Add(l.taskId);
                        tasksToAdd.Add(new ProjectTask()
                        {
                            Gid        = l.taskId,
                            ProjectGid = l.projectId
                        });
                    }

                    // 检查project是否存在,如果不存在,在project表里添加一条项目记录
                    if (!projectIdList.Contains(l.projectId))
                    {
                        projectIdList.Add(l.projectId);
                        projectsToAdd.Add(new Project()
                        {
                            Archived  = false,
                            Billable  = true,
                            Gid       = l.projectId,
                            IsDeleted = false,
                            Name      = l.projectName
                        });
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError(ex.Message);
                    _logger.LogError(JsonConvert.SerializeObject(l));
                }
            }

            // 然后在本地插入或者同步数据
            await _timeEntryService.DeleteAsync(a => a.Date >= startDate && a.Date < endDate.AddDays(1));

            //var affectedRecordCount = _timeEntryService.SqlExecute($"delete from timeentry where [date]>='{startDate.ToString("yyyy-MM-dd")}' and [date]<'{endDate.AddDays(1).ToString("yyyy-MM-dd")}'");

            var insertedRecordCount = await _timeEntryService.AddManyAsync(list);

            var cnt = _projectTaskService.AddManyAsync(tasksToAdd);

            cnt = _projectService.AddManyAsync(projectsToAdd);

            return(insertedRecordCount);
        }