public MyPageFollowingService(ComEntities dbContext) { // todo インスタンス管理 this.dbContext = dbContext; this.followInfoService = new FollowInfoService(this.dbContext); this.pointService = new PointInfoService(this.dbContext); }
/// <summary> /// Get AccessKey in table SnsCorpInformation /// </summary> /// <param name="socialType"></param> /// <returns>accessKey</returns> public static string GetAccessKey(string socialType) { string accessKey = string.Empty; ComEntities com = new ComEntities(); accessKey = com.SnsCorpInformation.SingleOrDefault(sns => sns.SnsName.Equals(socialType)).AccessKey; return accessKey; }
public UserFollowersService(ComEntities dbContext) { // todo インスタンス管理 this.dbContext = dbContext; this.followInfoService = new FollowInfoService(this.dbContext); this.pointService = new PointInfoService(this.dbContext); }
protected void Application_BeginRequest(object sender, EventArgs e) { var CookieName = "splgub"; if(HttpContext.Current.Request.Cookies[CookieName] == null) { HttpCookie myCookie = new HttpCookie(CookieName); string newGuid = Guid.NewGuid().ToString(); myCookie.Value = newGuid; myCookie.Expires = DateTime.MaxValue; HttpContext.Current.Response.Cookies.Add(myCookie); using (var comEntities = new ComEntities()) { var unitBrowser = new UnitBrowser(); unitBrowser.BrowserID = HttpContext.Current.Request.Browser.Id; unitBrowser.BrowserType = HttpContext.Current.Request.Browser.Type; unitBrowser.CookieGuid = newGuid; unitBrowser.UserAgent = HttpContext.Current.Request.UserAgent.ToString(); unitBrowser.CreatedDate = DateTime.Now; comEntities.UnitBrowser.Add(unitBrowser); comEntities.SaveChanges(); } } }
public MyPageGroupDetailsService(ComEntities dbContext) { // todo インスタンス管理 this.dbContext = dbContext; this.groupInfoService = new GroupInfoService(this.dbContext); this.pointInfoService = new PointInfoService(this.dbContext); this.systemDatetimeService = new SystemDatetimeService(); }
public MyPageGroupNewService(ComEntities dbContext) { // todo インスタンス管理 this.dbContext = dbContext; this.groupInfoService = new GroupInfoService(this.dbContext); this.followInfoService = new FollowInfoService(this.dbContext); this.pointInfoService = new PointInfoService(this.dbContext); }
public RallyService(PrizeEntities prizeEntities, ComEntities comEntities = null) { PrizeEntities = prizeEntities; if (comEntities != null) { ComEntities = comEntities; } }
/// <summary> /// Check email member logion exits /// </summary> /// <param name="email"></param> /// <returns>bool true or false</returns> public static bool CheckEmailForgotPass(string email) { bool result = false; ComEntities com = new ComEntities(); var data = com.Member.Where(p => p.Mail == email && p.Status == 1).ToList(); if (data.Count > 0) { result = true; } return result; }
/// <summary> /// get object member when user login /// </summary> /// <param name="email"></param> /// <param name="pass"></param> /// <returns></returns> public static Int64 GetMemberIDInSnsAuthInfo(string snsMemberID) { Int64 result = 0; ComEntities com = new ComEntities(); var snsAuthInformation= com.SnsAuthInformation.SingleOrDefault(u => u.SnsMemberID.Equals(snsMemberID)); if (snsAuthInformation !=null) { result = snsAuthInformation.MemberID; } return result; }
/// <summary> /// ログ書き込み /// </summary> public void WriteLog(ControllerContext filterContext) { //Todo:Importしたい var comEntities = new ComEntities(); using (var dbContextTransaction = comEntities.Database.BeginTransaction()) { try { var appActionLog = new AppActionLog() { MemberId = filterContext.HttpContext.Session["CurrentUser"].GetNullableLong(), ControllerName = filterContext.RouteData.Values["controller"].GetString(), ActionName = filterContext.RouteData.Values["action"].GetString(), Url = filterContext.HttpContext.Request.Url.UriString(), UserAgent = filterContext.HttpContext.Request.UserAgent, UrlReferrer = filterContext.HttpContext.Request.UrlReferrer.UriString(), SessionId = filterContext.HttpContext.Session.SessionID, Description = null, CreateDate = DateTime.Now }; var loggingDao = new LoggingDao(comEntities); loggingDao.CreateAppActionLog(appActionLog); comEntities.SaveChanges(); dbContextTransaction.Commit(); } finally { if (dbContextTransaction.UnderlyingTransaction.Connection != null && dbContextTransaction.UnderlyingTransaction.Connection.State == System.Data.ConnectionState.Open) { dbContextTransaction.Rollback(); } } } }
public static void SendMail(long memberID, string title, string body) { var com = new ComEntities(); using (var transaction = com.Database.BeginTransaction()) { //send mail var emailSender = new EmailSender(); try { string email = (from m in com.Member where m.MemberId == memberID select m.Mail).FirstOrDefault(); string result = emailSender.SendEmail2(email, body, title, null); if (result.Equals(Constants.EMAIL_SEND)) { List<MailDeliverCond> mailTypeList = new List<MailDeliverCond>(); foreach (var item in com.MailDeliverCondMaster) { // Set value for new row in MailDeliverCond table var newMailCondRow = new MailDeliverCond { MemberID = memberID, MailDelivCondID = item.MailDelivCondID, CreatedDate = System.DateTime.Now }; mailTypeList.Add(newMailCondRow); } //Insert to MailDeliverCond table com.MailDeliverCond.AddRange(mailTypeList); com.SaveChanges(); } } catch (Exception e) { transaction.Rollback(); } } }
public static IEnumerable<MyPageGroupListViewModel.GroupListInfo> GetGroupLists(ComEntities com, Int64 memberId) { List<MyPageGroupListViewModel.GroupListInfo> result = new List<MyPageGroupListViewModel.GroupListInfo> { }; if (memberId > 0) { var query = (from g in com.Groups join gm in com.GroupMember on g.GroupID equals gm.GroupID where gm.MemberID == memberId //自分が所属するグループを表示 && g.Status != false orderby g.CreatedDate descending select new MyPageGroupListViewModel.GroupListInfo { GroupID = g.GroupID, GroupName = g.GroupName, NumberOfMember = (from m in com.GroupMember where m.GroupID == g.GroupID select m).Count() } ); result = query.ToList(); } return result; }
public static Member GetMemberLogin(string email) { ComEntities com = new ComEntities(); var member = com.Member.SingleOrDefault(u => u.Mail.Equals(email)); return member; }
/// <summary> /// UserのTDKを取得する /// </summary> /// <param name="url">url</param> /// <returns>string array</returns> public static string[] GetUserTDK(string url, string pageNo, string nickName = null) { PageInfo page = null; ComEntities tkd = new ComEntities(); page = tkd.PageInfo.Find(pageNo); string title = string.Empty; string description = string.Empty; string keyWords = string.Empty; int userId, groupId; if (page != null) { title = page.Title; description = page.Description; keyWords = page.Keywords; } if (!String.IsNullOrEmpty(title) && title.Contains("(ユーザー名)")) { title = title.Replace("(ユーザー名)", nickName); } switch (pageNo) { case "4-1": break; case "4-2": break; case "4-3": break; case "4-4": break; case "4-5": break; } string[] result = new string[3]; result[0] = title; result[1] = description; result[2] = keyWords; return result; }
/// <summary> /// Get all topic that satisfy the conditions /// </summary> /// <param name=""></param> /// <returns>List of topicmaster that has the same id of news</returns> private static List<TopicMaster> GetTopicList(int type = 0, int? sportID = null, int? teamID = null, int? classificationType = null) { ComEntities news = new ComEntities(); var topicList = new List<TopicMaster>(); switch(type) { case 0: case 6: topicList = (from topicmaster in news.TopicMaster where (topicmaster.SportID == sportID.Value) select topicmaster).ToList(); break; case 2: topicList = (from topicmaster in news.TopicMaster where (topicmaster.SportID == sportID.Value && topicmaster.ClassificationType == classificationType.Value) select topicmaster).ToList(); break; case 1: //topicList = (from topicmaster in news.TopicMaster // where (topicmaster.ClassificationType == classificationType.Value && topicmaster.UniqueID == teamID.Value) // select topicmaster).ToList(); // break; case 3: topicList = (from topicmaster in news.TopicMaster where (topicmaster.SportID == sportID.Value && topicmaster.ClassificationType == classificationType.Value && topicmaster.UniqueID == teamID.Value) select topicmaster).ToList(); break; case 4: case 5: case 9: case 10: topicList = new List<TopicMaster>(news.TopicMaster); break; case 7: case 8: topicList = (from topicmaster in news.TopicMaster where (topicmaster.TopicID == sportID.Value) select topicmaster).ToList(); break; } return topicList; }
public static int GetTotalViewOfPost(long contributedId) { ComEntities com = new ComEntities(); var contributedReadingSum = (from r in com.ContributionReading select r).GroupBy(x => x.ContributeId).Select( l => new { ContributeID = l.Key, ReadingSum = l.Count() }).ToList(); var result = (from c in contributedReadingSum where c.ContributeID == contributedId select c).FirstOrDefault(); if (result != null) return result.ReadingSum; return 0; }
/// <summary> /// get object member when user login /// </summary> /// <param name="email"></param> /// <param name="pass"></param> /// <returns></returns> public static Member GetMemberLogin(string email, string pass) { ComEntities com = new ComEntities(); string passHash = Utils.MD5Hash(pass); var member = com.Member.SingleOrDefault(u => u.Mail.Equals(email) && u.Password.Equals(passHash) && u.Status == 1); return member; }
/// <summary> /// Title, description, keywords for 1-1, 1-2, 2-xxx, 5-xxx, 7-1 /// </summary> /// <param name="url">url</param> /// <returns>string array</returns> public static string[] GetHomeTDK(string url, string pageNO = "") { string mainUrl = url.Split('?').FirstOrDefault(); string[] subUrls = mainUrl.Split('/'); List<string> subUrlList = new List<string>(); for (int i = 0; i < subUrls.Count(); i++) { if (!string.IsNullOrEmpty(subUrls[i])) { subUrlList.Add(subUrls[i]); } } string pageNo = ""; int subUrlCount = subUrlList.Count(); if (!string.IsNullOrEmpty(pageNO)) { pageNo = pageNO; } else { if (subUrlCount == 0) pageNo = "1-1"; else { switch (subUrlList.ElementAt(0).ToLower()) { case "search": pageNo = "1-2"; break; case "login": pageNo = "2-2"; break; case "logout": pageNo = "2-3"; if (subUrlCount > 1) pageNo = "2-3-1"; break; case "delete": pageNo = "2-4"; if (subUrlCount > 1) pageNo = "2-4-1"; break; case "user_article": if (subUrlCount == 1) pageNo = "5-1"; else { switch (subUrlList.ElementAt(1).ToLower()) { case "new": if (subUrlCount >= 4) pageNo = "5-4"; break; case "edit": pageNo = "5-4-3"; break; default: if (subUrlCount == 3) { if (subUrlList.ElementAt(2).ToLower().Equals("sport") || subUrlList.ElementAt(2).ToLower().Equals("topic")) pageNo = "5-2"; else pageNo = "5-3"; } break; } } break; case "mypage": if (subUrlCount == 1) { pageNo = "3-1"; } else { switch (subUrlList.ElementAt(1).ToLower()) { case "expectedlist": pageNo = "3-2"; break; case "article": pageNo = "3-3"; break; case "group": if (subUrlCount == 2) pageNo = "3-4"; else { if (subUrlCount == 3) { if (subUrlList.ElementAt(2).ToLower().Equals("new")) pageNo = "3-4-2"; else pageNo = "3-4-1"; } else { if (subUrlList.ElementAt(3).ToLower().Equals("edit")) pageNo = "3-4-3"; } } break; case "following": pageNo = "3-5"; break; case "followers": pageNo = "3-6"; break; case "setting": if (subUrlCount == 2) pageNo = "3-7"; else { if (subUrlList.ElementAt(2).ToLower().Equals("address")) pageNo = "3-7-1"; else if (subUrlList.ElementAt(2).ToLower().Equals("address")) pageNo = "3-7-2"; } break; case "notice": pageNo = "3-8"; break; } } break; case "user": if (subUrlCount == 2) { pageNo = "4-1"; } else if (subUrlCount > 2) { switch (subUrlList.ElementAt(2).ToLower()) { case "expectedlist": pageNo = "4-2"; break; case "article": pageNo = "4-3"; break; case "following": pageNo = "4-4"; break; case "followers": pageNo = "4-5"; break; } } break; case "user_search": pageNo = "3-9"; break; case "prize": if (subUrlCount == 1) { pageNo = "6-1"; } else { if (subUrlCount == 2) { if (subUrlList.ElementAt(1).ToLower().Equals("ranking")) { pageNo = "6-4"; } else { pageNo = "6-3"; } } else if (subUrlCount == 3) { pageNo = "6-2"; } } break; case "support": if (subUrlCount > 1) { switch (subUrlList.ElementAt(1).ToLower()) { case "faq": pageNo = "12-1"; break; case "rules": pageNo = "12-2"; break; case "contact": pageNo = "12-3"; break; case "howto": pageNo = "12-4"; break; } } break; default: //pageNo = "1-1"; //if (subUrlCount > 2 && subUrlList.ElementAt(1).ToLower().Equals("news")) // pageNo = "7-1"; break; } } } if(string.IsNullOrEmpty(pageNo)) return (new string[4]); ComEntities tkd = new ComEntities(); var page = tkd.PageInfo.Find(pageNo); if (page == null) return (new string[4]); string title = string.Empty; string description = string.Empty; string keyWords = string.Empty; string robots = string.Empty; long newsclassID; switch (pageNo) { case "7-1": long newsItemId; if (!string.IsNullOrEmpty(subUrls[3]) && long.TryParse(subUrls[3], out newsItemId)) { ComEntities news = new ComEntities(); var newsDetail = (from n in news.BriefNews where n.NewsItemID == newsItemId && n.Status == Constants.NEWS_VALID_STATUS && n.CarryLimitDate >= DateTime.Now select n).FirstOrDefault(); if (newsDetail != null) { title = string.Format("{0} | スポログ", ShortenString(string.Format("{0} {1}", newsDetail.Headline, newsDetail.SubHeadline), 25)); description = ShortenString(newsDetail.newstext, 100); keyWords = subUrls[1]; } } break; case "5-2": if (!string.IsNullOrEmpty(subUrls[2]) && long.TryParse(subUrls[2], out newsclassID)) { string topicName = string.Empty; if (subUrls.Count() > 3 && (subUrls[3].ToLower().Equals("sport"))) { topicName = GetSportNameById(Convert.ToInt32(newsclassID)); } else { ComEntities news = new ComEntities(); var newsClass = (from n in news.TopicMaster where n.TopicID == newsclassID select n).FirstOrDefault(); if (newsClass != null) { topicName = newsClass.TopicName; } } title = page.Title.Replace("(トピック名)", topicName); description = page.Description.Replace("(トピック名)", topicName); keyWords = page.Keywords.Replace("(トピック名)", topicName); } break; case "5-3": if (!string.IsNullOrEmpty(subUrls[2]) && long.TryParse(subUrls[2], out newsclassID)) { ComEntities news = new ComEntities(); var topic = (from n in news.TopicMaster where n.TopicID == newsclassID select n).FirstOrDefault(); if (topic != null) { long contributedID; if (!string.IsNullOrEmpty(subUrls[3]) && long.TryParse(subUrls[3], out contributedID)) { var contribute = (from n in news.Contribution where n.ContributeId == contributedID select n).FirstOrDefault(); if (contribute != null) { title = string.Format("{0} | スポログ", ShortenString(contribute.Title, 25)); description = ShortenString(contribute.Body, 100); keyWords = page.Keywords.Replace("(トピック名)", topic.TopicName); if (page.CanAutomatic != null) if (page.CanAutomatic == 2 && contribute.Body.Count() < 100) robots = "none"; } } } } break; case "12-2": title = page.Title; description = ShortenString("スポログ利用規約(以下「本規約」といいます。)は、株式会社メディアーノ(以下「当社」といいます)が提供する「スポログ」情報提供サービス(以下「本サービス」といいます。)を利用するに当たり遵守しなければならない事項を定めたものであり、本サービスを利用する者(以下「利用者」といいます。)の全てに適用されるものとします。", 100); keyWords = page.Keywords; break; default: title = page.Title; description = page.Description; keyWords = page.Keywords; break; } if (page.CanAutomatic != null) { if (page.CanAutomatic == 1) { robots = "none"; } } string[] result = new string[4]; result[0] = title; result[1] = description; result[2] = keyWords; result[3] = robots; return result; }
/// <summary> /// フォローユーザーの予想の取得 /// </summary> /// <param name="com"></param> /// <param name="gameID"></param> /// <param name="memberId"></param> /// <param name="ClassClass"></param> /// <param name="SportsID"></param> /// <param name="FixBetSelectID"></param> /// <returns></returns> public static List<Member> GetExpectingMembers(ComEntities com, int gameID, long memberId, int ClassClass, int SportsID, int FixBetSelectID) { List<Member> result = (from fl in com.FollowList join ep in com.ExpectPoint on fl.MemberID.ToString() equals ep.CreatedAccountID join et in com.ExpectTarget on ep.ExpectTargetID equals et.ExpectTargetID join m in com.Member on fl.MemberID equals m.MemberId where fl.FollowerMemberID == memberId && et.UniqueID == (int)gameID && et.ClassClass == ClassClass //分類種別 && et.SportsID == SportsID && ep.BetSelectID == FixBetSelectID && ep.SituationStatus == 1//BET選択肢ID //TODO SituationStatus 要確認(!=2で見なくて良い?) select m).ToList(); //Old query - CucHTP //List<Member> result = (from fl in com.FollowList // join ep in com.ExpectPoint on fl.FollowerMemberID.ToString() equals ep.CreatedAccountID // join et in com.ExpectTarget on ep.ExpectTargetID equals et.ExpectTargetID // join m in com.Member on fl.FollowerMemberID equals m.MemberId // where fl.MemberID == memberId // && et.UniqueID == (int)gameID // && et.ClassClass == ClassClass //分類種別 // && et.SportsID == SportsID // && ep.BetSelectID == FixBetSelectID // && ep.SituationStatus == 1//BET選択肢ID // select m).ToList(); return result; }
/// <summary> /// Get all user that predicted for this game. /// </summary> /// <param name="com">Com context.</param> /// <param name="gameID">GameID.</param> /// <param name="sportID">SportID.</param> /// <param name="fixBetSelectID">FixBetSelectID : Team is selected.</param> /// <returns>List user bet for this team of this game.</returns> public static List<Member> GetAllUserPrediction(ComEntities com, int gameID, int classClass, int sportID, int fixBetSelectID) { List<Member> result = (from ep in com.ExpectPoint join et in com.ExpectTarget on ep.ExpectTargetID equals et.ExpectTargetID join m in com.Member on ep.CreatedAccountID equals m.MemberId.ToString() where et.UniqueID == gameID && et.UniqueID == (int)gameID && et.ClassClass == classClass //分類種別 && et.SportsID == sportID && ep.BetSelectID == fixBetSelectID //BET選択肢ID select m).ToList(); return result; }
/// <summary> /// 他の会員へのフォローを外す /// </summary> /// <param name="followerMemberId">フォローする会員(ログインユーザ)</param> /// <param name="followingMemberId">フォローされる会員</param> public static void unfollow(long followerMemberId, long followingMemberId) { if (followerMemberId <= 0) throw new Exception("フォローする側の会員IDが不正です。"); if (followingMemberId <= 0) throw new Exception("フォロー側の会員IDが不正です。"); if (followerMemberId == followingMemberId) throw new Exception("フォロー側とされる側の会員IDが同じです。"); using (ComEntities com = new ComEntities()) { using (var dbContextTransaction = com.Database.BeginTransaction()) { try { if (followerMemberId > 0 && followingMemberId > 0) { FollowList followList = (from f in com.FollowList where f.FollowerMemberID == followerMemberId && f.MemberID == followingMemberId select f).FirstOrDefault(); com.FollowList.Remove(followList); com.SaveChanges(); //お知らせ配信対象の削除 NoticeDeliverySubject nds = (from n in com.NoticeDeliverySubject where n.MemberId == (int)followingMemberId //フォローされた会員ID && n.ClassClass == 6 //フォロー && n.UniqueID == (int)followerMemberId //自分の会員ID && n.AlreadyReadFlg == false && n.NoticeDeliveryStatus == 1 select n).FirstOrDefault(); if (nds != null) { com.NoticeDeliverySubject.Remove(nds); com.SaveChanges(); } dbContextTransaction.Commit(); } } catch (Exception ex) { dbContextTransaction.Rollback(); throw ex; } } } }
public FollowInfoService(ComEntities dbContext) { this.dbContext = dbContext; }
/// <summary> /// Get all post that realted to a brief news /// </summary> public static IEnumerable<PostedInfoViewModel> GetRecentPosts(int type = 0, int? sportID = null, int? teamID = null, int? classificationType = null) { ComEntities com = new ComEntities(); NpbEntities npb = new NpbEntities(); JlgEntities jlg = new JlgEntities(); MlbEntities mlb = new MlbEntities(); short currentYear = Convert.ToInt16(DateTime.Now.Year); var topicList = GetTopicList(type, sportID, teamID, classificationType); var memberList = (from quot in com.QuotTopic join cont in com.Contribution on quot.ContributeID equals cont.ContributeId join contOrg in com.ContributionQuotOrg on cont.ContributeId equals contOrg.ContributeId join brief in com.BriefNews on new { c1 = contOrg.QuoteUniqueId1, c2 = contOrg.Status, c3 = contOrg.NewsClassId } equals new { c1 = brief.NewsItemID, c2 = (short)1, c3 = (long)1 } into brief_news from br in brief_news.DefaultIfEmpty() //join mr in com.MonthlyResults on new { g1 = contOrg.QuoteUniqueId2, g2 = contOrg.Status, g3 = contOrg.NewsClassId, g4 = contOrg.QuoteUniqueId1, g5 = currentYear, g6 = sportID.Value } // equals new { g1 = (long)mr.ReleVantMonth, g2 = (short)1, g3 = (long)6, g4 = (long)mr.MemberID, g5 = mr.ReleVantYear, g6 = mr.SportsID } into monthlyResult //from mlr in monthlyResult.DefaultIfEmpty() select new { TopicID = quot.TopicID, ContributeId = quot.ContributeID, ContributeDate = cont.ContributeDate, ModifiedDate = cont.ModifiedDate, Title = cont.Title, ContributedPicture = cont.ContributedPicture, Body = cont.Body, MemberId = cont.MemberId, NewsClassId = contOrg.NewsClassId, QuoteUniqueId1 = contOrg.QuoteUniqueId1, QuoteUniqueId2 = contOrg.QuoteUniqueId2, QuoteUniqueId3 = contOrg.QuoteUniqueId3, Status = contOrg.Status, //ReleVantYear = (mlr != null ? mlr.ReleVantYear : default(Nullable<short>)), //ReleVantMonth = (mlr != null ? mlr.ReleVantMonth : default(Nullable<short>)), //ExpectNumber = (mlr != null ? mlr.ExpectNumber : default(Nullable<int>)), //CorrectPercent = (mlr != null ? mlr.CorrectPercent : default(Nullable<short>)), //CorrectPoint = (mlr != null ? mlr.CorrectPoint : default(Nullable<int>)), HeadLine = (br != null ? br.Headline : null), SentFrom = (br != null ? br.SentFrom : null) } into member_list select member_list).ToList(); //Member var followMemberList = default(List<Member>); switch(type) { case 9: followMemberList = GetFollorMemberList(2); break; case 5: case 6: case 7: followMemberList = GetFollorMemberList(); break; case 10: //sportID save memberId in this case followMemberList = GetFollorMemberList(3, sportID ?? 0); break; default: followMemberList = new List<Member>(com.Member); break; } // total views of post var contributedReadingSum = (from r in com.ContributionReading select r).GroupBy(x => x.ContributeId).Select( l => new { ContributeID = l.Key, ReadingSum = l.Count() }).ToList(); // Npb info var npbTeamList = new List<TeamInfoMST>(npb.TeamInfoMST); var npbPlayerList = new List<PlayerInfoMST>(npb.PlayerInfoMST); var npbGameSSList = new List<GameInfoSS>(npb.GameInfoSS); // Jlg Info var jlgLeagueInfoList = new List<LeagueInfo>(jlg.LeagueInfo); var jlgTeamInfoTEList = new List<TeamInfoTE>(jlg.TeamInfoTE); var jlgPlayerInfoDIList = new List<PlayerInfoDI>(jlg.PlayerInfoDI); var jlgScheduleInfoList = new List<ScheduleInfo>(jlg.ScheduleInfo); // Mlb Info var mlbTeamInfoList = new List<TeamInfo>(mlb.TeamInfo); var mlbScheduleInfoList = (from ss in mlb.SeasonSchedule join dg in mlb.DayGroup on ss.DayGroupId equals dg.DayGroupId select new { GameID = ss.GameID, GameDate = dg.GameDate, HomeTeamFullName = ss.HomeTeamFullName, VisitorTeamFullName = ss.VisitorTeamFullName } into gameSS select gameSS).Distinct().ToList(); var result = default(IEnumerable<PostedInfoViewModel>); if (topicList == null || memberList == null) return result; var monthlyResultSum = (from m in com.MonthlyResults group m by new { m.MemberID, m.ReleVantMonth, m.ReleVantYear } into monthGroup select new { MemberID = monthGroup.Key.MemberID, ReleVantMonth = monthGroup.Key.ReleVantMonth, ReleVantYear = monthGroup.Key.ReleVantYear, ExpectNumber = monthGroup.Sum(x => x.ExpectNumber), CorrectPercent = monthGroup.Sum(x => (x.CorrectPercent * x.ExpectNumber)), CorrectPoint = monthGroup.Sum(x => x.CorrectPoint) }).ToList(); var query = from topic in topicList join mb in memberList on topic.TopicID equals mb.TopicID join m in followMemberList on mb.MemberId equals m.MemberId join c in contributedReadingSum on mb.ContributeId equals c.ContributeID into q_readings from views in q_readings.DefaultIfEmpty() join team in npbTeamList on new { c1 = (mb.NewsClassId == 2 ? mb.QuoteUniqueId3 : mb.QuoteUniqueId2), c2 = mb.Status, c3 = (mb.NewsClassId == 2 || mb.NewsClassId == 3) ? 1 : 2, c4 = mb.QuoteUniqueId1 } equals new { c1 = (long)team.TeamCD, c2 = (short)1, c3 = 1, c4 = (long)1 } into npb_team from npbTeam in npb_team.DefaultIfEmpty() join player in npbPlayerList on new { p1 = mb.QuoteUniqueId3, p2 = mb.Status, p3 = mb.NewsClassId, p4 = mb.QuoteUniqueId1 } equals new { p1 = (long)player.PlayerCD, p2 = (short)1, p3 = (long)3, p4 = (long)1 } into npb_player from npbPlayer in npb_player.DefaultIfEmpty() join game in npbGameSSList on new { g1 = mb.QuoteUniqueId2, g2 = mb.Status, g3 = (mb.NewsClassId == 4 || mb.NewsClassId == 5) ? 1 : 2, g4 = mb.QuoteUniqueId1 } equals new { g1 = (long)game.ID, g2 = (short)1, g3 = 1, g4 = (long)1 } into npb_game from npbGame in npb_game.DefaultIfEmpty() join league in jlgLeagueInfoList on new { l1 = mb.QuoteUniqueId2, l2 = mb.Status, l3 = mb.NewsClassId, l4 = mb.QuoteUniqueId1 } equals new { l1 = (long)league.LeagueID, l2 = (short)1, l3 = (long)2, l4 = (long)2 } into jlg_league from jlgLeague in jlg_league.DefaultIfEmpty() join jlgT in jlgTeamInfoTEList on new { t1 = (mb.NewsClassId == 2 ? mb.QuoteUniqueId3 : mb.QuoteUniqueId2), t2 = mb.Status, t3 = (mb.NewsClassId == 2 || mb.NewsClassId == 3) ? 1 : 2, t4 = mb.QuoteUniqueId1 } equals new { t1 = (long)jlgT.TeamID, t2 = (short)1, t3 = 1, t4 = (long)2 } into jlg_team from jlgTeam in jlg_team.DefaultIfEmpty() join jlgP in jlgPlayerInfoDIList on new { t1 = mb.QuoteUniqueId3, t2 = mb.Status, t3 = mb.NewsClassId, t4 = mb.QuoteUniqueId1 } equals new { t1 = (long)jlgP.PlayerID, t2 = (short)1, t3 = (long)3, t4 = (long)2 } into jlg_player from jlgPlayer in jlg_player.DefaultIfEmpty() join jlgSc in jlgScheduleInfoList on new { t1 = mb.QuoteUniqueId2, t2 = mb.Status, t3 = (mb.NewsClassId == 4 || mb.NewsClassId == 5) ? 1 : 2, t4 = mb.QuoteUniqueId1 } equals new { t1 = (long)jlgSc.GameID, t2 = (short)1, t3 = 1, t4 = (long)2 } into jlg_schedule from jlgSchedule in jlg_schedule.DefaultIfEmpty() join mlbT in mlbTeamInfoList on new { t1 = (mb.NewsClassId == 2 ? mb.QuoteUniqueId3 : mb.QuoteUniqueId2), t2 = mb.Status, t3 = (mb.NewsClassId == 2 || mb.NewsClassId == 3) ? 1 : 2, t4 = mb.QuoteUniqueId1 } equals new { t1 = (long)mlbT.TeamID, t2 = (short)1, t3 = 1, t4 = (long)3 } into mlb_team from mlbTeam in mlb_team.DefaultIfEmpty() join mlbSS in mlbScheduleInfoList on new { t1 = mb.QuoteUniqueId2, t2 = mb.Status, t3 = (mb.NewsClassId == 4 || mb.NewsClassId == 5) ? 1 : 2, t4 = mb.QuoteUniqueId1 } equals new { t1 = (long)mlbSS.GameID, t2 = (short)1, t3 = 1, t4 = (long)3 } into mlb_schedule from mlbSchedule in mlb_schedule.DefaultIfEmpty() join mr in monthlyResultSum on new { g1 = (mb.QuoteUniqueId2 % 100), g2 = mb.Status, g3 = mb.NewsClassId, g4 = mb.QuoteUniqueId1, g5 = (mb.QuoteUniqueId2 / 100) } equals new { g1 = (long)mr.ReleVantMonth, g2 = (short)1, g3 = (long)6, g4 = (long)mr.MemberID, g5 = (long)mr.ReleVantYear } into monthlyResult from mlr in monthlyResult.DefaultIfEmpty() select new PostedInfoViewModel { SportID = sportID ?? 0, TopicID = (int)topic.TopicID, ContributeId = mb.ContributeId, ContributeDate = mb.ContributeDate, ModifiedDate = mb.ModifiedDate, Title = mb.Title, ContributedPicture = mb.ContributedPicture, Body = mb.Body, MemberId = m.MemberId, Nickname = m.Nickname, ProfileImg = m.ProfileImg, NewsClassId = mb.NewsClassId, QuoteUniqueId1 = mb.QuoteUniqueId1, QuoteUniqueId2 = mb.QuoteUniqueId2, QuoteUniqueId3 = mb.QuoteUniqueId3, Status = mb.Status, ReleVantYear = (mlr != null ? mlr.ReleVantYear : default(Nullable<Int16>)), ReleVantMonth = (mlr != null ? mlr.ReleVantMonth : default(Nullable<Int16>)), ExpectNumber = (mlr != null ? mlr.ExpectNumber : default(Nullable<Int32>)), CorrectPercent = (mlr != null ? (short)mlr.CorrectPercent : default(Nullable<Int16>)), CorrectPoint = (mlr != null ? mlr.CorrectPoint : default(Nullable<Int32>)), HeadLine = mb.HeadLine, SentFrom = mb.SentFrom, NpbShortNameLeague = (npbTeam != null ? npbTeam.ShortNameLeague : null), NpbTeam = (npbTeam != null ? npbTeam.Team : null), NpbPlayer = (npbPlayer != null ? npbPlayer.Player : null), NpbHomeTeamName = (npbGame != null ? npbGame.HomeTeamName : null), NpbGameDate = (npbGame != null ? npbGame.GameDate : default(Nullable<int>)), NpbVisitorTeamName = (npbGame != null ? npbGame.VisitorTeamName : null), JlgLeagueNameS = (jlgLeague != null ? jlgLeague.LeagueNameS : null), JlgTeamName = (jlgTeam != null ? jlgTeam.TeamName : null), JlgPlayerName = (jlgPlayer != null ? jlgPlayer.PlayerName : null), JlgHomeTeamName = (jlgSchedule != null ? jlgSchedule.HomeTeamName : null), JlgGameDate = (jlgSchedule != null ? jlgSchedule.GameDate : default(Nullable<int>)), JlgAwayTeamName = (jlgSchedule != null ? jlgSchedule.AwayTeamName : null), MlbLeagueName = (mlbTeam != null ? mlbTeam.LeagueName : null), MlbTeamName = (mlbTeam != null ? mlbTeam.TeamFullName : null), MlbHomeTeamName = (mlbSchedule != null ? mlbSchedule.HomeTeamFullName : null), MlbGameDate = (mlbSchedule != null ? mlbSchedule.GameDate : default(Nullable<int>)), MlbAwayTeamName = (mlbSchedule != null ? mlbSchedule.VisitorTeamFullName : null), Views = ((views != null) ? views.ReadingSum : 0), PostMonth = mb.ContributeDate.Value.Month, PostYear = mb.ContributeDate.Value.Year } into posted_info select posted_info; if (query != null) result = query.GroupBy(c => c.ContributeId).Select(p => p.OrderBy(t => t.TopicID).FirstOrDefault()); return result.OrderByDescending(p => p.ContributeDate); }
public ExpectInfoService(ComEntities comEntities) { this.comEntities = comEntities; }
/// <summary> /// Get all members that follow the current login user /// /// </summary> /// <param name="withLoginMember">0 : Not add Login member, 1: add with login member, 2: with login member only</param> /// <returns>List of members that follow the current login user</returns> private static List<Member> GetFollorMemberList(int withLoginMember = 0, int inPutMemberId = 0) { ComEntities news = new ComEntities(); HttpContext context = HttpContext.Current; var followMemberList = default(List<Member>); if(withLoginMember == 3 && inPutMemberId > 0) { followMemberList = (from m in news.Member where m.MemberId == inPutMemberId select m).ToList(); return followMemberList; } if (context.Session["CurrentUser"] != null) { long memberID = Convert.ToInt64(context.Session["CurrentUser"].ToString()); switch(withLoginMember) { case 1: followMemberList = (from f in news.FollowList join m in news.Member on f.MemberID equals m.MemberId where f.FollowerMemberID == memberID || m.MemberId == memberID select m).ToList(); break; case 2: followMemberList = (from m in news.Member where m.MemberId == memberID select m).ToList(); break; default: followMemberList = (from f in news.FollowList join m in news.Member on f.MemberID equals m.MemberId where f.FollowerMemberID == memberID select m).ToList(); break; } } else { followMemberList = new List<Member>(news.Member); } return followMemberList; }
public static int GetNumberOfUnreadNotice(int memberID) { ComEntities com = new ComEntities(); DateTime oneMonthAgo = DateTime.Now.AddMonths(-1); int result = 0; var query = from ni in com.NoticeInfo join nds in com.NoticeDeliverySubject on ni.NoticeId equals nds.NoticeId where (ni.NoticeClass == 1 || ni.NoticeClass == 3) && nds.AlreadyReadFlg == false && nds.MemberId == memberID && nds.CreatedDate >= oneMonthAgo //&& ni.NoticeId <= 4 //PointsPtが付与の仕様確定待ちのため暫定で絞る select nds; if (query != null) result = query.Count(); else result = 0; return result; }
/// <summary> /// /// </summary> /// <param name="url">url</param> /// <returns>string array</returns> public static string[] GetNpbTDK(string url, string pageNo) { string mainUrl = url.Split('?').FirstOrDefault(); string[] subUrls = mainUrl.Split('/'); List<string> subUrlList = new List<string>(); for (int i = 0; i < subUrls.Count(); i++) { if (!string.IsNullOrEmpty(subUrls[i])) { subUrlList.Add(subUrls[i]); } } //var url = Context.Request.Path; PageInfo page = null; ComEntities tkd = new ComEntities(); page = tkd.PageInfo.Find(pageNo); string title = string.Empty; string description = string.Empty; string keyWords = string.Empty; int userId, groupId; if (page != null) { title = page.Title; description = page.Description; keyWords = page.Keywords; } else { return new string[4]; } int teamCD, playerCD, gameID; switch (pageNo) { case "8-1": case "8-2": case "8-3": case "8-4": case "8-5": case "8-7": title = page.Title; description = page.Description; keyWords = page.Keywords; break; case "8-5-1": case "8-5-2": case "8-5-3": case "8-5-4": case "8-5-5": case "8-5-6": case "8-5-7": if (!string.IsNullOrEmpty(subUrls[3]) && int.TryParse(subUrls[3], out teamCD)) { string teamName = GetTeamNameById(Constants.NPB_SPORT_ID, teamCD); title = page.Title.Replace("(チーム名)", teamName); description = page.Description.Replace("(チーム名)", teamName); keyWords = page.Keywords.Replace("(チーム名)", teamName); } break; case "8-5-8": case "8-5-9": if (!string.IsNullOrEmpty(subUrls[3]) && !string.IsNullOrEmpty(subUrls[4]) && int.TryParse(subUrls[3], out teamCD) && int.TryParse(subUrls[4], out playerCD)) { NpbEntities npb = new NpbEntities(); var teamName = (from t in npb.TeamInfoMST where t.TeamCD == teamCD select t).FirstOrDefault(); var playerName = (from t in npb.PlayerInfoMST where t.PlayerCD == playerCD select t).FirstOrDefault(); title = page.Title.Replace("(チーム名略称)", (teamName != null) ? teamName.ShortNameTeam : string.Empty).Replace("(選手名)", (playerName != null) ? playerName.Player : string.Empty); description = page.Description.Replace("(チーム名)", (teamName != null) ? teamName.Team : string.Empty).Replace("(選手名)", (playerName != null) ? playerName.Player : string.Empty); keyWords = page.Keywords.Replace("(チーム名)", (teamName != null) ? teamName.Team : string.Empty).Replace("(選手名)", (playerName != null) ? playerName.Player : string.Empty); } break; case "8-6": case "8-6-1": case "8-6-2": if (!string.IsNullOrEmpty(subUrls[3]) && int.TryParse(subUrls[3], out gameID)) { NpbEntities npb = new NpbEntities(); var gameNames = (from g in npb.GameInfoSS where g.ID == gameID select g).FirstOrDefault(); if (gameNames != null) { DateTime gd = DateTime.ParseExact(string.Format("{0}", gameNames.GameDate), "yyyyMMdd", null); string gameName = string.Format("{0} {1} vs {2}", gd.ToString("MM/dd"), gameNames.HomeTeamNameS, gameNames.VisitorTeamNameS); title = page.Title.Replace("(YY/MM 対戦カード名)", gameName); description = page.Description.Replace("(YY/MM 対戦カード名)", gameName); keyWords = page.Keywords.Replace("(チーム名1)", gameNames.HomeTeamName).Replace("(チーム名2)", gameNames.VisitorTeamName); } } break; case "7-1": long newsItemId; if (!string.IsNullOrEmpty(subUrls[3]) && long.TryParse(subUrls[3], out newsItemId)) { ComEntities news = new ComEntities(); var newsDetail = (from n in news.BriefNews where n.NewsItemID == newsItemId && n.Status == Constants.NEWS_VALID_STATUS && n.CarryLimitDate >= DateTime.Now select n).FirstOrDefault(); if (newsDetail != null) { title = string.Format("{0} | スポログ", ShortenString(newsDetail.Headline, 25)); description = ShortenString(newsDetail.newstext, 100); keyWords = subUrls[1]; } } break; default: title = page.Title; description = page.Description; keyWords = page.Keywords; break; } string robots = string.Empty; if (page.CanAutomatic != null) { if (page.CanAutomatic == 1) { robots = "none"; } } string[] result = new string[4]; result[0] = title; result[1] = description; result[2] = keyWords; result[3] = robots; return result; }
/// <summary> /// PrizeのTDKを取得する /// </summary> /// <param name="url">url</param> /// <returns>string array</returns> public static string[] GetPrizeTDK(string url, string pageNo) { ComEntities tkd = new ComEntities(); var page = tkd.PageInfo.Find(pageNo); string title = string.Empty; string description = string.Empty; string keyWords = string.Empty; int userId, prize_id; DateTime date; if (page != null) { title = page.Title; description = page.Description; keyWords = page.Keywords; } switch (pageNo) { case "6-1": break; case "6-2"://{YYYYMM}/{prize_id}/ break; case "6-3"://{YYYYMM}/ break; case "6-4": break; } string[] result = new string[3]; result[0] = title; result[1] = description; result[2] = keyWords; return result; }
public PredictService(ComEntities comEntities) { this.comEntities = comEntities; }
/// <summary> /// get object member when user login /// </summary> /// <param name="email"></param> /// <param name="pass"></param> /// <returns></returns> public static Member GetMemberByMemberId(Int64 memberId) { ComEntities com = new ComEntities(); return com.Member.SingleOrDefault(u => u.MemberId.Equals(memberId)); }