@@ -60,13 +60,15 @@ public ActionResult Index()
6060 model . IsPublicAccess = true ;
6161 }
6262
63-
6463 model . NewComponentsSetDatasetId = Models . Settings . get ( "lui:datasetNewComponentsSet" ) . ToString ( ) ;
6564 var datasetInfo = DataAccess . GetDatasetInfo ( model . NewComponentsSetDatasetId , GetServerInformation ( ) ) ;
6665 model . NewComponentsSetDatasetVersion = DataAccess . GetDatasetInfo ( model . NewComponentsSetDatasetId , GetServerInformation ( ) ) . Version ;
6766 XmlDocument doc = DataAccess . GetMetadata ( model . NewComponentsSetDatasetId , GetServerInformation ( ) ) ;
6867 model . NewComponentsSetLastUpdate = DateTime . Parse ( doc . GetElementsByTagName ( "metadataLastModificationDateType" ) [ 0 ] . InnerText ) . ToString ( "yyyy-MM-dd" ) ;
6968
69+ model . AvailableYearsNewComp = GetAvailableYears ( model . NewComponentsSetDatasetId , model . IsPublicAccess ) ;
70+ model . AvailableYearsOldComp = GetAvailableYears ( Models . Settings . get ( "lui:datasetOldComponentsSet" ) . ToString ( ) , model . IsPublicAccess ) ;
71+
7072 return View ( "Index" , model ) ;
7173
7274 }
@@ -150,18 +152,7 @@ public ActionResult CalculateLUI(LUIQueryModel model)
150152 break ;
151153 }
152154 DataTable dt_sourceData = DataAccess . GetComponentData ( dsId , GetServerInformation ( ) ) ;
153- if ( model . IsPublicAccess )
154- {
155- //remove not complete years data for non public access
156- var missingData = DataAccess . GetMissingComponentData ( GetServerInformation ( ) ) ;
157- if ( missingData . Count > 0 )
158- {
159- List < string > incompleteYears = missingData . Select ( x => x . Year ) . Distinct ( ) . ToList ( ) ;
160- RemoveNotComplateYears ( dt_sourceData , incompleteYears ) ;
161- }
162-
163- }
164-
155+
165156 var results = CalculateLui . DoCalc ( model , dt_sourceData ) ;
166157
167158 DataModel dataModel = new DataModel ( ) ;
@@ -391,6 +382,10 @@ public ServerInformation GetServerInformation()
391382
392383 return serverInformation ;
393384 }
385+ /// <summary>
386+ /// Get bexis token from logged-in user
387+ /// </summary>
388+ /// <returns></returns>
394389 private string GetUserToken ( )
395390 {
396391 var identityUserService = new IdentityUserService ( ) ;
@@ -417,6 +412,10 @@ private string GetUserToken()
417412 }
418413 }
419414
415+ /// <summary>
416+ /// Remove data for not complete uploaded years
417+ /// </summary>
418+ /// <returns></returns>
420419 private void RemoveNotComplateYears ( DataTable data , List < string > years )
421420 {
422421 foreach ( var year in years )
@@ -425,6 +424,33 @@ private void RemoveNotComplateYears(DataTable data, List<string> years)
425424 data . AcceptChanges ( ) ;
426425 }
427426 }
427+
428+ /// <summary>
429+ /// Get distinct available years from comp data
430+ /// </summary>
431+ /// <returns>List of years</returns>
432+ private List < CheckboxControlHelper > GetAvailableYears ( string datasetId , bool isPublicAccess )
433+ {
434+ DataTable data = DataAccess . GetComponentData ( datasetId , GetServerInformation ( ) ) ;
435+ if ( isPublicAccess )
436+ {
437+ var missingData = DataAccess . GetMissingComponentData ( GetServerInformation ( ) ) ;
438+ if ( missingData . Count > 0 )
439+ {
440+ List < string > incompleteYears = missingData . Select ( x => x . Year ) . Distinct ( ) . ToList ( ) ;
441+ RemoveNotComplateYears ( data , incompleteYears ) ;
442+ }
443+ }
444+
445+ var years = data . AsEnumerable ( ) . Select ( r => r . Field < DateTime > ( "Year" ) . ToString ( "yyyy" ) ) . ToList ( ) ;
446+ List < CheckboxControlHelper > yearList = new List < CheckboxControlHelper > ( ) ;
447+ years = years . Distinct ( ) . ToList ( ) ;
448+ foreach ( string year in years )
449+ {
450+ yearList . Add ( new CheckboxControlHelper { Name = year , Checked = false } ) ;
451+ }
452+ return yearList ;
453+ }
428454 }
429455
430456}
0 commit comments