示例#1
0
        public QueryAlertLogResult QueryAlertLog(AccessControl AccessInformation, AlertLogQueryCondition QueryCondition)
        {
            QueryAlertLogResult Result = new QueryAlertLogResult();
            if (QueryCondition.LimitTime)
            {
                anyType2anyTypeMapEntry[] requestData = new anyType2anyTypeMapEntry[]
               {
                Helper.XfireCreateKeyValue("dowhat","QueryRecordsByTime"),
                Helper.XfireCreateKeyValue("id","alertlogs"),
                Helper.XfireCreateKeyValue("begin_year",QueryCondition.StartTime.Year.ToString()),
                Helper.XfireCreateKeyValue("begin_month",QueryCondition.StartTime.Month.ToString()),
                Helper.XfireCreateKeyValue("begin_day",QueryCondition.StartTime.Day.ToString()),
                Helper.XfireCreateKeyValue("begin_hour",QueryCondition.StartTime.Hour.ToString()),
                Helper.XfireCreateKeyValue("begin_minute",QueryCondition.StartTime.Minute.ToString()),
                Helper.XfireCreateKeyValue("begin_second",QueryCondition.StartTime.Second.ToString()),
                Helper.XfireCreateKeyValue("end_year",QueryCondition.EndTime.Year.ToString()),
                Helper.XfireCreateKeyValue("end_month",QueryCondition.EndTime.Month.ToString()),
                Helper.XfireCreateKeyValue("end_day",QueryCondition.EndTime.Day.ToString()),
                Helper.XfireCreateKeyValue("end_hour",QueryCondition.EndTime.Hour.ToString()),
                Helper.XfireCreateKeyValue("end_minute",QueryCondition.EndTime.Minute.ToString()),
                Helper.XfireCreateKeyValue("end_second",QueryCondition.EndTime.Second.ToString())
              };
                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;
                }
                IList<NameValueCollection> resultData = Helper.XfireConventMapEntryToList(result.vmap);
            }
            else
            {

            }

            return Result;
        }
        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;
        }
示例#3
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);
        }