コード例 #1
0
        public ActionResult MyInfo()
        {
            this.LoginCheck("MyInfo");

            List <Channel> MyChannels = new List<Channel>();
            List<Favorite> favo = new List<Favorite>();

            using (var context = new SharedPlayerContext())
            {
                var obj = (from a in context.Favorites.Where(x => x.MemberID == this.LoginMember.MemberID)
                           join b in context.Channels on a.ChannelID equals b.ChannelID
                           select new
                           {
                               ChannelID = b.ChannelID,
                               Title = b.Title,
                               CreateMemberID = b.CreateMemberID,
                               RegDate = b.RegDate
                           });

                foreach (var item in obj)
                {
                    MyChannels.Add(new Channel()
                    {
                        ChannelID = item.ChannelID,
                        Title = item.Title,
                        CreateMemberID = item.CreateMemberID,
                        RegDate = item.RegDate
                    });
                }
            }

            ViewBag.MyChannels = MyChannels;

            return View(this);
        }
コード例 #2
0
        /// <summary>
        /// 로그인 여부를 체크합니다.
        /// </summary>
        protected void LoginCheck(string _menuString = "")
        {
            //저장된 Token은 저장할 때 Cypto.Encode 메소드를 이용해 암호화 합니다.
            string UserToken = CryptoCookie.GetCookie("Token");
            this.MenuString = _menuString;
            if (String.IsNullOrEmpty(this.MenuString))
            {
                this.MenuString = "Home";
            }

            if (!String.IsNullOrEmpty(UserToken))
            {
                //Database에 연결하여 해당 토큰이 유효한 토큰 인지 확인합니다.
                using (var context = new SharedPlayerContext())
                {
                    //토큰 유효성 검사는 토큰값과 만료일이 기준이 됩니다.
                    LoginAuth auth = context.Auths.Where(x => x.Token.Equals(UserToken)).Where(x => x.ExpiredDate >= DateTime.Now).FirstOrDefault();

                    if (auth != null && auth.idx > 0)
                    {
                        this.LoginMember = context.Members.Where(x => x.MemberID == auth.MemberID).FirstOrDefault();
                        if (this.LoginMember != null && this.LoginMember.MemberID > 0)
                        {
                            //회원정보를 정상적으로 불러왔다면, 로그인을 성공한 것으로 간주합니다.
                            this.IsLogin = true;
                        }
                    }
                }
            }
        }
コード例 #3
0
        public async Task<ActionResult> Index()
        {
            this.LoginCheck("Channel");
            List<Channel> list = new List<Channel>();
            List<Music> music = new List<Music>();

            using (var context = new SharedPlayerContext())
            {
                list = await context.Channels.ToListAsync().ConfigureAwait(false);
                music = await context.Musics.ToListAsync().ConfigureAwait(false);
            }

            ViewBag.list = list;
            ViewBag.music = music;

            return View(this);
        }
コード例 #4
0
        public async Task<ActionResult> Player(int ChannelID)
        {
            this.LoginCheck();

            Channel channel = new Channel();
            List<Music> list = new List<Music>();
            using (var context = new SharedPlayerContext())
            {
                channel = await context.Channels.Where(x => x.ChannelID == ChannelID).FirstOrDefaultAsync().ConfigureAwait(false) ?? new Channel();
                list = await context.Musics.Where(x => x.ChannelID == ChannelID).OrderBy(x => x.Seq).ToListAsync().ConfigureAwait(false) ?? new List<Music>();
            }

            ViewBag.list = list;
            ViewBag.channel = channel;

            return View(this);
        }
コード例 #5
0
        public async Task<ActionResult> View(int ChannelID)
        {
            this.LoginCheck("Channel");

            Favorite favo = new Favorite();
            Channel channel = new Channel();
            List<Music> list = new List<Music>();
            using (var context = new SharedPlayerContext())
            {
                channel = await context.Channels.Where(x => x.ChannelID == ChannelID).FirstOrDefaultAsync().ConfigureAwait(false) ?? new Channel();
                list = await context.Musics.Where(x => x.ChannelID == ChannelID).OrderBy(x => x.Seq).ToListAsync().ConfigureAwait(false) ?? new List<Music>();
                favo = await context.Favorites.Where(x => x.ChannelID == ChannelID).Where(x => x.MemberID == this.LoginMember.MemberID).FirstOrDefaultAsync().ConfigureAwait(false) ?? new Favorite();
            }
;
            ViewBag.channel = channel;
            ViewBag.list = list;
            ViewBag.favo = favo;

            return View(this);
        }
