varres=conn.ExecuteScalar<long>($@"select count(1) from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.result='{((int)SendTestType.Qalified).ToString()}' or s.result is null) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}");
varsql=$@"select count(1) from {dbName}.{TabelNameConstant.SnTraceTable} t left join {midDbName}.{TabelNameConstant.TraceInspection} s on t.ID=s.trace_id
where t.Status=1 and t.ProjectID={projectid} and (s.inspection_type={(int)InspectionType.ManualCollection} || s.trace_id is NULL) and
(s.status=1 or s.status is null) and (s.projectid={projectid} or s.projectid is null) {conditon}";
varres=conn.ExecuteScalar<long>(sql);
returnres;
}
else
{
varres=conn.ExecuteScalar<long>($@"select count(1) from {TabelNameConstant.SnTraceTable} t
where t.Status=1 and t.ProjectID={projectid}{conditon}");