public static string SerializeObject(FFTCreateAlarmParamDto graph) { try { var serializer = new DataContractJsonSerializer(typeof(FFTCreateAlarmParamDto)); string jsonCode; using (var ms = new MemoryStream()) { serializer.WriteObject(ms, graph); jsonCode = Encoding.Default.GetString(ms.ToArray()); } return(jsonCode); } catch (Exception ex) { _logger.Info("StreamInsightAlertService SerializeObject() Exception:" + ex.Message); string Message = "StreamInsightAlertService SerializeObject() Exception 1" + ex.Message; //InsertBrokerOperationLog.AddProcessLog(Message); //InsertTransactionLog.InsertLog(Message);//jatin } finally { //ClearMemoryStatic(); } return(null); }
public void PushDataToFFTTxnService(FFTCreateAlarmParamDto _FFTCreateAlarmParamDto) { try { string strData = SerializeObject(_FFTCreateAlarmParamDto); var json = JsonServicesHelper.GetJsonResponsePost("FFTTransactionService", "ConsumeFFTAlert", _FFTCreateAlarmParamDto); } catch (Exception ex) { } }
public void FFTTransactionServiceCreateAlert(long alarmId, DateTime alarmTimeUtc, SdkAlarmType alarmType, bool acknowledged, SdkCtrlData ctrlData, string strAlertType)//3 { try { SdkAlarmTypeDto _SdkAlarmTypeDto = null; if (alarmType != null) { _SdkAlarmTypeDto = new SdkAlarmTypeDto { Category = alarmType.Category, Id = alarmType.Id, Name = alarmType.Name, Severity = alarmType.Severity, Type = alarmType.Type }; } SdkCtrlDataDto _SdkCtrlData = null; if (ctrlData != null) { _SdkCtrlData = new SdkCtrlDataDto { Connected = ctrlData.Connected, Description = ctrlData.Description, HostName = ctrlData.HostName, Id = ctrlData.Id, IpAddress = ctrlData.IpAddress, Locator = ctrlData.Locator, Name = ctrlData.Name, Port = ctrlData.Port }; } //FFTTransactionServiceCreateAlert(alarmId, alarmTimeUtc, acknowledged, false, false, ctrlData, null, null, null, null, 0, "FFT SystemAlert", alarmType)); // SdkAlarmType alarmType, SdkCtrlData ctrlData,string strAlertType FFTCreateAlarmParamDto _FFTCreateAlarmParamDto = new FFTCreateAlarmParamDto { acknowledged = acknowledged, alarmId = alarmId, alarmTimeUtc = alarmTimeUtc.ToString(), alarmType = _SdkAlarmTypeDto, ctrl = _SdkCtrlData, strAlertType = strAlertType, functiontype = "SystemAlert" }; //call json function PushDataToFFTTxnService(_FFTCreateAlarmParamDto); } catch (Exception ex) { } }
public static string GetJsonResponsePost(string serviceName, string method, FFTCreateAlarmParamDto _FFTCreateAlarmParamDto) { try { using (var client = new WebClient()) { client.Headers["Content-type"] = "application/json"; MemoryStream ms = new MemoryStream(); DataContractJsonSerializer serializerToUplaod = new DataContractJsonSerializer(typeof(FFTCreateAlarmParamDto)); serializerToUplaod.WriteObject(ms, _FFTCreateAlarmParamDto); string ServerPath = "https://" + Storage.FFTTxnServiceAddress + ":6530/FFTTransactionService/ConsumeFFTAlert"; byte[] data = client.UploadData(ServerPath, "POST", ms.ToArray()); return(""); } } catch (Exception ex) { } return(null); }
//5 public void FFTTransactionServiceCreateAlertZoneEx(long eventId, DateTime eventTimeUtc, bool acknowledged, bool active, bool dynamic, SdkCtrlData ctrl, SdkSensorData sensor, SdkZoneData zone, SdkLocationInfo location, string classification, int classConfidenceIndex, string strAlertType) { try { SdkCtrlDataDto _SdkCtrlData = null; if (ctrl != null) { _SdkCtrlData = new SdkCtrlDataDto { Connected = ctrl.Connected, Description = ctrl.Description, HostName = ctrl.HostName, Id = ctrl.Id, IpAddress = ctrl.IpAddress, Locator = ctrl.Locator, Name = ctrl.Name, Port = ctrl.Port }; } List <CoordinateDto> _DrawingPoints = new List <CoordinateDto>(); foreach (var _cor in sensor.DrawingPoints) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = _cor.Alt, IsEmpty = _cor.IsEmpty, Lat = _cor.Lat, Long = _cor.Long }; _DrawingPoints.Add(_CoordinateDto); } List <SensorPointDto> _SensorPoints = new List <SensorPointDto>(); foreach (var _cor in sensor.SensorPoints) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = _cor.coordinate.Alt, IsEmpty = _cor.coordinate.IsEmpty, Lat = _cor.coordinate.Lat, Long = _cor.coordinate.Long }; SensorPointDto _SensorPointDto = new SensorPointDto { cableDistance = _cor.cableDistance, calibrationPoint = _cor.calibrationPoint, calibrationPointName = _cor.calibrationPointName, coordinate = _CoordinateDto, id = _cor.id, perimeterDistance = _cor.perimeterDistance, seq = _cor.seq }; _SensorPoints.Add(_SensorPointDto); } SdkSensorDataDto _SdkSensorDataDto = new SdkSensorDataDto { ControllerId = sensor.ControllerId, DrawingPoints = _DrawingPoints, Id = sensor.Id, Name = sensor.Name, Number = sensor.Number, SensorPoints = _SensorPoints }; List <SensorSectionDto> _SensorSections = new List <SensorSectionDto>(); foreach (var __SensorSections in zone.SensorSections) { List <CoordinateDto> Points = new List <CoordinateDto>(); foreach (var _cord in __SensorSections.Points) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = _cord.Alt, IsEmpty = _cord.IsEmpty, Lat = _cord.Lat, Long = _cord.Long }; Points.Add(_CoordinateDto); } SensorSectionDto _SensorSectionDto = new SensorSectionDto { CableEnd = __SensorSections.CableEnd, CableStart = __SensorSections.CableStart, Opposite = __SensorSections.Opposite, PerimeterEnd = __SensorSections.PerimeterEnd, PerimeterStart = __SensorSections.PerimeterStart, Points = Points, Reversed = __SensorSections.Reversed, SectionId = __SensorSections.SectionId, SensorEndIdx = __SensorSections.SensorEndIdx, SensorId = __SensorSections.SensorId, SensorStartIdx = __SensorSections.SensorStartIdx, ServerId = __SensorSections.ServerId }; _SensorSections.Add(_SensorSectionDto); } SdkZoneDataDTO _SdkZoneDataDTO = new SdkZoneDataDTO { Isolated = zone.Isolated, Description = zone.Description, Id = zone.Id, Name = zone.Name, SensorSections = _SensorSections }; CoordinateDto _CoordinateDtoinfo = new CoordinateDto { Alt = location.Location.Alt, IsEmpty = location.Location.IsEmpty, Lat = location.Location.Lat, Long = location.Location.Long }; SdkLocationInfoDto _location = new SdkLocationInfoDto { CableDistance = location.CableDistance, Location = _CoordinateDtoinfo, LocationWeight = location.LocationWeight, LocationWeightThreshold = location.LocationWeightThreshold, PerimeterDistance = location.PerimeterDistance }; //SdkCtrlData _SdkCtrlData, SdkSensorData _SdkSensorDataDto, SdkZoneData _SdkZoneDataDTO, SdkLocationInfo _location // string classification, int classConfidenceIndex, string strAlertType FFTCreateAlarmParamDto _FFTCreateAlarmParamDto = new FFTCreateAlarmParamDto { acknowledged = acknowledged, alarmId = eventId, alarmTimeUtc = eventTimeUtc.ToString(), ctrl = _SdkCtrlData, location = _location, sensor = _SdkSensorDataDto, zone = _SdkZoneDataDTO, classification = classification, strAlertType = strAlertType, functiontype = "ZoneAlert" }; //call json PushDataToFFTTxnService(_FFTCreateAlarmParamDto); } catch (Exception ex) { } }
//2 public void FFTTransactionServiceCreateSensorAlert(long alarmId, DateTime alarmTimeUtc, SdkAlarmType alarmType, bool acknowledged, SdkCtrlData ctrl, List <SdkSensorData> sensors, bool isValidLocation, SdkLocationInfo location, bool isOTDR, string strAlert) { try { SdkAlarmTypeDto _SdkAlarmTypeDto = new SdkAlarmTypeDto { Category = alarmType.Category, Id = alarmType.Id, Name = alarmType.Name, Severity = alarmType.Severity, Type = alarmType.Type }; SdkCtrlDataDto _SdkCtrlData = new SdkCtrlDataDto { Connected = ctrl.Connected, Description = ctrl.Description, HostName = ctrl.HostName, Id = ctrl.Id, IpAddress = ctrl.IpAddress, Locator = ctrl.Locator, Name = ctrl.Name, Port = ctrl.Port }; List <SdkSensorDataDto> _sensors = new List <SdkSensorDataDto>(); if (sensors != null) { try { foreach (var _sen in sensors) { List <CoordinateDto> _DrawingPoints = new List <CoordinateDto>(); foreach (var _cor in _sen.DrawingPoints) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = _cor.Alt, IsEmpty = _cor.IsEmpty, Lat = _cor.Lat, Long = _cor.Long }; _DrawingPoints.Add(_CoordinateDto); } List <SensorPointDto> _SensorPoints = new List <SensorPointDto>(); foreach (var _cor in _sen.SensorPoints) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = _cor.coordinate.Alt, IsEmpty = _cor.coordinate.IsEmpty, Lat = _cor.coordinate.Lat, Long = _cor.coordinate.Long }; SensorPointDto _SensorPointDto = new SensorPointDto { cableDistance = _cor.cableDistance, calibrationPoint = _cor.calibrationPoint, calibrationPointName = _cor.calibrationPointName, coordinate = _CoordinateDto, id = _cor.id, perimeterDistance = _cor.perimeterDistance, seq = _cor.seq }; _SensorPoints.Add(_SensorPointDto); } SdkSensorDataDto _SdkSensorDataDto = new SdkSensorDataDto { ControllerId = _sen.ControllerId, DrawingPoints = _DrawingPoints, Id = _sen.Id, Name = _sen.Name, Number = _sen.Number, SensorPoints = _SensorPoints }; _sensors.Add(_SdkSensorDataDto); } } catch (Exception ex) { } } SdkLocationInfoDto _location = null; if (location != null) { CoordinateDto _CoordinateDto = new CoordinateDto { Alt = location.Location.Alt, IsEmpty = location.Location.IsEmpty, Lat = location.Location.Lat, Long = location.Location.Long }; _location = new SdkLocationInfoDto { CableDistance = location.CableDistance, Location = _CoordinateDto, LocationWeight = location.LocationWeight, LocationWeightThreshold = location.LocationWeightThreshold, PerimeterDistance = location.PerimeterDistance }; } //_SdkAlarmTypeDto, _SdkCtrlData ,_sensors , SdkLocationInfo location FFTCreateAlarmParamDto _FFTCreateAlarmParamDto = new FFTCreateAlarmParamDto { acknowledged = acknowledged, alarmId = alarmId, alarmTimeUtc = alarmTimeUtc.ToString(), alarmType = _SdkAlarmTypeDto, ctrl = _SdkCtrlData, isOTDR = isOTDR, isValidLocation = isValidLocation, location = _location, sensors = _sensors, strAlertType = strAlert, functiontype = "SensorAlert" }; //call json method here PushDataToFFTTxnService(_FFTCreateAlarmParamDto); } catch (Exception ex) { } }