Beispiel #1
0
        public ActionResult Index(DateTime?dateFrom, DateTime?dateTo, int userId = 0, int exerciseId = 0,
                                  string difficulty = null, string subject = null, int pageIndex = 1, int pageSize = 10)
        {
            try
            {
                #region -- Get WorkItems --
                //Requirement: It is now Tuesday 2015-03-24 11:30:00 UTC
                var to   = dateTo == null ? new DateTime(2015, 03, 24, 11, 30, 00) : dateTo.Value.AddDays(1).AddMilliseconds(-1);
                var from = dateFrom == null ? new DateTime(2015, 03, 24, 11, 30, 00).Date : dateFrom.Value.AddDays(1).AddMilliseconds(-1);

                var result = _workRepository.WorkItemsReport(from, to, userId, exerciseId, difficulty, subject, pageIndex, pageSize);
                ViewBag.WorkItems    = result.Result;
                ViewBag.TotalRecords = result.TotalRecords;

                #endregion

                #region -- Get Subjects --

                var subjects = GetSubjects();
                ViewBag.Subjects = subjects.Result.Select(
                    x => new SelectListItem
                {
                    Text  = x,
                    Value = x
                }).ToList();

                #endregion

                ViewBag.Message = string.Empty;
            }
            catch (Exception exception)
            {
                ViewBag.Message      = exception.Message;
                ViewBag.WorkItems    = null;
                ViewBag.TotalRecords = 0;
                _appLogRepository.Log(exception);
            }
            var model = new WorkItem
            {
                Difficulty = difficulty,
                UserId     = userId,
                ExerciseId = exerciseId,
                Subject    = subject
            };

            return(View(model));
        }
Beispiel #2
0
        public DataTable LoadAndDataFile(string filePath = ApplicationConstants.WorkFilePath, char delimiter = ApplicationConstants.FileDelimiter)
        {
            var workItemsDataTables = new DataTable();

            try
            {
                workItemsDataTables = CsvEngine.CsvToDataTable(filePath, delimiter);
            }
            catch (Exception exception)
            {
                _appLogRepository.Log(exception);
            }
            return(workItemsDataTables);
        }
        //
        // GET: /Logs/
        public ActionResult Index(bool isRefresh = false)
        {
            var applogs = new QueryResult <AppLog>(null, 0);

            try
            {
                applogs         = _appLogRepository.FindAll();
                ViewBag.Message = isRefresh ? ApplicationConstants.LogRefresh : string.Empty;
            }
            catch (Exception exception)
            {
                _appLogRepository.Log(exception);
                ViewBag.Message = exception.Message;
            }
            ViewBag.TotalRecords    = applogs.TotalRecords;
            ViewBag.ApplicationLogs = applogs.Result;
            return(View());
        }
Beispiel #4
0
        private void CheckBulkUploadStatus()
        {
            #region -- Check if Bulk Upload has been done else do it--
            try
            {
                bool isBulkUploadCompleted;
                var  bulkUploadSettings = _appSettingsRepository.GetByName(ApplicationConstants.HasFileBeenUploaded);
                if (string.IsNullOrEmpty(bulkUploadSettings.Value) ||
                    bool.TryParse(bulkUploadSettings.Value, out isBulkUploadCompleted))
                {
                    return;
                }
                var bulkData = new WorkService().LoadAndDataFile();
                new WorkRepository().BulkInsert(bulkData);
            }
            catch (Exception exception)
            {
                _appLogRepository.Log(exception);
            }

            #endregion
        }