コード例 #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            //Gzip압축 전송 설정
            //실서버인 경우에만 Gzip 압축 전송을 진행합니다.
            bool IsReal = System.Configuration.ConfigurationManager.AppSettings["IsReal"].Equals("True");
            if (IsReal)
            {
                GlobalFilters.Filters.Add(new CompressAttribute());
            }
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //WebGrease Set
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //EntityFramework MigrateDatabase
            Database.SetInitializer<SharedPlayerContext>(new MigrateDatabaseToLatestVersion<SharedPlayerContext, Configuration>());
            using (var context = new SharedPlayerContext())
            {
                var dbMigrator = new DbMigrator(new Configuration());
                dbMigrator.Update();
            }
        }
コード例 #7
0
        public JsonResult AddMusicProc(int ChannelID, int Seq, string Title, string URL)
        {
            this.LoginCheck();

            try
            {
                Music music = new Music();

                using (var context = new SharedPlayerContext())
                {    
                    music.ChannelID = ChannelID;
                    music.RegDate = DateTime.Now;
                    if (Seq > 0)
                    {
                        music.Seq = Seq;
                    }
                    else
                    {
                        if (context.Musics.Where(x => x.ChannelID == ChannelID).Count() > 0)
                        {
                            int num = context.Musics.Where(x => x.ChannelID == ChannelID).Max(x => x.Seq);
                            music.Seq = num + 1;
                        }
                        else
                        {
                            music.Seq = 1;
                        }
                    }
                    music.Title = Server.UrlDecode(Title);
                    music.URL = Server.UrlDecode(URL);
                    music.MemberID = this.LoginMember.MemberID;


                    context.Musics.Add(music);
                    context.SaveChanges();
                }

                if (music.MusicID > 0)
                {
                    return Json(new
                    {
                        Check = true,
                        Message = "",
                        ChannelID = ChannelID,
                        MusicID = music.MusicID,
                        UserName = this.LoginMember.NickName
                    });
                }
                else
                {
                    return Json(new
                    {
                        Check = false,
                        Message = "등록하지 못했습니다.",
                        ChannelID = ChannelID
                    });
                }
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    Check = false,
                    Message = ex.Message,
                    ChannelID = ChannelID
                });
            }
        }
コード例 #8
0
        public JsonResult RemoveFavorite(int ChannelID)
        {
            ReturnResult result = new ReturnResult();

            this.LoginCheck();

            using (var context = new SharedPlayerContext())
            {
                Channel channel = context.Channels.Where(x => x.ChannelID == ChannelID).FirstOrDefault();
                if (channel != null && channel.ChannelID > 0)
                {
                    Favorite favo = context.Favorites.Where(x => x.MemberID == this.LoginMember.MemberID).Where(x => x.ChannelID == ChannelID).FirstOrDefault();

                    if (favo != null && favo.FavoriteID > 0)
                    {
                        context.Favorites.Remove(favo);
                        context.SaveChanges();
                        result.Success();
                    }
                    else
                    {
                        result.Fail("대상을 찾을 수 없습니다.");
                    }
                }
                else
                {
                    result.Fail("대상을 찾을 수 없습니다.");
                }
            }

            return Json(result);
        }
コード例 #9
0
        public ActionResult JoinCompleteProc(string Token)
        {
            if (!String.IsNullOrEmpty(Token))
            {
                string HashToken = AES256.Decrypt(Token, this.Secret, true);
                if (!String.IsNullOrEmpty(HashToken))
                {
                    MailAuth auth = new MailAuth();
                    Member member = new Member();

                    using (var context = new SharedPlayerContext())
                    {
                        auth = context.MailAuths.Where(x => x.Token.Equals(HashToken)).Where(x => x.IsComplete == false).FirstOrDefault();

                        if (auth != null && auth.AuthID > 0)
                        {
                            member = context.Members.Where(x => x.MemberID == auth.MemberID).FirstOrDefault();
                            auth.IsComplete = true;
                            auth.AcceptDate = DateTime.Now;
                            member.IsMailAuth = true;
                            member.LastUpdate = DateTime.Now;
                            context.SaveChanges();
                            return View(this);
                        }
                        else
                        {
                            return RedirectToAction("ErrorGuide", "Home", new { ErrCode = 4901 });
                        }
                    }
                }
                else
                {
                    return RedirectToAction("ErrorGuide", "Home", new { ErrCode = 4902 });
                }
            }
            else
            {
                return RedirectToAction("ErrorGuide", "Home", new { ErrCode = 4903 });
            }
        }
