Пример #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";
                }
            }
        }
Пример #2
0
        void list_ItemCreated(object sender, RepeaterItemEventArgs e)
        {
            DBViewTagAlert log = e.Item.DataItem as DBViewTagAlert;

            if (log != null)
            {
                SmartLabel description = e.Item.FindControl("description") as SmartLabel;
                description.Text = CommonExtension.GetEventDescription((SupportEvent)log.AlertType, log.HostId.Value);

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

                DateTimeLabel writeTime = e.Item.FindControl("writeTime") as DateTimeLabel;
                writeTime.DisplayValue = log.WriteTime;

                SmartLabel coordinatesName = e.Item.FindControl("coordinatesName") as SmartLabel;
                coordinatesName.Text = log.CoordinatesName;
            }
        }
        protected void LoadTagAlert()
        {
            using (AppDataContext db = new AppDataContext())
            {
                _tagAlert = db.TagAlerts.SingleOrDefault(t => t.AlertId == _id);

                if (_tagAlert == null)
                {
                    ShowMessagePage("报警事件不存在。");
                }
                else
                {
                    HostTag thisHostTag = HostTag.GetById(_tagAlert.HostId);
                    Tag     thisTag     = Tag.Select(thisHostTag.TagId);
                    if (thisTag != null)
                    {
                        tagName.Text = thisHostTag.HostName;
                        int coorid = _tagAlert.CoordinatesId;
                        if (CommonExtension.IsIlltreatTag(_tagAlert.HostId) && Config.Settings.ProjectType != ProjectTypeEnum.NMPrison)
                        {
                            coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2));
                        }

                        if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison)
                        {
                            coordinatesName.Text = thisHostTag.HostName;
                        }
                        else
                        {
                            coordinatesName.Text = Coordinates.GetName(coorid);
                        }

                        if (LocatingServiceUtil.IsAvailable())
                        {
                            IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                            bool        boolean    = serviceApi.ClearTagStatus(thisTag.TagMac, (SupportEvent)_tagAlert.AlertType);
                        }

                        description.Text  = CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId);
                        time.DisplayValue = _tagAlert.WriteTime;
                        if (_tagAlert.MasterUserId > 0)
                        {
                            alertMaster.Text = Data.User.Select(_tagAlert.MasterUserId) == null ? "未知" : Data.User.Select(_tagAlert.MasterUserId).UserName;
                        }

                        alertStatus.Text = NetRadio.Common.LocatingMonitor.Misc.GetAlertStatus((AlertStatusType)_tagAlert.AlertStatus);

                        list.DataSource   = db.AlertProcessLogs.Where(t => t.AlertId == _id).OrderBy(t => t.UpdateTime).ToList();
                        list.ItemCreated += new RepeaterItemEventHandler(list_ItemCreated);
                        list.DataBind();

                        if (!IsPostBack)
                        {
                            Dictionary <string, int> alertResults = new Dictionary <string, int>();
                            alertResults.Add(CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId), 1);
                            alertResults.Add("误报", 2);
                            alertResults.Add("其它", 3);

                            foreach (var item in alertResults)
                            {
                                ListItem listitem = new ListItem(item.Key, item.Value.ToString());

                                if (item.Value == 1)
                                {
                                    listitem.Selected = true;
                                }

                                alertResultList.Items.Add(listitem);
                            }
                        }

                        if (_tagAlert.AlertStatus == (byte)AlertStatusType.New || _tagAlert.AlertStatus == (byte)AlertStatusType.Processing)
                        {
                            alertResultList.Visible = true;
                            alertResult.Visible     = false;
                            handover.Visible        = true;
                            alertProcess.Visible    = true;
                            otherReason.Visible     = true;
                        }
                        else
                        {
                            alertResultList.Visible = false;
                            alertResult.Visible     = true;
                            handover.Visible        = false;
                            alertProcess.Visible    = false;
                            otherReason.Visible     = false;

                            AlertProcessLog alertProcessLog = db.AlertProcessLogs.SingleOrDefault(t => t.AlertId == _id && t.AlertStatus == (byte)AlertStatusType.Resolved);

                            if (alertProcessLog != null)
                            {
                                alertResult.Text = alertProcessLog.ChangeReason;
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        public static object GetData(int alertID)
        {
            string id_name     = "";
            string id_position = "";
            string id_type     = "";
            string id_time     = "";
            string id_table    = "";

            NameID[] id_selectResult = null;

            using (AppDataContext db = new AppDataContext())
            {
                TagAlert _tagAlert = db.TagAlerts.SingleOrDefault(t => t.AlertId == alertID);

                if (_tagAlert == null)
                {
                    throw new Exception("报警事件不存在!");
                }
                else
                {
                    HostTag thisHostTag = HostTag.GetById(_tagAlert.HostId);
                    Tag     thisTag     = Tag.Select(thisHostTag.TagId);
                    if (thisTag != null)
                    {
                        if (CommonExtension.IsIlltreatTag(_tagAlert.HostId))
                        {
                            if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison)
                            {
                                id_position = thisHostTag.HostName;
                            }
                            else
                            {
                                int coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2));
                                id_position = Coordinates.GetName(coorid);
                            }
                        }
                        else
                        {
                            id_position = Coordinates.GetName(_tagAlert.CoordinatesId);
                        }


                        //if (Config.Settings.ProjectType == ProjectTypeEnum.NMPrison)
                        //{
                        //    id_position = thisHostTag.HostName;
                        //}
                        //else
                        //{

                        //    int coorid = CommonExtension.GetCoordinatesId(thisHostTag.Description.Substring(0, thisHostTag.Description.Length - 2));
                        //    id_position = Coordinates.GetName(coorid);

                        //}

                        if (LocatingServiceUtil.IsAvailable())
                        {
                            IServiceApi serviceApi = LocatingServiceUtil.Instance <IServiceApi>();
                            bool        boolean    = serviceApi.ClearTagStatus(thisTag.TagMac, (SupportEvent)_tagAlert.AlertType);
                        }

                        id_name = thisHostTag.HostName;
                        //id_position = Coordinates.GetName(coorid);
                        id_type = CommonExtension.GetEventDescription((SupportEvent)_tagAlert.AlertType, _tagAlert.HostId);
                        id_time = _tagAlert.WriteTime.ToString("yyyy/MM/dd HH:mm:ss");

                        id_selectResult = db.ProcessResults.Select(_d => new NameID {
                            ID = _d.ID, Name = _d.Text
                        }).ToArray();

                        id_table = GetProcessTable(alertID);


                        return(new
                        {
                            id_name,
                            id_position,
                            id_type,
                            id_time,
                            id_table,
                            id_selectResult
                        });
                    }
                }
            }



            return("");
        }
        private string CreateOutputContent()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<?xml version=\"1.0\" standalone=\"yes\" ?>");
            sb.AppendLine("<LatestEvents>");

            using (AppDataContext db = new AppDataContext())
            {
                //var list = db.LatestEvents
                //            .Where(x => x.ResolveFlag != (byte)ResolveFlag.Processed)
                //            .Where(x => HostTag.All.Where(u => u.TagId != 0).Select(u => u.TagId).ToArray().Contains(x.TagId))
                //            .OrderByDescending(x => x.LastHappenTime)
                //            .ToList();

                var list = db.TagAlerts.Where(l => l.AlertStatus == (byte)AlertStatusType.New)
                           .Where(l => l.HostId > 0)
                           .OrderByDescending(l => l.WriteTime)
                           .ThenByDescending(l => l.AlertLevel)
                           //.OrderByDescending(l => l.AlertLevel)
                           .ToList();

                //lyz 获取用户的类型
                System.Collections.Generic.IEnumerable <int>            hostidds = list.Select(u => u.HostId);
                System.Collections.Generic.IEnumerable <Data.HostGroup> hgs      = db.HostGroups.Where(_d => hostidds.Contains(_d.HostId) && (_d.HostGroupId == 1 || _d.HostGroupId == 2)).AsEnumerable();

                var str = "	<item id='{0}' tagId='{1}' tagMac='{2}' tagName='{3}' coordinatesId='{4}' coodinatesName='{5}' eventType='{6}' eventDescription='{7}' lastHappenTime='{8}' hostGroupID='{9}' />\r\n";
                foreach (var i in list)
                {
                    //lyz 获取用户的类型
                    Data.HostGroup hg = hgs.Where(_d => _d.HostId == i.HostId).FirstOrDefault();

                    //20100106: select by host
                    //TagStatusView tagStatusView = TagStatusView.SelectTagStatus(i.TagId);
                    TagStatusView tagStatusView = TagStatusView.SelectTagStatusByHostId(i.HostId);
                    if (hg != null && tagStatusView != null)//判断对象是否存在 lyz
                    {
                        sb.AppendFormat(str, i.HostId, i.TagId, tagStatusView.Mac, tagStatusView.HostTag.HostName, i.CoordinatesId, Coordinates.GetName(i.CoordinatesId), i.AlertType, CommonExtension.GetEventDescription((SupportEvent)i.AlertType, i.HostId), i.WriteTime, hg.HostGroupId);
                    }
                }
            }

            sb.AppendLine("</LatestEvents>");
            return(sb.ToString());
        }
Пример #6
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 = "" });
            }
        }