Ejemplo n.º 1
0
        public string SaveCurriculumDeliveryInformation(CurriculumDeliveryModel curriculumDelivery, List <EducatorResourceModel> teacherResources, List <CoveredGradeFundamentalModel> coveredGradeFundamentals, List <Grade12LevelOfCompletionModel> grade12LevelOfCompletion)
        {
            string               results    = string.Empty;
            List <string>        resultList = new List <string>();
            JavaScriptSerializer js         = new JavaScriptSerializer();

            try
            {
                SurveyRepository repo = new SurveyRepository();
                bool             data = repo.SaveCurriculumDeliveryInformation(curriculumDelivery, teacherResources, coveredGradeFundamentals, grade12LevelOfCompletion);

                if (data)
                {
                    resultList.Add("Success");
                }
                else
                {
                    resultList.Add("Error when saving Curriculum Delivery Information");
                }
            }
            catch (Exception ex)
            {
                resultList.Add(string.Format("Error - {0}", ex.Message));
            }

            results = js.Serialize(resultList);
            return(results);
        }
Ejemplo n.º 2
0
 public AddOptionController(ILogger <AddOptionController> logger, UserManager <User> userManager)
 {
     _logger           = logger;
     _userManager      = userManager;
     _surveyRepository = new SurveyRepository();
     _optionRepository = new OptionRepository();
 }
Ejemplo n.º 3
0
        public QuestionQuery(SurveyRepository _surveyRepository, ApplicationDbContextFactory _contextFactory)
        {
            Field <QuestionType>(
                "question",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: context =>
                _surveyRepository.GetQuestion(context.GetArgument <int>("id")));

            Field <ListGraphType <QuestionType> >(
                "questions",
                resolve: context => _surveyRepository.Questions());

            Field <SurveyType>(
                "survey",
                arguments: new QueryArguments(new QueryArgument <NonNullGraphType <IntGraphType> > {
                Name = "id"
            }),
                resolve: context =>
                _surveyRepository.GetSurvey(context.GetArgument <int>("id")));

            Field <ListGraphType <SurveyType> >(
                "surveys",
                resolve: context => _surveyRepository.Surveys());
        }
Ejemplo n.º 4
0
        public string GetCurriculumDeliveryInformationBySchoolID(int schoolID)
        {
            string results          = string.Empty;
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                //CurriculumDeliveryModel curriculumDelivery, List<EducatorResourceModel> teacherResources, List<CoveredGradeFundamentalModel> coveredGradeFundamentals, List<Grade12LevelOfCompletionModel> grade12LevelOfCompletion
                SurveyRepository _repo = new SurveyRepository();

                CurriculumDeliveryModel                     curriculumDelivery       = _repo.GetCurriculumDeliveryBySchoolID(schoolID);
                IEnumerable <EducatorResourceModel>         teacherResources         = _repo.GetEducatorResourcesBySchoolID(schoolID);
                IEnumerable <CoveredGradeFundamentalModel>  coveredGradeFundamentals = _repo.GetCoveredGradeFundamentalsBySchoolID(schoolID);
                IEnumerable <Grade12LevelOfCompletionModel> grade12LevelOfCompletion = _repo.GetGrade12LevelOfCompletionBySchoolID(schoolID);

                var data = new
                {
                    CurriculumDelivery       = curriculumDelivery,
                    TeacherResources         = teacherResources,
                    CoveredGradeFundamentals = coveredGradeFundamentals,
                    Grade12LevelOfCompletion = grade12LevelOfCompletion
                };

                results = js.Serialize(new { Message = "Success", Data = data });
            }
            catch (Exception ex)
            {
                results = js.Serialize(new { Message = string.Format("Error - {0}", ex.Message) });
            }

            return(results);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Parses out the survey HTML for use in an email or printing.
        /// </summary>
        /// <param name="responseHeaderId">The response header id.</param>
        /// <param name="title">The title.</param>
        /// <param name="displayName">The display name.</param>
        /// <returns>
        /// A string containing table based html that represents a survey.
        /// </returns>
        private string GenerateTableBasedSurvey(int responseHeaderId, string title, string displayName)
        {
            var    builder = new StringBuilder();
            string body    = this.Localize("SurveyCompleted_Body.Text");

            if (body != null)
            {
                body = body.Replace(Utility.UserNameMarker, displayName);
                body = body.Replace(Utility.SurveyInformationMarker, title);

                var survey = new SurveyRepository().LoadReadOnlySurvey(responseHeaderId, this.ModuleId);
                var table  = new Table();
                var sb     = new StringBuilder();
                var writer = new HtmlTextWriter(new StringWriter(sb));
                survey.Render(table, new DnnLocalizer(this.LocalResourceFile));
                table.RenderControl(writer);

                body = body.Replace(Utility.SurveyTableMarker, sb.ToString());
                builder.Append(body);
            }

            ////Because the output of the controls are type "input" the disabled, checked and selected properties must be changed
            ////to just disabled, checked and selected to be recognized by certain email clients i.e. Hotmail.
            return
                (builder.ToString().Replace('"', '\'').Replace(Environment.NewLine, string.Empty).Replace("\t", string.Empty).Replace(
                     "='selected'", string.Empty).Replace("='disabled'", string.Empty).Replace("='checked'", string.Empty));
        }
Ejemplo n.º 6
0
        public static Vote Convert(VoteInput input)
        {
            var optionRepo = new OptionRepository();
            var surveyRepo = new SurveyRepository();

            return(new Vote(input.Date, surveyRepo.GetById(input.SurveyId), optionRepo.GetById(input.OptionId)));
        }
Ejemplo n.º 7
0
        public string GetEnablingConditionsInformationBySchoolID(int schoolID)
        {
            string results          = string.Empty;
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                SurveyRepository _repo = new SurveyRepository();

                EnablingConditionModel       enablingConditionsInformation = _repo.GetEnablingConditionsBySchoolID(schoolID);
                SchoolBuildingConditionModel buildingConditions            = _repo.GetSchoolBuildingConditionBySchoolID(schoolID);
                IEnumerable <LTSMModel>      noOfTextbooksList             = _repo.GetLTSMBySchoolID(schoolID);

                var data = new
                {
                    EnablingConditions = enablingConditionsInformation,
                    BuildingConditions = buildingConditions,
                    LTSM = noOfTextbooksList
                };

                results = js.Serialize(new { Message = "Success", Data = data });
            }
            catch (Exception ex)
            {
                results = js.Serialize(new { Message = string.Format("Error - {0}", ex.Message) });
            }

            return(results);
        }
Ejemplo n.º 8
0
 public SurveyBaseVm(AdminLevel a, int typeId, ICalcIndicators c)
 {
     adminLevel = a;
     r = new SurveyRepository();
     model = r.CreateSurvey(typeId);
     calc = c;
 }
Ejemplo n.º 9
0
 public SurveyBaseVm(AdminLevel a, SurveyDetails s, ICalcIndicators c)
 {
     r = new SurveyRepository();
     this.model = r.GetById(s.Id);
     adminLevel = a;
     calc = c;
 }
