开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 319

TWT20161022/视频学习+在线考试+题库+直播

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (4)
标签 (8)
master
dev
beta
optimize
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
master
分支 (4)
标签 (8)
master
dev
beta
optimize
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (4)
标签 (8)
master
dev
beta
optimize
2.3
2.1.1.21041
2.0.8627
2.0.8499
2.0.8460
2.0.8384
2.0.8355
2.0Beta
Accessory.cs 13.62 KB
一键复制 编辑 原始数据 按行查看 历史
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using Newtonsoft.Json.Linq;
using Song.Entities;
using Song.ServiceInterfaces;
using Song.ViewData.Attri;
using WeiSha.Core;
namespace Song.ViewData.Methods
{
/// <summary>
/// 附件的管理
/// </summary>
[HttpPut,HttpGet]
public class Accessory : ViewMethod, IViewAPI
{
/// <summary>
/// 某一类的附件列表
/// </summary>
/// <param name="uid">这一类附件的uid</param>
/// <param name="type"></param>
/// <returns></returns>
[Cache(Expires = 20, AdminDisable = true)]
public List<Song.Entities.Accessory> List(string uid, string type)
{
List<Song.Entities.Accessory> acs = Business.Do<IAccessory>().GetAll(uid,type);
if (acs == null) return null;
//资源的虚拟路径和物理路径
string VirPath = WeiSha.Core.Upload.Get[type].Virtual;
string PhyPath = WeiSha.Core.Upload.Get[type].Physics;
foreach (Song.Entities.Accessory ac in acs)
{
if (System.IO.File.Exists(PhyPath + ac.As_FileName))
ac.As_FileName = VirPath + ac.As_FileName;
}
return acs;
}
/// <summary>
/// 上传视频附件,其实已经上传到服务器,此处只是创建数据库记录
/// </summary>
/// <param name="olid">章节id</param>
/// <param name="type">附件关联主题的类型,例如新闻是News</param>
/// <param name="fileinfo">文件信息</param>
/// <returns></returns>
[HttpPost]
[Admin, Teacher]
public Song.Entities.Accessory SaveOutlineVideoFile(long olid, string type, JObject fileinfo)
{
Song.Entities.Outline outline = Business.Do<IOutline>().OutlineSingle(olid);
if (outline == null)
{
throw new Exception("Not found entity for Outline!");
}
Business.Do<IAccessory>().Delete(outline.Ol_UID, type);
//创建附件对象
Song.Entities.Accessory acc = new Entities.Accessory();
JObject jo = fileinfo;
string filename = jo["filename"].ToString();
acc.As_Name = jo["name"].ToString();
acc.As_Type = type;
acc.As_CrtTime = DateTime.Now;
acc.As_Size = Convert.ToInt64(jo["size"].ToString());
acc.As_Uid = outline.Ol_UID;
acc.As_Extension = jo["ext"].ToString();
acc.As_IsOther = false;
acc.As_IsOuter = false;
acc.As_FileName = filename;
Business.Do<IAccessory>().Add(acc);
return acc;
}
/// <summary>
/// 选择视频附件,其实已经上传到服务器,此处只是创建数据库记录
/// </summary>
/// <param name="olid">章节id</param>
/// <param name="type">附件关联主题的类型,例如新闻是News</param>
/// <param name="fileinfo">文件信息</param>
/// <returns></returns>
[HttpPost]
[Admin, Teacher]
public bool SelectOutlineVideoFile(long olid, string type, JObject fileinfo)
{
Song.Entities.Outline outline = Business.Do<IOutline>().OutlineSingle(olid);
if (outline == null)
{
throw new Exception("Not found entity for Outline!");
}
//创建附件对象
Song.Entities.Accessory acc = Business.Do<IAccessory>().GetSingle(outline.Ol_UID, "CourseVideo");
if (acc == null) acc = new Entities.Accessory();
JObject jo = fileinfo;
string filename = jo["filename"].ToString();
acc.As_Name = jo["name"].ToString();
acc.As_Type = type;
acc.As_CrtTime = DateTime.Now;
acc.As_Size = Convert.ToInt64(jo["size"].ToString());
acc.As_Uid = outline.Ol_UID;
acc.As_Extension = jo["ext"].ToString();
acc.As_IsOther = false;
acc.As_IsOuter = false;
acc.As_FileName = filename;
if (acc.As_Id <= 0)
{
Business.Do<IAccessory>().Add(acc);
}
else
{
Business.Do<IAccessory>().Save(acc);
}
return true;
}
/// <summary>
/// 上传附件
/// </summary>
/// <param name="uid">附件关联主题的uid,例如文章的Art_Uid</param>
/// <param name="type">附件关联主题的类型,例如新闻是News</param>
/// <returns></returns>
[HttpPost]
[Teacher, Admin]
[Upload(Extension = "zip,rar,pdf,ppt,pptx,doc,docx,xls,xlsx", MaxSize = int.MaxValue, CannotEmpty = true)]
public List<Song.Entities.Accessory> Upload(string uid, string type)
{
//资源的虚拟路径和物理路径
string VirPath = WeiSha.Core.Upload.Get[type].Virtual;
string PhyPath = WeiSha.Core.Upload.Get[type].Physics;
if (this.Files.Count > 0)
{
foreach (string key in this.Files)
{
Song.Entities.Accessory entity = new Song.Entities.Accessory();
HttpPostedFileBase file = this.Files[key];
string filename = WeiSha.Core.Request.UniqueID() + Path.GetExtension(file.FileName);
file.SaveAs(PhyPath + filename);
//
entity.As_Name = file.FileName;
entity.As_FileName = filename;
entity.As_Size = file.ContentLength;
entity.As_Uid = uid;
entity.As_Type = type;
Business.Do<IAccessory>().Add(entity);
}
}
return this.List(uid, type);
}
/// <summary>
/// 获取附件记录
/// </summary>
/// <param name="uid">附件关联对象的Uid,例如章节视频,此处为章节的uid</param>
/// <param name="type"></param>
/// <returns></returns>
public Song.Entities.Accessory ForUID(string uid,string type)
{
Song.Entities.Accessory entity = Business.Do<IAccessory>().GetSingle(uid, type);
if (entity != null)
{
if (entity.As_Extension == "flv")
entity.As_FileName = Path.ChangeExtension(entity.As_FileName, ".mp4");
if (!entity.As_IsOther && !entity.As_IsOuter)
{
//资源的虚拟路径和物理路径
string VirPath = WeiSha.Core.Upload.Get[entity.As_Type].Virtual;
string PhyPath = WeiSha.Core.Upload.Get[entity.As_Type].Physics;
if (System.IO.File.Exists(Path.Combine(PhyPath, entity.As_FileName)))
{
entity.As_FileName = Path.Combine(VirPath, entity.As_FileName);
}
else
{
entity.As_FileName = "";
}
}
}
return entity;
}
/// <summary>
/// 修改附件信息
/// </summary>
/// <param name="entity">友情链接的分类</param>
/// <returns></returns>
[Admin,Teacher]
[HttpPost]
public bool Modify(Song.Entities.Accessory entity)
{
Song.Entities.Accessory old = Business.Do<IAccessory>().GetSingle(entity.As_Id);
if (old == null) throw new Exception("Not found entity for Accessory!");
old.Copy<Song.Entities.Accessory>(entity);
Business.Do<IAccessory>().Save(old);
return true;
}
/// <summary>
/// 设置视频地址为其它视频网页的播放页
/// </summary>
/// <param name="uid"></param>
/// <param name="type"></param>
/// <param name="url"></param>
/// <param name="outer">是否是外部视频</param>
/// <param name="other">是否是其它平台的播放页</param>
/// <returns></returns>
[Admin, Teacher]
[HttpPost]
public bool SaveOtherVideo(string uid, string type, string url, bool outer, bool other)
{
Song.Entities.Outline outline = Business.Do<IOutline>().OutlineSingle(uid);
if (outline == null)
{
throw new Exception("Not found entity for Outline!");
}
//创建附件对象
Song.Entities.Accessory acc = Business.Do<IAccessory>().GetSingle(outline.Ol_UID, "CourseVideo");
if (acc == null) acc = new Entities.Accessory();
acc.As_FileName = url;
acc.As_Name = outline.Ol_Name;
acc.As_Type = type;
acc.As_CrtTime = DateTime.Now;
acc.As_Uid = outline.Ol_UID;
acc.As_IsOther = other;
acc.As_IsOuter = outer;
if (acc.As_Id <= 0)
{
Business.Do<IAccessory>().Add(acc);
}
else
{
Business.Do<IAccessory>().Save(acc);
}
return true;
}
/// <summary>
/// 设置视频地址为外部地址
/// </summary>
/// <param name="uid"></param>
/// <param name="type"></param>
/// <param name="url"></param>
/// <returns></returns>
[Admin, Teacher]
[HttpPost]
public bool SaveOuterVideo(string uid, string type, string url)
{
Song.Entities.Outline outline = Business.Do<IOutline>().OutlineSingle(uid);
if (outline == null)
{
throw new Exception("Not found entity for Outline!");
}
//创建附件对象
Song.Entities.Accessory acc = Business.Do<IAccessory>().GetSingle(outline.Ol_UID, "CourseVideo");
if (acc == null) acc = new Entities.Accessory();
acc.As_FileName = url;
acc.As_Name = outline.Ol_Name;
acc.As_Type = type;
acc.As_CrtTime = DateTime.Now;
acc.As_Uid = outline.Ol_UID;
acc.As_IsOther = false;
acc.As_IsOuter = true;
if (acc.As_Id <= 0)
{
Business.Do<IAccessory>().Add(acc);
}
else
{
Business.Do<IAccessory>().Save(acc);
}
return true;
}
/// <summary>
/// 删除附件
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
[Admin, Teacher]
public int DeleteForID(string id)
{
int i = 0;
if (string.IsNullOrWhiteSpace(id)) return i;
string[] arr = id.Split(',');
foreach (string s in arr)
{
int idval = 0;
int.TryParse(s, out idval);
if (idval == 0) continue;
try
{
Business.Do<IAccessory>().Delete(idval);
i++;
}
catch (Exception ex)
{
throw ex;
}
}
return i;
}
/// <summary>
/// 删除附件
/// </summary>
/// <param name="uid"></param>
/// <param name="type"></param>
/// <returns></returns>
[HttpDelete]
[Admin,Teacher]
public bool DeleteForUID(string uid,string type)
{
Business.Do<IAccessory>().Delete(uid, type);
return true;
}
#region 文件列表
/// <summary>
/// 获取上传的文件列表
/// </summary>
/// <param name="pathkey">路径的key,是web.config中Upload节点项的key值</param>
/// <param name="search">按文件名检索</param>
/// <param name="ext">后缀名,如mp4(不带点),只能写一个</param>
/// <param name="index"></param>
/// <param name="size"></param>
/// <returns></returns>
[HttpPost,HttpGet]
public ListResult PagerForFiles(string pathkey, string search, string ext, int index, int size)
{
//资源的虚拟路径和物理路径
string virPath = WeiSha.Core.Upload.Get[pathkey].Virtual;
string phyPath = WeiSha.Core.Upload.Get[pathkey].Physics;
JArray list = new JArray();
System.IO.DirectoryInfo dir = new DirectoryInfo(phyPath);
System.IO.FileInfo[] files;
if (string.IsNullOrWhiteSpace(search))
files = dir.GetFiles("*." + ext);
else
files = dir.GetFiles("*" + search + "*." + ext);
int sum = files.Length;
for (int i = size * (index - 1); i < files.Length && i < size * index; i++)
{
System.IO.FileInfo f = files[i];
JObject jo = new JObject();
jo.Add("name", f.Name);
jo.Add("size", f.Length);
jo.Add("ext", f.Extension);
jo.Add("fullname", Path.Combine(virPath, f.Name));
jo.Add("crttime", f.CreationTime);
jo.Add("lasttime", f.LastWriteTime);
list.Add(jo);
}
Song.ViewData.ListResult result = new ListResult(list);
result.Index = index;
result.Size = size;
result.Total = sum;
return result;
}
#endregion
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

前后端分离,C#、Vue。web端采用ElementUI,手机端采用VantUI,管理后台采用WebdeskUI。直播、视频学习、试题练习、测试、考试、学习证明、成绩打印,实现"学、练、考"一体。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/wtt2016/LearningSystem.git
git@gitee.com:wtt2016/LearningSystem.git
wtt2016
LearningSystem
视频学习+在线考试+题库+直播
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /