public HttpResponseMessage Logout(int equipmentId, int sessionId) { try { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI was called."), LogLevelType.Info); var equipmentConnectionSetting = Setup(equipmentId); var response = new CalixService(_tenantId, equipmentConnectionSetting, _logger).Logout(sessionId); //var doc = new XmlDocument(); //doc.LoadXml(response); //var jsonResponse = JsonConvert.SerializeXmlNode(doc); //var myObject = JsonConvert.DeserializeObject(jsonResponse); _logger.WriteLogEntry(_tenantId.ToString(), new List <object> { response }, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response({0})", HttpStatusCode.OK), LogLevelType.Info); return(this.Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response."), LogLevelType.Error, ex); throw; } }
public HttpResponseMessage PostJsonMessage(HttpRequestMessage request) { try { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI was called."), LogLevelType.Info); if (request == null) { throw new Exception("Did not receive an json message in the post body."); } var jsonString = request.Content.ReadAsStringAsync().Result; var requestObject = JObject.Parse(jsonString); int equipmentId = Convert.ToInt32(requestObject["calixRequest"]["equipmentId"]); var equipmentConnectionSetting = Setup(equipmentId); if (equipmentConnectionSetting == null) { throw new Exception("Could not find and connection settings for the equipmentId."); } _logger.WriteLogEntry(_tenantId.ToString(), new List <object> { equipmentId }, string.Format("EquipmentId."), LogLevelType.Info); var service = new CalixService(_tenantId, equipmentConnectionSetting, _logger); _logger.WriteLogEntry(_tenantId.ToString(), null, "got here", LogLevelType.Info); var resultObject = service.PostMessage(requestObject["calixRequest"]["request"]); _logger.WriteLogEntry(_tenantId.ToString(), new List <object> { resultObject }, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response({0})", HttpStatusCode.OK), LogLevelType.Info); return(Request.CreateResponse(HttpStatusCode.OK, resultObject)); } catch (Exception ex) { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response."), LogLevelType.Error, ex); throw; } }
public HttpResponseMessage PostMessage([FromBody] ProvisioningPostMessage message) { try { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI was called."), LogLevelType.Info); if (message == null) { throw new Exception("Did not receive an json message in the post body."); } var equipmentConnectionSetting = Setup(message.EquipmentId); if (equipmentConnectionSetting == null) { throw new Exception("Could not find and connection settings for the equipmentId."); } var service = new CalixService(_tenantId, equipmentConnectionSetting, _logger); var response = service.PostMessageRaw(message.SoapMessage); //var doc = new XmlDocument(); //doc.LoadXml(response); //var jsonResponse = JsonConvert.SerializeXmlNode(doc); //var myObject = JsonConvert.DeserializeObject(jsonResponse); _logger.WriteLogEntry(_tenantId.ToString(), new List <object> { response }, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response({0})", HttpStatusCode.OK), LogLevelType.Info); return(this.Request.CreateResponse(HttpStatusCode.OK, response)); } catch (Exception ex) { _logger.WriteLogEntry(_tenantId.ToString(), null, string.Format(MethodBase.GetCurrentMethod().Name + " in ProvisioningAPI. Response."), LogLevelType.Error, ex); throw; } }