Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="jsonArray"></param>
        /// <returns></returns>
        protected internal List <NetmeraContent> convertJsonArrayToNetmeraContent(JArray jsonArray)
        {
            List <NetmeraContent> contentList = new List <NetmeraContent>();
            JArray entries = new JArray();

            //If the entry is type of JArray, it is already able to be casted to JArray.
            //Else it does not accept JArray cast. Instead, it is added to a JArray as a JObject
            if (jsonArray[0]["entry"].Type == JTokenType.Array)
            {
                entries = (JArray)jsonArray[0]["entry"];
            }
            else
            {
                entries.Add(jsonArray[0]["entry"]);
            }

            for (int i = 0; i < entries.Count; i++)
            {
                try
                {
                    JObject        json        = (JObject)entries[i];
                    String         contentName = (String)json[NetmeraConstants.Content_Params][NetmeraConstants.ContentData_Params][NetmeraConstants.ApiContentType];
                    NetmeraContent content     = new NetmeraContent(contentName);
                    content.setContent(json);
                    contentList.Add(content);
                }
                catch (JsonException e)
                {
                    throw new NetmeraException(NetmeraException.ErrorCode.EC_INVALID_JSON, "Json contains content is invalid.", e.Message);
                }
            }

            return(contentList);
        }
        public void bulkUpdate(Action <JObject, Exception> callback)
        {
            String tmpPath = path;

            NetmeraHttpUtils.updateBulkContent(data, (json, e) =>
            {
                NetmeraContent content = new NetmeraContent();
                content.setContent(json);
                if (mediaData != null && mediaData.Count != 0)
                {
                    createMedia(content, (j, exc) =>
                    {
                        if (callback != null)
                        {
                            callback(j, exc);
                        }
                    });
                }
                else
                {
                    if (callback != null)
                    {
                        if (callback != null)
                        {
                            callback(json, e);
                        }
                    }
                }
            });
        }
        /// <summary>
        /// Updates the specified data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="path">The path.</param>
        /// <param name="callback">method called when content update operation finishes</param>
        protected internal void update(JObject data, String path, Action <JObject, Exception> callback)
        {
            String tmpPath = path;

            NetmeraHttpUtils.updateContent(data, tmpPath, (json, e) =>
            {
                NetmeraContent content = new NetmeraContent();
                content.setContent(json);
                if (mediaData != null && mediaData.Count != 0)
                {
                    createMedia(content, (j, exc) =>
                    {
                        if (callback != null)
                        {
                            callback(j, exc);
                        }
                    });
                }
                else
                {
                    if (callback != null)
                    {
                        if (callback != null)
                        {
                            callback(json, e);
                        }
                    }
                }
            });
        }
Beispiel #4
0
        /// <summary>
        /// Updates the specified data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="path">The path.</param>
        protected internal JObject update(JObject data, String path)
        {
            JObject        json    = NetmeraHttpUtils.updateContent(data, path);
            NetmeraContent content = new NetmeraContent();

            content.setContent(json);
            if (mediaData != null && mediaData.Count != 0)
            {
                json = createMedia(content);
            }
            return(json);
        }
Beispiel #5
0
        protected internal JObject createBulk(JObject data)
        {
            JObject        jArray  = NetmeraHttpUtils.createBulkContent(data);
            NetmeraContent content = new NetmeraContent();

            //foreach (JObject json in jArray)
            //{

            content.setContent(jArray);
            //if (mediaData != null && mediaData.Count != 0)
            //{
            //    jarray = createMedia(content);
            //}
            //}

            return((JObject)jArray);
        }