Exemple #1
0
        public JsonResult PersonalAudioList(string currentpage, string pagesize)
        {
            #region 检查授权
            string           myMobilePhone      = "";//手机号
            AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance();
            AuthCodeClass    myAuthCodeClass    = new AuthCodeClass();
            bool             checkAuthCodeBool  = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance);
            #endregion
            //
            StatusData myStatusData = new StatusData();//返回状态
            //
            if (checkAuthCodeBool)
            {
                myMobilePhone = myAuthCodeInstance.mobilePhone;

                using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
                {
                    #region 翻页属性
                    int    recordCount  = 0;
                    int    pageCount    = 0;
                    string orderbyfiled = "AudioUserId";
                    bool   isDesc       = true;//倒序
                    //当前页
                    int sqlCurrentpage = 1;
                    if (!String.IsNullOrWhiteSpace(currentpage))
                    {
                        bool isOk = int.TryParse(currentpage, out sqlCurrentpage);
                        if (!isOk)
                        {
                            sqlCurrentpage = 1;
                        }
                    }
                    //页大小
                    int sqlPagesize = 10;
                    if (!String.IsNullOrWhiteSpace(pagesize))
                    {
                        bool isOk = int.TryParse(pagesize, out sqlPagesize);
                        if (!isOk)
                        {
                            sqlPagesize = 10;
                        }
                    }
                    #endregion
                    IQueryable <Child_Audio_List_User> myIQueryable = null;
                    myIQueryable = myOperating.Child_Audio_List_User.Where(p => p.MobilePhone == myMobilePhone);
                    //
                    if (myIQueryable != null)
                    {
                        var UserSoundTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).ToList();
                        List <PersonalSoundData> myUserSoundDataList = new List <PersonalSoundData>();
                        if (UserSoundTable != null)
                        {
                            for (int i = 0; i < UserSoundTable.Count(); i++)
                            {
                                PersonalSoundData myUserSoundDataItem = new PersonalSoundData();
                                Nullable <long>   myAudioId           = 0; //听一听主键
                                Nullable <int>    myAlbumId           = 0; //专辑主键
                                string            mySoundTitle        = "佚名";
                                string            myAudioWords        = "";
                                string            mySoundImage        = "";//封面图片
                                //
                                myAudioId = UserSoundTable[i].AudioId;
                                #region 音乐名称和歌词
                                if (myAudioId != null)
                                {
                                    Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAudioId);
                                    if (myChild_Audio_List != null)
                                    {
                                        myAlbumId    = myChild_Audio_List.AlbumId;
                                        mySoundTitle = myChild_Audio_List.AudioTitle;
                                        myAudioWords = myChild_Audio_List.AudioWords;
                                    }
                                }
                                #endregion
                                //
                                #region 背景图片
                                if (myAlbumId != null)
                                {
                                    Child_Audio_Album myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == myAlbumId);
                                    if (myChild_Audio_Album != null)
                                    {
                                        mySoundImage = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage;
                                    }
                                }
                                #endregion
                                //
                                myUserSoundDataItem.AudioUserId = UserSoundTable[i].AudioUserId;
                                myUserSoundDataItem.MusicTitle  = mySoundTitle;
                                myUserSoundDataItem.AudioImage  = mySoundImage;
                                myUserSoundDataItem.AudioWords  = myAudioWords;
                                myUserSoundDataItem.BgMusicUrl  = StaticVarClass.myDomain + UserSoundTable[i].BgMusicUrl;
                                myUserSoundDataItem.AudioUrl    = StaticVarClass.myDomain + UserSoundTable[i].AudioUrl;
                                myUserSoundDataItem.AddDate     = UserSoundTable[i].AddDate;
                                myUserSoundDataItem.TimeSeconds = UserSoundTable[i].TimeSeconds;
                                myUserSoundDataItem.PlayTimes   = UserSoundTable[i].PlayTimes;
                                myUserSoundDataItem.Status      = UserSoundTable[i].Status;
                                //
                                myUserSoundDataList.Add(myUserSoundDataItem);
                            }
                            myStatusData.dataPageCount   = pageCount;
                            myStatusData.dataRecordCount = recordCount;
                            myStatusData.dataTable       = myUserSoundDataList;
                        }
                    }
                    myStatusData.operateStatus = 200;
                }
            }
            else
            {
                myStatusData.operateStatus = 5;
            }
            return(Json(myStatusData));
        }
Exemple #2
0
        public JsonResult AudioList(string albumid, string currentpage, string pagesize, string orderby, string isasc)
        {                                               //orderby=1按日期排序,2按播放次数排序
            string mobilePhone = "";                    //
            //
            StatusData myStatusData = new StatusData(); //返回状态

            //
            #region 检查授权
            AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance();
            AuthCodeClass    myAuthCodeClass    = new AuthCodeClass();
            bool             checkAuthCodeBool  = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance);
            if (checkAuthCodeBool)
            {
                mobilePhone = myAuthCodeInstance.mobilePhone;
            }
            #endregion
            using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
            {
                #region 翻页属性
                int    recordCount  = 0;
                int    pageCount    = 0;
                string orderbyfiled = "OrderBy";
                bool   isDesc       = true;//倒序
                //
                #region 指定排序规则
                if (String.IsNullOrWhiteSpace(orderby))
                {
                    orderby = "";
                }
                switch (orderby)
                {
                case "1":
                    orderbyfiled = "AddDate";
                    break;

                case "2":
                    orderbyfiled = "PlayTimes";
                    break;
                }
                if (String.IsNullOrWhiteSpace(isasc))
                {
                    isasc = "";
                }
                switch (isasc)
                {
                case "1":
                    isDesc = true;    //倒序
                    break;

                case "2":
                    isDesc = false;    //倒序
                    break;
                }
                #endregion
                //当前页
                int sqlCurrentpage = 1;
                if (!String.IsNullOrWhiteSpace(currentpage))
                {
                    bool isOk = int.TryParse(currentpage, out sqlCurrentpage);
                    if (!isOk)
                    {
                        sqlCurrentpage = 1;
                    }
                }
                //页大小
                int sqlPagesize = 10;
                if (!String.IsNullOrWhiteSpace(pagesize))
                {
                    bool isOk = int.TryParse(pagesize, out sqlPagesize);
                    if (!isOk)
                    {
                        sqlPagesize = 10;
                    }
                }
                #endregion
                string soundBgImage = "";//获取专辑图片
                IQueryable <Child_Audio_List> myIQueryable = null;
                if (!String.IsNullOrWhiteSpace(albumid))
                {
                    int  myInt = 0;
                    bool isOk  = int.TryParse(albumid, out myInt);
                    if (isOk)
                    {
                        #region 背景图片
                        Child_Audio_Album myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == myInt);
                        if (myChild_Audio_Album != null)
                        {
                            soundBgImage = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage;
                        }
                        #endregion
                        myIQueryable = myOperating.Child_Audio_List.Where(p => p.AlbumId == myInt && p.Status == 200);
                    }
                    else
                    {
                        myIQueryable = null;
                        myStatusData.operateStatus = 400;
                    }
                }
                //
                if (myIQueryable != null)
                {
                    var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { AudioId = s.AudioId, AudioTitle = s.AudioTitle, AudioImage = soundBgImage, AudioUrl = StaticVarClass.myDomain + s.AudioUrl, PlayTimes = s.PlayTimes, TimeSeconds = s.TimeSeconds, AudioWords = s.AudioWords, AddDate = s.AddDate }).ToList();
                    //
                    myStatusData.dataPageCount   = pageCount;
                    myStatusData.dataRecordCount = recordCount;
                    myStatusData.dataTable       = BookTable;
                    myStatusData.operateStatus   = 200;
                }
            }
            return(Json(myStatusData));
        }
 public ActionResult AlbumList(string currentpage, long del = 0)
 {
     #region 翻页定义
     ViewBag.CurrentPage = 0;  //当前页
     ViewBag.PPage       = 0;  //上一页
     ViewBag.NPage       = 0;  //下一页
     ViewBag.PageCount   = 0;  //总页数
     ViewBag.RecordCount = 0;  //记录总数
     ViewBag.IsFirstPage = ""; //第一条记录,禁用首页和上一页
     ViewBag.IsEndPage   = ""; //最后条记录,禁用首页和下一页
     #endregion
     //
     ViewBag.Headline = "专辑管理";//栏目主题
     //
     ViewBag.DataList   = null;
     ViewBag.RecordItem = null;
     ViewBag.Operate    = "add";                                           //add添加;edit编辑取出数据;editsave编辑保存
     //
     StatusData myStatusData = new StatusData();                           //返回状态
     //
     using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作
     {
         #region  除
         if (del > 0)
         {
             Child_Audio_Album myDelRecord = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == del);
             if (myDelRecord != null)
             {
                 FunctionClass.delFile(myDelRecord.AlbumImage);
                 myOperating.Child_Audio_Album.Remove(myDelRecord);
                 myOperating.SaveChanges();
             }
         }
         #endregion
         //
         #region 翻页属性
         int    recordCount  = 0;
         int    pageCount    = 0;
         string orderbyfiled = "OrderBy";
         //
         //当前页
         int sqlCurrentpage = 1;
         if (!String.IsNullOrWhiteSpace(currentpage))
         {
             bool isOk = int.TryParse(currentpage, out sqlCurrentpage);
             if (!isOk)
             {
                 sqlCurrentpage = 1;
             }
         }
         //页大小
         int sqlPagesize = 10;
         #endregion
         //
         #region 取出内容
         IQueryable <Child_Audio_Album> myIQueryable = null;
         myIQueryable = myOperating.Child_Audio_Album;
         //
         if (myIQueryable != null)
         {
             List <Child_Audio_Album> BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true).ToList();
             //
             ViewBag.DataList = BookTable;
             #region 页数取值
             ViewBag.CurrentPage = sqlCurrentpage;
             ViewBag.PageCount   = pageCount;
             ViewBag.RecordCount = recordCount;
             if (sqlCurrentpage > 1)
             {
                 ViewBag.PPage = sqlCurrentpage - 1;
             }
             else
             {
                 ViewBag.IsFirstPage = "disabled";
                 ViewBag.PPage       = 1;
             }
             if (sqlCurrentpage < pageCount)
             {
                 ViewBag.NPage = sqlCurrentpage + 1;
             }
             else
             {
                 ViewBag.NPage     = sqlCurrentpage;
                 ViewBag.IsEndPage = "disabled";
             }
             #endregion
         }
         #endregion
     }
     return(View());
 }
