private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(txtTaskName.Text) || String.IsNullOrEmpty(txtWorksheetUrl.Text))
            {
                MessageBox.Show("Task Name or Worksheet URL cannot be empty");
                return;
            }
            using (var context = new WorkDeskManager.Desktop.Data.WorkdeskContext())
            {

                try
                {
                    var task = new Data.Task { Name = txtTaskName.Text.Trim(), WorksheetUrl = txtWorksheetUrl.Text.Trim() };
                    context.Tasks.Add(task);
                    context.SaveChanges();
                    MessageBox.Show(String.Format("Task -{0}- Added",txtTaskName.Text));
                }
                catch (Exception ex)
                {

                    MessageBox.Show(String.Format("Error adding new task: {0}",ex.Message));
                }
            }

            Close();
        }
Ejemplo n.º 2
0
        public List <Data.Task> getPendingTasks(int codUser, int codTask)
        {
            List <Data.Task> pendingTasks = new List <Data.Task>();

            using (DbConnection cn = b.CreateConnection())
            {
                using (DbCommand cmd = b.CreateCommand(cn))
                {
                    cmd.CommandText = "wfSP_GET_PENDING_TASKS";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(CreateParameter("@CodUser", DbType.Int32, codUser));
                    cmd.Parameters.Add(CreateParameter("@CodTask", DbType.Int32, codTask));

                    cn.Open();
                    using (DbDataReader reader = b.ExecuteReader(cmd))
                    {
                        while (reader.Read())
                        {
                            Data.Task t = new Data.Task();

                            t.CodFlowExecuteTask = Util.Parse.ToInt(reader["CodFlowExecuteTask"]);
                            t.CodFlow            = Util.Parse.ToInt(reader["CodFlow"]);
                            t.CodFlowExecute     = Util.Parse.ToInt(reader["CodFlowExecute"]);
                            t.CodTask            = codTask;
                            t.DsTask             = Util.Parse.ToString(reader["DsTaskTitle"]);

                            pendingTasks.Add(t);
                        }
                    }
                    return(pendingTasks);
                }
            }
        }
Ejemplo n.º 3
0
        public Data.Task getTaskInfo(int codFlowExecuteTask)
        {
            // Retorno
            Data.Task t = new Data.Task();

            using (DbConnection cn = b.CreateConnection())
            {
                using (DbCommand cmd = b.CreateCommand(cn))
                {
                    cmd.CommandText = "wfSP_GET_TASK_INFO";
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add(CreateParameter("@CodFlowExecuteTask", DbType.Int32, codFlowExecuteTask));

                    cn.Open();

                    using (DbDataReader reader = b.ExecuteReader(cmd))
                    {
                        if (reader.Read())
                        {
                            t.CodFlow        = Util.Parse.ToInt(reader["CodFlow"]);
                            t.CodFlowExecute = Util.Parse.ToInt(reader["CodFlowExecute"]);
                            t.CodTask        = Util.Parse.ToInt(reader["CodTask"]);
                            t.DsTask         = Util.Parse.ToString(reader["DsTaskTitle"]);
                        }
                    }
                }
            }

            return(t);
        }
Ejemplo n.º 4
0
        async public static Task UpsertTask(Data.Task task, bool addToBacklog = true)
        {
            var taskJsonString = task.ToJson().ToString();

            using (connection)
            {
                // TODO: handle SqliteException
                await connection.OpenAsync();

                using (var tx = connection.BeginTransaction())
                {
                    var sql = "INSERT OR REPLACE INTO tasks (uuid, task) VALUES (@uuid, @task);";
                    if (addToBacklog)
                    {
                        sql += "\nINSERT INTO sync_backlog(sync_key, task) VALUES ((SELECT value FROM metadata WHERE key = 'sync_key'), @task);";
                    }
                    var insert = new SqliteCommand(sql, connection, tx);
                    insert.Parameters.AddWithValue("@uuid", task.Uuid.ToString());
                    insert.Parameters.AddWithValue("@task", taskJsonString);
                    await insert.ExecuteNonQueryAsync();

                    tx.Commit();
                }
            }
        }