Ejemplo n.º 10
0
        private async void AddSurveyAsync()
        {
            if (!string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Description) && !string.IsNullOrEmpty(LowUpperBound) && !string.IsNullOrEmpty(MidUpperBound))
            {
                var survey = await SurveyRepository.AddSurvey(new Survey
                {
                    Name          = Name,
                    Description   = Description,
                    CreatedOn     = DateTime.Now,
                    SurveyStatus  = SurveyStatus.Pending,
                    LowUpperBound = double.Parse(LowUpperBound),
                    MidUpperBound = double.Parse(MidUpperBound)
                });

                if (survey != null)
                {
                    Name          = string.Empty;
                    Description   = string.Empty;
                    LowUpperBound = string.Empty;
                    MidUpperBound = string.Empty;
                    await SweetAlertMessage.SuccessMessage();
                }
                else
                {
                    await SweetAlertMessage.ErrorMessage();
                }
            }
            else
            {
                await SweetAlertMessage.ErrorMessage();
            }
        }
Ejemplo n.º 11
0
        public string SubmitSurvey(int schoolID)
        {
            string               results    = string.Empty;
            List <string>        resultList = new List <string>();
            JavaScriptSerializer js         = new JavaScriptSerializer();

            try
            {
                SurveyRepository repo = new SurveyRepository();
                SchoolModel      data = repo.SubmitSurvey(schoolID);

                if (data != null)
                {
                    resultList.Add("Success");
                }
                else
                {
                    resultList.Add("Error when saving Submitting Survey");
                }
            }
            catch (Exception ex)
            {
                resultList.Add(string.Format("Error - {0}", ex.Message));
            }

            results = js.Serialize(resultList);
            return(results);
        }
Ejemplo n.º 12
0
        private void InitializeViewModelExecute()
        {
            this.BusyCount++;
            this.IsNoResponses      = false;
            this.IsResponsesVisible = false;
            Locator.NavigationStatic.NavigateToQuestionsCommand.RaiseCanExecuteChanged();

            _surveyInfoLoader        = new BackgroundWorker();
            this.CurrentSurvey       = new Survey();
            this.SubmittedResponses  = new ObservableCollection <ResponseSet>();
            this.InProgressResponses = new ObservableCollection <ResponseSet>();
            this.CompletedResponses  = new ObservableCollection <ResponseSet>();
            this.surveyRepository    = new SurveyRepository();
            var pageParameters = NavigationProvider.GetNavigationParameters();

            if (pageParameters.ContainsKey(SURVEY_ID))
            {
                this.currentSurveyId = int.Parse(pageParameters[SURVEY_ID]);

                this.CurrentSurvey = surveyRepository.GetSurveyByID(this.currentSurveyId);
            }

            _surveyInfoLoader.DoWork += new DoWorkEventHandler(LoadSurveyInformation);
            this.IsNoResponses        = this.CurrentSurvey.ResponseSet.Count == 0;
            this.IsResponsesVisible   = !this.IsNoResponses;
            _surveyInfoLoader.RunWorkerAsync();
        }
Ejemplo n.º 13
0
        public string SaveInfectionsAndMortalityInformation(List <LearnersCovid19StatisticsPerGradeModel> learnersByGradeCovid19Statistics, List <LearnersCovid19StatisticsPerAgeGroupModel> learnersByAgeGroupCovid19Statistics, List <StaffCovid19StatisticsPerAgeGroupModel> staffCovid19Statistics)
        {
            string               results    = string.Empty;
            List <string>        resultList = new List <string>();
            JavaScriptSerializer js         = new JavaScriptSerializer();

            try
            {
                SurveyRepository repo = new SurveyRepository();
                bool             data = repo.SaveInfectionsAndMortalityInformation(learnersByGradeCovid19Statistics, learnersByAgeGroupCovid19Statistics, staffCovid19Statistics);

                if (data)
                {
                    resultList.Add("Success");
                }
                else
                {
                    resultList.Add("Error when saving Infections And Mortality Information");
                }
            }
            catch (Exception ex)
            {
                resultList.Add(string.Format("Error - {0}", ex.Message));
            }

            results = js.Serialize(resultList);
            return(results);
        }
Ejemplo n.º 14
0
        public string GetInfectionsAndMortalityInformationBySchoolID(int schoolID)
        {
            string results          = string.Empty;
            JavaScriptSerializer js = new JavaScriptSerializer();

            try
            {
                //learnersByGradeCovid19Statistics, learnersByAgeGroupCovid19Statistics, staffCovid19Statistics
                SurveyRepository _repo = new SurveyRepository();

                IEnumerable <LearnersCovid19StatisticsPerGradeModel>    learnersByGradeCovid19Statistics    = _repo.GetLearnersCovid19StatisticsPerGradeBySchoolID(schoolID);
                IEnumerable <LearnersCovid19StatisticsPerAgeGroupModel> learnersByAgeGroupCovid19Statistics = _repo.GetLearnersCovid19StatisticsPerAgeGroupBySchoolID(schoolID);
                IEnumerable <StaffCovid19StatisticsPerAgeGroupModel>    staffCovid19Statistics = _repo.GetStaffCovid19StatisticsPerAgeGroupBySchoolID(schoolID);

                var data = new
                {
                    LearnersByGradeCovid19Statistics    = learnersByGradeCovid19Statistics,
                    LearnersByAgeGroupCovid19Statistics = learnersByAgeGroupCovid19Statistics,
                    StaffCovid19Statistics = staffCovid19Statistics
                };

                results = js.Serialize(new { Message = "Success", Data = data });
            }
            catch (Exception ex)
            {
                results = js.Serialize(new { Message = string.Format("Error - {0}", ex.Message) });
            }

            return(results);
        }
Ejemplo n.º 15
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            double d;
            if (!model.IsValid() || (tbLat.Text.Length > 0 && !double.TryParse(tbLat.Text, out d)) || 
                (tbLng.Text.Length > 0 && !double.TryParse(tbLng.Text, out d)))
            {
                MessageBox.Show(Translations.ValidationError, Translations.ValidationErrorTitle);
                return;
            }
            if (model.AdminLevels == null || model.AdminLevels.Count < 1)
            {
                MessageBox.Show(Translations.LocationRequired, Translations.ValidationErrorTitle);
                return;
            }

            bsSentinelSite.EndEdit();
            SurveyRepository r = new SurveyRepository();
            int userid = ApplicationData.Instance.GetUserId();
            if (model.Id > 0)
                model = r.Update(model, userid);
            else
                model = r.Insert(model, userid);

            OnSave(model);
            this.Close();
        }
Ejemplo n.º 16
0
        public void Delete_Normal_Conditions()
        {
            var repo   = new SurveyRepository();
            var survey = repo.GetAll().LastOrDefault();

            repo.Delete(survey);
        }
