Exemple #1
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("");
        }
        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;
                            }
                        }
                    }
                }
            }
        }
Exemple #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 = "" });
            }
        }