Ejemplo n.º 5
0
        public void WhenUpdatingTaskPropertiesAreSavedCorrectly()
        {
            // Assemble
            var dbContext = new InMemoryOCCDB()
                            .WithEvent("Test Event")
                            .WithEvent("Second Event")
                            .WithTask("Test Task");

            _expectedTask = new Services.Task
            {
                Description = "This is the Modified Task",
                Capacity    = 5,
                StartTime   = DateTime.Today,
                EndTime     = DateTime.Now,
                EventID     = 2
            };

            var service = TestHelper.GetTestService(dbContext);

            var originalTask = service.GetTaskById(1);

            originalTask.Description = _expectedTask.Description;
            originalTask.Capacity    = _expectedTask.Capacity;
            originalTask.StartTime   = _expectedTask.StartTime;
            originalTask.EndTime     = _expectedTask.EndTime;
            originalTask.EventID     = _expectedTask.EventID;

            // Act
            service.UpdateTask(originalTask);

            // Assert
            _actualTask = dbContext.Tasks.First();
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            Username = HttpContext.Session.GetString("username"); // establish session

            if (Username != null)
            {
                if (id == null)
                {
                    return(NotFound());
                }

                Task = await _context.Task
                       .Include(t => t.Employee)
                       .Include(t => t.Status).FirstOrDefaultAsync(m => m.Id == id);

                if (Task == null)
                {
                    return(NotFound());
                }
                return(Page());
            }
            else
            {
                return(RedirectToPage("../Index"));
            }
        }
Ejemplo n.º 7
0
 protected void Fetch(Data.Task data)
 {
     this.LoadProperty(TaskIdProperty, data.TaskId);
     this.LoadProperty(ProjectProperty, ProjectInfo.FetchProjectInfo(data.Project));
     this.LoadProperty(ProjectIdProperty, data.ProjectId);
     this.LoadProperty(ProjectNameProperty, data.Project.Name);
     this.LoadProperty(SprintProperty, SprintInfo.FetchSprintInfo(data.Sprint));
     this.LoadProperty(SprintIdProperty, data.SprintId);
     this.LoadProperty(SprintNameProperty, data.SprintName);
     this.LoadProperty(CategoryProperty, CategoryInfo.FetchCategoryInfo(data.Category));
     this.LoadProperty(CategoryIdProperty, data.CategoryId);
     this.LoadProperty(CategoryNameProperty, data.Category.Name);
     this.LoadProperty(StatusProperty, StatusInfo.FetchStatusInfo(data.Status));
     this.LoadProperty(StatusIdProperty, data.StatusId);
     this.LoadProperty(StatusNameProperty, data.Status.Name);
     this.LoadProperty(DescriptionProperty, data.Description);
     this.LoadProperty(AssignedToProperty, data.AssignedTo);
     this.LoadProperty(AssignedToNameProperty, data.AssignedToUser == null ? "No one" : data.AssignedToUser.Name);
     this.LoadProperty(AssignedDateProperty, data.AssignedDate);
     this.LoadProperty(StartDateProperty, data.StartDate);
     this.LoadProperty(CompletedDateProperty, data.CompletedDate);
     this.LoadProperty(EstimatedCompletedDateProperty, data.EstimatedCompletedDate);
     this.LoadProperty(DurationProperty, data.Duration);
     this.LoadProperty(EstimatedDurationProperty, data.EstimatedDuration);
     this.LoadProperty(LabelsProperty, data.Labels);
     this.LoadProperty(IsArchivedProperty, data.IsArchived);
     this.LoadProperty(NotesProperty, data.Notes);
     this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
     this.LoadProperty(ModifiedByNameProperty, data.ModifiedByUser.Name);
     this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);
     this.LoadProperty(CreatedByProperty, data.CreatedBy);
     this.LoadProperty(CreatedByNameProperty, data.CreatedByUser.Name);
     this.LoadProperty(CreatedDateProperty, data.CreatedDate);
     this.LoadProperty(TaskLabelsProperty, TaskLabels.FetchTaskLabels(this));
 }
        public TaskDTO GetTaskById(int taskId)
        {
            Data.Task tasks    = _taskData.GetTaskById(taskId);
            TaskDTO   DTOTasks = Mapper.Map <TaskDTO>(tasks);

            return(DTOTasks);
        }
Ejemplo n.º 9
0
        public async Task <Data.Task> AddAsync(Data.Task task)
        {
            _dbContext.Tasks.Add(task);
            await _dbContext.SaveChangesAsync();

            return(task);
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> PutTask([FromRoute] int id, [FromBody] Data.Task task)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != task.Id)
            {
                return(BadRequest());
            }

            _context.Entry(task).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TaskExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 11