コード例 #10
0
        public JsonResult LoginProc(string Email, string Password)
        {
            bool chk = false;
            string msg = String.Empty;

            try
            {
                Member member = new Member();
                using (var context = new SharedPlayerContext())
                {
                    member = context.Members.Where(x => x.Email.Equals(Email)).FirstOrDefault() ?? new Member();

                    if (member != null && member.MemberID > 0)
                    {
                        if (Sha512.ValidatePassword(Password, member.Password))
                        {
                            if (member.IsMailAuth)
                            {
                                LoginAuth auth = new LoginAuth();
                                auth.RegDate = DateTime.Now;
                                auth.ExpiredDate = Convert.ToDateTime(String.Format("{0} 23:59:59", DateTime.Now.ToString("yyyy-MM-dd")));
                                auth.UserBrowser = String.Format("{0} v{1}.{2}", Request.Browser.Browser, Request.Browser.MajorVersion, Request.Browser.MinorVersion);
                                auth.MemberID = member.MemberID;
                                auth.UserIP = Request.UserHostAddress;
                                auth.Token = Salt.RandomString(16);

                                int cnt = 0;
                                do
                                {
                                    auth.Token = Salt.RandomString(16);
                                    cnt = context.Auths.Where(x => x.Token.Equals(auth.Token)).Count();
                                } while (cnt > 0);

                                context.Auths.Add(auth);
                                context.SaveChanges();

                                CryptoCookie.SetCookie("Token", auth.Token);
                                chk = true;
                                msg = "";
                            }
                            else
                            {
                                chk = false;
                                msg = "메일인증이 완료되지 않았습니다.  메일을 확인해 주세요.";
                            }
                        }
                        else
                        {
                            chk = false;
                            msg = "아이디 또는 비밀번호가 일치하지 않습니다.";
                        }
                    }
                    else
                    {
                        chk = false;
                        msg = "아이디 또는 비밀번호가 일치하지 않습니다.";
                    }
                }
            }
            catch (Exception ex)
            {
                chk = false;
                msg = ex.Message;
                if (ex.InnerException != null)
                {
                    msg = ex.InnerException.Message;
                }
            }

            return Json(new {
                    Check = chk,
                    Message = msg
            });
        }
コード例 #11
0
        public JsonResult RecommendProc(int MusicID)
        {
            ReturnResult result = new ReturnResult();

            this.LoginCheck();

            using (var context = new SharedPlayerContext())
            {
                Music music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault();
                if (music != null && music.MusicID > 0)
                {
                    music.RecommendCount = music.RecommendCount + 1;
                    context.SaveChanges();
                    result.Success();
                }
                else
                {
                    result.Error("대상을 찾을 수 없습니다.");
                }
            }

            return Json(result);
        }
コード例 #12
0
        public JsonResult RemoveChannel(int ChannelID)
        {
            ReturnResult result = new ReturnResult();

            this.LoginCheck();

            using (var context = new SharedPlayerContext())
            {
                Channel channel = context.Channels.Where(x => x.ChannelID == ChannelID).FirstOrDefault();
                if (channel != null && channel.ChannelID > 0)
                {
                    if (channel.CreateMemberID == this.LoginMember.MemberID)
                    {
                        List<Music> music = context.Musics.Where(x => x.ChannelID == ChannelID).ToList();
                        if (music != null && music.Count > 0)
                        {
                            foreach (Music item in music)
                            {
                                context.Musics.Remove(item);
                            }
                        }
                        context.Channels.Remove(channel);
                        context.SaveChanges();
                        result.Success();
                    }
                    else
                    {
                        result.Error("채널을 삭제할 권한이 없습니다.");
                    }
                }
                else
                {
                    result.Error("채널이 존재하지 않습니다.");
                }
            }
            
            return Json(result);
        }
