예제 #1
0
        public ActionResult AssignTask([Bind(Include = "Description, EmployeeId")] GTask task)
        {
            if (User.Identity.IsAuthenticated)
            {
                Guid userId = Guid.Parse(User.Identity.GetUserId());
                var  emp    = db.Employees.Find(userId);

                if (emp.IsManager)
                {
                    if (ModelState.IsValid)
                    {
                        task.DateAssigned = DateTime.Now;
                        task.IsDone       = false;

                        db.Tasks.Add(task);
                        db.SaveChanges();

                        Employee employee = db.Employees.Find(task.EmployeeId);
                        Productivity.TeamProductivity(employee.Team);
                        Productivity.CalculateProductivity(employee);
                        Productivity.TeamProductivity(employee.Team);
                        db.Entry(employee).State = EntityState.Modified;
                        db.SaveChanges();
                        return(RedirectToAction("Edit", employee));
                    }

                    return(View(task));
                }

                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            return(RedirectToAction("Login", "Account"));
        }
예제 #2
0
        public static void tasks(GEnRouteManager manager)
        {
            GTaskManager taskManager = manager.getTaskManager();

            // Enumerate tasks
            foreach (GTask taskFromList in taskManager.getTasks())
            {
                // Do something with each task
            }

            // Start top pending task. Notes
            // - task list may be empty
            GTask task = taskManager.getPendingTasks().at(0);

            taskManager.startTask(task);

            // Change task phase to "live". Notes
            // - task needs to be in active state
            // - operation object needs to be available
            taskManager.setOperationPhase(task.getOperation(), EnRouteConstants.PHASE_PROPERTY_LIVE());

            // Complete task. Notes
            // - task needs to be in active state
            // - operation object needs to be available
            taskManager.completeOperation(task.getOperation());
        }
예제 #3
0
        // GET: Employees/AssignTask/{id}
        public ActionResult AssignTask(Guid?id)
        {
            if (User.Identity.IsAuthenticated)
            {
                Guid userId = Guid.Parse(User.Identity.GetUserId());
                var  emp    = db.Employees.Find(userId);

                if (emp.IsManager)
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }

                    Employee employee = db.Employees.Find(id);

                    if (employee == null)
                    {
                        return(HttpNotFound());
                    }

                    GTask task = new GTask
                    {
                        EmployeeId = employee.Id
                    };

                    return(View(task));
                }

                return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
            }

            return(RedirectToAction("Login", "Account"));
        }
예제 #4
0
        public async Task <GTask> GetTaskAsync(string taskID, string taskListID)
        {
            GTask              result     = null;
            string             requestUrl = $"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks/{taskID}";
            HttpRequestMessage request    = new HttpRequestMessage(HttpMethod.Get, requestUrl);

            RequestHelper.AddAuthorizationHeader(request, ClientToken);

            var responseMessage = await _client.SendAsync(request);

            if (responseMessage.IsSuccessStatusCode)
            {
                string jsonReturned = await responseMessage.Content.ReadAsStringAsync();

                result = JsonConvert.DeserializeObject <GTask>(jsonReturned);
            }

            return(result);
        }
예제 #5
0
        public async Task <GTask> MoveTaskAsync(string taskID, string taskListID, string parentID = null, string previousSiblingID = null)
        {
            GTask result = null;

            StringBuilder requestBuilder = new StringBuilder();

            requestBuilder.Append($"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks/{taskID}/move");

            Dictionary <string, object> queries = new Dictionary <string, object>();

            if (parentID != null)
            {
                queries.Add("parent", parentID);
            }

            if (previousSiblingID != null)
            {
                queries.Add("previous", previousSiblingID);
            }

            RequestHelper.AddQueriesToRequest(requestBuilder, queries);

            HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestBuilder.ToString());

            RequestHelper.AddAuthorizationHeader(request, ClientToken);

            var responseMessage = await _client.SendAsync(request);

            if (responseMessage.IsSuccessStatusCode)
            {
                string jsonReturned = await responseMessage.Content.ReadAsStringAsync();

                result = JsonConvert.DeserializeObject <GTask>(jsonReturned);
            }

            return(result);
        }
예제 #6
0
        // GET: Tasks/RemoveTask/{id}
        public ActionResult RemoveTask(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GTask gTask = db.Tasks.Find(id);

            if (gTask == null)
            {
                return(HttpNotFound());
            }
            db.Tasks.Remove(gTask);
            db.SaveChanges();

            Employee employee = db.Employees.Find(gTask.EmployeeId);

            Productivity.CalculateProductivity(employee);
            Productivity.TeamProductivity(employee.Team);
            db.Entry(employee).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Edit", db.Employees.Find(gTask.EmployeeId)));;
        }
예제 #7
0
        public async Task <GTask> UpdateTaskAsync(string taskListID, GTask updatedTask)
        {
            GTask result = null;

            string             requestUrl = $"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks/{updatedTask.ID}";
            HttpRequestMessage request    = new HttpRequestMessage(HttpMethod.Put, requestUrl);

            RequestHelper.AddAuthorizationHeader(request, ClientToken);

            var listJson = new StringContent(JsonConvert.SerializeObject(updatedTask), Encoding.UTF8,
                                             JsonMediaType);

            request.Content = listJson;
            var responseMessage = await _client.SendAsync(request);

            if (responseMessage.IsSuccessStatusCode)
            {
                string jsonReturned = await responseMessage.Content.ReadAsStringAsync();

                result = JsonConvert.DeserializeObject <GTask>(jsonReturned);
            }

            return(result);
        }
예제 #8
0
 public bool startTask(GTask task)
 {
     return(_raw.startTask((GlyTask)task.raw()));
 }
예제 #9
0
 public bool startTask(GTask task)
 {
     return(_raw.startTask((com.glympse.enroute.android.api.GTask)task.raw()));
 }