Пример #1
0
        public QueryAlertLogResult QueryAlertLog(AccessControl AccessInformation, AlertLogQueryCondition QueryCondition)
        {
            QueryAlertLogResult queryAlertLogResult = new QueryAlertLogResult();
            //dowhat= QueryAlertLog,
            //begin_year= XXX,
            //begin_month= XXX,
            //begin_day= XXX,
            //begin_hour= XXX,
            //begin_minute= XXX,
            //begin_second= XXX,
            //end_year= XXX,
            //end_month= XXX,
            //end_day= XXX,
            //end_hour= XXX,
            //end_minute= XXX,
            //end_second= XXX,
            //alertName= XXX,
            //alertReceive= XXX,
            //alertType= XXX;
            ////alertName��alertReceive��alertType �� and ��ϵ�����Ϊ����Ϊȫ����

            SortedDictionary<string, string> paras = new SortedDictionary<string,string>();

            paras.Add("dowhat","QueryAlertLog");
            paras.Add("begin_year",QueryCondition.StartTime.Year.ToString());
            paras.Add("begin_month",QueryCondition.StartTime.Month.ToString());
            paras.Add("begin_day",QueryCondition.StartTime.Day.ToString());
            paras.Add("begin_hour",QueryCondition.StartTime.Hour.ToString());
            paras.Add("begin_minute",QueryCondition.StartTime.Minute.ToString());
            paras.Add("begin_second",QueryCondition.StartTime.Second.ToString());
            paras.Add("end_year",QueryCondition.EndTime.Year.ToString());
            paras.Add("end_month",QueryCondition.EndTime.Month.ToString());
            paras.Add("end_day",QueryCondition.EndTime.Day.ToString());
            paras.Add("end_hour",QueryCondition.EndTime.Hour.ToString());
            paras.Add("end_minute",QueryCondition.EndTime.Minute.ToString());
            paras.Add("end_second",QueryCondition.EndTime.Second.ToString());

            if(QueryCondition.LimitName)
            {
                paras.Add("alertName", QueryCondition.AlertName);
            }

            if(QueryCondition.LimitReceiver)
            {
                paras.Add("alertReceive", QueryCondition.AlertReceiver);
            }

            if(QueryCondition.LimitType)
            {
                paras.Add("alertType", QueryCondition.AlertType.ToString("D"));
            }
            if (QueryCondition.LimitIndex)
            {
                paras.Add("alertIndex", QueryCondition.AlertIndex);
            }

            anyType2anyTypeMapEntry[] requestData = new anyType2anyTypeMapEntry[paras.Count];

            int i = 0;
            foreach(string key in paras.Keys)
            {
                anyType2anyTypeMapEntry node = Helper.XfireCreateKeyValue(key, paras[key]);
                requestData[i++] = node;
            }

            this.service.Url = UserPermissionContext.Instance.Url;
            RetMapInVector result = ServiceClient.GetForestData(requestData);
            //RetMapInVector result = this.service.GetForestData(requestData);
            if (!result.retbool)
            {
                if (logger.IsWarnEnabled)
                {
                    logger.Warn(result.estr);
                }
                return null;
            }

            queryAlertLogResult.ErrorInformation = result.estr;
            queryAlertLogResult.QueryAlertLogOK = result.retbool;

            IList<NameValueCollection> resultData = Helper.XfireConventMapEntryToList(result.vmap);
            AlertLogItem[] responseData = new AlertLogItem[resultData.Count];
            for (int j = 0; j < resultData.Count; j++)
            {
                NameValueCollection record = resultData[j];
                AlertLogItem item = new AlertLogItem();
                item.AlertIndex = record["_AlertIndex"];
                item.AlertName = record["_AlertRuleName"];
                item.EntityName = record["_DeviceName"];
                item.MonitorName = record["_MonitorName"];
                item.AlertReceiver = record["_AlertReceive"];
                item.AlertStatus = (AlertStatus)Enum.Parse(typeof(AlertStatus), record["_AlertStatus"]);
                item.AlertTime = DateTime.Parse(record["_AlertTime"]);
                item.AlertType = (AlertType)Enum.Parse(typeof(AlertType), record["_AlertType"]);

                responseData[j] = item;

            }

            queryAlertLogResult.ResponseData = responseData;

            return queryAlertLogResult;
        }
