Exemple #1
0
 public void DeviceProcessMessage(MessageModel subscribeData)
 {
     try
     {
         //XML device with or without child device
         var         xmlDeviceData = Convert.ToString(JsonConvert.DeserializeXNode(JsonConvert.SerializeObject(subscribeData.Data), "items"));
         XmlDocument xmlDoc        = new XmlDocument();
         xmlDoc.LoadXml(xmlDeviceData);
         if (xmlDoc.ChildNodes.Count > 0)
         {
             xmlDeviceData = xmlDoc.ChildNodes[0].InnerXml;
         }
         var baseDataAccess = new BaseDataAccess(_connectionString);
         var sqlParameters  = new List <SqlParameter>
         {
             baseDataAccess.AddInParameter("DeviceXml", xmlDeviceData),
             baseDataAccess.AddInParameter("action", subscribeData.Action),
             baseDataAccess.AddInParameter("companyGuid", subscribeData.Company)
         };
         baseDataAccess.Execute("IotConnect_ManageDevice", sqlParameters);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(new Exception($"Error in sync iotconnect device data : {ex.Message}, StackTrace : {ex.StackTrace}, Data : {JsonConvert.SerializeObject(subscribeData)}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
 }
 public void UserProcessMessage(MessageModel subscribeData)
 {
     try
     {
         var xmlUserData    = Convert.ToString(JsonConvert.DeserializeXNode(JsonConvert.SerializeObject(subscribeData.Data), "items"));
         var baseDataAccess = new BaseDataAccess(_connectionString);
         var sqlParameters  = new List <SqlParameter>
         {
             baseDataAccess.AddInParameter("UserXml", xmlUserData),
             baseDataAccess.AddInParameter("action", subscribeData.Action),
             baseDataAccess.AddInParameter("companyGuid", subscribeData.Company)
         };
         baseDataAccess.Execute("IotConnect_ManageUser ", sqlParameters);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(new Exception($"Error in sync iotconnect user data : {ex.Message}, StackTrace : {ex.StackTrace}, Data : {JsonConvert.SerializeObject(subscribeData)}"), this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
 }