0% found this document useful (0 votes)
27 views10 pages

Public Async Task-List-Su

The document contains a C# asynchronous method that fetches surveillance data based on a given collection ID from a database context. It retrieves surveillance plans, associated jobs, unique attributes, and additional details, organizing them into structured data objects. The method also handles grouping and filtering of attributes and prepares the data for further processing or output.

Uploaded by

Keshava Sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

Public Async Task-List-Su

The document contains a C# asynchronous method that fetches surveillance data based on a given collection ID from a database context. It retrieves surveillance plans, associated jobs, unique attributes, and additional details, organizing them into structured data objects. The method also handles grouping and filtering of attributes and prepares the data for further processing or output.

Uploaded by

Keshava Sai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

public async Task<List<SurveillanceData>>

FetchSurveillance(string collectionId) { /*var


surveillencedataquery = (from sp in
_surveillanceDBContext.SurveillancePlans
where [Link] == collectionId select
new SurveillanceData {
CollectionId = collectionId,
SurveillancePlanId = [Link],
*//*TestProgramJob = (from sj in
_surveillanceDBContext.SurveillanceJobs
where [Link] == [Link]
select new TestJob {
JobId = [Link], Jobstatus
= [Link], JobName =
[Link] ?? "", }).ToList(),
UniqueColumns = _surveillanceDBContext.FusAttributes
.Where(fa => [Link] == [Link])
.GroupBy(fa => [Link])
.Select(g => [Link]())
.Select(fa => new UniqueColumn
{ AttributeName =
[Link] ?? [Link],
DataParamName = [Link]() ?? [Link],
DisplayName = [Link] ?? [Link],
ColumnSeq = [Link]() ?? [Link]
}) .ToList()*//*
}).ToList();*/ var surveillanceDataQuery = await
_surveillanceDBContext.SurveillancePlans .Where(sp =>
[Link] == collectionId) .Select(sp => new SurveillanceData {
CollectionId = collectionId, SurveillancePlanId =
[Link], TestProgramJob =
_surveillanceDBContext.SurveillanceJobs .Where(sj =>
[Link] == [Link]) .Select(sj =>
new TestJob { JobId = [Link], Jobstatus =
[Link], JobName = [Link] ?? [Link] })
.ToList(), UniqueColumns =
_surveillanceDBContext.FusAttributes .Where(fa =>
[Link] == [Link]) .GroupBy(fa
=> [Link]) .Select(g =>
[Link]()) .Select(fa => new UniqueColumn {
AttributeName = [Link] ?? [Link],
DataParamName = [Link]() ?? [Link],
DisplayName = [Link] ?? [Link],
ColumnSeq = [Link]() ??
[Link] }) .ToList() }).ToListAsync();
//surveillance Data foreach (var datadto in
surveillanceDataQuery) { var testProgramJob = (from
sp in _surveillanceDBContext.SurveillancePlans
join sj in _surveillanceDBContext.SurveillanceJobs
on [Link] equals [Link]
where [Link] == collectionId select new
TestJob { JobId =
[Link], Jobstatus = [Link],
JobName = [Link] ?? "", }).ToList();
[Link] = testProgramJob; var
uniqueColumns = _surveillanceDBContext.FusAttributes
.Join( _surveillanceDBContext.SurveillanceP
lans, fa => [Link],
sp => [Link], (fa, sp) =>
new { fa, sp }) .Where(joined =>
[Link] == collectionId && [Link] !=
null) .GroupBy(joined => new
{ [Link], [Link] })
.Select(group => new UniqueColumn {
AttributeName = [Link]().[Link]??"",
DataParamName = [Link]().[Link]()??"",
DisplayName = [Link]().[Link]??"",
ColumnSeq = [Link]().[Link]()??""
}).ToList(); //adding unique attributes to
surveillencedatadto class [Link] =
uniqueColumns; var surveillencequery = (from sp in
_surveillanceDBContext.SurveillancePlans join sm
in _surveillanceDBContext.SurveillanceMaster on
[Link] equals [Link]
into sms from smresult in [Link]()
join sg in _surveillanceDBContext.SurveillanceGroup
on [Link] equals [Link]
into sgs from sgresult in [Link]()
join fa in _surveillanceDBContext.FusAssetInfo on
[Link] equals [Link] into fas
from faresult in [Link]() join co in
_surveillanceDBContext.Configurator on
[Link] equals [Link] into
cos from coresult in [Link]()
where [Link] == collectionId orderby
[Link] select new SurveillanceDto
{ SurveillanceID = [Link]?? "",
GroupId = [Link]?? "", AssetID =
[Link]?? "", ModelName =
[Link]?? "", Volume =
[Link]?? "", Ccn = [Link] ?? "",
SchemeType = [Link]?? "", //
[Link] File = [Link]?? "",
IssueDate = (DateTime)[Link],
ProductionStatus = [Link] ?? "",
ConfigId = [Link] ?? "",
TestProgramType =
[Link] ??"" }); var
result = [Link]().ToList(); List<string>
surveillenceids = [Link](x =>
[Link]).Distinct().ToList(); //assigning attribute
and testprogram property to dto class foreach (var dto in
result) { // Fetching attributes with sequence for
the current dto.Asset_ID var Attributeswithsequence = (
from fa in _surveillanceDBContext.FusAttributes join
sp in _surveillanceDBContext.SurveillancePlans on
[Link] equals [Link]
where [Link] == collectionId && [Link] != null &&
[Link] != null && [Link] == [Link] group
new { fa } by new { [Link], [Link], [Link] }
into grouped select
[Link]() ).ToList(); // Fetching empty
sequence or data group records for the current dto.Asset_ID
var emptySeqNoOrDataGroupRecords = ( from fa in
_surveillanceDBContext.FusAttributes join sp in
_surveillanceDBContext.SurveillancePlans on [Link]
equals [Link] where [Link] ==
collectionId && [Link] != null && [Link] ==
[Link] && ([Link] == null || [Link]
== null || [Link]([Link])) select
new Rowdata { DataGroup =
[Link] ?? "", AttributeName =
[Link] ?? "", AttributeValue =
[Link] ?? "", DisplayName =
[Link] ?? "", AttributeId = [Link],
DataParamName = [Link]() ?? "",
DataGroupSeq = [Link], AttributeType =
[Link] ??
"" } ).ToList(); // Creating the
dictionary to hold the attribute data for the current
SurveillanceDto Dictionary<string, List<Rowdata>>
Attributedictionary = new Dictionary<string, List<Rowdata>>();
for (int i = 0; i < [Link]; i++) {
string key = $"row{i}"; List<Rowdata> rows = new
List<Rowdata>(); foreach (var item in
Attributeswithsequence[i]) { Rowdata
rowdata = new Rowdata
{ AttributeId = [Link],
AttributeName = [Link] ?? "",
DataParamName = [Link]() ?? "",
AttributeValue = [Link] ?? "",
DisplayName = [Link] ?? "",
DataGroup = [Link] ?? "",
DataGroupSeq = [Link], AttributeType =
[Link] ?? "" };
[Link](rowdata); }
[Link](key, rows); } // Adding
records with empty sequence or data group to the dictionary
string row0 = "row0"; if
([Link](row0))
{ Attributedictionary[row0].AddRange(emptySeqNoOr
DataGroupRecords); } else {
Attributedictionary[row0] = new
List<Rowdata>(emptySeqNoOrDataGroupRecords); }
// Assign the resultdictionary to the Attribute property of the
current SurveillanceDto [Link] =
Attributedictionary; //Test Program var
testprogramwithsequence = (from tp in
_surveillanceDBContext.SurveillanceTestProgram
where [Link] == [Link] && [Link] !=
null group new { tp } by new
{ [Link] } into grouped select
new SurveillanceTestProgramDto {
TestProgramId = [Link](",", [Link](a =>
[Link])),
TestProgramList = [Link](",", [Link](a =>
[Link])) } Item details
Logo for Gemini Apps
Gemini Apps
☐ Prompted public async Task<List<SurveillanceData>>
FetchSurveillance(string collectionId) { /*var
surveillencedataquery = (from sp in
_surveillanceDBContext.SurveillancePlans
where [Link] == collectionId select
new SurveillanceData {
CollectionId = collectionId,
SurveillancePlanId = [Link],
*//*TestProgramJob = (from sj in
_surveillanceDBContext.SurveillanceJobs
where [Link] == [Link]
select new TestJob {
JobId = [Link], Jobstatus
= [Link], JobName =
[Link] ?? "", }).ToList(),
UniqueColumns = _surveillanceDBContext.FusAttributes
.Where(fa => [Link] == [Link])
.GroupBy(fa => [Link])
.Select(g => [Link]())
.Select(fa => new UniqueColumn
{ AttributeName =
[Link] ?? [Link],
DataParamName = [Link]() ?? [Link],
DisplayName = [Link] ?? [Link],
ColumnSeq = [Link]() ?? [Link]
}) .ToList()*//*
}).ToList();*/ var surveillanceDataQuery = await
_surveillanceDBContext.SurveillancePlans .Where(sp =>
[Link] == collectionId) .Select(sp => new SurveillanceData {
CollectionId = collectionId, SurveillancePlanId =
[Link], TestProgramJob =
_surveillanceDBContext.SurveillanceJobs .Where(sj =>
[Link] == [Link]) .Select(sj =>
new TestJob { JobId = [Link], Jobstatus =
[Link], JobName = [Link] ?? [Link] })
.ToList(), UniqueColumns =
_surveillanceDBContext.FusAttributes .Where(fa =>
[Link] == [Link]) .GroupBy(fa
=> [Link]) .Select(g =>
[Link]()) .Select(fa => new UniqueColumn {
AttributeName = [Link] ?? [Link],
DataParamName = [Link]() ?? [Link],
DisplayName = [Link] ?? [Link],
ColumnSeq = [Link]() ??
[Link] }) .ToList() }).ToListAsync();
//surveillance Data foreach (var datadto in
surveillanceDataQuery) { var testProgramJob = (from
sp in _surveillanceDBContext.SurveillancePlans
join sj in _surveillanceDBContext.SurveillanceJobs
on [Link] equals [Link]
where [Link] == collectionId select new
TestJob { JobId =
[Link], Jobstatus = [Link],
JobName = [Link] ?? "", }).ToList();
[Link] = testProgramJob; var
uniqueColumns = _surveillanceDBContext.FusAttributes
.Join( _surveillanceDBContext.SurveillanceP
lans, fa => [Link],
sp => [Link], (fa, sp) =>
new { fa, sp }) .Where(joined =>
[Link] == collectionId && [Link] !=
null) .GroupBy(joined => new
{ [Link], [Link] })
.Select(group => new UniqueColumn {
AttributeName = [Link]().[Link]??"",
DataParamName = [Link]().[Link]()??"",
DisplayName = [Link]().[Link]??"",
ColumnSeq = [Link]().[Link]()??""
}).ToList(); //adding unique attributes to
surveillencedatadto class [Link] =
uniqueColumns; var surveillencequery = (from sp in
_surveillanceDBContext.SurveillancePlans join sm
in _surveillanceDBContext.SurveillanceMaster on
[Link] equals [Link]
into sms from smresult in [Link]()
join sg in _surveillanceDBContext.SurveillanceGroup
on [Link] equals [Link]
into sgs from sgresult in [Link]()
join fa in _surveillanceDBContext.FusAssetInfo on
[Link] equals [Link] into fas
from faresult in [Link]() join co in
_surveillanceDBContext.Configurator on
[Link] equals [Link] into
cos from coresult in [Link]()
where [Link] == collectionId orderby
[Link] select new SurveillanceDto
{ SurveillanceID = [Link]?? "",
GroupId = [Link]?? "", AssetID =
[Link]?? "", ModelName =
[Link]?? "", Volume =
[Link]?? "", Ccn = [Link] ?? "",
SchemeType = [Link]?? "", //
[Link] File = [Link]?? "",
IssueDate = (DateTime)[Link],
ProductionStatus = [Link] ?? "",
ConfigId = [Link] ?? "",
TestProgramType =
[Link] ??"" }); var
result = [Link]().ToList(); List<string>
surveillenceids = [Link](x =>
[Link]).Distinct().ToList(); //assigning attribute
and testprogram property to dto class foreach (var dto in
result) { // Fetching attributes with sequence for
the current dto.Asset_ID var Attributeswithsequence = (
from fa in _surveillanceDBContext.FusAttributes join
sp in _surveillanceDBContext.SurveillancePlans on
[Link] equals [Link]
where [Link] == collectionId && [Link] != null &&
[Link] != null && [Link] == [Link] group
new { fa } by new { [Link], [Link], [Link] }
into grouped select
[Link]() ).ToList(); // Fetching empty
sequence or data group records for the current dto.Asset_ID
var emptySeqNoOrDataGroupRecords = ( from fa in
_surveillanceDBContext.FusAttributes join sp in
_surveillanceDBContext.SurveillancePlans on [Link]
equals [Link] where [Link] ==
collectionId && [Link] != null && [Link] ==
[Link] && ([Link] == null || [Link]
== null || [Link]([Link])) select
new Rowdata { DataGroup =
[Link] ?? "", AttributeName =
[Link] ?? "", AttributeValue =
[Link] ?? "", DisplayName =
[Link] ?? "", AttributeId = [Link],
DataParamName = [Link]() ?? "",
DataGroupSeq = [Link], AttributeType =
[Link] ??
"" } ).ToList(); // Creating the
dictionary to hold the attribute data for the current
SurveillanceDto Dictionary<string, List<Rowdata>>
Attributedictionary = new Dictionary<string, List<Rowdata>>();
for (int i = 0; i < [Link]; i++) {
string key = $"row{i}"; List<Rowdata> rows = new
List<Rowdata>(); foreach (var item in
Attributeswithsequence[i]) { Rowdata
rowdata = new Rowdata
{ AttributeId = [Link],
AttributeName = [Link] ?? "",
DataParamName = [Link]() ?? "",
AttributeValue = [Link] ?? "",
DisplayName = [Link] ?? "",
DataGroup = [Link] ?? "",
DataGroupSeq = [Link], AttributeType =
[Link] ?? "" };
[Link](rowdata); }
[Link](key, rows); } // Adding
records with empty sequence or data group to the dictionary
string row0 = "row0"; if
([Link](row0))
{ Attributedictionary[row0].AddRange(emptySeqNoOr
DataGroupRecords); } else {
Attributedictionary[row0] = new
List<Rowdata>(emptySeqNoOrDataGroupRecords); }
// Assign the resultdictionary to the Attribute property of the
current SurveillanceDto [Link] =
Attributedictionary; //Test Program var
testprogramwithsequence = (from tp in
_surveillanceDBContext.SurveillanceTestProgram
where [Link] == [Link] && [Link] !=
null group new { tp } by new
{ [Link] } into grouped select
new SurveillanceTestProgramDto {
TestProgramId = [Link](",", [Link](a =>
[Link])),
TestProgramList = [Link](",", [Link](a =>
[Link])) }
).ToList(); var modelleveltestprogram = (from tp in
_surveillanceDBContext.SurveillanceTestProgram
where [Link] == [Link] &&
[Link](null) group new
{ tp } by new { [Link] } into grouped
select new SurveillanceTestProgramDto
{ TestProgramId = [Link](",",
[Link](a => [Link])),
TestProgramList = [Link](",", [Link](a =>
[Link])) }).ToList();
var modelleveltestprogramindexzero =
[Link](); var
combinedTestPrograms = new
List<SurveillanceTestProgramDto>(); // comibining the
first element of testprogramwithsequence with
modelleveltestprogram if
(modelleveltestprogramindexzero != null &&
[Link] > 0) { var
combinedFirstElement = new SurveillanceTestProgramDto
{ TestProgramId =
$"{testprogramwithsequence[0].TestProgramId},
{[Link]}",
TestProgramList =
$"{testprogramwithsequence[0].TestProgramList},
{[Link]}"
};
[Link](combinedFirstElement); }
// Adding the remaing elements of testprogramwithsequence into
combinedTestPrograms for (int i = 1; i <
[Link]; i++)
{ [Link](testprogramwithseque
nce[i]); } // Creating Dictionay
Dictionary<string, SurveillanceTestProgramDto>
testProgramsDictionary = new Dictionary<string,
SurveillanceTestProgramDto>(); // adding in elements
as value in each row key for (int i = 0; i <
[Link]; i++)
{ [Link]($"row{i}",
combinedTestPrograms[i]); } [Link]
= testProgramsDictionary; } String
testprgjsonOutput =
[Link](result,
[Link]); [Link] = result;
String surveillencedataoutput =
[Link](surveillanceDataQue
ry, [Link]); } return
surveillanceDataQuery; }

You might also like