Ejemplo n.º 17
0
        public string SaveEnablingConditionsInformation(EnablingConditionModel enablingConditionsInformation, SchoolBuildingConditionModel buildingConditions, List <LTSMModel> noOfTextbooksList)
        {
            string               results    = string.Empty;
            List <string>        resultList = new List <string>();
            JavaScriptSerializer js         = new JavaScriptSerializer();

            try
            {
                SurveyRepository repo = new SurveyRepository();
                bool             data = repo.SaveEnablingConditionsInformation(enablingConditionsInformation, buildingConditions, noOfTextbooksList);

                if (data)
                {
                    resultList.Add("Success");
                }
                else
                {
                    resultList.Add("Error when saving Enabling Conditions Information");
                }
            }
            catch (Exception ex)
            {
                resultList.Add(string.Format("Error - {0}", ex.Message));
            }

            results = js.Serialize(resultList);
            return(results);
        }
Ejemplo n.º 18
0
        public static string GetUrlSendSurvey(Bookings bookings)
        {
            using (var surveyRepository = new SurveyRepository())
            {
                if (bookings != null)
                {
                    var    survey     = surveyRepository.GetSurvey(bookings.BookingId);
                    string surveyCode = string.Empty;
                    if (survey != null)
                    {
                        surveyCode = survey.Code;
                    }

                    string url = bookings.BrowsePassUrl;
                    if (Regex.IsMatch(bookings.BrowsePassUrl, ".+(?<ProductId>/\\d+)$"))
                    {
                        url = bookings.BrowsePassUrl.Replace(
                            Regex.Match(bookings.BrowsePassUrl, ".+(?<ProductId>/\\d+)$").Groups["ProductId"].Value,
                            string.Empty);
                    }
                    return(string.Format(AppConfiguration.DefaultImageUrlSendEmail + "{0}/{1}",
                                         url,
                                         surveyCode));
                }
                return(string.Empty);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the graphs for each question.
        /// </summary>
        private void CreateGraphs()
        {
            var questions = new SurveyRepository().LoadAnswerResponseCounts(this.SurveyId);

            foreach (var questionPair in questions)
            {
                var question = questionPair.First;
                var answers  = questionPair.Second.ToArray();

                const int TitleHeight        = 25;
                const int AnswerHeight       = 16;
                const int HeaderFooterHeight = 70;
                var       linesOfTitleText   = (int)Math.Ceiling(question.Text.Length / (double)35);
                var       chart = new RadChart
                {
                    ChartTitle        = { TextBlock = { Text = this.GetQuestionLabel(question.RelativeOrder, question.Text, false) } },
                    SeriesOrientation = ChartSeriesOrientation.Horizontal,
                    Skin                   = TelerikChartsSkin,
                    Height                 = Unit.Pixel((linesOfTitleText * TitleHeight) + (AnswerHeight * answers.Length) + HeaderFooterHeight),
                    Legend                 = { Visible = false },
                    AutoTextWrap           = true,
                    AutoLayout             = true,
                    HttpHandlerUrl         = this.ResolveUrl("~/ChartImage.axd"),
                    EnableHandlerDetection = false,
                    PlotArea               =
                    {
                        XAxis = { Appearance = { TextAppearance = { Visible = false                            }      } },
                        YAxis = { AxisLabel  = { TextBlock      = { Text    = this.Localize("Axis Label.Text") }, Visible = true} }
                    },
                };

                var chartSeries = new ChartSeries();
                foreach (var answerPair in answers)
                {
                    var answer      = answerPair.First;
                    var answerCount = answerPair.Second;

                    chartSeries.Items.Insert(0, new ChartSeriesItem(answerCount, this.GetAnswerLabel(answer.RelativeOrder, answer.Text, false)));
                }

                chart.Series.Add(chartSeries);
                this.ChartsPanel.Controls.Add(chart);
            }

            var charts = this.ChartsPanel.Controls.OfType <RadChart>();

            if (!charts.Any())
            {
                return;
            }

            var maxHeight = charts.Select(c => (int)c.Height.Value).Max();

            foreach (var chart in charts)
            {
                chart.Height = Unit.Pixel(maxHeight);
            }
        }
Ejemplo n.º 20
0
 private void lnkSurvey_ClickOverride()
 {
     ReportRepository repo = new ReportRepository();
     opts.EntityType = Model.IndicatorEntityType.Survey;
     opts.AvailableIndicators = repo.GetSurveyIndicators(false);
     SurveyRepository typeRepo = new SurveyRepository();
     var types = typeRepo.GetSurveyTypes();
     opts.FormTypes = types.Select(t => t.SurveyTypeName).OrderBy(t => t).ToList();
     OnSwitchStep(new IndStepIndicators(opts));
 }
Ejemplo n.º 21
0
 public UnitOfWork(EGramContext context)
 {
     if (context == null)
     {
         throw new Exception("Context cannot be null");
     }
     _context   = context;
     Surveys    = new SurveyRepository(_context);
     Educations = new EducationRepository(_context);
 }
Ejemplo n.º 22
0
 private void InitializeViewModelExecute()
 {
     this._searchProcessor    = new SearchProcessor();
     this.SearchString        = string.Empty;
     this.SubmittedResponses  = new ObservableCollection <ResponseSet>();
     this.SavedResponses      = new ObservableCollection <ResponseSet>();
     this.Surveys             = new ObservableCollection <Survey>();
     this.surveyRepository    = new SurveyRepository();
     this.responsesRepository = new ResponseSetRepository();
 }
Ejemplo n.º 23
0
 public SurveyType(SurveyRepository _surveyRepository)
 {
     Field(x => x.Id);
     Field(x => x.Name);
     Field <ListGraphType <QuestionType>, IEnumerable <Question> >()
     .Name("Questions")
     .Resolve(ctx => {
         return(_surveyRepository.GetQuestionsBySurvey(ctx.Source.Id));
     });
 }
Ejemplo n.º 24
0
        public UnitOfWork(IDbContextFactory <KhaoSatDbContext> dbContextFactory, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor)
        {
            _dbContext = dbContextFactory.GetContext();

            UserAnswersRepository = new UserAnswersRepository(_dbContext);
            UserRepository        = new UserRepository(_dbContext);
            UserSurveysRepository = new UserSurveysRepository(_dbContext);
            SurveysRepository     = new SurveyRepository(_dbContext);
            AnswerRepository      = new AnswerRepository(_dbContext);
            QuestionsRepository   = new QuestionsRepository(_dbContext);
        }
Ejemplo n.º 25
0
        public void Add_Normal_Condition()
        {
            var repo   = new SurveyRepository();
            var survey = new Survey("Test Survey", DateTime.Today.AddDays(1),
                                    DateTime.Today.AddDays(2), "Description",
                                    options, owner);

            repo.Add(survey);

            Assert.True(repo.GetAll().Last().Author != null);
        }
Ejemplo n.º 26
0
        public void Edit_Normal_Conditions()
        {
            var repo   = new SurveyRepository();
            var survey = new Survey("Test Survey", DateTime.Today.AddDays(1),
                                    DateTime.Today.AddDays(2), "Description",
                                    options, owner);

            repo.Add(survey);
            survey.Color = "#800000";
            repo.Edit(survey);
        }
Ejemplo n.º 27
0
        private async void TakeSurvey(string Id)
        {
            Surveys = new HashSet <Survey>();
            var confirm = await SweetAlertMessage.ConfirmDialogAsync(Title : "Take Survey", Text : "Choose any available survey.");

            if (confirm == "Yes")
            {
                Surveys = await SurveyRepository.GetSurveys();

                Open = true;
            }
        }
Ejemplo n.º 28
0
 private void SurveyTypeView_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         Localizer.TranslateControl(this);
         repo = new SurveyRepository();
         bsSurveyType.DataSource = model;
         lvIndicators.SetObjects(model.Indicators.Values.Where(i => i.IsEditable));
         if (model.Id == 0)
             pnlName.Visible = true;
     }
 }
