Exemplo n.º 1
0
        public IHttpActionResult SilVideo()
        {
            var video = Newtonsoft.Json.JsonConvert.DeserializeObject <Videolar>(HttpContext.Current.Request.Form["video"]);

            VideoDAL.silVideo(video);
            return(Ok(video));
        }
Exemplo n.º 2
0
        //public IHttpActionResult getServerName()
        //{
        //    return Json(string.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority));
        //}

        public IHttpActionResult hitUp()
        {
            var video = Newtonsoft.Json.JsonConvert.DeserializeObject <Videolar>(HttpContext.Current.Request.Form["video"]);

            VideoDAL.arttirHit(video);
            return(Json(video));
        }
Exemplo n.º 3
0
        public ActionResult Delete(string primaryKey)
        {
            var res = VideoDAL.Delete(primaryKey.ToStrArray());
            var msg = res > 0 ? "删除成功" : "删除失败";

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        public ActionResult GetForm()
        {
            int Id     = Convert.ToInt32(Request["primaryKey"]);
            var entity = VideoDAL.GetObject(Id);

            return(Content(entity.ToJson()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// X.PagedList插件渲染
        /// </summary>
        /// <returns></returns>
        public ActionResult TableByChaJ(int?page)
        {
            int PageNumber = page ?? 1;//page为null时默认值为1
            int PageSize   = 5;

            ViewData["page"] = PageNumber;

            var test = VideoDAL.GetListPage().ToPagedList(PageNumber, PageSize);

            return(View(test));
        }
Exemplo n.º 6
0
        public IHttpActionResult getirVideo()
        {
            var videolar = VideoDAL.getirVideolar();

            foreach (var v in videolar)
            {
                if (v.videoYoutubeLinki != null && v.videoYoutubeLinki == false)
                {
                    v.videoKapak = string.Format("{0}://{1}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority) + v.videoKapak; // HttpContext.Current.Request.Url.Scheme; //string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme , HttpContext.Current. Request.Url.Authority, Url.Content("~")); //  HttpContext.Current.Request.Url + v.videoUrl;
                }
            }
            ;
            return(Ok(videolar));
        }
Exemplo n.º 7
0
        public ActionResult Index(string keyWord, int limit, int page)
        {
            string cond     = swhere(keyWord);
            var    pageData = VideoDAL.GetVideoPageList("*", "id desc", limit, page, cond);
            var    result   = new LayPadding <VideoMDL>()
            {
                code  = 0,
                msg   = "success",
                data  = pageData.data,
                count = VideoDAL.SelectCount(cond)
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public ActionResult RequestSave(VideoMDL model)
        {
            HttpPostedFileBase pathfile = HttpContext.Request.Files["img"] as HttpPostedFileBase;
            string             path     = "/Upload/MyFile";
            //获取上传目录 转换为物理路径
            string uploadPath = Server.MapPath(path);

            //判断目录是否存在
            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            //保存文件的物理路径
            string saveFile = uploadPath + pathfile.FileName;

            //保存图片到服务器
            try
            {
                pathfile.SaveAs(saveFile);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            int res = 0;

            model.img = "../../Upload/Movies_Img/3.jpg";
            if (string.IsNullOrEmpty(Convert.ToString(model.id)))
            {
                model.img = "../../" + pathfile.FileName;
                res       = VideoDAL.Insert(model);
            }
            else
            {
                model.img = "../../" + pathfile.FileName;
                res       = VideoDAL.Update(model);
            }
            var msg = res > 0 ? "OK" : "Fail";

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 9
0
        public IHttpActionResult ekleGuncelle()
        {
            var video = Newtonsoft.Json.JsonConvert.DeserializeObject <Videolar>(HttpContext.Current.Request.Form["video"]);

            HttpFileCollection file = HttpContext.Current.Request.Files;

            try
            {
                for (int iCnt = 0; iCnt <= file.Count - 1; iCnt++)
                {
                    HttpPostedFile hpf = file[iCnt];
                    if (hpf.ContentLength > 0)
                    {
                        if (!Directory.Exists(HttpContext.Current.Server.MapPath("~/Content/")))
                        {
                            Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/Content/"));
                        }

                        var filename  = (Path.GetFileName(hpf.FileName));
                        var extension = Path.GetExtension(filename);
                        if (Path.GetExtension(filename) == ".mp4")
                        {
                            filename = Guid.NewGuid().ToString() + ".mp4";
                            var filePath = HttpContext.Current.Server.MapPath("~/Content/" + filename);
                            video.videoUrl = "/content/" + filename;
                            hpf.SaveAs(filePath);
                        }
                        else if (Path.GetExtension(filename) == ".png")
                        {
                            filename = Guid.NewGuid().ToString() + ".png";
                            var filePath = HttpContext.Current.Server.MapPath("~/Content/" + filename);
                            video.videoKapak = "/content/" + filename;
                            hpf.SaveAs(filePath);
                        }
                        else if (Path.GetExtension(filename) == ".jpeg")
                        {
                            filename = Guid.NewGuid().ToString() + ".jpeg";
                            var filePath = HttpContext.Current.Server.MapPath("~/Content/" + filename);
                            video.videoKapak = "/content/" + filename;
                            hpf.SaveAs(filePath);
                        }
                        else if (Path.GetExtension(filename) == ".jpg")
                        {
                            filename = Guid.NewGuid().ToString() + ".jpg";
                            var filePath = HttpContext.Current.Server.MapPath("~/Content/" + filename);
                            video.videoKapak = "/content/" + filename;
                            hpf.SaveAs(filePath);
                        }
                        else if (Path.GetExtension(filename) == ".svg")
                        {
                            filename = Guid.NewGuid().ToString() + ".svg";
                            var filePath = HttpContext.Current.Server.MapPath("~/Content/" + filename);
                            video.videoKapak = "/content/" + filename;
                            hpf.SaveAs(filePath);
                        }
                        else
                        {
                            throw new Exception("Dosya tipi desteklenmemektedir!!");
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
            VideoDAL.EkleGuncelleVideo(video);
            return(Ok(video));
        }
Exemplo n.º 10
0
        void Salvar()
        {
            if (Txt_Nome.Text.Trim() == "")
            {
                MessageBox.Show("Digite o nome do conteudo", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                processar = false;
            }
            if (CB_Materia.Text.Trim() == "")
            {
                MessageBox.Show("Selecione a matéria do conteudo", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                processar = false;
            }
            else
            {
                try
                {
                    Materia    m   = new Materia();
                    MateriaDAL dal = new MateriaDAL();
                    m = dal.Consultar(CB_Materia.Text.Trim());
                    if (m.ID == 0)
                    {
                        MessageBox.Show("Selecione uma matéria válida", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        processar = false;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Erro de Conexão. Tente novamente", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    processar = false;
                }
            }
            if (Grid_Conteudo.RowCount == 0)
            {
                MessageBox.Show("Insira os valores desse conteudo", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                processar = false;
            }
            if (processar)
            {
                Form load = new Form_Load();
                load.Show();
                load.Refresh();
                try
                {
                    Materia    m   = new Materia();
                    MateriaDAL dal = new MateriaDAL();
                    m = dal.Consultar(CB_Materia.Text.Trim());
                    ConteudoDAL dalcont = new ConteudoDAL();
                    if (cadastrar)
                    {
                        Conteudo cont = new Conteudo
                        {
                            Materia = m,
                            Nome    = Txt_Nome.Text.Trim(),
                            Usuario = UsuarioAtual.ID,
                            Ordem   = m.Conteudo.Count + 1,
                            Imagem  = null
                        };
                        if (PB_Foto.Image != null)
                        {
                            cont.Imagem = File.ReadAllBytes(PB_Foto.ImageLocation);
                        }
                        cont.ID = dalcont.Inserir(cont);
                        m       = dal.Consultar(m.ID);

                        foreach (var item in Conteudos.OrderBy(x => x.Ordem))
                        {
                            item.Conteudo = cont;
                            if (item.Texto != null)
                            {
                                TextoDAL daltex = new TextoDAL();
                                item.Texto.ID = daltex.Inserir(item.Texto);
                            }
                            if (item.Imagem != null)
                            {
                                ImagemDAL dalimg = new ImagemDAL();
                                item.Imagem.ID = dalimg.Inserir(item.Imagem);
                            }
                            if (item.Video != null)
                            {
                                VideoDAL dalvid = new VideoDAL();
                                item.Video.ID = dalvid.Inserir(item.Video);
                            }
                            ConteudoTextoDAL dalct = new ConteudoTextoDAL();
                            dalct.Inserir(item);
                        }
                        foreach (var item in Resumos)
                        {
                            item.Conteudo = cont;
                            ResumoDAL dalresum = new ResumoDAL();
                            dalresum.Inserir(item);
                        }
                        MessageBox.Show("Conteúdo cadastrado com sucesso", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimparCampos();
                    }
                    else
                    {
                        conteudo.Materia = m;
                        conteudo.Nome    = Txt_Nome.Text.Trim();
                        conteudo.Usuario = UsuarioAtual.ID;
                        if (PB_Foto.Image != null)
                        {
                            try
                            {
                                conteudo.Imagem = File.ReadAllBytes(PB_Foto.ImageLocation);
                            }
                            catch
                            {
                            }
                        }
                        else
                        {
                            conteudo.Imagem = null;
                        }
                        dalcont.Alterar(conteudo);

                        foreach (var item in Conteudos.OrderBy(x => x.Ordem))
                        {
                            item.Conteudo = conteudo;
                            if (item.Texto != null)
                            {
                                TextoDAL daltex = new TextoDAL();
                                item.Texto.ID = daltex.Inserir(item.Texto);
                            }
                            if (item.Imagem != null)
                            {
                                ImagemDAL dalimg = new ImagemDAL();
                                item.Imagem.ID = dalimg.Inserir(item.Imagem);
                            }
                            if (item.Video != null)
                            {
                                VideoDAL dalvid = new VideoDAL();
                                item.Video.ID = dalvid.Inserir(item.Video);
                            }
                            ConteudoTextoDAL dalct = new ConteudoTextoDAL();
                            dalct.Inserir(item);
                        }
                        foreach (var item in Resumos)
                        {
                            item.Conteudo = conteudo;
                            ResumoDAL dalresum = new ResumoDAL();
                            dalresum.Inserir(item);
                        }
                        MessageBox.Show("Conteúdo atualizado com sucesso", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        load.Close();
                        Close();
                    }
                }
                catch
                {
                    MessageBox.Show("Erro de Conexão. Tente novamente", "EnigmaADMSys", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                load.Close();
            }
            processar = true;
        }
Exemplo n.º 11
0
 public VideoService(VideoDAL videodal)
 {
     VideoDAL = videodal;
 }