Ejemplo n.º 1
0
        public static async void AddTask(string description)
        {
            if (App.CurrentUserID != -1)
            {
                DateTime currentTime = DateTime.Now;
                // 上传一个起止时间相同的时间记录,表明有这个任务
                TomatoTime time = new TomatoTime()
                {
                    BeginTime     = currentTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    EndTime       = currentTime.ToString("yyyy-MM-dd HH:mm:ss"),
                    UserId        = App.StaticUser.UserId,
                    Description   = description,
                    BeginTimeDate = currentTime.Date.ToShortDateString(),
                    SpanString    = currentTime.ToShortTimeString() + " → " + currentTime.ToShortTimeString()
                };
                await App.TomatoTimeManager.AddTomatoTimeTaskAsync(time);

                await App.UserManager.ModifyUserTaskAsync(App.StaticUser);
            }

            TomatoTask tomatoTask = new TomatoTask();

            tomatoTask.TaskName    = description;
            tomatoTask.TimeRecords = new List <TomatoTime>();
            tomatoTask.TotalTimes  = new TimeSpan();
            tasks.Insert(0, tomatoTask);
            RecordCountChanged();
        }
Ejemplo n.º 2
0
        public void AddTimeRecord(TomatoTime tomatoTime)
        {
            string key = tomatoTime.Description;

            if (!UserTomatoTimes.ContainsKey(key))
            {
                UserTomatoTimes.Add(key, new List <TomatoTime>());
            }
            UserTomatoTimes[key].Insert(0, tomatoTime);
        }
Ejemplo n.º 3
0
        public static void AddTimeRecord(TomatoTime tomatoTime)
        {
            var tempTasks = new List <TomatoTask>();

            for (int i = 0; i < tasks.Count; i++)
            {
                if (tasks[i].TaskName == tomatoTime.Description)
                {
                    tasks[i].TimeRecords.Insert(0, tomatoTime);
                    tasks[i].TotalTimes += Convert.ToDateTime(tomatoTime.EndTime) - Convert.ToDateTime(tomatoTime.BeginTime);
                }
                tempTasks.Add(tasks[i]);
            }
            tasks.Clear();
            tempTasks.ForEach(g => tasks.Add(g));
        }
Ejemplo n.º 4
0
        public async Task AddTomatoTimeAsync(TomatoTime tomatoTime)
        {
            var uri = new Uri(string.Format(Constants.TomatoTimeUrl, string.Empty));

            try
            {
                var json    = JsonConvert.SerializeObject(tomatoTime);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;
                response = await _client.PostAsync(uri, content);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"\tERROR {0}", ex.Message);
            }
        }
Ejemplo n.º 5
0
 public Task AddTomatoTimeTaskAsync(TomatoTime tomatoTime)
 {
     return(restService.AddTomatoTimeAsync(tomatoTime));
 }
Ejemplo n.º 6
0
 public AddTimeRecordViewModel()
 {
     tomatoTime = new TomatoTime();
 }