Ejemplo n.º 29
0
 public RoomController(IConfiguration configuration)
 {
     roomRepository        = new RoomRepository(configuration);
     equipmentRepository   = new EquipmentRepository(configuration);
     buildingRepository    = new BuildingRepository(configuration);
     accountRepository     = new AccountRepository(configuration);
     complaintRepository   = new ComplaintRepository(configuration);
     departmentRepository  = new DepartmentRepository(configuration);
     maintenanceRepository = new MaintenanceRepository(configuration);
     surveyRepository      = new SurveyRepository(configuration);
     historyRepository     = new HistoryRepository(configuration);
 }
Ejemplo n.º 30
0
 internal void Refresh()
 {
     this.BusyCount++;
     this.surveyRepository    = new SurveyRepository();
     this.CurrentSurvey       = surveyRepository.GetSurveyByID(this.currentSurveyId);
     this.SubmittedResponses  = new ObservableCollection <ResponseSet>(this.surveyRepository.GetSubmittedResponseSets(currentSurveyId));
     this.CompletedResponses  = new ObservableCollection <ResponseSet>(this.surveyRepository.GetCompletedResponseSets(currentSurveyId));
     this.InProgressResponses = new ObservableCollection <ResponseSet>(this.surveyRepository.GetInProgressResponseSets(currentSurveyId));
     this.IsNoResponses       = this.CompletedResponses.Count == 0 && this.SubmittedResponses.Count == 0 && InProgressResponses.Count == 0;
     this.IsResponsesVisible  = !this.IsNoResponses;
     this.BusyCount--;
 }
Ejemplo n.º 31
0
 public void GetSurveysCallback(IEnumerable <Survey> surveys)
 {
     if (surveys != null)
     {
         using (var surveyRepository = new SurveyRepository())
         {
             var existingSurveys = surveyRepository.GetAllUserSurveys(Membership.CurrentUser.ID).Select(s => s.SystemID).ToList();
             surveys = surveys.Where(s => !existingSurveys.Contains(s.SystemID));
         }
     }
     _callback.Invoke(surveys);
 }
        public void DeleteQuestion(int questionId)
        {
            var surveyRepository = new SurveyRepository();
            var moduleId         = surveyRepository.GetModuleIdForQuestion(questionId);

            if (!this.CanEditModule(moduleId))
            {
                this.DenyAccess();
            }

            surveyRepository.DeleteQuestion(questionId);
        }
        public void DeleteSurvey(int surveyId)
        {
            var surveyRepository = new SurveyRepository();
            var moduleId         = surveyRepository.GetModuleIdForSurvey(surveyId);

            if (!this.CanEditModule(moduleId))
            {
                this.DenyAccess();
            }

            surveyRepository.DeleteSurvey(surveyId, moduleId);
        }
Ejemplo n.º 34
0
 public ViewSurveyController(IUnitOfWork unitOfWork, MultichoiceQuestionRepository mr, Survey_MultichoiceQuestionRepository smr, Survey_FreeTextQuestionRepository sfr, FreeTextQuestionRepository ftr, ChapterRepository cr, OptionsRepository or, MultichoiceQuestion_OptionsRepository mor, SurveyRepository sr)
 {
     _unitOfWork = unitOfWork;
     _mr         = mr;
     _smr        = smr;
     _sfr        = sfr;
     _ftr        = ftr;
     _cr         = cr;
     _or         = or;
     _mor        = mor;
     _sr         = sr;
 }
Ejemplo n.º 35
0
        public async Task <Survey> GenerateSurvey(SubmissionData data, List <List <Snapshot> > assignmentSnapshots)
        {
            var snapshots = assignmentSnapshots.SelectMany(s => s);
            var survey    = new Survey()
            {
                Snapshots = snapshots.ToList(),
                Student   = data.Student,
            };
            await SurveyRepository.Add(survey);

            return(survey);
        }
Ejemplo n.º 36
0
 private void SentinelSiteList_Load(object sender, EventArgs e)
 {
     if (!DesignMode)
     {
         // Translate the UI
         Localizer.TranslateControl(this);
         // Make sure there is an AdminlevelId
         if (AdminLevelId == 0)
             return;
         // Update the title
         AdminLevel adminLevel = Survey.AdminLevels.FirstOrDefault();
         if (adminLevel != null && adminLevel.Name != null)
             headerLabel.Text = String.Format("{0}: {1}", headerLabel.Text, adminLevel.Name);
         // Get the Survey repo
         SurveyRepo = new SurveyRepository();
         // Get all the SentinelSites for this Admin unit
         SentinelSites = SurveyRepo.GetSitesForAdminLevel(new List<string>() { AdminLevelId.ToString() });
         // Order the sites
         SentinelSites = SentinelSites.OrderBy(s => s.SiteName).ToList();
         // Load the SentinelSites into the ListView
         sentinelSiteListView.SetObjects(SentinelSites);
     }
 }
Ejemplo n.º 37
0
 //Worksheet 4: Mapping Survey
 //no aggregation - list all
 //all Oncho Mapping indicators
 private void Add4(excel.Worksheet xlsWorksheet, excel.Range rng, List<AdminLevel> districts, DateTime start, DateTime end, int month)
 {
     ReportOptions options = new ReportOptions { MonthYearStarts = month, StartDate = start, EndDate = end, IsCountryAggregation = false, IsByLevelAggregation = false, IsAllLocations = true, IsNoAggregation = true };
     SurveyRepository repo = new SurveyRepository();
     SurveyType survey = repo.GetSurveyType((int)StaticSurveyType.OnchoMapping);
     SurveyReportGenerator gen = new SurveyReportGenerator();
     AddReportToSheet(xlsWorksheet, survey.Indicators, options, gen, (int)StaticSurveyType.OnchoMapping, survey.SurveyTypeName, rng);
 }
 public SentinelSitePickerControl()
 {
     r = new SurveyRepository();
     demo = new DemoRepository();
     InitializeComponent();
 }
