Пример #1
0
        protected void messageRepeater_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DBViewTagAlert ev = e.Item.DataItem as DBViewTagAlert;

            if (ev != null)
            {
                SmartLabel isResolved = (SmartLabel)e.Item.FindControl("isResolved");
                if (ev.AlertStatus != (byte)AlertStatusType.New)
                {
                    isResolved.Text = "√";
                }
                else
                {
                    isResolved.Text = "<input type='checkbox' name='selection' value='" + ev.AlertId + "' />";
                }
                Img icon = e.Item.FindControl("icon") as Img;
                HostTagGroupStatus hostTagGroupStatus = HostTagGroupStatus.SelectByHostId((int)ev.HostId);
                int groupId = hostTagGroupStatus.HostGroupId;
                icon.Src = CommonExtension.IdentityIconByGroupId(groupId);

                Anchor tagName = (Anchor)e.Item.FindControl("tagName");
                tagName.Text = ev.HostName;
                tagName.Href = PathUtil.ResolveUrl(string.Format("/TagUsers/TagUser.aspx?id={0}&type={1}", ev.HostId, groupId));

                SmartLabel facilityName = (SmartLabel)e.Item.FindControl("facilityName");
                facilityName.Text = ev.FacilityName;

                SmartLabel coordinatesName = (SmartLabel)e.Item.FindControl("coordinatesName");
                coordinatesName.Text = ev.CoordinatesName;

                SmartLabel eventType = (SmartLabel)e.Item.FindControl("eventType");
                eventType.Text = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId.Value);

                SmartLabel alertStatus = (SmartLabel)e.Item.FindControl("alertStatus");
                alertStatus.Text = Misc.GetAlertStatus((AlertStatusType)ev.AlertStatus);

                DateTimeLabel lastHappenTime = (DateTimeLabel)e.Item.FindControl("lastHappenTime");
                lastHappenTime.DisplayValue = ev.WriteTime;

                Anchor alertDetail = (Anchor)e.Item.FindControl("alertDetail");
                alertDetail.Text = "详情";
                alertDetail.Href = PathUtil.ResolveUrl("/Monitor/TagAlertProcess.aspx?id=" + ev.AlertId);

                if (ev.AlertStatus == (byte)ResolveFlag.Processed)
                {
                    HtmlTableRow tr = (HtmlTableRow)e.Item.FindControl("tr");
                    tr.Attributes["class"] = "t3";
                    tagName.CssClass       = "t3";
                }
            }
        }
        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());
        }
Пример #3
0
        public object GetResult()
        {
            StringBuilder sb = new StringBuilder();

            TagAlert[] tas = null;
            using (AppDataContext db = new AppDataContext())
            {
                tas = db.TagAlerts.Where(t => t.AlertStatus == (byte)AlertStatusType.New)
                      .Where(t => t.HostId > 0)
                      .OrderByDescending(x => x.WriteTime).ToArray();
            }
            string div                 = "";
            string tagName             = "";
            string tagNameHref         = "";
            string coordinatesName     = "";
            string coordinatesNameHref = "";
            string description         = "";
            string time                = "";
            string tagIcon             = "";
            int    firstCoordinateID   = 0;

            foreach (TagAlert ev in tas)
            {
                if (firstCoordinateID == 0)
                {
                    firstCoordinateID = ev.CoordinatesId;
                }

                if (ev != null)
                {
                    div = "id_" + ev.AlertId;

                    HostTagGroupStatus hostTag = HostTagGroupStatus.SelectByHostId(ev.HostId);
                    tagName = hostTag.HostName;
                    tagIcon = CommonExtension.IdentityIconByGroupId(hostTag.HostGroupId);



                    //need to open video based on the _alertId
                    if (CommonExtension.IsIlltreatTag(ev.HostId))
                    {
                        if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison)
                        {
                            coordinatesName = hostTag.HostName;
                        }
                        else
                        {
                            int coorid = CommonExtension.GetCoordinatesId(hostTag.Description.Substring(0, hostTag.Description.Length - 2));
                            coordinatesName = Coordinates.GetName(coorid);

                            switch (VedioType)
                            {
                            case 1:
                                coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");";
                                break;

                            case 2:
                                coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");";
                                break;

                            case 3:
                                coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");";
                                break;

                            default: break;
                            }
                        }
                    }
                    else
                    {
                        int hosttype = TagStatusView.SelectTagStatus(ev.TagId).HostTag.HostGroupId.Contains(1) ? 1 : 2;
                        tagNameHref = "../TagUsers/TagUser.aspx?id=" + ev.HostId + "&type=" + hosttype;

                        coordinatesName = Coordinates.GetName(ev.CoordinatesId);
                        switch (VedioType)
                        {
                        case 1:
                            coordinatesNameHref = "javascript:AlertView(" + ev.CoordinatesId + ");";
                            break;

                        case 2:
                            coordinatesNameHref = "javascript:AlertView2(" + ev.CoordinatesId + ");";
                            //coordinatesName.Attributes["onclick"] = "AlertView2(" + ev.CoordinatesId + ")";
                            break;

                        case 3:
                            coordinatesNameHref = "javascript:AlertView3(" + ev.CoordinatesId + ");";
                            break;

                        default: break;
                        }
                    }

                    description = CommonExtension.GetEventDescription((SupportEvent)ev.AlertType, ev.HostId);

                    time = ev.WriteTime.ToString();


                    /**********************/
                    sb.AppendFormat(@"
        <tr>
            <td>
                <img src='{0}' Width='13' Height='13'/>
                <a href='{1}' style='font-weight: bold;' target='_blank'>{2}</a> 
            </td>
            <td>
                {3}
            </td>
            <td>
                <span>{4}</span>
            </td>
            <td>
                <span>{5}</span>
            </td>
            <td>  
                <div id='{6}'>                          
		    <a onclick='javascript:setResolved(this);' href='#' style='width:35px; height:19px;' title='点此按钮后该事件将标记为已确认,页面将跳转到事件处理页面'>[确认]</a>
                </div>
            </td>
        </tr>
               ", tagIcon, tagNameHref, tagName, coordinatesNameHref.Length > 0 ? "<a href='" + coordinatesNameHref + "' style='font-weight: bold;'>" + coordinatesName + "</a>" : coordinatesName, description, time, div);
                    /**********************/
                }
            }//foreach


            if (sb.Length > 0)
            {
                sb.Insert(0, "<table cellpadding=0 cellspacing=0 border=0>");
                sb.Append("</table>");
            }
            else
            {
                sb.Append("<br/>暂时没有发现报警。。。&nbsp;&nbsp;【<span onclick=\" window.opener=null;window.open('','_self');window.close();\" style=\"cursor:pointer;\">关闭窗口</span>】<br/><br/>");
            }

            switch (VedioType)
            {
            case 1:
                return(new { html = sb.ToString(), callBackFunction = "loadfirst(" + firstCoordinateID + ")" });

            case 2:
                return(new { html = sb.ToString(), callBackFunction = "loadfirst2(" + firstCoordinateID + ")" });

            default:
                return(new { html = sb.ToString(), callBackFunction = "" });
            }
        }