public List <ActivityDetail> GetActivityDetails(int act_id) { List <ActivityDetail> activityDetails = new List <ActivityDetail>(); string sql = "select * from activity where act_id='" + act_id + "'" + " and status = 1"; var row = _theDataSource.SelectOne(sql); string material = row["material"].ToString(); List <MWMaterial> mWMaterials = (List <MWMaterial>)DaoUtil.ConvertMaterialJson(material); for (int i = 0; i < mWMaterials.Count; i++) { MWMaterial data = mWMaterials[i]; //Debug.Log(data[i]["cuteffect_id"]); ActivityDetail activityDetail = new ActivityDetail(); if (data.type == "video") { activityDetail.Type = 1; activityDetail.Image = data.cover; activityDetail.VideoUrl = data.path; } else if (data.type == "image") { activityDetail.Type = 0; activityDetail.Image = data.path; } activityDetail.Description = data.description; activityDetails.Add(activityDetail); } return(activityDetails); }
public List <Video> GetVideosByEnvId(int envId) { List <Video> videos = new List <Video>(); string sql = "select video from company where com_id=" + envId + " and status = 1"; //Debug.Log("GetVideosByEnvId : " + sql); var row = _theDataSource.SelectOne(sql); if (row != null) { string material = row["video"].ToString(); object mWMaterialsObj = DaoUtil.ConvertMaterialJson(material); if (mWMaterialsObj != null) { List <MWMaterial> mWMaterials = (List <MWMaterial>)mWMaterialsObj; for (int i = 0; i < mWMaterials.Count; i++) { MWMaterial data = mWMaterials[i]; //Debug.Log(data[i]["cuteffect_id"]); Video video = new Video(); video.V_id = i; if (data.type == "video") { video.Cover = data.cover; video.Address = data.path; } video.Description = data.description; videos.Add(video); } } } return(videos); }
public List <ProductDetail> GetProductDetails(int pro_id) { List <ProductDetail> productDetails = new List <ProductDetail>(); string sql = "select * from product where prod_id=" + pro_id; var row = _theDataSource.SelectOne(sql); if (row != null) { string material = row["material"].ToString(); List <MWMaterial> mWMaterials = (List <MWMaterial>)DaoUtil.ConvertMaterialJson(material); for (int i = 0; i < mWMaterials.Count; i++) { MWMaterial data = mWMaterials[i]; //Debug.Log(data[i]["cuteffect_id"]); ProductDetail productDetail = new ProductDetail(); if (data.type == "video") { productDetail.Type = 1; productDetail.Image = data.cover; productDetail.VideoUrl = data.path; } else if (data.type == "image") { productDetail.Type = 0; productDetail.Image = data.path; } productDetail.Description = data.description; productDetails.Add(productDetail); } } return(productDetails); }
public MWMaterial ConvertJSONToObject(string str) { bool hasType = false; bool hasPath = false; bool hasDescription = false; bool hasCover = false; //Debug.Log(str); if (str.Contains("type")) { str = str.Replace("type", "'type'"); hasType = true; } if (str.Contains("path")) { str = str.Replace("path", "'path'"); hasPath = true; } if (str.Contains("description")) { str = str.Replace("description", "'description'"); hasDescription = true; } if (str.Contains("cover")) { str = str.Replace("cover", "'cover'"); hasCover = true; } if (str.IndexOf("}") < 0) { str = str + "}"; } if (str.IndexOf("{") < 0) { str = "{" + str; } //Debug.Log("After Convert"); //Debug.Log(str); JsonData data = JsonMapper.ToObject(str); MWMaterial mWMaterial = new MWMaterial(); if (hasType) { mWMaterial.type = (string)data["type"]; } if (hasPath) { mWMaterial.path = (string)data["path"]; } if (hasDescription) { mWMaterial.description = (string)data["description"]; } if (hasCover) { mWMaterial.cover = (string)data["cover"]; } return(mWMaterial); }
private static MWMaterial ConvertMaterialObject(string jsonstr) { MWMaterial mWMaterial = new MWMaterial(); return(mWMaterial.ConvertJSONToObject(jsonstr)); }