コード例 #13
0
        public JsonResult RemoveMusic(long MusicID)
        {
            ReturnResult result = new ReturnResult();

            this.LoginCheck();

            using (var context = new SharedPlayerContext())
            {
                Music music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault();
                if (music != null && music.MusicID > 0)
                {
                    Channel channel = context.Channels.Where(x => x.ChannelID == music.ChannelID).FirstOrDefault();
                    if (channel != null)
                    {
                        if (channel.CreateMemberID == this.LoginMember.MemberID || music.MemberID == this.LoginMember.MemberID)
                        {
                            context.Musics.Remove(music);
                            context.SaveChanges();
                            result.Success();
                        }
                        else
                        {
                            result.Error("삭제할 권한이 없습니다.");
                        }
                    }
                    else
                    {
                        result.Error("소속 채널에 오류가 있습니다.");
                    }
                }
                else
                {
                    result.Error("대상을 찾을 수 없습니다.");
                }
            }

            return Json(result);

        }
コード例 #14
0
        public JsonResult MusicInfo(long MusicID)
        {
            Music music = new Music();

            using (var context = new SharedPlayerContext())
            {
                music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault() ?? new Music();
            }

            return Json(new
            {
                User = this.LoginMember,
                Music = music
            });
        }
コード例 #15
0
        public JsonResult SeqDownProc(long MusicID)
        {
            bool chk = false;
            string msg = String.Empty;
            Music music = new Music();

            using (var context = new SharedPlayerContext())
            {
                music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault() ?? new Music();

                int num = music.Seq;

                Music nxtMusic = context.Musics.Where(x => x.ChannelID == music.ChannelID).Where(x => x.MusicID > music.MusicID).OrderBy(x => x.MusicID).FirstOrDefault();
                if (nxtMusic != null && nxtMusic.MusicID > 0)
                {
                    music.Seq = nxtMusic.Seq;
                    nxtMusic.Seq = num;
                    context.SaveChanges();
                    chk = true;
                    msg = "";
                }
                else
                {
                    chk = false;
                    msg = "교체할 대상이 없습니다.";
                }
            }

            return Json(new
            {
                Check = chk,
                Message = msg,
                MusicID = MusicID
            });
        }
コード例 #16
0
        public JsonResult JoinProc(Member member)
        {
            try
            {
                bool chk = false;
                string msg = String.Empty;

                member.RegDate = DateTime.Now;
                member.LastUpdate = DateTime.Now;
                member.IsMailAuth = false;
                member.Password = Sha512.CreateHash(member.Password);
                using (var context = new SharedPlayerContext())
                {
                    var checkList = context.Members.Where(x => x.Email.Equals(member.Email)).Count();
                    if (checkList > 0)
                    {
                        chk = false;
                        msg = "이미 사용중인 이메일 입니다.";
                    }
                    else
                    {
                        context.Members.Add(member);
                        context.SaveChanges();
                        if (member.MemberID > 0)
                        {
                            MailAuth auth = new MailAuth();
                            auth.AcceptDate = DateTime.Now;
                            auth.Email = member.Email;
                            auth.IsComplete = false;
                            auth.member = member;
                            auth.RegDate = DateTime.Now;
                            auth.Token = Salt.RandomString(16);
                            context.MailAuths.Add(auth);
                            context.SaveChanges();
                            if (auth.AuthID > 0)
                            {
                                string URL = String.Format("{0}://{1}/Member/JoinCompleteProc?Token={2}", Request.Url.Scheme, Request.Url.Host, AES256.Encrypt(auth.Token, this.Secret, true));
                                StringBuilder builder = new StringBuilder();
                                builder.Append(FileHandler.ReadFile(Server.MapPath("~/Content/MemberJoin.html"), Encoding.UTF8));
                                builder.Replace("{URL}", URL);
                                if (Mail.Send(member.Email, "[SharedPlayer.net] 회원가입 인증메일입니다.", builder.ToString()))
                                {
                                    chk = true;
                                }
                                else
                                {
                                    chk = false;
                                    msg = "인증메일 발송이 실패하였습니다. 잠시 후 다시 시도해 주세요.";
                                }
                            }
                            else
                            {
                                chk = false;
                                msg = "인증메일 발송이 실패하였습니다. 잠시 후 다시 시도해 주세요.";
                            }
                        }
                    }
                }

                return Json(new
                {
                    Check = chk,
                    Message = msg
                });
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    return Json(new
                    {
                        Check = false,
                        Message = ex.InnerException.InnerException.Message
                    });
                }
                else
                {
                    return Json(new
                    {
                        Check = false,
                        Message = "2. " + ex.Message
                    });
                }
            }
        }
