Esempio n. 1
0
        internal static void DeleteTask(TaskCriteria criteria)
        {
            var task = Task.FetchTask(criteria);

            if (!Task.CanDeleteObject(task))
            {
                throw new SecurityException("Only users with full control can delete and archived task");
            }

            Csla.DataPortal.Delete<Task>(criteria);
        }
Esempio n. 2
0
        internal static void DeleteTask(TaskCriteria criteria)
        {
            var task = Task.FetchTask(criteria);

            if (!Task.CanDeleteObject(task))
            {
                throw new SecurityException("Only users with full control can delete and archived task");
            }

            Csla.DataPortal.Delete <Task>(criteria);
        }
Esempio n. 3
0
        private void DataPortal_Delete(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Tasks
                           .Single(row => row.TaskId == criteria.TaskId);

                ctx.ObjectContext.Tasks.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Esempio n. 4
0
        private void DataPortal_Fetch(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Tasks
                           .Include("Category")
                           .Include("Status")
                           .Include("Project")
                           .Include("Sprint")
                           .Include("AssignedToUser")
                           .Single(row => row.TaskId == criteria.TaskId);

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
Esempio n. 5
0
        public ActionResult Index(int[] projectId, int[] categoryId, int[] statusId, int? sprintId, int[] assignedTo, string completedDate, string modifiedDate, string createdDate, int? isArchived, string label, string text, string sortBy, string sortOrder)
        {
            var model = new TaskIndexModel();

            model.Tab = "Task";

            model.Projects = DataHelper.GetProjectList();
            model.ProjectId = projectId ?? new int[0];
            model.ProjectName = DataHelper.ToString(model.Projects, model.ProjectId, "any project");
            model.ProjectDisplayName = DataHelper.Clip(model.ProjectName, 40);

            model.Categories = DataHelper.GetCategoryList();
            model.CategoryId = categoryId ?? new int[0];
            model.CategoryName = DataHelper.ToString(model.Categories, model.CategoryId, "any category");
            model.CategoryDisplayName = DataHelper.Clip(model.CategoryName, 20);

            model.Statuses = DataHelper.GetStatusList();
            model.StatusId = statusId ?? new int[0];
            model.StatusName = DataHelper.ToString(model.Statuses, model.StatusId, "any status");
            model.StatusDisplayName = DataHelper.Clip(model.StatusName, 20);

            model.AssignedToUsers = DataHelper.GetUserList();
            model.AssignedTo = assignedTo ?? new int[0];
            model.AssignedToName = DataHelper.ToString(model.AssignedToUsers, model.AssignedTo, "any user");
            model.AssignedToDisplayName = DataHelper.Clip(model.AssignedToName, 20);

            model.Label = label;
            model.IsArchived = isArchived ?? 0;

            model.Filters = MyService.FilterFetchInfoList("Task");

            model.SortBy = sortBy ?? "TaskId";
            model.SortOrder = sortOrder ?? "ASC";
            model.SortableColumns.Add("EstimatedCompletedDate", "Due");
            model.SortableColumns.Add("ProjectName", "Project");
            model.SortableColumns.Add("AssignedToName", "User");
            model.SortableColumns.Add("StatusName", "Status");
            model.SortableColumns.Add("TaskId", "No.");

            model.LabelByCountListModel =
                new LabelByCountListModel
                {
                    Action = "Task",
                    Label = label,
                    Labels = DataHelper.GetTaskLabelByCountList()
                };

            var criteria = new TaskCriteria()
                {
                    ProjectId = projectId,
                    SprintId = sprintId,
                    CategoryId = categoryId,
                    StatusId = statusId,
                    AssignedTo = assignedTo,
                    CompletedDate = new DateRangeCriteria(completedDate ?? string.Empty),
                    ModifiedDate = new DateRangeCriteria(modifiedDate ?? string.Empty),
                    CreatedDate = new DateRangeCriteria(createdDate ?? string.Empty),
                    IsArchived = DataHelper.ToBoolean(isArchived),
                    TaskLabels = string.IsNullOrEmpty(label) ? null : new[] { label },
                    Text = text
                };

            var tasks = TaskService.TaskFetchInfoList(criteria)
                .AsQueryable();

            tasks = tasks.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder));

            model.Tasks = tasks;

            var hours = HourService.HourFetchInfoList(tasks.Cast<ITask>().ToArray());

            model.Hours = hours;

            return RespondTo(format =>
            {
                format[RequestExtension.Html] = () => this.View(model);
                format[RequestExtension.Xml] = () => new XmlResult { Data = model.Tasks.ToList(), TableName = "Task" };
                format[RequestExtension.Json] = () => new JsonResult { Data = model.Tasks, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            });
        }
Esempio n. 6
0
        public void Export(int[] projectId, int[] categoryId, int[] statusId, int? sprintId, int[] assignedTo, string completedDate, string modifiedDate, string createdDate, int? isArchived, string text, string sortBy, string sortOrder)
        {
            var criteria = new TaskCriteria()
            {
                ProjectId = projectId,
                SprintId = sprintId,
                CategoryId = categoryId,
                StatusId = statusId,
                AssignedTo = assignedTo,
                CompletedDate = new DateRangeCriteria(completedDate ?? string.Empty),
                ModifiedDate = new DateRangeCriteria(modifiedDate ?? string.Empty),
                CreatedDate = new DateRangeCriteria(createdDate ?? string.Empty),
                IsArchived = DataHelper.ToBoolean(isArchived, false),
                Text = text
            };

            var tasks = TaskService.TaskFetchInfoList(criteria)
                .AsQueryable();

            tasks = tasks.OrderBy(string.Format("{0} {1}", sortBy ?? "TaskId", sortOrder ?? "ASC"));

            var sw = new StringWriter();

            sw.WriteLine(
                "TaskId,ProjectName,SprintName,CategoryName,StatusName,Description,AssignedToName,AssignedDate,StartDate,CompletedDate,EstimatedCompletedDate,Duration,EstimatedDuration,Labels,IsArchived,Notes,ModifiedByName,ModifiedDate,CreatedByName,CreatedByDate");

            foreach (var task in tasks)
            {
                var sb = new StringBuilder();

                sb.AppendFormat("{0},", task.TaskId);
                sb.AppendFormat("\"{0}\",", task.ProjectName);
                sb.AppendFormat("\"{0}\",", task.SprintName);
                sb.AppendFormat("{0},", task.CategoryName);
                sb.AppendFormat("{0},", task.StatusName);
                sb.AppendFormat("\"{0}\",", task.Description.Replace("\"", "'"));
                sb.AppendFormat("{0},", task.AssignedToName);
                sb.AppendFormat("{0},", task.AssignedDate);
                sb.AppendFormat("{0},", task.StartDate);
                sb.AppendFormat("{0},", task.CompletedDate);
                sb.AppendFormat("{0},", task.EstimatedCompletedDate);
                sb.AppendFormat("{0},", task.Duration);
                sb.AppendFormat("{0},", task.EstimatedDuration);
                sb.AppendFormat("\"{0}\",", task.Labels);
                sb.AppendFormat("{0},", task.IsArchived);
                sb.AppendFormat("\"{0}\",", task.Notes);
                sb.AppendFormat("{0},", task.ModifiedByName);
                sb.AppendFormat("{0},", task.ModifiedDate);
                sb.AppendFormat("{0},", task.CreatedByName);
                sb.AppendFormat("{0}", task.CreatedDate);

                sw.WriteLine(sb.ToString());
            }

            this.Response.AddHeader("Content-Disposition", "attachment; filename=Stories.csv");
            this.Response.ContentType = "application/ms-excel";
            this.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
            this.Response.Write(sw);
            this.Response.End();
        }
Esempio n. 7
0
 internal static Task FetchTask(TaskCriteria criteria)
 {
     return Csla.DataPortal.Fetch<Task>(criteria);
 }
Esempio n. 8
0
        private void DataPortal_Fetch(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly = false;

                IQueryable<Data.Task> query = ctx.ObjectContext.Tasks
                    .Include("Category")
                    .Include("Status")
                    .Include("Project")
                    .Include("Sprint")
                    .Include("AssignedToUser");

                if (criteria.TaskId != null)
                {
                    query = query.Where(row => row.TaskId == criteria.TaskId);
                }

                if (criteria.ProjectId != null && criteria.ProjectId.Count() != 0)
                {
                    query = query.Where(row => criteria.ProjectId.Contains(row.ProjectId));
                }

                if (criteria.SprintId != null)
                {
                    query = query.Where(row => row.SprintId == criteria.SprintId);
                }

                if (criteria.CategoryId != null && criteria.CategoryId.Count() != 0)
                {
                    query = query.Where(row => criteria.CategoryId.Contains(row.CategoryId));
                }

                if (criteria.StatusId != null && criteria.StatusId.Count() != 0)
                {
                    query = query.Where(row => criteria.StatusId.Contains(row.StatusId));
                }

                if (criteria.Description != null)
                {
                    query = query.Where(row => row.Description == criteria.Description);
                }

                if (criteria.AssignedTo != null && criteria.AssignedTo.Count() != 0)
                {
                    query = query.Where(row => criteria.AssignedTo.Contains(row.AssignedTo));
                }

                if (criteria.AssignedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.AssignedDate >= criteria.AssignedDate.DateFrom);
                }

                if (criteria.AssignedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.AssignedDate <= criteria.AssignedDate.DateTo);
                }

                if (criteria.StartDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.StartDate >= criteria.StartDate.DateFrom);
                }

                if (criteria.StartDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.StartDate <= criteria.StartDate.DateTo);
                }

                if (criteria.CompletedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CompletedDate >= criteria.CompletedDate.DateFrom);
                }

                if (criteria.CompletedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CompletedDate <= criteria.CompletedDate.DateTo);
                }

                if (criteria.EstimatedCompletedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.EstimatedCompletedDate >= criteria.EstimatedCompletedDate.DateFrom);
                }

                if (criteria.EstimatedCompletedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.EstimatedCompletedDate <= criteria.EstimatedCompletedDate.DateTo);
                }

                if (criteria.Duration != null)
                {
                    query = query.Where(row => row.Duration == criteria.Duration);
                }

                if (criteria.EstimatedDuration != null)
                {
                    query = query.Where(row => row.EstimatedDuration == criteria.EstimatedDuration);
                }

                if (criteria.Label != null)
                {
                    query = query.Where(row => row.Notes.Contains(criteria.Label));
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.Notes != null)
                {
                    query = query.Where(row => row.Notes == criteria.Notes);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.TaskLabels != null
                        && criteria.TaskLabels.Count() != 0)
                {
                    query = query.Join(ctx.ObjectContext.TaskLabels
                        .Where(tl => criteria.TaskLabels.Contains(tl.Name)), t => t.TaskId, tl => tl.TaskId, (t, tl) => t);
                }

                if (criteria.Text != null)
                {
                    query = query.Where(row => SqlFunctions.StringConvert((double)row.TaskId).Contains(criteria.Text)
                        || row.Description.Contains(criteria.Text)
                        || row.Project.Name.Contains(criteria.Text));
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                        "{0} {1}",
                        criteria.SortBy,
                        criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(row => TaskInfo.FetchTaskInfo(row,
                    ctx.ObjectContext.Hours.Where(hour => hour.TaskId == row.TaskId).Sum(hour => (decimal?)hour.Duration),
                    ctx.ObjectContext.Notes.Count(note => note.SourceType == (int)SourceType.Task && note.SourceId == row.TaskId),
                    ctx.ObjectContext.Attachments.Count(attachment => attachment.SourceType == (int)SourceType.Task && attachment.SourceId == row.TaskId),
                    ctx.ObjectContext.Invoices.Count(invoice => invoice.TaskId == row.TaskId)));

                this.AddRange(data);

                this.IsReadOnly = true;
                this.RaiseListChangedEvents = true;
            }
        }