0
        public void WhenUpdatingTaskPropertiesAreSavedCorrectly()
        {
            // Assemble
            var dbContext = new InMemoryOCCDB()
                .WithEvent("Test Event")
                .WithEvent("Second Event")
                .WithTask("Test Task");

            _expectedTask = new Services.Task
            {
                Description = "This is the Modified Task",
                Capacity = 5,
                StartTime = DateTime.Today,
                EndTime = DateTime.Now,
                EventID = 2
            };

            var service = TestHelper.GetTestService(dbContext);

            var originalTask =service.GetTaskById(1);
            originalTask.Description = _expectedTask.Description;
            originalTask.Capacity = _expectedTask.Capacity;
            originalTask.StartTime = _expectedTask.StartTime;
            originalTask.EndTime = _expectedTask.EndTime;
            originalTask.EventID = _expectedTask.EventID;

            // Act
            service.UpdateTask(originalTask);

            // Assert
            _actualTask = dbContext.Tasks.First();
        }
Ejemplo n.º 12
0
 public Overview(Data.Task task)
 {
     TaskId        = task.Id;
     TaskName      = task.Name;
     TaskStartTime = task.StartTime;
     TaskEndTime   = task.EndTime;
     CategoryName  = task.Category.Name;
     if (task.Appointments != null)
     {
         AppointmentsCount = task.Appointments.Count();
     }
     else
     {
         AppointmentsCount = 0;
     }
     if (task.Notes != null)
     {
         NotesCount = task.Notes.Count();
     }
     else
     {
         NotesCount = 0;
     }
     if (task.Documents != null)
     {
         DocumentsCount = task.Documents.Count();
     }
     else
     {
         DocumentsCount = 0;
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates the all tasks cached query results when a task is updated
        /// </summary>
        void AllTasksOnTaskUpdated(object sender, TaskUpdatedEventArgs e)
        {
            QueryCacheItem cachedQuery = _appInfo.GlobalQueryCache.GetCacheItem(Constants.AllTasksCacheItem);

            if (cachedQuery != null)
            {
                // updated the query results if needed
                List <Data.Task> allTasks = (List <Data.Task>)cachedQuery.Value;
                Data.Task        oldTask  = allTasks.FirstOrDefault(t => t.TaskID == e.UpdatedTask.TaskId);
                Data.Task        newTask  = e.UpdatedDbTask;
                if (oldTask != null && newTask != null)
                {
                    allTasks.Remove(oldTask);
                    allTasks.Add(newTask);
                }
                else if (newTask != null)
                {
                    allTasks.Add(newTask);
                }

                allTasks = SortList(allTasks);

                _appInfo.GlobalQueryCache.UpdateCacheItem(Constants.AllTasksCacheItem, allTasks);
            }
        }
Ejemplo n.º 14
0
        public Details(ITaskData taskData, int taskId) : this()
        {
            Data.Task task = taskData.Get(taskId);

            TaskId         = taskId;
            TaskCategoryId = task.CategoryId;
            TaskName       = task.Name;
            TaskStartTime  = task.StartTime;
            TaskEndTime    = task.EndTime;
            CategoryName   = task.Category.Name;

            if (task.Appointments != null)
            {
                foreach (Data.Appointment appointment in task.Appointments)
                {
                    Appointments.Add(new Appointment(appointment));
                }
            }

            if (task.Notes != null)
            {
                foreach (Data.Note note in task.Notes)
                {
                    Notes.Add(new Note(note));
                }
            }

            if (task.Documents != null)
            {
                foreach (Data.Document document in task.Documents)
                {
                    Documents.Add(new Document(document));
                }
            }
        }
Ejemplo n.º 15
0
        protected void Insert(Data.Task data)
        {
            data.TaskId      = this.ReadProperty(TaskIdProperty);
            data.CreatedBy   = ((BusinessIdentity)Csla.ApplicationContext.User.Identity).UserId;
            data.CreatedDate = DateTime.Now;

            this.Update(data);
        }
Ejemplo n.º 16
0
        public TaskDto Create(TaskDto dto)
        {
            Data.Task task = ConvertToEntity(dto);
            appContext.Task.Add(task);
            Save();

            return(ConverToDto(task));
        }
Ejemplo n.º 17
0
 private void AddChildrenRecursive(List <Task> list, Data.Task task)
 {
     foreach (var childtask in task.ChildTasks)
     {
         list.Add(childtask);
         AddChildrenRecursive(list, childtask);
     }
 }
Ejemplo n.º 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            t = new Business.Task().getTaskInfo(Convert.ToInt32(this.CodFlowExecuteTask));
            this.DsTaskTitle = t.DsTask;

            checkAutomaticExecution();

            runDecisionSupport();
        }
Ejemplo n.º 19
0
        protected void BtnActivate_Click(object sender, EventArgs e)
        {
            t = new Business.Task().getTaskInfo(Convert.ToInt32(this.CodFlowExecuteTask));
            this.DsTaskTitle = t.DsTask;

            new Business.AutomaticTaskExecution().activateAutomaticExecution(t.CodTask, Convert.ToInt32(this.CodUser));
            this.PhActvate.Visible    = false;
            this.PhDeactivate.Visible = true;
        }
Ejemplo n.º 20
0
 public static Data.Task InsertTask(InMemoryOCCDB context, string description)
 {
     var @event = context.Events.First();
     var task = new Data.Task
     {
         Description = description,
         Event_ID = @event.ID
     };
     context.Tasks.Add(task);
     return task;
 }
Ejemplo n.º 21
0
 private TaskDto ConverToDto(Data.Task entity)
 {
     return(new TaskDto
     {
         Id = entity.Id,
         Subject = entity.Subject,
         Description = entity.Description,
         ToDoId = entity.ToDoId,
         //TaskDtos =
     });
 }
Ejemplo n.º 22
0
 public static Task Map(this Data.Task task)
 {
     return(new Task
     {
         Id = task.ID,
         Description = task.Description,
         Event = task.Event.Map(),
         StartTime = task.StartTime,
         EndTime = task.EndTime,
         Capacity = task.Capacity
     });
 }
Ejemplo n.º 23
0
        public static Data.Task InsertTask(InMemoryOCCDB context, string description)
        {
            var @event = context.Events.First();
            var task   = new Data.Task
            {
                Description = description,
                Event_ID    = @event.ID
            };

            context.Tasks.Add(task);
            return(task);
        }
Ejemplo n.º 24
0
        internal static TaskInfo FetchTaskInfo(
            Data.Task data,
            decimal?duration,
            int?numberOfNotes,
            int?numberOfAttachments,
            int?numberOfInvoices)
        {
            var result = new TaskInfo();

            result.Fetch(data, duration, numberOfNotes, numberOfAttachments, numberOfInvoices);
            return(result);
        }
Ejemplo n.º 25
0
        public Data.Task Create(Data.Task task)
        {
            // validation
            if (string.IsNullOrWhiteSpace(task.Title))
            {
                throw new AppException("Title is required");
            }

            _context.Tasks.Add(task);
            _context.SaveChanges();
            task.owner = _userProvider.getUser();

            return(task);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// If the assigned unregisters from the task, the board get an email on this event.
        /// </summary>
        /// <param name="task">A task that have been revoked by the user and that needs to be reassigned</param>
        /// <param name="emailAddress">The board's email address</param>
        public void SendTaskRevokeMail(Data.Task task, string emailAddress)
        {
            string taskRevokeSubject = string.Format("Volunteer has unregistered from {0}", task.Description);

            var mailMessage = new StringBuilder();

            mailMessage.Append("This email is to confirm this task is now available and needs to be re-assigned.");

            mailMessage.AppendFormat("<b> Volunteer Task: {0} </b>", task.Description);
            mailMessage.AppendFormat("<b> Start Time: {0} </b>", task.StartTime.ToShortTimeString());
            mailMessage.AppendFormat("<b> End Time: {0}. </b>", task.EndTime.ToShortTimeString());

            SendMail(mailMessage.ToString(), emailAddress, taskRevokeSubject);
        }
Ejemplo n.º 27
0
        public static Data.Task Map(this Task dcTask)
        {
            var task = new Data.Task
            {
                ID          = dcTask.Id,
                StartTime   = dcTask.StartTime,
                EndTime     = dcTask.EndTime,
                Capacity    = dcTask.Capacity,
                Description = dcTask.Description,
                Event_ID    = dcTask.EventID
            };

            return(task);
        }
Ejemplo n.º 28
0
        public ActionResult <Data.Task> PostTask([FromBody] Data.Task task)
        {
            // Calculation //
            task.KeyFigure = new Data.KeyFigure
            {
                AvgProcessingTime   = 99,
                TotalProcessingTime = 88,
                VMax = 77,
                VMid = 66,
                VSum = 55
            };

            return(task);
        }
Ejemplo n.º 29
0
        public async System.Threading.Tasks.Task UpdateAsync(Data.Task task)
        {
            var excluded = new[] { "StatusId", "StartDate", "EndDate" };

            var entry = _dbContext.Entry(task);

            entry.State = EntityState.Modified;

            foreach (var item in excluded)
            {
                entry.Property(item).IsModified = false;
            }

            await _dbContext.SaveChangesAsync();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Returns a shallow-copied list of a single task by task id.
        /// </summary>
        public Task GetTaskByTaskId(int taskId)
        {
            Task requestedTask = null;

            Data.Task requestedDbTask = (from t in _appInfo.GcContext.Tasks
                                         where t.TaskID == taskId
                                         select t).FirstOrDefault();

            if (requestedDbTask != null)
            {
                requestedTask = Task.CreateTask(requestedDbTask);
            }

            return(requestedTask);
        }
Ejemplo n.º 31
0
        /// <summary>
        /// Updates the active tasks cached query results when a task is deleted
        /// </summary>
        void ActiveTasksOnTaskDeleted(object sender, TaskDeletedEventArgs e)
        {
            QueryCacheItem cachedQuery = _appInfo.GlobalQueryCache.GetCacheItem(Constants.ActiveTasksCacheItem);

            if (cachedQuery != null)
            {
                List <Data.Task> activeTasks = (List <Data.Task>)cachedQuery.Value;
                Data.Task        deletedTask = activeTasks.FirstOrDefault(t => t.TaskID == e.DeletedTask.TaskId);
                if (deletedTask != null)
                {
                    activeTasks.Remove(deletedTask);
                    _appInfo.GlobalQueryCache.UpdateCacheItem(Constants.ActiveTasksCacheItem, activeTasks);
                }
            }
        }
Ejemplo n.º 32
0
        public TaskDTO GetTaskById(int taskId)
        {
            Data.Task            tasks          = _appRepository.GetTaskById(taskId);
            TaskDTO              DTOTasks       = Mapper.Map <TaskDTO>(tasks);
            List <ParentTaskDTO> parentTaskDTOs = GetParentTasks();

            if (parentTaskDTOs.Count > 0)
            {
                if (DTOTasks.Parent_Id != null)
                {
                    DTOTasks.ParentTask = parentTaskDTOs.Where(a => a.Parent_Id == DTOTasks.Parent_Id).Select(a => a.Parent_Task).FirstOrDefault();
                }
            }
            return(DTOTasks);
        }
Ejemplo n.º 33
0
        protected override void DataPortal_DeleteSelf()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Task
                {
                    TaskId = this.ReadProperty(TaskIdProperty)
                };

                ctx.ObjectContext.Tasks.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Ejemplo n.º 34
0
        protected override void DataPortal_DeleteSelf()
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Task
                {
                    TaskId = this.ReadProperty(TaskIdProperty)
                };

                ctx.ObjectContext.Tasks.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Ejemplo n.º 35
0
        protected override void DataPortal_Insert()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Task();

                this.Insert(data);

                ctx.ObjectContext.AddToTasks(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(TaskIdProperty, data.TaskId);
                this.LoadProperty(CreatedByProperty, data.CreatedBy);
                this.LoadProperty(CreatedDateProperty, data.CreatedDate);

                Csla.DataPortal.UpdateChild(this.ReadProperty(TaskLabelsProperty), this);
            }
        }
Ejemplo n.º 36
0
        protected override void DataPortal_Update()
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = new Data.Task
                {
                    TaskId = this.ReadProperty(TaskIdProperty)
                };

                ctx.ObjectContext.Tasks.Attach(data);

                this.Update(data);

                ctx.ObjectContext.SaveChanges();

                this.LoadProperty(ModifiedByProperty, data.ModifiedBy);
                this.LoadProperty(ModifiedDateProperty, data.ModifiedDate);

                Csla.DataPortal.UpdateChild(this.ReadProperty(TaskLabelsProperty), this);
            }
        }
Ejemplo n.º 37
0
 public static Data.Task Map(this Task dcTask)
 {
     var task = new Data.Task
                    {
                        ID = dcTask.Id,
                        StartTime = dcTask.StartTime,
                        EndTime = dcTask.EndTime,
                        Capacity = dcTask.Capacity,
                        Description = dcTask.Description,
                        Event_ID = dcTask.EventID
                    };
     return task;
 }