public AgilorResponseData GetTargetHistoryByTargetName(string targetName) { AgilorResponseData response = new AgilorResponseData(); if (!checkACIObject()) { response.responseMessage = "Get All Device Names And Status ERROR: ACI IS NULL, Server Need Be Restart!"; response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_AGILOR_ACI_IS_NULL; return(response); } try { response.responseBody = agilorACI.QueryTagHistory(targetName, DateTime.Now.AddMonths(-1), DateTime.Now); response.responseMessage = "Get Target History Information By Target Name Success!"; response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_NORMAL; } catch (Exception ex) { response.responseMessage = ex.ToString(); response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_UNKNOWN_ERROR; } return(response); }
public AgilorResponseData GetTargetHistoryByTargetName(string targetName, string start = null, string end = null, int step = 0) { AgilorResponseData response = new AgilorResponseData(); if (!checkACIObject()) { response.responseMessage = "Get All Device Names And Status ERROR: ACI IS NULL, Server Need Be Restart!"; response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_AGILOR_ACI_IS_NULL; return(response); } try { DateTime start_t, end_t; if (!DateTime.TryParse(end, out end_t)) { end_t = DateTime.Now; } if (!DateTime.TryParse(start, out start_t)) { int minutes = 1; int.TryParse(ConfigurationManager.AppSettings["AgilorQueryHistoryDefaultIntervalMinute"], out minutes); start_t = end_t.AddMinutes(-1 * minutes); } if (end_t >= start_t) { var body = agilorACI.QueryTagHistory(targetName, start_t, end_t, step); if (body.Count > 0 && body[0].Type == Agilor.Interface.Val.Value.Types.STRING) { for (int i = 0; i < body.Count; i++) { body[i].Val = ((string)body[i].Val).Remove(((string)body[i].Val).IndexOf("\0")); } } body.Reverse(); response.responseBody = body; } response.responseMessage = "Get Target History Information By Target Name Success! start: " + start_t.ToString() + ", end: " + end_t.ToString(); response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_NORMAL; } catch (Exception ex) { response.responseMessage = ex.ToString(); response.responseCode = (int)AgilorResponseData.RESPONSE_CODE.RESPONSE_UNKNOWN_ERROR; } return(response); }