Exemple #1
0
        /// <summary>
        /// Method <c>GetMultipleHolograms</c> is used to retrieve multiple hologram meta data from Storage server
        /// </summary>
        /// <param name="hologramList">Hologram object list, used to store information</param>
        /// <param name="IDs">IDs of querying holograms</param>
        public static IEnumerator GetMultipleHolograms(List <Hologram> hologramList, string IDs, QueryType queryType = QueryType.hids)
        {
            string multipleHologramUri = $"{BaseUri}/holograms?{queryType.ToString()}={IDs}";

            yield return(GetRequest(multipleHologramUri));

            hologramList.Clear();
            string[] ids = IDs.Split(',');
            if (WebRequestReturnData != null)
            {
                JSONNode initialJsonData = JSON.Parse(WebRequestReturnData);
                foreach (string id in ids)
                {
                    JSONNode  data      = initialJsonData[id];
                    JSONArray JsonArray = data.AsArray;

                    if (JsonArray.Count == 0)
                    {
                        Debug.LogWarning($"Response from server is empty with this patient ID: {id}");
                    }

                    foreach (JSONNode hologramJson in JsonArray)
                    {
                        Hologram hologram = JsonToHologram(hologramJson, id);
                        hologramList.Add(hologram);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Method <c>GetHologram</c> allows user retrieve single hologram from Storage server by hologram ID
        /// </summary>
        /// <param name="resultHologram">Hologram object, used to store information</param>
        /// <param name="holgramID">ID of querying hologram</param>
        public static IEnumerator GetHologram(Hologram resultHologram, string holgramID)
        {
            string getHologramUri = $"{BaseUri}/holograms/{holgramID}";

            yield return(GetRequest(getHologramUri));

            if (WebRequestReturnData != null)
            {
                JSONNode hologramJson     = JSON.Parse(WebRequestReturnData);
                Hologram receivedHologram = JsonToHologram(hologramJson, holgramID);
                CopyProperties(receivedHologram, resultHologram);
            }
        }
Exemple #3
0
        /// <summary>
        /// Method <c>JsonToHologram</c> map the json data into Hologram object
        /// </summary>
        /// <param name="json">Initial json data</param>
        /// <returns>Hologram object with retrieved information</returns>
        public static Hologram JsonToHologram(JSONNode json, string id)
        {
            Hologram hologram = new Hologram();

            if (json == null)
            {
                Debug.LogWarning($"Response error with this hologram ID: {id}");
                return(hologram);
            }

            if (json["hid"].Value == "")
            {
                Debug.LogWarning($"Response from server is empty with this hologram ID: {id}");
                return(hologram);
            }

            try
            {
                hologram.hid                 = json["hid"].Value;
                hologram.title               = json["title"].Value;
                hologram.description         = json["description"].Value;
                hologram.contentType         = json["contentType"].Value;
                hologram.fileSizeInKb        = json["fileSizeInKb"].AsInt;
                hologram.bodySite            = json["bodySite"].Value;
                hologram.dateOfImaging       = json["dateOfImaging"].Value;
                hologram.creationDate        = json["creationDate"].Value;
                hologram.creationMode        = json["creationMode"].Value;
                hologram.creationDescription = json["creationDescription"].Value;
                hologram.aid                 = json["aid"].Value;
                hologram.pid                 = json["pid"].Value;
            }
            catch (Exception e)
            {
                Debug.LogError("Failed to map hologram from response data! \n[Error message]: " + e);
            }
            return(hologram);
        }