예제 #1
0
        public IHttpActionResult GetLineSegmentForLine(int lineID)
        {
            if (GetRoles == string.Empty || User.IsInRole(GetRoles))
            {
                using (AdoDataConnection connection = new AdoDataConnection(Connection))
                {
                    LineDetails result = new LineDetails();

                    List <LineSegment> record = new TableOperations <LineSegment>(connection).QueryRecordsWhere("ID in (select ChildID from AssetRelationship where AssetRelationshipTypeID = (SELECT ID FROM AssetRelationshipType WHERE Name = 'Line-LineSegment') AND ParentID = {0})", lineID).ToList();
                    record = record.Concat(new TableOperations <LineSegment>(connection).QueryRecordsWhere("ID in (select ParentID from AssetRelationship where AssetRelationshipTypeID = (SELECT ID FROM AssetRelationshipType WHERE Name = 'Line-LineSegment') AND ChildID = {0})", lineID)).ToList();

                    result.Length        = record.Select(item => item.Length).Sum();
                    result.X0            = record.Select(item => item.X0).Sum();
                    result.R0            = record.Select(item => item.R0).Sum();
                    result.X1            = record.Select(item => item.X1).Sum();
                    result.R1            = record.Select(item => item.R1).Sum();
                    result.ThermalRating = record.Select(item => item.ThermalRating).Count() > 0 ? record.Select(item => item.ThermalRating).Min() : 0;

                    return(Ok(result));
                }
            }
            else
            {
                return(Unauthorized());
            }
        }
예제 #2
0
 public IHttpActionResult GetLineSegmentsForLine(int lineID)
 {
     if (GetRoles == string.Empty || User.IsInRole(GetRoles))
     {
         using (AdoDataConnection connection = new AdoDataConnection(Connection))
         {
             List <LineSegment> record = new TableOperations <LineSegment>(connection).QueryRecordsWhere("ID in (select ChildID from AssetRelationship where AssetRelationshipTypeID = (SELECT ID FROM AssetRelationshipType WHERE Name = 'Line-LineSegment') AND ParentID = {0})", lineID).ToList();
             record = record.Concat(new TableOperations <LineSegment>(connection).QueryRecordsWhere("ID in (select ParentID from AssetRelationship where AssetRelationshipTypeID = (SELECT ID FROM AssetRelationshipType WHERE Name = 'Line-LineSegment') AND ChildID = {0})", lineID)).ToList();
             return(Ok(record));
         }
     }
     else
     {
         return(Unauthorized());
     }
 }