Esempio n. 1
0
        public ActionResult RawDataExport(DataExportViewModel dataExportViewModel)
        {
            string response = Request["g-recaptcha-response"];
            bool   status   = GetReCaptchaStatus(response);

            if (!status)
            {
                dataExportViewModel.RecaptchaMessage = "Google reCaptcha validation failed";
                return(View(dataExportViewModel));
            }
            if (ModelState.IsValid)
            {
                List <int> eventParams, eventCodes;
                GetEventCodesAndEventParameters(dataExportViewModel, out eventParams, out eventCodes);
                int recordCount = controllerEventLogRepository.GetRecordCountByParameterAndEvent(dataExportViewModel.SignalId,
                                                                                                 dataExportViewModel.DateTimePickerViewModel.GetStartDateTime(), dataExportViewModel.DateTimePickerViewModel.GetEndDateTimePlusOneMinute(), eventParams, eventCodes);
                if (recordCount > dataExportViewModel.RecordCountLimit)
                {
                    return(Content("The data set you have selected is too large. Your current request will generate " + recordCount.ToString() +
                                   " records. Please reduces the number of records you have selected."));
                }
                else
                {
                    List <Controller_Event_Log> events = controllerEventLogRepository.GetRecordsByParameterAndEvent(dataExportViewModel.SignalId,
                                                                                                                    dataExportViewModel.DateTimePickerViewModel.GetStartDateTime(), dataExportViewModel.DateTimePickerViewModel.GetEndDateTimePlusOneMinute(), eventParams, eventCodes);
                    byte[] file = Exporter.GetCsvFileForControllerEventLogs(events);
                    return(File(file, "csv", "ControllerEventLogs.csv"));
                }
            }
            return(Content("This request cannot be processed. You may be missing parameters"));
        }
Esempio n. 2
0
        //private ApplicationDbContext db = new ApplicationDbContext();

        // GET: DataExportViewModels
        public ActionResult RawDataExport()
        {
            DataExportViewModel viewModel = new DataExportViewModel();

            viewModel.DateTimePickerViewModel.SetDates();
            return(View(viewModel));
        }
Esempio n. 3
0
 public ActionResult GetRecordCount(DataExportViewModel dataExportViewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             List <int> eventParams, eventCodes;
             GetEventCodesAndEventParameters(dataExportViewModel, out eventParams, out eventCodes);
             int recordCount = controllerEventLogRepository.GetRecordCountByParameterAndEvent(dataExportViewModel.SignalId,
                                                                                              dataExportViewModel.DateTimePickerViewModel.GetStartDateTime(), dataExportViewModel.DateTimePickerViewModel.GetEndDateTimePlusOneMinute(), eventParams, eventCodes);
             if (recordCount > dataExportViewModel.RecordCountLimit)
             {
                 return(Content("The data set you have selected is too large. Your current request will generate " + recordCount.ToString() +
                                " records. Please reduces the number of records you have selected."));
             }
             else
             {
                 return(Content("Your current request will generate " + recordCount.ToString() + " records."));
             }
         }
         catch (Exception e)
         {
             return(Content(e.Message));
         }
     }
     return(Content("This request cannot be processed. You may be missing parameters"));
 }
        public DataExportPage()
        {
            InitializeComponent();
            _viewModel            = new DataExportViewModel();
            _viewModel.Completed += OnCompleted;

            DataContext = _viewModel;
        }
Esempio n. 5
0
        private string ValidateData(DataExportViewModel viewModel)
        {
            if (!viewModel.ShouldIncludeIncome && !viewModel.ShouldIncludeExpenses)
            {
                return("Reikia pasirinkti kažką eksportuoti!");
            }
            if (viewModel.StartingDate == null || viewModel.EndingDate == null)
            {
                return("Pasirinkite laiko intervalą duomenų eksportui");
            }

            return(string.Empty);
        }
Esempio n. 6
0
 private void GetEventCodesAndEventParameters(DataExportViewModel dataExportViewModel, out List <int> eventParams, out List <int> eventCodes)
 {
     eventParams = new List <int>();
     eventCodes  = new List <int>();
     if (!String.IsNullOrEmpty(dataExportViewModel.EventParams))
     {
         eventParams = CommaDashSeparated(dataExportViewModel.EventParams);
         if (eventParams.Count == 0)
         {
             throw new Exception("Unable to process Event Parameters");
         }
     }
     if (!String.IsNullOrEmpty(dataExportViewModel.EventCodes))
     {
         eventCodes = CommaDashSeparated(dataExportViewModel.EventCodes);
         if (eventCodes.Count == 0)
         {
             throw new Exception("Unable to process Event Codes");
         }
     }
 }