Ejemplo n.º 39
0
 public SurveyBase CreateCopy(int newTypeId, int roundsId, int surveyTimingId, string roundsName, string timingName)
 {
     SurveyRepository repo = new SurveyRepository();
     SurveyBase copy = new SurveyBase();
     copy.TypeOfSurvey = repo.GetSurveyType(newTypeId);
     copy.AdminLevels = AdminLevels;
     copy.StartDate = StartDate;
     copy.EndDate = EndDate;
     copy.SiteType = Translations.Sentinel;
     copy.SiteTypeId = SiteTypeId.Sentinel;
     copy.Notes = Notes;
     copy.HasSentinelSite = true;
     copy.IndicatorValues.Add(new IndicatorValue { DynamicValue = "0", IndicatorId = roundsId, Indicator = copy.TypeOfSurvey.Indicators[roundsName] });
     copy.IndicatorValues.Add(new IndicatorValue { DynamicValue = Translations.Baseline, IndicatorId = surveyTimingId, Indicator = copy.TypeOfSurvey.Indicators[timingName] });
     return copy;
 }
Ejemplo n.º 40
0
        /// <summary>
        /// Adds data for the SCH sheet
        /// </summary>
        /// <param name="xlsWorksheet"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        private void AddSch(excel.Worksheet xlsWorksheet, DateTime start, DateTime end)
        {
            SurveyRepository repo = new SurveyRepository();
            int rowCount = 0;
            var surveys = repo.GetByTypeForDistrictsInDateRange(new List<int> { (int)StaticSurveyType.SchistoSentinel, (int)StaticSurveyType.SchMapping }, start, end);
            int rowNumber = 8;

            foreach (SurveyBase survey in surveys.OrderBy(s => s.SortOrder))
            {
                if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.SchistoSentinel)
                {
                    if (survey.SentinelSiteId.HasValue)
                    {
                        var site = repo.GetSiteById(survey.SentinelSiteId.Value);
                        if (site.Lat.HasValue)
                            xlsWorksheet.Cells[rowNumber,4] = Math.Round(site.Lat.Value, 2);
                        if (site.Lng.HasValue)
                            xlsWorksheet.Cells[rowNumber, 5] = Math.Round(site.Lng.Value, 2);
                        xlsWorksheet.Cells[rowNumber, 2] = site.SiteName;

                    }
                    else
                    {
                        if (survey.Lat.HasValue)
                            xlsWorksheet.Cells[rowNumber,4] = Math.Round(survey.Lat.Value, 2);
                        if (survey.Lng.HasValue)
                            xlsWorksheet.Cells[rowNumber, 5] = Math.Round(survey.Lng.Value, 2);
                        xlsWorksheet.Cells[rowNumber, 2] = survey.SpotCheckName;
                    }
                }

                foreach (AdminLevel unit in survey.AdminLevels)
                {
                    xlsWorksheet.Cells[rowNumber, 1] = unit.Name;
                    foreach (IndicatorValue val in survey.IndicatorValues)
                    {
                        if (val.Indicator.DisplayName == "SCHMapSurSiteNames")
                            xlsWorksheet.Cells[rowNumber, 2] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurStartDateOfSurvey" || val.Indicator.DisplayName == "SCHMapSurStartDateOfSurvey")
                        {
                            DateTime date;
                            if (DateTime.TryParse(val.DynamicValue, out date))
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = date.ToString("MMMM");
                        }
                        else if (val.Indicator.DisplayName == "SCHMapSurLatitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, 4] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                        else if (val.Indicator.DisplayName == "SCHMapSurLongitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, 5] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);

                        else if (val.Indicator.DisplayName == "SCHMapSurTestType" || val.Indicator.DisplayName == "SCHSurTestType")
                            xlsWorksheet.Cells[rowNumber, 6] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHMapSurAgeGroupSurveyed" || val.Indicator.DisplayName == "SCHSurAgeGroupSurveyed")
                            xlsWorksheet.Cells[rowNumber, 7] = val.DynamicValue;

                        else if (val.Indicator.DisplayName == "SCHSurNumberOfIndividualsExaminedForUrin" || val.Indicator.DisplayName == "SCHMapSurNumberOfIndividualsExaminedForU")
                            xlsWorksheet.Cells[rowNumber, 8] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurNumberOfIndividualsPositiveForHaem" || val.Indicator.DisplayName == "SCHMapSurNumberOfIndividualsPositiveForH")
                            xlsWorksheet.Cells[rowNumber, 9] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurProportionOfHeavyIntensityUrinaryS" || val.Indicator.DisplayName == "SCHMapSurProportionOfHeavyIntensityUrina")
                            xlsWorksheet.Cells[rowNumber, 11] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurProportionOfModerateIntensityUrina" || val.Indicator.DisplayName == "SCHMapSurProportionOfModerateIntensityUr")
                            xlsWorksheet.Cells[rowNumber, 12] = val.DynamicValue;

                        else if (val.Indicator.DisplayName == "SCHSurNumberOfIndividualsExaminedForInte" || val.Indicator.DisplayName == "SCHMapSurNumberOfIndividualsExaminedForI")
                            xlsWorksheet.Cells[rowNumber, 13] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurNumberOfIndividualsPositiveForInte" || val.Indicator.DisplayName == "SCHMapSurNumberOfIndividualsPositiveForI")
                            xlsWorksheet.Cells[rowNumber, 14] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurProportionOfHeavyIntensityIntestin" || val.Indicator.DisplayName == "SCHMapSurProportionOfHeavyIntensityIntes")
                            xlsWorksheet.Cells[rowNumber, 16] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "SCHSurProportionOfModerateIntensityIntes" || val.Indicator.DisplayName == "SCHMapSurProportionOfModerateIntensityIn")
                            xlsWorksheet.Cells[rowNumber, 17] = val.DynamicValue;
                    }
                    rowNumber++;
                    rowCount++;
                }
            }
            xlsWorksheet.Cells[3, 5] = rowCount;
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Adds data for the Oncho sheet
 /// </summary>
 /// <param name="xlsWorksheet"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 private void AddOncho(excel.Worksheet xlsWorksheet, DateTime start, DateTime end)
 {
     SurveyRepository repo = new SurveyRepository();
     int rowCount = 0;
     var surveys = repo.GetByTypeForDistrictsInDateRange(new List<int> { (int)StaticSurveyType.OnchoAssessment, (int)StaticSurveyType.OnchoMapping }, start, end);
     int rowNumber = 8;
     foreach (SurveyBase survey in surveys.OrderBy(s => s.SortOrder))
     {
         foreach (AdminLevel unit in survey.AdminLevels)
         {
             xlsWorksheet.Cells[rowNumber, 1] = unit.Name;
             foreach (IndicatorValue val in survey.IndicatorValues)
             {
                 if (val.Indicator.DisplayName == "OnchoSurSiteName" || val.Indicator.DisplayName == "OnchoMapSiteName")
                     xlsWorksheet.Cells[rowNumber, 2] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurStartDateOfSurvey" || val.Indicator.DisplayName == "OnchoMapSurStartDateOfSurvey")
                 {
                     DateTime date;
                     if (DateTime.TryParse(val.DynamicValue, out date))
                         xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = date.ToString("MMMM");
                 }
                 else if ((val.Indicator.DisplayName == "OnchoSurLatitude" || val.Indicator.DisplayName == "OnchoMapSurLatitude") && !string.IsNullOrEmpty(val.DynamicValue))
                     xlsWorksheet.Cells[rowNumber, 4] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                 else if ((val.Indicator.DisplayName == "OnchoSurLongitude" || val.Indicator.DisplayName == "OnchoMapSurLongitude") && !string.IsNullOrEmpty(val.DynamicValue))
                     xlsWorksheet.Cells[rowNumber, 5] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                 else if (val.Indicator.DisplayName == "OnchoSurSurveyType" || val.Indicator.DisplayName == "OnchoMapSurSurveyType")
                     xlsWorksheet.Cells[rowNumber, 6] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                 else if (val.Indicator.DisplayName == "OnchoSurAgeRange" || val.Indicator.DisplayName == "OnchoMapSurAgeRange")
                     xlsWorksheet.Cells[rowNumber, 7] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurTestType" || val.Indicator.DisplayName == "OnchoMapSurTestType")
                     xlsWorksheet.Cells[rowNumber, 8] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                 else if (val.Indicator.DisplayName == "OnchoSurNumberOfIndividualsExamined" || val.Indicator.DisplayName == "OnchoMapSurNumberOfIndividualsExamined")
                     xlsWorksheet.Cells[rowNumber, 9] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurNumberOfIndividualsPositive" || val.Indicator.DisplayName == "OnchoMapSurNumberOfIndividualsPositive")
                     xlsWorksheet.Cells[rowNumber, 10] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurIfTestTypeIsNpNumDep" || val.Indicator.DisplayName == "OnchoMapSurIfTestTypeIsNpNumDep")
                     xlsWorksheet.Cells[rowNumber, 12] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurIfTestTypeIsNpNumNod" || val.Indicator.DisplayName == "OnchoMapSurIfTestTypeIsNpNumNod")
                     xlsWorksheet.Cells[rowNumber, 13] = val.DynamicValue;
                 else if (val.Indicator.DisplayName == "OnchoSurIfTestTypeIsNpNumWri" || val.Indicator.DisplayName == "OnchoMapSurIfTestTypeIsNpNumWri")
                     xlsWorksheet.Cells[rowNumber, 14] = val.DynamicValue;
             }
             rowNumber++;
             rowCount++;
         }
     }
     xlsWorksheet.Cells[3, 5] = rowCount;
 }
