/* Return back the TimeSeriesResourcesList object for which the ResourceConsumer is Authorized*/ public TimeSeriesResourcesList AuthorizatizedTimeSeriesList(string siteCode, int resourceConsumerId, string accessType) { TimeSeriesResourcesList tr = new TimeSeriesResourcesList(); List <Guid> entireResourceGuidList = new List <Guid>(); List <Guid> authorizedResourceGuidList = new List <Guid>(); List <Guid> finalAuthorizedGuid = new List <Guid>(); Priviledge pv = new Priviledge(); ResourcesList rs = new ResourcesList(); PersonResouces pr = new PersonResouces(); pv.Load(accessType); entireResourceGuidList = rs.load(siteCode); authorizedResourceGuidList = pr.PersonAuthorized(resourceConsumerId, pv.priviledgeId); foreach (Guid g in entireResourceGuidList) { foreach (Guid d in authorizedResourceGuidList) { if (g == d) { finalAuthorizedGuid.Add(g); } } } tr = tr.AuthorizedTimeSeriesList(finalAuthorizedGuid); string test = "test"; return(tr); }
/* return back entire TimeSeriesResourcesList object for which is ResourceConsumer is Authorized*/ public TimeSeriesResourcesList AuthorizedTimeSeriesList(List <Guid> authGuid) { TimeSeriesResourcesList AuthTimeSeries = new TimeSeriesResourcesList(); string connectionString = ConfigurationManager.ConnectionStrings["SecurityDb"].ConnectionString; SqlConnection myConnection = new SqlConnection(connectionString); foreach (Guid g in authGuid) { try { myConnection.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = myConnection; string queryString = "SELECT timeseriesresourceid as timeseriesresourceid, timeseriesmetadataid as timeseriesmetadataid, SeriesID as seriesid,SiteID as siteid,SiteCode as sitecode, SiteName as sitename, VariableID as variableid, VariableCode as variablecode, VariableName as variablename, Speciation as speciation, VariableUnitsID as variableunitsid, VariableUnitsName as variableunitsname, SampleMedium as samplemedium, ValueType as valuetype, TimeSupport as timesupport, TimeUnitsID as timeunitsid, TimeUnitsName as timeunitsname, DataType as datatype, GeneralCategory as generalcategory, MethodID as methodid, MethodDescription as methoddescription, SourceID as sourceid, Organization as organization, SourceDescription as sourcedescription,citation as citation, QualityControlLevelID as qualitycontrollevelid, QualityControlLevelCode as qualitycontrollevelcode, ValueCount as valuecount, DateCreated as datecreated, DatabaseName as databasename, WaterOneFlowWSDL as wateroneflowwsdl FROM TimeSeriesResource where timeseriesresourcesid = '" + g + "';"; cmd.CommandText = queryString; SqlDataReader reader = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(reader); foreach (DataRow row in dt.Rows) { TimeSeriesResource timeSeriesResources = new TimeSeriesResource(); Guid m = new Guid(row["timeseriesmetadataid"].ToString()); timeSeriesResources.dataGuid = g; timeSeriesResources.metadataGuid = m; timeSeriesResources.seriesId = Convert.ToInt16(row["seriesid"].ToString()); timeSeriesResources.siteId = Convert.ToInt16(row["siteid"].ToString()); timeSeriesResources.siteCode = row["sitecode"].ToString(); timeSeriesResources.siteName = row["sitename"].ToString(); timeSeriesResources.variableId = Convert.ToInt16(row["variableid"].ToString()); timeSeriesResources.variableCode = row["variablecode"].ToString(); timeSeriesResources.variableName = row["variablename"].ToString(); timeSeriesResources.speciation = row["speciation"].ToString(); timeSeriesResources.variableUnitsId = Convert.ToInt16(row["variableunitsid"].ToString()); timeSeriesResources.variableUnitsName = row["variableunitsname"].ToString(); timeSeriesResources.sampleMedium = row["samplemedium"].ToString(); timeSeriesResources.valueType = row["valuetype"].ToString(); timeSeriesResources.timeSupport = Convert.ToDouble(row["timesupport"].ToString()); timeSeriesResources.timeUnitsId = Convert.ToInt16(row["timeunitsid"].ToString()); timeSeriesResources.timeUnitsName = row["timeunitsname"].ToString(); timeSeriesResources.dataType = row["datatype"].ToString(); timeSeriesResources.generalCategory = row["generalcategory"].ToString(); timeSeriesResources.methodId = Convert.ToInt16(row["methodid"].ToString()); timeSeriesResources.methodDescription = row["methoddescription"].ToString(); timeSeriesResources.sourceId = Convert.ToInt16(row["sourceid"].ToString()); timeSeriesResources.organization = row["organization"].ToString(); timeSeriesResources.sourceDescription = row["sourcedescription"].ToString(); timeSeriesResources.citation = row["citation"].ToString(); timeSeriesResources.qualityControLlevelId = Convert.ToInt16(row["qualitycontrollevelid"].ToString()); timeSeriesResources.qualityControlLevelCode = row["qualitycontrollevelcode"].ToString(); timeSeriesResources.valueCount = Convert.ToInt32(row["valuecount"].ToString()); timeSeriesResources.dateCreated = Convert.ToDateTime(row["datecreated"].ToString()); timeSeriesResources.databaseName = row["databasename"].ToString(); timeSeriesResources.waterOneflowWSDL = row["wateroneflowwsdl"].ToString(); AuthTimeSeries.timeResourcesLocal.Add(timeSeriesResources); } myConnection.Close(); } catch (Exception e) { Console.WriteLine("this is not successful :" + e.Message.ToString()); } } return(AuthTimeSeries); }