Esempio n. 7
0
        public IActionResult ExportData(DataExportViewModel viewModel)
        {
            string validation = ValidateData(viewModel);

            if (!string.IsNullOrWhiteSpace(validation))
            {
                TempData["Error"] = validation;
                return(View("DataExportPage", viewModel));
            }

            IList <Income>  incomeList = null;
            IList <Expense> expenses   = null;

            if (viewModel.ShouldIncludeIncome)
            {
                incomeList = FetchUserIncomeList(viewModel.StartingDate.Value, viewModel.EndingDate.Value);
            }
            if (viewModel.ShouldIncludeExpenses)
            {
                expenses = SelectUsersExpenses(viewModel.StartingDate.Value, viewModel.EndingDate.Value);
            }

            return(GenerateDocument(incomeList, expenses));
        }
Esempio n. 8
0
        /*
         * Compute Overview as the Total No Of Times for each task
         */
        public List <DataExportViewModel> ExportData(string internshipId, string userId)
        {
            List <DataExportViewModel> exportList = new List <DataExportViewModel>();

            try
            {
                var filter = Builders <ExperienceDescription> .Filter.Eq(x => x.InternshipId, internshipId);

                var filter2 = Builders <ExperienceDescription> .Filter.Eq(x => x.UserId, userId);

                filter = filter & filter2 & Builders <ExperienceDescription> .Filter.Gt(x => x.NoOfTimes, 0);

                var listData = (from expDesc in _context.ExperiencesDescriptions.Find(filter).ToEnumerable()
                                join exp in _context.Experiences.Find(_ => true).ToEnumerable() on expDesc.TaskId equals exp.Id
                                join iship in _context.Internships.Find(_ => true).ToEnumerable() on expDesc.InternshipId equals iship.Id
                                join us in _context.Users.Find(_ => true).ToEnumerable() on expDesc.UserId equals us.Id
                                select new
                {
                    exp.Id,
                    exp.Title,
                    expDesc.Date,
                    expDesc.IsChecked,
                    expDesc.NoOfTimes,
                    expDesc.TaskId,
                    expDesc.UserId,
                    iship.InternshipName,
                    us.Email,
                    us.FirstName,
                    us.LastName
                }).ToList();

                Dictionary <string, int> dictionary = new Dictionary <string, int>();

                // This first iteration is for computing the sum of each task
                listData.ForEach(x =>
                {
                    int prevSumNum = 0;

                    // This is a previously seen taskID
                    if (dictionary.ContainsKey(x.TaskId))
                    {
                        // Get previous sum
                        prevSumNum = dictionary[x.TaskId];

                        // Update the sum of taskID by adding with the current value
                        dictionary[x.TaskId] = prevSumNum + x.NoOfTimes;
                        Debug.WriteLine("Existing task[" + x.TaskId + "]: Current sum is " + dictionary[x.TaskId]);
                    }

                    // This is a new taskID
                    else
                    {
                        // Add a new task to the dictionary with the first sum value
                        dictionary.Add(x.TaskId, prevSumNum + x.NoOfTimes);
                        Debug.WriteLine("New task[" + x.TaskId + "]: Current sum is " + dictionary[x.TaskId]);
                    }
                });

                // This second iteration is for assign the final sum to each distinct task object
                HashSet <String> taskIDList = new HashSet <String>();
                listData.ForEach(x =>
                {
                    // Check if a taskID is not seen before
                    if (!taskIDList.Contains(x.TaskId))
                    {
                        DataExportViewModel obj = new DataExportViewModel();

                        obj.Title          = x.Title;
                        obj.InternshipName = x.InternshipName;
                        obj.TotalNoOfTimes = dictionary[x.TaskId];
                        obj.Email          = x.Email;
                        obj.FirstName      = x.FirstName;
                        obj.LastName       = x.LastName;

                        exportList.Add(obj);

                        // Update the list of taskID that has been added
                        taskIDList.Add(x.TaskId);
                    }
                });
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(exportList);
        }