コード例 #17
0
        public JsonResult UpdateMusicProc(int ChannelID, long MusicID, string Title, string URL)
        {
            this.LoginCheck();

            try
            {
                using (var context = new SharedPlayerContext())
                {
                    Music music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault();
                    if (music != null && music.MusicID > 0)
                    {
                        music.Title = Title;
                        music.URL = URL;
                        context.SaveChanges();

                        return Json(new
                        {
                            Check = true,
                            Message = "",
                            ChannelID = ChannelID,
                            MusicID = MusicID
                        });
                    }
                    else
                    {
                        return Json(new
                        {
                            Check = false,
                            Message = "대상을 찾을 수 없습니다.",
                            ChannelID = ChannelID
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                return Json(new
                {
                    Check = false,
                    Message = ex.Message,
                    ChannelID = ChannelID
                });
            }
        }
コード例 #18
0
        public JsonResult UserInfo(int MemberID)
        {
            Member member = new Member();

            using (var context = new SharedPlayerContext())
            {
                member = context.Members.Where(x => x.MemberID == MemberID).FirstOrDefault() ?? new Member();
            }

            if (member != null && member.MemberID > 0)
            {
                return Json(new
                {
                    Check = true,
                    Message = String.Empty,
                    Data = member
                });
            }
            else
            {
                return Json(new
                {
                    Check = false,
                    Message = "대상이 없습니다."
                });
            }
        }
コード例 #19
0
        public JsonResult RegistProc(string Title)
        {
            this.LoginCheck();

            Channel channel = new Channel();
            channel.CreateMemberID = this.LoginMember.MemberID;
            channel.RegDate = DateTime.Now;
            channel.Title = Title;
            using (var context = new SharedPlayerContext())
            {
                context.Channels.Add(channel);
                context.SaveChanges();
            }

            if (channel.ChannelID > 0)
            {
                return Json(new
                {
                    Check = true,
                    Message = "",
                    ChannelID = channel.ChannelID
                });
            }
            else
            {
                return Json(new
                {
                    Check = false,
                    Message = "등록하지 못했습니다."
                });
            }
        }
コード例 #20
0
 public ActionResult ListViewItem(string mode, int MusicID)
 {
     this.LoginCheck();
     ViewItem item = new ViewItem();
     using (var context = new SharedPlayerContext())
     {
         Music music = context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefault();
         Channel channel = context.Channels.Where(x => x.ChannelID == music.ChannelID).FirstOrDefault();
         item = new ViewItem(mode, channel, music, this.LoginMember);
     }
         
     return View(item);
 }
コード例 #21
0
        public async Task<ActionResult> ModMusic(int ChannelID, long MusicID)
        {
            this.LoginCheck("Channel");

            Channel channel = new Channel();
            Music music = new Music();
            using (var context = new SharedPlayerContext())
            {
                channel = await context.Channels.Where(x => x.ChannelID == ChannelID).FirstOrDefaultAsync().ConfigureAwait(false) ?? new Channel();
                music = await context.Musics.Where(x => x.MusicID == MusicID).FirstOrDefaultAsync().ConfigureAwait(false) ?? new Music();
            }

            ViewBag.channel = channel;
            ViewBag.music = music;

            return View(this);
        }
コード例 #22
0
        public JsonResult RemoveFavorite(int ChannelID)
        {
            this.LoginCheck();
            bool chk = false;
            string msg = String.Empty;

            using (var context = new SharedPlayerContext())
            {
                Favorite favo = context.Favorites.Where(x => x.ChannelID == ChannelID)
                    .Where(x => x.MemberID == this.LoginMember.MemberID)
                    .FirstOrDefault();

                if (favo != null && favo.FavoriteID > 0)
                {
                    context.Favorites.Remove(favo);
                    context.SaveChanges();
                    chk = true;
                    msg = "";
                }
                else
                {
                    chk = false;
                    msg = "대상이 없습니다.";
                }
            }

            return Json(new
            {
                Check = chk,
                Message = msg
            });
        }