コード例 #1
0
        public static string GetHTML(int pageIndex, string userids, string begintime, string endtime)
        {
            AppDataContext   db     = new AppDataContext();
            string           sql    = "select * from history_TagPositionLog";
            List <PatrolLog> patlog = Patrol.FigerOut();
            int recordcount         = Convert.ToInt32(patlog.Count);
            int pageCount           = 0;

            NetRadio.LocatingMonitor.PageData pd = NetRadio.LocatingMonitor.__Pager.GetPageData(pageIndex, recordcount);
            DataTable dt = Summer.QueryExtension.GetPageDataTableForMSSQL("LocatingMonitor", sql, pageIndex, pd.PageSize, out pageCount);


            var tt = (from _d in patlog
                      join _d1 in db.HostTags
                      on _d.HostId equals _d1.HostId
                      join _d2 in db.Coordinates
                      on _d.StartCoordinateId equals _d2.Id
                      select new
            {
                _d1.HostName,
                _d2.CoordinatesName,
                _d.PatrolStartTime,
                _d.PatrolEndTime,
                _d.PatrolReturnTime,
                _d.EndCoordinateId,
                _d.TimeInteval,
                _d.PointsCount
            }

                      ).AsEnumerable();

            StringBuilder sb = new StringBuilder();

            sb.Append(@"
            <table cellpadding=""0"" cellspacing=""0"" class=""grid alternate fixed"">
                <thead class=""category"">
                     <th width=""100"" style=""text-align: center"">
                       警察名称
                     </th>
                     <th  width=""200"" style=""text-align: center;"">
                        起始位置
                     </th>
                        <th  width=""150""  style=""text-align: center;"">
                        起始时间
                     </th>
                     
                    <th  width=""100""  style=""text-align: center;"">
                        终点位置
                     </th>
                    <th  width=""150""  style=""text-align: center;"">
                      返回到起点时间
                     </th>
                 <th  width=""100""  style=""text-align: center;"">
                       巡逻时间
                     </th>  
                   
                  
                </thead>
            ");
            var q =
                from _d in tt
                select new
            {
                name        = _d.HostName,
                coorname    = _d.CoordinatesName,
                sttime      = _d.PatrolStartTime,
                endId       = _d.EndCoordinateId,
                endtime     = _d.PatrolEndTime,
                returntime  = _d.PatrolReturnTime,
                timeInteval = _d.TimeInteval,
                pointCount  = _d.PointsCount
            };

            foreach (var item in q)
            {
                sb.AppendFormat(@"
                <tr>
                    <td width=""100""  style=""text-align: center"">
                         {0} 
                    </td>
                    <td   style=""text-align: center;"">  
                           {1}
                    </td>
                    <td   style=""text-align: center;"">  
                           {2}
                    </td>
                     <td   style=""text-align: center;"">  
                           {3}
                    </td>
                    <td   style=""text-align: center;"">  
                           {4}
                    </td>
                    <td   style=""text-align: center;"">  
                           {5}
                    </td>
               
                    
                    
                </tr>
            ", item.name, item.coorname, item.sttime, Coordinates.GetName(item.endId), item.returntime, item.timeInteval);
            }

            if (sb.Length == 0)
            {
                sb.AppendFormat(@"
                <tr>
                    <td colspan=""4"">                
                       无数据记录
                    </td>
                </tr>");
            }
            sb.Append(@"</table>");
            sb.Append("<br />" + pd.HtmlCode);
            return(sb.ToString());
        }