Ejemplo n.º 42
0
        /// <summary>
        /// Adds the LF sheet
        /// </summary>
        /// <param name="xlsWorksheet"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        private void AddLfMm(excel.Worksheet xlsWorksheet, DateTime start, DateTime end)
        {
            ReportOptions options = new ReportOptions { MonthYearStarts = 1, StartDate = start, EndDate = end, IsCountryAggregation = true, IsByLevelAggregation = false, IsAllLocations = false, IsNoAggregation = false };
            IntvReportGenerator gen = new IntvReportGenerator();
            IntvRepository repo = new IntvRepository();
            SurveyRepository surveys = new SurveyRepository();
            // Indicator parser
            IndicatorParser indicatorParser = new IndicatorParser();
            indicatorParser.LoadRelatedLists();

            int rowCount = 0;
            IntvType type = repo.GetIntvType((int)StaticIntvType.LfMorbidityManagement);
            foreach (var indicator in type.Indicators)
                if (!indicator.Value.IsCalculated)
                    options.SelectedIndicators.Add(ReportRepository.CreateReportIndicator(type.Id, indicator));
            ReportResult result = gen.Run(new SavedReport { ReportOptions = options });

            // Top horizontal columns
            foreach (DataRow dr in result.DataTableResults.Rows)
            {
                foreach (DataColumn col in result.DataTableResults.Columns)
                {
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatients", "LFMMDPNumLymphoedemaPatients") + " -"))
                        xlsWorksheet.Cells[5, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatientsTreated", "LFMMDPNumLymphoedemaPatientsTreated") + " -"))
                        xlsWorksheet.Cells[7, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumHydroceleCases", "LFMMDPNumHydroceleCases") + " -"))
                        xlsWorksheet.Cells[8, 10] = dr[col];
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumHydroceleCasesTreated", "LFMMDPNumHydroceleCasesTreated") + " -"))
                        xlsWorksheet.Cells[9, 10] = dr[col];
                }
            }

            // Last half of year (J6)
            options.StartDate = start.AddMonths(6);
            result = gen.Run(new SavedReport { ReportOptions = options });
            foreach (DataRow dr in result.DataTableResults.Rows)
            {
                foreach (DataColumn col in result.DataTableResults.Columns)
                {
                    if (col.ColumnName.Contains(TranslationLookup.GetValue("LFMMDPNumLymphoedemaPatients", "LFMMDPNumLymphoedemaPatients") + " -"))
                        xlsWorksheet.Cells[6, 10] = dr[col];
                }
            }

            // Get surveys for rows
            var lfSurveys = surveys.GetByTypeForDistrictsInDateRange(new List<int> { (int)StaticSurveyType.LfMapping, (int)StaticSurveyType.LfSentinel, (int)StaticSurveyType.LfTas }, start, end);
            int rowNumber = 15;
            foreach (SurveyBase survey in lfSurveys.OrderBy(s => s.SortOrder))
            {
                foreach (var adminLevel in survey.AdminLevels)
                {
                    bool isMfTestType = false;
                    
                    // Static indicators
                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.B] = adminLevel.Name;
                    if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfMapping)
                    {
                        var testTypeVal = survey.IndicatorValues.FirstOrDefault(v => v.Indicator.DisplayName == "LFMapSurTestType");
                        if (testTypeVal != null && testTypeVal.DynamicValue == "Mf")
                            isMfTestType = true; 

                        xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = TranslationLookup.GetValue("Mapping", "Mapping");
                    }
                    else if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfSentinel)
                    {
                        var testTypeVal = survey.IndicatorValues.FirstOrDefault(v => v.Indicator.DisplayName == "LFSurTestType");
                        if (testTypeVal != null && testTypeVal.DynamicValue == "Mf")
                            isMfTestType = true;

                        xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = survey.SiteType;
                        if (survey.SentinelSiteId.HasValue)
                        {
                            var site = surveys.GetSiteById(survey.SentinelSiteId.Value);
                            if (site.Lat.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(site.Lat.Value, 2);
                            if (site.Lng.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(site.Lng.Value, 2);
                            // Name of survey site
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = site.SiteName;
                        }
                        else
                        {
                            if (survey.Lat.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(survey.Lat.Value, 2);
                            if (survey.Lng.HasValue)
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(survey.Lng.Value, 2);
                            // Name of survey site
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = survey.SpotCheckName;

                        }
                    }
                    else if (survey.TypeOfSurvey.Id == (int)StaticSurveyType.LfTas)
                    {
                        // Year of Start date of MDA of earliest Intervention
                        List<IntvBase> interventions = repo.GetAll(new List<int>
                        {
                            (int)StaticIntvType.Alb, (int)StaticIntvType.Alb2, (int)StaticIntvType.DecAlb, (int)StaticIntvType.Ivm, (int)StaticIntvType.IvmAlb,
                            (int)StaticIntvType.IvmPzq, (int)StaticIntvType.IvmPzqAlb, (int)StaticIntvType.Mbd, (int)StaticIntvType.Pzq, (int)StaticIntvType.PzqAlb,
                            (int)StaticIntvType.PzqMbd, (int)StaticIntvType.ZithroTeo
                        }, new List<int> {adminLevel.Id});
                        if (interventions.Count > 0) {
                            // Get all the MDA Start date indicators
                            List<string> mdaStarts = interventions.SelectMany(x => x.IndicatorValues).Where(v => v.Indicator.DisplayName == "PcIntvStartDateOfMda")
                                .Select(x => x.DynamicValue).ToList();
                            if (mdaStarts.Count > 0) {
                                // Get the earliest one
                                DateTime earliestMda = Convert.ToDateTime(mdaStarts.OrderBy(x => Convert.ToDateTime(x)).FirstOrDefault());
                                // Add it to the worksheet
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.H] = earliestMda.Year;
                            }
                        }
                    }
 

                    // Dynamic indicators
                    foreach (IndicatorValue val in survey.IndicatorValues)
                    {
                        // Eval name
                        if (val.Indicator.DisplayName == "EuName")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.A] = indicatorParser.Parse(val.Indicator.DataTypeId, val.IndicatorId, val.DynamicValue);
                        // Name of survey site
                        else if (val.Indicator.DisplayName == "LFMapSurSiteNames")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.C] = val.DynamicValue;
                        // TAS objective
                        else if (val.Indicator.DisplayName == "TASTasObjective")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.D] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        else if (val.Indicator.DisplayName == "LFMapSurStartDateOfSurvey" || val.Indicator.DisplayName == "LFSurStartDateOfSurvey" || val.Indicator.DisplayName == "TASStartDateOfSurvey")
                        {
                            DateTime date;
                            if (DateTime.TryParse(val.DynamicValue, out date))
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.E] = date.ToString("MMMM");
                        }
                        else if (val.Indicator.DisplayName == "LFMapSurLatitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.F] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                        else if (val.Indicator.DisplayName == "LFMapSurLongitude" && !string.IsNullOrEmpty(val.DynamicValue))
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.G] = Math.Round(Convert.ToDouble(val.DynamicValue), 2);
                        else if (val.Indicator.DisplayName == "LFSurDateOfTheFirstRoundOfPc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.H] = val.DynamicValue;
                        else if (val.Indicator.DisplayName == "LFSurNumberOfRoundsOfPcCompletedPriorToS" || val.Indicator.DisplayName == "4190984d-f272-4359-8414-6e7ef06fc4bc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.I] = val.DynamicValue;
                        //else if (val.Indicator.DisplayName == "LFMapSurTestType" || val.Indicator.DisplayName == "LFSurTestType")
                        //    xlsWorksheet.Cells[rowNumber, 9] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        // MF: Number of people examined
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfIndividualsExamined" || val.Indicator.DisplayName == "LFSurNumberOfIndividualsExamined")
                        {
                            if (isMfTestType) // MF: Number of people examined
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.J] = val.DynamicValue;
                            else // Ag/Ab: Number of people examined
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.S] = val.DynamicValue;
                        }
                        // MF: Number of people positive
                        else if (val.Indicator.DisplayName == "LFSurNumberOfIndividualsPositive" || val.Indicator.DisplayName == "LFMapSurNumberOfIndividualsPositive")
                        {
                            if (isMfTestType) // MF: Number of people positive
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.K] = val.DynamicValue;
                            else // Ag/Ab: Number of people positive
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.T] = val.DynamicValue;
                        }
                        // mean dens
                        //else if (val.Indicator.DisplayName == "LFMapSurMeanDensity" || val.Indicator.DisplayName == "LFSurMeanDensity")
                        //    xlsWorksheet.Cells[rowNumber, 13] = val.DynamicValue;
                        // count
                        //else if (val.Indicator.DisplayName == "LFSurCount" || val.Indicator.DisplayName == "LFMapSurCount")
                        //    xlsWorksheet.Cells[rowNumber, 14] = val.DynamicValue;
                        // community load
                        //else if (val.Indicator.DisplayName == "LFMapSurCommunityMfLoad" || val.Indicator.DisplayName == "LFSurCommunityMfLoad")
                        //    xlsWorksheet.Cells[rowNumber, 15] = val.DynamicValue;

                        // MF: % Positive
                        else if (val.Indicator.DisplayName == "LFMapSurPositive" || val.Indicator.DisplayName == "LFSurPositive")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.L] = val.DynamicValue;
                        // Test Type
                        else if (val.Indicator.DisplayName == "LFMapSurTestType" || val.Indicator.DisplayName == "LFSurTestType" || val.Indicator.DisplayName == "TASDiagnosticTest")
                        {
                            if (val.Indicator.DisplayName == "TASDiagnosticTest")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.M] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.M] = val.DynamicValue;
                            }
                        }
                        // Age range
                        else if (val.Indicator.DisplayName == "LFSurAgeRange" || val.Indicator.DisplayName == "LFMapSurAgeRange" || val.Indicator.DisplayName == "TASAgeRange")
                        {
                            if (val.Indicator.DisplayName == "TASAgeRange")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.N] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.N] = val.DynamicValue;
                            }
                        }
                        // Survey site
                        else if (val.Indicator.DisplayName == "LFMapSurMappingSiteLocation" || val.Indicator.DisplayName == "eab663f6-1eb8-4efc-85da-2844ee720020" || val.Indicator.DisplayName == "TASLocationType")
                        {
                            if (val.Indicator.DisplayName == "TASLocationType")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.O] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.O] = val.DynamicValue;
                            }
                        }
                        // Ag/Ab: Survey type
                        else if (val.Indicator.DisplayName == "TASSurveyType")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.P] = val.DynamicValue;
                        // Ag/Ab: # schools or EA targeted
                        else if (val.Indicator.DisplayName == "TASTargetNumberOfSchoolsOrEas")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.Q] = val.DynamicValue;
                        // Ag/Ab: Target sample size
                        else if (val.Indicator.DisplayName == "LFMapSurTargetSampleSize" || val.Indicator.DisplayName == "LFSurTargetSampleSize" || val.Indicator.DisplayName == "TASTargetSampleSize")
                        {
                            if (val.Indicator.DisplayName == "TASTargetSampleSize")
                                xlsWorksheet.Cells[rowNumber, (int)ExcelCol.R] = val.DynamicValue;
                            else
                            {
                                if (!isMfTestType)
                                    xlsWorksheet.Cells[rowNumber, (int)ExcelCol.R] = val.DynamicValue;
                            }
                        }
                        // Ag/Ab: Number of people examined
                        else if (val.Indicator.DisplayName == "d807913f-b3a1-4948-a2b3-54eb0800a3bc")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.S] = val.DynamicValue;
                        // Ag/Ab: Number of people positive
                        else if (val.Indicator.DisplayName == "TASActualSampleSizePositive")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.T] = val.DynamicValue;
                        // Ag/Ab: Critical cut-off
                        else if (val.Indicator.DisplayName == "TASCriticalCutoffValue")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.V] = val.DynamicValue;
                        // Ag/Ab: Decision
                        else if (val.Indicator.DisplayName == "TASCriticalCutoff")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.W] = TranslationLookup.GetValue(val.DynamicValue, val.DynamicValue);
                        // Lymphoedema: Number of people examined
                        else if (val.Indicator.DisplayName == "LFSurExaminedLympho" || val.Indicator.DisplayName == "LFMapSurExaminedLympho")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.X] = val.DynamicValue;
                        // Lymphoedema: Number of people positive
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfCasesOfLymphoedema" || val.Indicator.DisplayName == "LFSurPosLympho")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.Y] = val.DynamicValue;
                        // Hydrocele: Number of people examined
                        else if (val.Indicator.DisplayName == "LFSurExaminedHydro" || val.Indicator.DisplayName == "LFMapSurExaminedHydro1")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AA] = val.DynamicValue;
                        // Hydrocele: Number of people positive
                        else if (val.Indicator.DisplayName == "LFMapSurNumberOfCasesOfHydrocele" || val.Indicator.DisplayName == "LFSurPosHydro")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AB] = val.DynamicValue;
                        // Notes
                        else if (val.Indicator.DisplayName == "Notes")
                            xlsWorksheet.Cells[rowNumber, (int)ExcelCol.AD] = val.DynamicValue;

                    }
                    rowNumber++;
                    rowCount++;
                }
            }

            // run formula
            xlsWorksheet.Cells[3, 5] = rowCount;

        }