Esempio n. 9
0
        private void DataPortal_Fetch(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Tasks
                    .Include("Category")
                    .Include("Status")
                    .Include("Project")
                    .Include("Sprint")
                    .Include("AssignedToUser")
                    .Single(row => row.TaskId == criteria.TaskId);

                this.Fetch(data);

                this.BusinessRules.CheckRules();
            }
        }
Esempio n. 10
0
        private void DataPortal_Delete(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager<ApplicationEntities>
                        .GetManager(Database.ApplicationConnection, false))
            {
                var data = ctx.ObjectContext.Tasks
                    .Single(row => row.TaskId == criteria.TaskId);

                ctx.ObjectContext.Tasks.DeleteObject(data);

                ctx.ObjectContext.SaveChanges();
            }
        }
Esempio n. 11
0
 internal static TaskInfoList FetchTaskInfoList(TaskCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <TaskInfoList>(criteria));
 }
Esempio n. 12
0
 internal static Task FetchTask(TaskCriteria criteria)
 {
     return(Csla.DataPortal.Fetch <Task>(criteria));
 }
Esempio n. 13
0
        private void DataPortal_Fetch(TaskCriteria criteria)
        {
            using (var ctx = Csla.Data.ObjectContextManager <ApplicationEntities>
                             .GetManager(Database.ApplicationConnection, false))
            {
                this.RaiseListChangedEvents = false;
                this.IsReadOnly             = false;

                IQueryable <Data.Task> query = ctx.ObjectContext.Tasks
                                               .Include("Category")
                                               .Include("Status")
                                               .Include("Project")
                                               .Include("Sprint")
                                               .Include("AssignedToUser");

                if (criteria.TaskId != null)
                {
                    query = query.Where(row => row.TaskId == criteria.TaskId);
                }

                if (criteria.ProjectId != null && criteria.ProjectId.Count() != 0)
                {
                    query = query.Where(row => criteria.ProjectId.Contains(row.ProjectId));
                }

                if (criteria.SprintId != null)
                {
                    query = query.Where(row => row.SprintId == criteria.SprintId);
                }

                if (criteria.CategoryId != null && criteria.CategoryId.Count() != 0)
                {
                    query = query.Where(row => criteria.CategoryId.Contains(row.CategoryId));
                }

                if (criteria.StatusId != null && criteria.StatusId.Count() != 0)
                {
                    query = query.Where(row => criteria.StatusId.Contains(row.StatusId));
                }

                if (criteria.Description != null)
                {
                    query = query.Where(row => row.Description == criteria.Description);
                }

                if (criteria.AssignedTo != null && criteria.AssignedTo.Count() != 0)
                {
                    query = query.Where(row => criteria.AssignedTo.Contains(row.AssignedTo));
                }

                if (criteria.AssignedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.AssignedDate >= criteria.AssignedDate.DateFrom);
                }

                if (criteria.AssignedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.AssignedDate <= criteria.AssignedDate.DateTo);
                }

                if (criteria.StartDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.StartDate >= criteria.StartDate.DateFrom);
                }

                if (criteria.StartDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.StartDate <= criteria.StartDate.DateTo);
                }

                if (criteria.CompletedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CompletedDate >= criteria.CompletedDate.DateFrom);
                }

                if (criteria.CompletedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CompletedDate <= criteria.CompletedDate.DateTo);
                }

                if (criteria.EstimatedCompletedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.EstimatedCompletedDate >= criteria.EstimatedCompletedDate.DateFrom);
                }

                if (criteria.EstimatedCompletedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.EstimatedCompletedDate <= criteria.EstimatedCompletedDate.DateTo);
                }

                if (criteria.Duration != null)
                {
                    query = query.Where(row => row.Duration == criteria.Duration);
                }

                if (criteria.EstimatedDuration != null)
                {
                    query = query.Where(row => row.EstimatedDuration == criteria.EstimatedDuration);
                }

                if (criteria.Label != null)
                {
                    query = query.Where(row => row.Notes.Contains(criteria.Label));
                }

                if (criteria.IsArchived != null)
                {
                    query = query.Where(row => row.IsArchived == criteria.IsArchived);
                }

                if (criteria.Notes != null)
                {
                    query = query.Where(row => row.Notes == criteria.Notes);
                }

                if (criteria.ModifiedBy != null)
                {
                    query = query.Where(row => row.ModifiedBy == criteria.ModifiedBy);
                }

                if (criteria.ModifiedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate >= criteria.ModifiedDate.DateFrom);
                }

                if (criteria.ModifiedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.ModifiedDate <= criteria.ModifiedDate.DateTo);
                }

                if (criteria.CreatedBy != null)
                {
                    query = query.Where(row => row.CreatedBy == criteria.CreatedBy);
                }

                if (criteria.CreatedDate.DateFrom.Date != DateTime.MinValue.Date)
                {
                    query = query.Where(row => row.CreatedDate >= criteria.CreatedDate.DateFrom);
                }

                if (criteria.CreatedDate.DateTo.Date != DateTime.MaxValue.Date)
                {
                    query = query.Where(row => row.CreatedDate <= criteria.CreatedDate.DateTo);
                }

                if (criteria.TaskLabels != null &&
                    criteria.TaskLabels.Count() != 0)
                {
                    query = query.Join(ctx.ObjectContext.TaskLabels
                                       .Where(tl => criteria.TaskLabels.Contains(tl.Name)), t => t.TaskId, tl => tl.TaskId, (t, tl) => t);
                }

                if (criteria.Text != null)
                {
                    query = query.Where(row => SqlFunctions.StringConvert((double)row.TaskId).Contains(criteria.Text) ||
                                        row.Description.Contains(criteria.Text) ||
                                        row.Project.Name.Contains(criteria.Text));
                }

                if (criteria.SortBy != null)
                {
                    query = query.OrderBy(string.Format(
                                              "{0} {1}",
                                              criteria.SortBy,
                                              criteria.SortOrder == ListSortDirection.Ascending ? "ASC" : "DESC"));
                }

                if (criteria.MaximumRecords != null)
                {
                    query = query.Take(criteria.MaximumRecords.Value);
                }

                var data = query.AsEnumerable().Select(row => TaskInfo.FetchTaskInfo(row,
                                                                                     ctx.ObjectContext.Hours.Where(hour => hour.TaskId == row.TaskId).Sum(hour => (decimal?)hour.Duration),
                                                                                     ctx.ObjectContext.Notes.Count(note => note.SourceType == (int)SourceType.Task && note.SourceId == row.TaskId),
                                                                                     ctx.ObjectContext.Attachments.Count(attachment => attachment.SourceType == (int)SourceType.Task && attachment.SourceId == row.TaskId),
                                                                                     ctx.ObjectContext.Invoices.Count(invoice => invoice.TaskId == row.TaskId)));

                this.AddRange(data);

                this.IsReadOnly             = true;
                this.RaiseListChangedEvents = true;
            }
        }