/// <summary> /// Inserts the specified identified data in the back-end /// </summary> public void Insert(IdentifiedData data) { try { var amiClient = new AmiServiceClient(ApplicationContext.Current.GetRestClient("ami")); amiClient.Client.Credentials = this.GetCredentials(amiClient.Client); if (amiClient.Client.Credentials == null) { return; } switch (data.GetType().Name) { case "AuditInfo": // Only send audits over wifi if (ApplicationContext.Current.GetService <INetworkInformationService>().IsNetworkWifi || SynchronizationQueue.Admin.Count() > 10) { foreach (var a in (data as AuditInfo).Audit) { AuditUtil.AddDeviceActor(a); } amiClient.SubmitAudit(data as AuditInfo); } break; default: throw new NotSupportedException($"AMI servicing not supported for {data.GetType().Name}"); } } catch (Exception ex) { this.m_tracer.TraceError("Error contacting AMI: {0}", ex); throw; } }