Ejemplo n.º 1
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"))));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            ViewBag.Title = "tracktor";
            ViewBag.User  = Request.GetOwinContext().Authentication.User.Identity.Name;
            int userID;
            var timezone = TracktorController.GetUserTimezone(Request.GetOwinContext(), out userID);

            ViewBag.Timezone = timezone.Id;

            return(View());
        }