/// <summary> /// BJ 매칭 /// </summary> /// <param name="bj"></param> /// <param name="user"></param> /// <param name="serverBjs"></param> /// <returns></returns> private UserModel BjUserMatching(BjModel bj, UserModel user, List <RankBjModel> serverBjs) { try { var resultBj = new RankBjModel(); for (int Idx = 0; Idx < serverBjs.Count(); Idx++) { if (serverBjs[Idx].BjID == user.ID) { resultBj = serverBjs[Idx]; break; } } if (resultBj == null && string.IsNullOrEmpty(resultBj.BjID)) { return(null); } user.Type = UserType.BJ; user.PictureUrl = resultBj.BjImgUrl; user.RankingInfo = resultBj; user.BjInfo = resultBj.Bjinfo; return(user); } catch (Exception e) { string log = e.Message; return(null); } }
private UserModel RankBjModelToUserModel(RankBjModel serverBjs) { try { var user = new UserModel { ID = serverBjs.BjID, Type = UserType.BJ, PictureUrl = serverBjs.BjImgUrl, RankingInfo = serverBjs, BjInfo = serverBjs.Bjinfo }; return(user); } catch (Exception e) { string log = e.Message; return(null); } }
public List <BjInfoModel> GetBjInfo(RankBjModel rankBjModel) { var result = new List <BjInfoModel>(); var url = $"http://live.afreecatv.com:8079/app/index.cgi?szBjId={rankBjModel.BjID}"; var html = GetUserRankHtml(rankBjModel.BjID, url); var page = new BeautifulPage(html); var xPath = "/html/body/div[5]/div[4]/div[1]/div[2]/div[4]/ul/li"; var nodes = page.SelectNodes(xPath); for (int Idx = 0; Idx < nodes.Count(); Idx++) { var node = nodes?.ToList()?[Idx]; var name = node.Text?.Split(':')?[0].Trim() ?? string.Empty; if (string.IsNullOrEmpty(name)) { continue; } var pHtmlArray = node.Html?.Trim().Replace(" ", "").Split(new string[] { "<span>", "</span>" }, StringSplitOptions.RemoveEmptyEntries); var pCount = pHtmlArray[1]; var pUint = name == "방송시간" ? "시간" : "명"; //Console.WriteLine(rankBjModel.BjID + " nmae : " + name + "html : " + pHtml + "text : " + pText); if (node != null) { result.Add(new BjInfoModel() { BjID = rankBjModel.BjID, Name = name, Count = pCount, Unit = pUint, HistoryDepth = rankBjModel.HistoryDepth, }); } } return(result); }
private RankBjModel GetBjModel(ALLRANK allrank, RankingType rankingType) { if (string.IsNullOrEmpty(allrank.Bj_id)) { return(new RankBjModel()); } var bjModel = new RankBjModel() { BjID = allrank.Bj_id, BjNick = allrank.Bj_nick, BjImgUrl = $"http://stimg.afreecatv.com/LOGO/{allrank.Bj_id.Substring(0, 2)}/{allrank.Bj_id}/{allrank.Bj_id}.jpg" }; if (!int.TryParse(allrank.Total_rank, out int rank)) { return(null); } SetRank(ref bjModel, rank, rankingType); return(bjModel); }
private void SetRank(ref RankBjModel bjModel, int rank, RankingType rankingType) { switch (rankingType) { case RankingType.rookie: bjModel.RookieRanking = rank; break; case RankingType.viewer: bjModel.ViewerRanking = rank; break; case RankingType.favoriteup: bjModel.FavoriteupRanking = rank; break; case RankingType.up: bjModel.UpRanking = rank; break; case RankingType.mobile: bjModel.MobileRanking = rank; break; case RankingType.game: bjModel.GameRanking = rank; break; case RankingType.mobilegame: bjModel.MobilegameRanking = rank; break; case RankingType.sports_broadcast: bjModel.SportsBroadcastRanking = rank; break; case RankingType.sports_general: bjModel.SportsGeneralRanking = rank; break; case RankingType.talkcam: bjModel.TalkcamRanking = rank; break; case RankingType.mukbang: bjModel.MukbangRanking = rank; break; case RankingType.music: bjModel.MusicRanking = rank; break; case RankingType.pet: bjModel.PetRanking = rank; break; case RankingType.hobby: bjModel.HobbyRanking = rank; break; case RankingType.study: bjModel.StudyRanking = rank; break; case RankingType.dubradio: bjModel.DubradioRanking = rank; break; case RankingType.stock: bjModel.StockRanking = rank; break; case RankingType.enter: bjModel.EnterRanking = rank; break; case RankingType.videos: bjModel.VideosRanking = rank; break; case RankingType.favorite: bjModel.FavoriteRanking = rank; break; case RankingType.fanclub: bjModel.FanclubRanking = rank; break; } }
public void SetTargetRank(RankBjModel fromModel, RankBjModel toModel, RankingType rankingType) { int rank = GetRank(fromModel, rankingType); SetRank(ref toModel, rank, rankingType); }
private int GetRank(RankBjModel bjModel, RankingType rankingType) { switch (rankingType) { case RankingType.rookie: return(bjModel.RookieRanking); case RankingType.viewer: return(bjModel.ViewerRanking); case RankingType.favoriteup: return(bjModel.FavoriteupRanking); case RankingType.up: return(bjModel.UpRanking); case RankingType.mobile: return(bjModel.MobileRanking); case RankingType.game: return(bjModel.GameRanking); case RankingType.mobilegame: return(bjModel.MobilegameRanking); case RankingType.sports_broadcast: return(bjModel.SportsBroadcastRanking); case RankingType.sports_general: return(bjModel.SportsGeneralRanking); case RankingType.talkcam: return(bjModel.TalkcamRanking); case RankingType.mukbang: return(bjModel.MukbangRanking); case RankingType.music: return(bjModel.MusicRanking); case RankingType.pet: return(bjModel.PetRanking); case RankingType.hobby: return(bjModel.HobbyRanking); case RankingType.study: return(bjModel.StudyRanking); case RankingType.dubradio: return(bjModel.DubradioRanking); case RankingType.stock: return(bjModel.StockRanking); case RankingType.enter: return(bjModel.EnterRanking); case RankingType.videos: return(bjModel.VideosRanking); case RankingType.favorite: return(bjModel.FavoriteRanking); case RankingType.fanclub: return(bjModel.FanclubRanking); default: return(0); } }
public void SetBjModel(RankBjModel bjModel, string query) { var mysqlParams = new List <MysqlParam> { // 동작 구분 //new MysqlParam("@p_WorkingTag", MysqlDbType.VarChar, "AP"), // BJ 아이디 new MysqlParam("@BjID", MysqlDbType.VarChar, bjModel.BjID), // BJ 닉네임 new MysqlParam("@BjNick", MysqlDbType.VarChar, bjModel.BjNick), // BJ 사진 url new MysqlParam("@BjImgUrl", MysqlDbType.VarChar, bjModel.BjImgUrl), // new MysqlParam("@HistoryDepth", MysqlDbType.Int16, bjModel.HistoryDepth), // 아프리카 신입bj 랭킹 new MysqlParam("@RookieRanking", MysqlDbType.Int16, bjModel.RookieRanking), // 최고시청자 평균 new MysqlParam("@ViewerRanking", MysqlDbType.Int16, bjModel.ViewerRanking), // 애청자 증가수 new MysqlParam("@FavoriteupRanking", MysqlDbType.Int16, bjModel.FavoriteupRanking), // UP 수 new MysqlParam("@UpRanking", MysqlDbType.Int16, bjModel.UpRanking), // 모바일 new MysqlParam("@MobileRanking", MysqlDbType.Int16, bjModel.MobileRanking), // 게임 new MysqlParam("@GameRanking", MysqlDbType.Int16, bjModel.GameRanking), // 모바일게임 new MysqlParam("@MobilegameRanking", MysqlDbType.Int16, bjModel.MobilegameRanking), // 스포츠중계 new MysqlParam("@SportsBroadcastRanking", MysqlDbType.Int16, bjModel.SportsBroadcastRanking), // 스포츠일반 new MysqlParam("@SportsGeneralRanking", MysqlDbType.Int16, bjModel.SportsGeneralRanking), // 토크/캠방 new MysqlParam("@TalkcamRanking", MysqlDbType.Int16, bjModel.TalkcamRanking), // 먹방/쿡방 new MysqlParam("@MukbangRanking", MysqlDbType.Int16, bjModel.MukbangRanking), // 음악 new MysqlParam("@MusicRanking", MysqlDbType.Int16, bjModel.MusicRanking), // 펫방 new MysqlParam("@PetRanking", MysqlDbType.Int16, bjModel.PetRanking), // 취미 new MysqlParam("@HobbyRanking", MysqlDbType.Int16, bjModel.HobbyRanking), // 학습 new MysqlParam("@StudyRanking", MysqlDbType.Int16, bjModel.StudyRanking), // 더빙/라디오 new MysqlParam("@DubradioRanking", MysqlDbType.Int16, bjModel.DubradioRanking), // 주식/금융 new MysqlParam("@StockRanking", MysqlDbType.Int16, bjModel.StockRanking), // 엔터테인먼트 new MysqlParam("@EnterRanking", MysqlDbType.Int16, bjModel.EnterRanking), // 동영상 new MysqlParam("@VideosRanking", MysqlDbType.Int16, bjModel.VideosRanking), // 누적 애청자 수 new MysqlParam("@FavoriteRanking", MysqlDbType.Int16, bjModel.FavoriteRanking), // 누적 팬클럽 수 new MysqlParam("@FanclubRanking", MysqlDbType.Int16, bjModel.FanclubRanking), // 값 유효성 여부 //new MysqlParam("@iId", MysqlDbType.VarChar, bjModel.Valid), // 추가된 날짜 //new MysqlParam("@AddDate", MysqlDbType.Datetime, bjModel.AddDate) }; ExecuteNonQuery(query, mysqlParams, System.Data.CommandType.Text); }