protected void ParseNotes(IHaveDynamicIndicatorValues form, Indicator notesIndicator) { var notesInd = form.IndicatorValues.FirstOrDefault(i => i.Indicator.DisplayName == "Notes"); if (notesInd != null) { if (IsRedistricted) notesInd.CalcByRedistrict = true; else if (notesInd.CalcByRedistrict && notesInd.DynamicValue != Notes) notesInd.CalcByRedistrict = false; notesInd.DynamicValue = Notes; } else form.IndicatorValues.Add(new IndicatorValue { DynamicValue = Notes, Indicator = notesIndicator, IndicatorId = notesIndicator.Id, CalcByRedistrict = IsRedistricted }); }
protected virtual void AddTypeSpecificListValues(Microsoft.Office.Interop.Excel.Worksheet xlsWorksheet, Microsoft.Office.Interop.Excel.Worksheet xlsValidation, int adminLevelId, int r, CultureInfo currentCulture, int colCount, IHaveDynamicIndicatorValues form) { }
protected virtual void UpdateTypeSpecificValues(IHaveDynamicIndicatorValues form, DataRow row, ref string objerrors) { }
protected virtual string GetAdminLevelName(AdminLevel adminLevel, IHaveDynamicIndicatorValues form) { return adminLevel.Name; }
protected override string GetAdminLevelName(AdminLevel adminLevel, IHaveDynamicIndicatorValues form) { SurveyBase survey = (SurveyBase)form; return string.Join(", ", survey.AdminLevels.Select(a => a.Name).ToArray()); }
protected override void UpdateTypeSpecificValues(IHaveDynamicIndicatorValues form, DataRow row, ref string objerrors) { if (Indicators.Values.FirstOrDefault(i => i.DataTypeId == (int)IndicatorDataType.SentinelSite) == null) return; SurveyBase survey = (SurveyBase)form; survey.HasSentinelSite = true; if (string.IsNullOrEmpty(row[TranslationLookup.GetValue("IndSentinelSiteName")].ToString())) { survey.SiteType = TranslationLookup.GetValue("SpotCheck"); survey.SpotCheckName = row[TranslationLookup.GetValue("IndSpotCheckName")].ToString(); double d; if (!string.IsNullOrEmpty(row[TranslationLookup.GetValue("IndSpotCheckLat")].ToString())) if (double.TryParse(row[TranslationLookup.GetValue("IndSpotCheckLat")].ToString(), out d)) survey.Lat = d; else objerrors += TranslationLookup.GetValue("ValidLatitude") + Environment.NewLine; if (!string.IsNullOrEmpty(row[TranslationLookup.GetValue("IndSpotCheckLng")].ToString())) if (double.TryParse(row[TranslationLookup.GetValue("IndSpotCheckLng")].ToString(), out d)) survey.Lng = d; else objerrors += TranslationLookup.GetValue("ValidLongitude") + Environment.NewLine; } else { survey.SiteType = TranslationLookup.GetValue("Sentinel"); var sites = repo.GetSitesForAdminLevel(survey.AdminLevels.Select(a => a.Id.ToString())); var site = sites.FirstOrDefault(s => s.SiteName == row[TranslationLookup.GetValue("IndSentinelSiteName")].ToString()); if (site != null) survey.SentinelSiteId = site.Id; else objerrors += TranslationLookup.GetValue("ValidSentinelSite") + Environment.NewLine; } }
protected override void AddTypeSpecificListValues(Microsoft.Office.Interop.Excel.Worksheet xlsWorksheet, Microsoft.Office.Interop.Excel.Worksheet xlsValidation, int adminLevelId, int r, CultureInfo currentCulture, int colCount, IHaveDynamicIndicatorValues form) { if (Indicators.Values.FirstOrDefault(i => i.DataTypeId == (int)IndicatorDataType.SentinelSite) == null) return; SurveyBase sur = (SurveyBase)form; if (sur.SentinelSiteId.HasValue && sur.SentinelSiteId.Value > 0) { var site = repo.GetSiteById(sur.SentinelSiteId.Value); xlsWorksheet.Cells[r, siteColumnIndex] = site.SiteName; } else { xlsWorksheet.Cells[r, spotColumnIndex] = sur.SpotCheckName; xlsWorksheet.Cells[r, lngColumnIndex] = sur.Lng; xlsWorksheet.Cells[r, latColumnIndex] = sur.Lat; } }
private void AddIndicatorValues(OleDbConnection connection, IHaveDynamicIndicatorValues distro, int id, int userId) { OleDbCommand command = new OleDbCommand(@"DELETE FROM DiseaseDistributionIndicatorValues WHERE DiseaseDistributionId=@DiseaseDistributionId", connection); command.Parameters.Add(new OleDbParameter("@DiseaseDistributionId", id)); command.ExecuteNonQuery(); foreach (IndicatorValue val in distro.IndicatorValues) { command = new OleDbCommand(@"Insert Into DiseaseDistributionIndicatorValues (IndicatorId, DiseaseDistributionId, DynamicValue, MemoValue, UpdatedById, UpdatedAt, CalcByRedistrict) VALUES (@IndicatorId, @DiseaseDistributionId, @DynamicValue, @MemoValue, @UpdatedById, @UpdatedAt, @CalcByRedistrict)", connection); command.Parameters.Add(new OleDbParameter("@IndicatorId", val.IndicatorId)); command.Parameters.Add(new OleDbParameter("@DiseaseDistributionId", id)); AddValueParam(command, val); command.Parameters.Add(new OleDbParameter("@UpdatedById", userId)); command.Parameters.Add(OleDbUtil.CreateDateTimeOleDbParameter("@UpdatedAt", DateTime.Now)); command.Parameters.Add(new OleDbParameter("@CalcByRedistrict", val.CalcByRedistrict)); command.ExecuteNonQuery(); } }