Ejemplo n.º 43
0
 void importerWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int userId = ApplicationData.Instance.GetUserId();
         Nada.UI.View.Wizard.SplitDistro.WorkerPayload payload = (Nada.UI.View.Wizard.SplitDistro.WorkerPayload)e.Argument;
         ImportResult result = payload.Importer.UpdateData(payload.FileName, userId, payload.Forms);
         if (result.WasSuccess)
         {
             SurveyRepository repo = new SurveyRepository();
             repo.Save(result.Forms.Cast<SurveyBase>().ToList(), userId);
         }
         e.Result = result;
     }
     catch (Exception ex)
     {
         Logger log = new Logger();
         log.Error("Error updating survey forms during split. SplitSurveys:importerWorker_DoWork. ", ex);
         throw;
     }
 }
Ejemplo n.º 44
0
        public List<ReportIndicator> GetSurveyIndicators(bool addStaticFields)
        {
            List<ReportIndicator> indicators = new List<ReportIndicator>();
            SurveyRepository repo = new SurveyRepository();
            var types = repo.GetSurveyTypes();
            var pc = new ReportIndicator { Name = TranslationLookup.GetValue("PcNtds"), IsCategory = true };
            var cm = new ReportIndicator { Name = TranslationLookup.GetValue("OtherNtds"), IsCategory = true };
            indicators.Add(pc);
            indicators.Add(cm);
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("PC")).OrderBy(t => t.SurveyTypeName))
            {
                var cat = new ReportIndicator { Name = t.SurveyTypeName, IsCategory = true, ID = t.Id };
                var instance = repo.CreateSurvey(t.Id);
                if (addStaticFields && (t.Id == (int)StaticSurveyType.LfSentinel || t.Id == (int)StaticSurveyType.SchistoSentinel || t.Id == (int)StaticSurveyType.SthSentinel))
                {
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSentinelSiteName"), TypeId = t.Id, Key = "IndSentinelSiteName" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSentinelSiteLat"), TypeId = t.Id, Key = "IndSentinelSiteLat" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSentinelSiteLng"), TypeId = t.Id, Key = "IndSentinelSiteLng" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSpotCheckName"), TypeId = t.Id, Key = "IndSpotCheckName" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSpotCheckLat"), TypeId = t.Id, Key = "IndSpotCheckLat" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("IndSpotCheckLng"), TypeId = t.Id, Key = "IndSpotCheckLng" });
                    cat.Children.Add(new ReportIndicator { Name = TranslationLookup.GetValue("SiteType"), TypeId = t.Id, Key = "SiteType" });
                }

                foreach (var i in instance.TypeOfSurvey.Indicators)
                    if (i.Value.DataTypeId != (int)IndicatorDataType.SentinelSite)
                        cat.Children.Add(CreateReportIndicator(t.Id, i, t.SurveyTypeName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                pc.Children.Add(cat);
            }
            foreach (var t in types.Where(i => i.DiseaseType == TranslationLookup.GetValue("CM")).OrderBy(t => t.SurveyTypeName))
            {
                var cat = new ReportIndicator { Name = t.SurveyTypeName, IsCategory = true };
                var instance = repo.CreateSurvey(t.Id);
                foreach (var i in instance.TypeOfSurvey.Indicators)
                    cat.Children.Add(CreateReportIndicator(t.Id, i, t.SurveyTypeName, t.DisplayNameKey));
                cat.Children = cat.Children.OrderBy(c => c.Name).ToList();
                cm.Children.Add(cat);
            }
            return indicators;
        }
