Ejemplo n.º 1
0
    private void handle(string str)
    {
        if (string.IsNullOrEmpty(str))
        {
            if (callback != null)
            {
                callback(false);
            }
            return;
        }
        List <Scene> updateList;
        List <Scene> deleteList;

        SceneSerializer.ToObjects(str, out updateList, out deleteList);
        bool result = false;

        if (updateList != null && updateList.Count != 0)
        {
            LogicController.ReplaceScenesIgnoreFavourite(updateList);
            result = true;
        }
        if (deleteList != null && deleteList.Count != 0)
        {
            LogicController.DeleteScenes(deleteList);
            result = true;
        }
        if (callback != null)
        {
            callback(result);
        }
    }
    void handle(string res)
    {
        if (string.IsNullOrEmpty(res))
        {
            if (callback != null)
            {
                callback(false);
            }
            return;
        }
        JsonData jd = JsonMapper.ToObject(res);

        if (jd.Contains(Param.SCENE))
        {
            List <Scene> updateList;
            List <Scene> deleteList;
            SceneSerializer.ToObjects(jd[Param.SCENE].ToJson(), out updateList, out deleteList);
            if (updateList != null && updateList.Count != 0)
            {
                LogicController.ReplaceScenesIgnoreFavourite(updateList);
            }
            if (deleteList != null && deleteList.Count != 0)
            {
                LogicController.DeleteScenes(deleteList);
            }
        }
        if (jd.Contains(Param.PRODUCT))
        {
            List <Product> updateList;
            List <Product> deleteList;
            ProductSerializer.ToObjects(jd[Param.PRODUCT].ToJson(), out updateList, out deleteList);
            if (updateList != null && updateList.Count != 0)
            {
                LogicController.ReplaceProducts(updateList);
            }
            if (deleteList != null && deleteList.Count != 0)
            {
                LogicController.DeleteProducts(deleteList);
            }
        }
        if (jd.Contains(Param.PICTURE))
        {
            List <Picture> list = PictureSerializer.ToObjects(jd[Param.PICTURE].ToJson());
            if (list != null && list.Count != 0)
            {
                LogicController.ReplacePictures(list);
            }
        }
        if (jd.Contains(Param.ASSET))
        {
            List <Asset> list = AssetSerializer.ToObjects(jd[Param.ASSET].ToJson());
            if (list != null && list.Count != 0)
            {
                LogicController.ReplaceAssets(list);
            }
        }
        if (callback != null)
        {
            callback(true);
        }
    }