Beispiel #1
0
 public void NullTests()
 {
     Assert.IsNotNull(_service.GetEntriesModel(_requestUTC, null, null, 0, 0, 999));
     Assert.IsNotNull(_service.GetEntry(_requestUTC, _entryID_A));
     Assert.IsNotNull(_service.GetReportModel(_requestUTC, null, null, 0, 0));
     Assert.IsNotNull(_service.GetStatusModel(_requestUTC));
     Assert.IsNotNull(_service.GetSummaryModel(_requestUTC));
 }
Beispiel #2
0
        public FileResult CSV()
        {
            try
            {
                var context = TracktorController.GetContext(Request.GetOwinContext());
                var entries = _service.GetEntriesModel(context, null, null, 0, 0, 99999);

                var csvFile = new StringBuilder();
                csvFile.AppendLine("Start,End,Month,Project,Task,Hours,InProgress");
                foreach (var entry in entries.Entries)
                {
                    csvFile.AppendLine(
                        String.Format(
                            "{0},{1},{2},{3},{4},{5},{6}",
                            entry.StartDate.ToString("yyyy-MM-dd HH:mm:ss"),
                            entry.EndDate.HasValue ? entry.EndDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
                            entry.StartDate.ToString("yyyy-MMM"),
                            entry.ProjectName,
                            entry.TaskName,
                            (entry.Contrib / 3600).ToString(), // hours
                            entry.InProgress ? "Yes" : "No"));
                }
                return(File(
                           System.Text.Encoding.UTF8.GetBytes(csvFile.ToString()),
                           "text/csv",
                           string.Format("tracktor tasks {0}.csv", DateTime.UtcNow.ToString("yyyy-MM-dd"))));
            }
            catch (Exception ex)
            {
                return(File(
                           System.Text.Encoding.UTF8.GetBytes("Error: " + ex.Message),
                           "text/plain",
                           string.Format("error {0}.txt", DateTime.UtcNow.ToString("yyyy-MM-dd"))));
            }
        }
        protected TracktorWebModel GenerateWebModel(bool updateOnly = false)
        {
            var summaryModel = _service.GetSummaryModel(Context);

            return(new TracktorWebModel
            {
                SummaryModel = summaryModel,
                EntriesModel = _service.GetEntriesModel(Context, null, null, 0, 0, 20),
                StatusModel = _service.GetStatusModel(Context),
                EditModel = updateOnly ? null : new TEditModelDto
                {
                    Entry = new TEntryDto
                    {
                        EndDate = DateTime.UtcNow,
                        StartDate = DateTime.UtcNow,
                        IsDeleted = false,
                        InProgress = false,
                        TaskName = "",
                        ProjectName = "",
                        TTaskID = 0,
                        TEntryID = 0,
                        Contrib = 0,
                    }
                },
                ReportModel = updateOnly ? null : WebReportModel.Create(summaryModel, DateTime.UtcNow)
            });
        }