Ejemplo n.º 45
0
        private List<KeyValuePair<string, int>> GetFormTypes(DataRow dr)
        {
            var result = new List<KeyValuePair<string, int>>();
            if (!string.IsNullOrEmpty(dr["Type ID"].ToString()))
            {
                var entityType = (IndicatorEntityType)Convert.ToInt32(dr["Type ID"]);

                switch (entityType)
                {
                    case IndicatorEntityType.DiseaseDistribution:
                        DiseaseRepository typeRepo = new DiseaseRepository();
                        result = typeRepo.GetSelectedDiseases().Select(d => new KeyValuePair<string, int>(d.DisplayName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Intervention:
                        IntvRepository intv = new IntvRepository();
                        result = intv.GetAllTypes().Select(d => new KeyValuePair<string, int>(d.IntvTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Survey:
                        SurveyRepository sRepo = new SurveyRepository();
                        result = sRepo.GetSurveyTypes().Select(d => new KeyValuePair<string, int>(d.SurveyTypeName, d.Id)).ToList();
                        break;
                    case IndicatorEntityType.Process:
                        ProcessRepository pRepo = new ProcessRepository();
                        result = pRepo.GetProcessTypes().Select(d => new KeyValuePair<string, int>(d.TypeName, d.Id)).ToList();
                        break;
                }        
            }
            return result;
        }
Ejemplo n.º 46
0
 public void CanFetchLfMfPrevalence()
 {
     SurveyRepository repo = new SurveyRepository();
 }