private int GetActiveTagTotalCount(int groupId) { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = new int[1]; _hostGroupArray[0] = groupId; int totalCount = 0; if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, 0, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); } } return(totalCount); }
protected void list_ItemCreated(object sender, RepeaterItemEventArgs e) { Facility f = (Facility)e.Item.DataItem; SmartLabel facilityName = e.Item.FindControl("facilityName") as SmartLabel; SmartLabel headCount = e.Item.FindControl("headCount") as SmartLabel; facilityName.Text = f.FacilityName; IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; //GTang 20101122 修改为统计hostGroupid=1,2 //int[] _hostGroupArray = new int[1] { 1 }; int[] _hostGroupArray = new int[2] { 1, 2 }; int totalCount = 0; IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null && LocatingServiceUtil.IsAvailable()) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, f.MapId, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); headCount.Text = totalCount.ToString(); _totalCount += totalCount; } }
private string CreateOutputContent() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>"); sb.AppendLine("<tagCoordinates>"); if (!LocatingServiceUtil.IsAvailable()) { sb.AppendLine("</tagCoordinates>"); return(sb.ToString()); } IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); TagStatusView tagStatusView = new TagStatusView(); if (_tagId > 0) { tagStatusView = serviceApi.SelectTagStatus(_tagId); if (tagStatusView != null && _mapId > 0 && tagStatusView.TagId > 0) { _mapId = tagStatusView.MapId; } if (tagStatusView.WorkingStatus != TagWorkingStatus.Locating) { _tagId = 0; _mapId = Fetch.QueryUrlAsIntegerOrDefault("mapId", -1); } } int totalCount = 0; IList <TagStatusView> tagList = new List <TagStatusView>(); if (_hostGroupArray == null || _hostGroupArray.Length == 0) { _hostGroupArray = new int[] { 1, 2 }; } if (_keyword.Length > 0 && !_keyword.Contains(',')) { _mapId = 0; tagList = serviceApi.SelectTagStatusListByKeywords( _keyword, _hostGroupArray, _mapId, true, _eventTypes.Contains((int)SupportEvent.Absent), _eventTypes.Contains((int)SupportEvent.BatteryInsufficient), _eventTypes.Contains((int)SupportEvent.AreaEvent), _eventTypes.Contains((int)SupportEvent.ButtonPressed), _eventTypes.Contains((int)SupportEvent.WristletBroken), "Position", SortDirection.Ascending, _pageSize, _pageSize * (_currentPage - 1), out totalCount ).ToList(); tagList = tagList.Where(x => x.X > 0 && !x.HostTag.HostGroupId.Contains((int)TagUserType.Position)).OrderBy(x => x.X).ToList(); //totalCount = tagList.Count; } else { tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, _mapId, true, _eventTypes.Contains((int)SupportEvent.Absent), _eventTypes.Contains((int)SupportEvent.BatteryInsufficient), _eventTypes.Contains((int)SupportEvent.AreaEvent), _eventTypes.Contains((int)SupportEvent.ButtonPressed), _eventTypes.Contains((int)SupportEvent.WristletBroken), "Position", SortDirection.Ascending, _pageSize, _pageSize * (_currentPage - 1), out totalCount ).ToList(); tagList = tagList.Where(x => x.X > 0).OrderBy(x => x.X).ToList(); //totalCount = tagList.Count; } int tracingItemIndex = -1; if (tagStatusView != null && _tagId > 0) { for (int i = 0; i < tagList.Count(); i++) { if (tagList[i].Mac == tagStatusView.Mac) { tracingItemIndex = i; } } } //IList<TagStatusView> tagStatusList = tagList.ToList(); if (tracingItemIndex != 0 && _tagId > 0) { if (tracingItemIndex > 0) { tagList.RemoveAt(tracingItemIndex); } tagList.Insert(0, tagStatusView); } sb.AppendLine("<pagination>"); sb.AppendFormat("<recordCount>{0}</recordCount>\r\n", totalCount); sb.AppendFormat("<pageSize>{0}</pageSize>\r\n", _pageSize); sb.AppendFormat("<currentPage>{0}</currentPage>\r\n", _currentPage); sb.AppendLine("</pagination>"); var coordinatesFormat = "<coordinates id=\"{0}\" mapId=\"{1}\" mapName=\"{2}\" coordinatesName=\"{3}\" x=\"{4}\" y=\"{5}\">"; var tagFormat = "<tag id=\"{0}\" tagName=\"{1}\" warningTypes=\"{2}\" warningLevel=\"{3}\" moveSpeed=\"{4}\" icon=\"{5}\" updateTime=\"{6}\" groupIds=\"{7}\" />"; foreach (var item in tagList) { if (_coordinatesId != item.CoordinatesId) { if (_coordinatesId >= 0) { sb.AppendLine("</coordinates>"); } sb.AppendFormat(coordinatesFormat, item.CoordinatesId, item.MapId, Facility.GetNameByMapId(item.MapId), item.CoordinatesName, item.X, item.Y); _coordinatesId = item.CoordinatesId; } List <string> warningTypes = new List <string>(); if (item.AreaEventStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.AreaEvent).ToString()); } if (item.AbsenceStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.Absent).ToString()); } if (item.BatteryInsufficientStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.BatteryInsufficient).ToString()); } if (item.BatteryResetStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.BatteryReset).ToString()); } if (item.ButtonPressedStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.ButtonPressed).ToString()); } if (item.WristletBrokenStatus == EventStatus.Occurring) { warningTypes.Add(((int)SupportEvent.WristletBroken).ToString()); } string hostGroupIds = ""; if (item.HostTag.HostGroupId.Length > 0) { foreach (int gId in item.HostTag.HostGroupId) { if (gId > 0) { if (hostGroupIds == "") { hostGroupIds += gId.ToString(); } else { hostGroupIds += "," + gId.ToString(); } } } } string hostName = item.HostTag.HostName; if (hostName == "") { hostName = item.TagName; } sb.AppendFormat(tagFormat, item.TagId, hostName, string.Join(",", warningTypes.ToArray()), warningTypes.ToArray().Length > 0 ? "3" : "1", "2", CommonExtension.IdentityIconByGroupId(item.HostTag.HostGroupId), item.PositionUpdateTime.ToString("yyyy/M/d H:mm:ss").Replace('-', '/'), hostGroupIds /*item.HostTag.HostGroupId.Contains(1) ? 1 : 2*/); } if (_coordinatesId >= 0) { sb.AppendLine("</coordinates>"); } sb.AppendLine("</tagCoordinates>"); return(sb.ToString()); }
private void LoadRepeater(string p_keyword, string p_extandId, int p_jailRoomSelectedIndex, string p_jailRoomSelectedValue, string tagBindingSelectedValue, string tagOnlineSelectedValue) { // var query = HostTagGroupStatus.All().Where(u => u.HostGroupId == (byte)_userType); using (AppDataContext db = new AppDataContext()) { var query = db.HostPositionStatusViews.ToList().Where(u => u.HostGroupId == (byte)_userType); if (!string.IsNullOrEmpty(p_keyword.Trim())) { query = query.Where(u => u.HostName.ToUpper().Contains(p_keyword.Trim().ToUpper())); } if (!string.IsNullOrEmpty(p_extandId.Trim())) { query = query.Where(u => u.HostExternalId.ToUpper().Contains(p_extandId.Trim().ToUpper())); } if (tagBindingSelectedValue == "1") { query = query.Where(u => u.TagId != 0); } if (tagBindingSelectedValue == "2") { query = query.Where(u => u.TagId == 0); } if (tagOnlineSelectedValue == "1") { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = null; int totalCount = 0; if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, 0, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 9999, 0, out totalCount); } } query = query.Where(u => tagList.Where(t => t.X > 0).Select(t => t.TagId).ToList().Contains(u.TagId)); } if (tagOnlineSelectedValue == "2") { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = null; int totalCount = 0; if (LocatingServiceUtil.IsAvailable()) { IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, 0, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 9999, 0, out totalCount); } } query = query.Where(u => !tagList.Where(t => t.X > 0).Select(t => t.TagId).ToList().Contains(u.TagId)); } if (_userType == TagUserType.Culprit && p_jailRoomSelectedIndex > 0) { int[] range = CulpritRoomReference.GetCulpritIdByRoomId(int.Parse(p_jailRoomSelectedValue)); query = query.Where(u => range.Contains(u.HostId)); } p.RecordCount = query.Count(); //if (_sortDir == SortDirection.Ascending) //{ // query = query.OrderBy(u => u.HostName); //} //else //{ // query = query.OrderByDescending(u => u.HostName); //} list.DataSource = query.Skip(p.RecordOffset).Take(p.PageSize).ToList(); list.DataBind(); } }
private string CreateOutputContent() { StringBuilder sb = new StringBuilder(); sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>"); sb.AppendLine("<areaList>"); if (_mapId > 0) { var list = this.SelectItemList(); var format = " <area id=\"{0}\" name=\"{1}\" coordinatesArray=\"{2}\" quota=\"{3}\" currentCount=\"{4}\" mapId=\"{5}\" />"; foreach (var a in list) { try { if (a.LinkedMapId > 0) { IList <TagStatusView> tagList = new List <TagStatusView>(); string _keyword = ""; int[] _hostGroupArray = new int[2] { 1, 2 }; //2010-11-bydyp int totalCount = 0; IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>(); if (serviceApi != null) { TagStatusView tagStatusView = new TagStatusView(); tagList = serviceApi.SelectTagStatusList( _keyword, _hostGroupArray, a.LinkedMapId, true, false, //SupportEvent.Absent), false, //SupportEvent.BatteryInsufficient), false, //SupportEvent.AreaEvent), false, //SupportEvent.ButtonPressed), false, //SupportEvent.WristletBroken), "", SortDirection.Ascending, 0,//only get total count 0, out totalCount); sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, 0, totalCount, a.LinkedMapId); sb.AppendLine(); } } else { int quota = 0; try { quota = CulpritRoomReference.All.Count(x => x.JailRoomId == a.Id); } catch { } int currentCount = 0; var coordinates = MapAreaCoverage.All.Where(x => x.AreaId == a.Id).Select(x => x.CoordinatesId).ToArray(); foreach (var item in FullTagStatusView) { if (coordinates.Contains(item.CoordinatesId) && item.AbsenceStatus != EventStatus.Occurring && item.X > 0) { currentCount++; } } sb.AppendFormat(format, a.Id, a.AreaName, a.CoordinatesArray, quota, currentCount, -1); sb.AppendLine(); } } catch { } } } sb.AppendLine("</areaList>"); return(sb.ToString()); }