Пример #2
0
        public QueryAlertLogResult QueryAlertLog(AccessControl AccessInformation, AlertLogQueryCondition QueryCondition)
        {
            QueryAlertLogResult queryAlertLogResult = new QueryAlertLogResult();
            //dowhat= QueryAlertLog,
            //begin_year= XXX,
            //begin_month= XXX,
            //begin_day= XXX,
            //begin_hour= XXX,
            //begin_minute= XXX,
            //begin_second= XXX,
            //end_year= XXX,
            //end_month= XXX,
            //end_day= XXX,
            //end_hour= XXX,
            //end_minute= XXX,
            //end_second= XXX,
            //alertName= XXX,
            //alertReceive= XXX,
            //alertType= XXX;
            ////alertName、alertReceive、alertType 是 and 关系,如果为空则为全部。

            SortedDictionary <string, string> paras = new SortedDictionary <string, string>();

            paras.Add("dowhat", "QueryAlertLog");
            paras.Add("begin_year", QueryCondition.StartTime.Year.ToString());
            paras.Add("begin_month", QueryCondition.StartTime.Month.ToString());
            paras.Add("begin_day", QueryCondition.StartTime.Day.ToString());
            paras.Add("begin_hour", QueryCondition.StartTime.Hour.ToString());
            paras.Add("begin_minute", QueryCondition.StartTime.Minute.ToString());
            paras.Add("begin_second", QueryCondition.StartTime.Second.ToString());
            paras.Add("end_year", QueryCondition.EndTime.Year.ToString());
            paras.Add("end_month", QueryCondition.EndTime.Month.ToString());
            paras.Add("end_day", QueryCondition.EndTime.Day.ToString());
            paras.Add("end_hour", QueryCondition.EndTime.Hour.ToString());
            paras.Add("end_minute", QueryCondition.EndTime.Minute.ToString());
            paras.Add("end_second", QueryCondition.EndTime.Second.ToString());

            if (QueryCondition.LimitName)
            {
                paras.Add("alertName", QueryCondition.AlertName);
            }

            if (QueryCondition.LimitReceiver)
            {
                paras.Add("alertReceive", QueryCondition.AlertReceiver);
            }

            if (QueryCondition.LimitType)
            {
                paras.Add("alertType", QueryCondition.AlertType.ToString("D"));
            }
            if (QueryCondition.LimitIndex)
            {
                paras.Add("alertIndex", QueryCondition.AlertIndex);
            }


            anyType2anyTypeMapEntry[] requestData = new anyType2anyTypeMapEntry[paras.Count];

            int i = 0;

            foreach (string key in paras.Keys)
            {
                anyType2anyTypeMapEntry node = Helper.XfireCreateKeyValue(key, paras[key]);
                requestData[i++] = node;
            }

            this.service.Url = UserPermissionContext.Instance.Url;
            RetMapInVector result = ServiceClient.GetForestData(requestData);

            //RetMapInVector result = this.service.GetForestData(requestData);
            if (!result.retbool)
            {
                if (logger.IsWarnEnabled)
                {
                    logger.Warn(result.estr);
                }
                return(null);
            }

            queryAlertLogResult.ErrorInformation = result.estr;
            queryAlertLogResult.QueryAlertLogOK  = result.retbool;

            IList <NameValueCollection> resultData = Helper.XfireConventMapEntryToList(result.vmap);

            AlertLogItem[] responseData = new AlertLogItem[resultData.Count];
            for (int j = 0; j < resultData.Count; j++)
            {
                NameValueCollection record = resultData[j];
                AlertLogItem        item   = new AlertLogItem();
                item.AlertIndex    = record["_AlertIndex"];
                item.AlertName     = record["_AlertRuleName"];
                item.EntityName    = record["_DeviceName"];
                item.MonitorName   = record["_MonitorName"];
                item.AlertReceiver = record["_AlertReceive"];
                item.AlertStatus   = (AlertStatus)Enum.Parse(typeof(AlertStatus), record["_AlertStatus"]);
                item.AlertTime     = DateTime.Parse(record["_AlertTime"]);
                item.AlertType     = (AlertType)Enum.Parse(typeof(AlertType), record["_AlertType"]);

                responseData[j] = item;
            }

            queryAlertLogResult.ResponseData = responseData;

            return(queryAlertLogResult);
        }