Exemple #4
0
        public ActionResult Share(int classtype = 0, long aboutid = 0)
        {
            ShareModel myShareModel = new ShareModel();

            myShareModel.ClassType  = classtype;//属于哪一个表的内容
            myShareModel.AboutTitle = "芮卡家园";
            //
            #region 根据类别取出分享的内容
            using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作
            {
                switch (classtype)
                {///1点一点;2听一听;3看一看;
                ///4课程讲解;5幼儿公开课;6教育技能;
                ///7操作说明;8教师社区;9精彩瞬间;
                case 1:    //点一点
                    #region 点一点
                    Child_Book_Click myChild_Book_Click = new Child_Book_Click();
                    myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == aboutid);
                    if (myChild_Book_Click != null)
                    {
                        myShareModel.AboutTitle = myChild_Book_Click.BookName;
                        if (!String.IsNullOrWhiteSpace(myChild_Book_Click.BookImage))
                        {
                            myShareModel.AboutImages = StaticVarClass.BookClickResourceUrl + myChild_Book_Click.BookImage;
                        }
                    }
                    #endregion
                    return(View("ShareClick", myShareModel));

                //break;
                case 2:    //2听一听
                    #region 听一听
                    Child_Audio_List myChild_Audio_List = new Child_Audio_List();
                    myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutid);
                    if (myChild_Audio_List != null)
                    {
                        myShareModel.AboutTitle = myChild_Audio_List.AudioTitle;
                        #region 取专辑图片
                        int AlibumId = myChild_Audio_List.AlbumId;
                        try
                        {
                            Child_Audio_Album myChild_Audio_Album = new Child_Audio_Album();
                            myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == AlibumId);
                            if (myChild_Audio_Album != null)
                            {
                                if (!String.IsNullOrWhiteSpace(myChild_Audio_Album.Anchor))
                                {
                                    myShareModel.AboutAuthor = myChild_Audio_Album.Anchor;
                                }
                                if (!String.IsNullOrWhiteSpace(myChild_Audio_Album.AlbumImage))
                                {
                                    myShareModel.AboutImages = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage;
                                }
                            }
                        }
                        catch { }
                        #endregion
                        if (!String.IsNullOrWhiteSpace(myChild_Audio_List.AudioUrl))
                        {
                            myShareModel.AboutAudio = StaticVarClass.myDomain + myChild_Audio_List.AudioUrl;
                        }
                        myShareModel.AboutContent = myChild_Audio_List.AudioWords;
                        DateTime myDateTime = DateTime.Now;
                        DateTime.TryParse(myChild_Audio_List.AddDate.ToString(), out myDateTime);
                        myShareModel.AddDate = myDateTime;
                    }
                    #endregion
                    break;

                case 3:    //3看一看
                    #region  一看
                    Child_Video_List myChild_Video_List = new Child_Video_List();
                    myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == aboutid);
                    if (myChild_Video_List != null)
                    {
                        myShareModel.AboutTitle = myChild_Video_List.VideoTitle;
                        if (!String.IsNullOrWhiteSpace(myChild_Video_List.VideoImage))
                        {
                            myShareModel.AboutImages = StaticVarClass.myDomain + myChild_Video_List.VideoImage;
                        }
                        if (!String.IsNullOrWhiteSpace(myChild_Video_List.VideoUrl))
                        {
                            myShareModel.AboutVideo = StaticVarClass.myDomain + myChild_Video_List.VideoUrl;
                        }

                        myShareModel.AboutContent = myChild_Video_List.VideoDes;
                        DateTime myDateTime = DateTime.Now;
                        DateTime.TryParse(myChild_Video_List.AddDate.ToString(), out myDateTime);
                        myShareModel.AddDate = myDateTime;
                    }
                    #endregion
                    break;

                case 4:
                case 5:
                case 6:
                case 7:    //4课程讲解;5幼儿公开课;6教育技能;7操作说明
                    #region 教师视频
                    Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List();
                    myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == aboutid);
                    if (myTeacher_Video_List != null)
                    {
                        myShareModel.AboutTitle = myTeacher_Video_List.VideoTitle;
                        if (!String.IsNullOrWhiteSpace(myTeacher_Video_List.VideoImage))
                        {
                            myShareModel.AboutImages = StaticVarClass.myDomain + myTeacher_Video_List.VideoImage;
                        }
                        if (!String.IsNullOrWhiteSpace(myTeacher_Video_List.VideoUrl))
                        {
                            myShareModel.AboutVideo = StaticVarClass.myDomain + myTeacher_Video_List.VideoUrl;
                        }
                        myShareModel.AboutContent = myTeacher_Video_List.VideoDes;
                        DateTime myDateTime = DateTime.Now;
                        DateTime.TryParse(myTeacher_Video_List.AddDate.ToString(), out myDateTime);
                        myShareModel.AddDate = myDateTime;
                    }
                    #endregion
                    break;

                case 8:    //8教师社区
                    #region 教师社区
                    Teacher_Article myTeacher_Article = new Teacher_Article();
                    myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == aboutid);
                    if (myTeacher_Article != null)
                    {
                        myShareModel.AboutTitle = myTeacher_Article.ArticleTitle;
                        if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleImages))
                        {
                            myShareModel.AboutImages = StaticVarClass.myDomain + myTeacher_Article.ArticleImages;
                        }
                        if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleVideo))
                        {
                            myShareModel.AboutVideo = StaticVarClass.myDomain + myTeacher_Article.ArticleVideo;
                        }
                        myShareModel.AboutContent = myTeacher_Article.ArticleContent;
                        DateTime myDateTime = DateTime.Now;
                        DateTime.TryParse(myTeacher_Article.AddDate.ToString(), out myDateTime);
                        myShareModel.AddDate = myDateTime;
                    }
                    #endregion
                    break;

                case 9:    //9精彩瞬间
                    #region 精彩瞬间
                    Discover_Article myDiscover_Article = new Discover_Article();
                    myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == aboutid);
                    if (myDiscover_Article != null)
                    {
                        myShareModel.AboutTitle   = myDiscover_Article.ArticleTitle;
                        myShareModel.AboutImages  = myDiscover_Article.ArticleImages;
                        myShareModel.AboutVideo   = myDiscover_Article.ArticleVideo;
                        myShareModel.AboutContent = myDiscover_Article.ArticleContent;
                        DateTime myDateTime = DateTime.Now;
                        DateTime.TryParse(myDiscover_Article.AddDate.ToString(), out myDateTime);
                        myShareModel.AddDate = myDateTime;
                    }
                    #endregion
                    break;
                }
            }
            #endregion

            return(View(myShareModel));
        }
 //
 #region 专辑添加-编辑
 public ActionResult AlbumAdd(AudioAlbumModel model, string ReturnUrl, Nullable <int> myid = 0)
 {
     #region 获取来路路径
     if (System.Web.HttpContext.Current.Request.UrlReferrer != null)
     {
         ViewBag.ReturnUrl = System.Web.HttpContext.Current.Request.UrlReferrer.PathAndQuery;
     }
     #endregion
     ViewBag.Headline    = "专辑添加";                                         //栏目主题
     ViewBag.ButtonValue = "添加";                                           //按钮名称
     using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作
     {
         if ((myid > 0) && (model.Operate == null))
         {
             int mySelfId = 0;
             int.TryParse(myid.ToString(), out mySelfId);
             ViewBag.Headline    = "专辑编辑";
             ViewBag.ButtonValue = "修改";
             model.Operate       = "edit";
             //
             #region 取出数据
             Child_Audio_Album editRecord = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == mySelfId);
             if (editRecord != null)
             {
                 model.AlbumId      = editRecord.AlbumId;
                 model.AlbumTitle   = editRecord.AlbumTitle;
                 model.Anchor       = editRecord.Anchor;
                 model.AlbumImage   = editRecord.AlbumImage;
                 model.AlbumDescrib = editRecord.AlbumDescrib;
                 model.OrderBy      = editRecord.OrderBy;
             }
             #endregion
         }
         else if (model.Operate == "add")
         {
             #region 保存添加
             if (ModelState.IsValid)
             {
                 Child_Audio_Album addRecord = new Child_Audio_Album();
                 addRecord.ClassId      = 0;
                 addRecord.AlbumTitle   = model.AlbumTitle;
                 addRecord.Anchor       = model.Anchor;
                 addRecord.AlbumImage   = model.AlbumImage;
                 addRecord.AlbumDescrib = model.AlbumDescrib;
                 addRecord.AddDate      = DateTime.Now;
                 addRecord.AudioCount   = 0;
                 addRecord.PlayTimes    = 0;
                 addRecord.OrderBy      = model.OrderBy;
                 addRecord.Status       = 200;
                 //
                 myOperating.Child_Audio_Album.Add(addRecord);
                 myOperating.SaveChanges();
                 model = null;
                 //
                 return(RedirectToLocal(ReturnUrl));
             }
             else
             {
                 ModelState.AddModelError("", "输入错误");
             }
             #endregion
         }
         else if (model.Operate == "edit")
         {
             #region 保存编辑
             if (ModelState.IsValid)
             {
                 Child_Audio_Album editSaveRecord = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == model.AlbumId);
                 if (editSaveRecord != null)
                 {
                     editSaveRecord.AlbumTitle   = model.AlbumTitle;
                     editSaveRecord.Anchor       = model.Anchor;
                     editSaveRecord.AlbumImage   = model.AlbumImage;
                     editSaveRecord.AlbumDescrib = model.AlbumDescrib;
                     editSaveRecord.OrderBy      = model.OrderBy;
                     //
                     myOperating.SaveChanges();
                     //
                     return(RedirectToLocal(ReturnUrl));
                 }
             }
             else
             {
                 ModelState.AddModelError("", "输入错误");
             }
             #endregion
         }
         else
         {
             model.Operate = "add";
             #region 默认值
             try
             {
                 model.OrderBy = myOperating.Child_Audio_Album.Max(p => p.OrderBy) + 1;
             }
             catch
             {
                 model.OrderBy = 0;
             }
             if (model.OrderBy == null)
             {
                 model.OrderBy = 1;
             }
             #endregion
         }
     }
     //
     return(View(model));
 }