开源 企业版 高校版 私有云 模力方舟 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
Learningcard.cs 20.16 KB
一键复制 编辑 原始数据 按行查看 历史
宋_微厦科技 提交于 2024年04月16日 18:26 +08:00 . 优化:学习卡的编辑界面重新布局
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 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
//using System.Web.Mvc;
using Song.Entities;
using Song.ServiceInterfaces;
using Song.ViewData.Attri;
using WeiSha.Core;
namespace Song.ViewData.Methods
{
/// <summary>
/// 学习卡管理
/// </summary>
[HttpPut, HttpGet]
public class Learningcard : ViewMethod, IViewAPI
{
#region 卡片信息
/// <summary>
/// 学员拥有的卡片数量
/// </summary>
/// <param name="acid">学员id</param>
/// <returns></returns>
public JObject AccountOfCount(int acid)
{
if (acid <= 0)
{
Song.Entities.Accounts acc = this.User;
if (acc != null) acid = acc.Ac_ID;
}
JObject jo = new JObject();
//学员拥有几个学习卡
int cardcount = Business.Do<ILearningCard>().AccountCardOfCount(acid);
//使用了几张
int usecount = cardcount - Business.Do<ILearningCard>().AccountCardOfCount(acid, 0);
jo.Add("count", cardcount);
jo.Add("usecount", usecount);
return jo;
}
/// <summary>
/// 学员拥有的学习卡
/// </summary>
/// <param name="acid">学员id</param>
/// <returns></returns>
public Song.Entities.LearningCard[] ForAccount(int acid)
{
if (acid <= 0)
{
Song.Entities.Accounts acc = this.User;
if (acc != null) acid = acc.Ac_ID;
}
//学员的学习卡信息
return Business.Do<ILearningCard>().AccountCards(acid);
}
/// <summary>
/// 使用学习卡
/// </summary>
/// <param name="code">卡号-密码</param>
/// <returns>关联的课程列表</returns>
[Student]
public JArray UseCode(string code)
{
JArray jarr = new JArray();
//开始验证
Song.Entities.LearningCard card = Business.Do<ILearningCard>().CardCheck(code);
Business.Do<ILearningCard>().CardUse(card, this.User);
//输出关联的课程
List<Song.Entities.Course> courses = Business.Do<ILearningCard>().CoursesForCard(card.Lc_Code, card.Lc_Pw);
for (int i = 0; i < courses.Count; i++)
{
Song.Entities.Course c = courses[i];
jarr.Add(c.Cou_Name);
}
return jarr;
}
/// <summary>
/// 使用学习卡,指定学习卡实体和学员账号实体
/// </summary>
/// <param name="card">学习卡的数据实体</param>
/// <param name="account">账号的数据实体</param>
/// <returns></returns>
[HttpPost,HttpGet(Ignore =true) ]
[Admin]
public bool UseCode(LearningCard card, Accounts account)
{
Business.Do<ILearningCard>().CardUse(card, account);
return true;
}
/// <summary>
/// 收下学习卡(可以暂时收入学习卡,之后再使用)
/// </summary>
/// <param name="code">卡号-密码</param>
/// <returns></returns>
[Student]
public bool AcceptCode(string code)
{
try
{
Song.Entities.LearningCard card = Business.Do<ILearningCard>().CardCheck(code);
if (card != null)
{
Song.Entities.Accounts acc = this.User;
if (card.Ac_ID == acc.Ac_ID) throw new Exception("您已经拥有过该学习卡");
Business.Do<ILearningCard>().CardReceive(card, this.User);
return true;
}
}
catch (Exception ex)
{
throw ex;
}
return false;
}
#endregion
#region 卡片设置项
/// <summary>
/// 学习卡的最小长度
/// </summary>
/// <returns></returns>
public int MinLength()
{
return Business.Do<ILearningCard>().MinLength();
}
/// <summary>
/// 根据ID获取学习卡设置
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public Song.Entities.LearningCardSet SetForID(int id)
{
return Business.Do<ILearningCard>().SetSingle(id);
}
/// <summary>
/// 判断学习卡名称是否重复
/// </summary>
/// <param name="name">学习卡名称</param>
/// <param name="id">学习卡id</param>
/// <returns></returns>
public bool SetExist(string name,int id)
{
return Business.Do<ILearningCard>().SetIsExist(name, id);
}
/// <summary>
/// 修改学习卡设置
/// </summary>
/// <param name="entity">习卡设置项(或叫主题)的实体对象</param>
/// <param name="scope">更改范围,1为更改使用的,已经使用的不改;2为更改全部,默认是1</param>
/// <returns></returns>
[Admin]
[HttpPost]
[HtmlClear(Not = "entity")]
public bool SetModify(Song.Entities.LearningCardSet entity,int scope)
{
int min_len = entity.Lcs_Count.ToString().Length + 1 + this.MinLength();
if (entity.Lcs_CodeLength < min_len) throw new Exception("学习码长度不得小于" + min_len);
Song.Entities.LearningCardSet old = Business.Do<ILearningCard>().SetSingle(entity.Lcs_ID);
if (old == null) throw new Exception("Not found entity");
old.Copy<Song.Entities.LearningCardSet>(entity);
Business.Do<ILearningCard>().SetSave(old, scope);
return true;
}
/// <summary>
/// 删除学习卡的设置项
/// </summary>
/// <param name="id">id,可以是多个,用逗号分隔</param>
/// <returns>返回删除的个数</returns>
[HttpPost(Ignore = true), HttpDelete, Admin]
public int SetDelete(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<ILearningCard>().SetDelete(idval);
i++;
}
catch (Exception ex)
{
throw ex;
}
}
return i;
}
/// <summary>
/// 添加学习卡的设置项
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[Admin]
[HttpPost]
[HtmlClear(Not = "entity")]
public bool SetAdd(Song.Entities.LearningCardSet entity)
{
int min_len = entity.Lcs_Count.ToString().Length + 1 + this.MinLength();
if (entity.Lcs_CodeLength < min_len) throw new Exception("学习码长度不得小于" + min_len);
try
{
Business.Do<ILearningCard>().SetAdd(entity);
return true;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 分页获取学习卡的设置项
/// </summary>
/// <param name="orgid">机构id</param>
/// <param name="search">检索字符,按课程名称</param>
/// <param name="size">每页几条</param>
/// <param name="index">第几页</param>
/// <returns></returns>
public ListResult SetPager(int orgid, string search, int size, int index)
{
int count = 0;
Song.Entities.LearningCardSet[] eas = null;
eas = Business.Do<ILearningCard>().SetPager(orgid, null, search, size, index, out count);
ListResult result = new ListResult(eas);
result.Index = index;
result.Size = size;
result.Total = count;
return result;
}
/// <summary>
/// 学习卡设置项所关联的课程
/// </summary>
/// <param name="id">学习卡设置项的id</param>
/// <returns></returns>
public List<Song.Entities.Course> SetCourses(int id)
{
Song.Entities.LearningCardSet set = Business.Do<ILearningCard>().SetSingle(id);
if (set == null) throw new Exception("设置项不存在");
List<Song.Entities.Course> courses = Business.Do<ILearningCard>().CoursesGet(set);
if (courses == null) return null;
for (int i = 0; i < courses.Count; i++)
{
courses[i] = _tran(courses[i]);
}
return courses;
}
/// <summary>
/// 学习卡设置项的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public JObject SetDataInfo(int id)
{
Song.Entities.LearningCardSet set = Business.Do<ILearningCard>().SetSingle(id);
//学习卡总数
int count = set.Lcs_Count;
int used = Business.Do<ILearningCard>().CardOfCount(-1, id, null, true, null);
int rollback = Business.Do<ILearningCard>().CardOfCount(-1, id, null, null, true);
int disable = Business.Do<ILearningCard>().CardOfCount(-1, id, false, null, null);
JObject jo = new JObject();
jo.Add("total", count);
jo.Add("used", used);
jo.Add("rollbak", rollback);
jo.Add("disable", disable);
jo.Add("usable", count - used - disable);
return jo;
}
#endregion
#region 学习卡相关
/// <summary>
/// 学习卡的卡号,分页获取
/// </summary>
/// <param name="lsid">学习卡设置项的id</param>
/// <param name="isused">true选择使用后的学习卡,为false选择所有</param>
/// <param name="isback">true为回滚后的学习卡,false为所有</param>
/// <param name="isdisable">true禁用的学习卡,false为所有</param>
/// <param name="card">供检索的学习卡卡号</param>
/// <param name="account">学员账号</param>
/// <param name="index"></param>
/// <param name="size"></param>
/// <returns></returns>
public ListResult CardPager(int lsid, bool isused, bool isback, bool isdisable, string card, string account, int index, int size)
{
//总记录数
int count = 0;
Song.Entities.LearningCard[] eas = null;
bool? isUsed = isused ? (bool?)true : null;
bool? isBack = isback ? (bool?)true : null;
bool? isEnable = !isdisable ? null : (bool?)false;
eas = Business.Do<ILearningCard>().CardPager(-1, lsid, card, account, isEnable, isUsed, isBack, size, index, out count);
Song.ViewData.ListResult result = new ListResult(eas);
result.Index = index;
result.Size = size;
result.Total = count;
return result;
}
/// <summary>
/// 某个设置项下的所有学习卡
/// </summary>
/// <param name="lsid">学习卡设置项(或叫主题)的id</param>
/// <param name="enable">是否启用,null取所有</param>
/// <param name="used">是否是使用过的,null取所有</param>
/// <returns></returns>
public List<Song.Entities.LearningCard> Cards(int lsid, bool? enable, bool? used)
{
//当前学习卡的编码
List<Song.Entities.LearningCard> cards = Business.Do<ILearningCard>().CardCount(-1, lsid, enable, used, -1);
return cards;
}
/// <summary>
/// 学习卡回滚
/// </summary>
/// <param name="code">卡号</param>
/// <param name="pw">密码</param>
/// <param name="clear">是否清理学习记录</param>
/// <returns></returns>
[Admin]
[HttpPost]
public LearningCard CardRollback(string code,string pw,bool clear)
{
Song.Entities.LearningCard card = Business.Do<ILearningCard>().CardSingle(code, pw);
//return card;
if (card == null) throw new Exception("未查询到学习卡,卡号或密码错误");
try
{
Business.Do<ILearningCard>().CardRollback(card, clear);
return card;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 更改学习卡启用状态
/// </summary>
/// <param name="code"></param>
/// <param name="pw"></param>
/// <param name="isenable"></param>
/// <returns></returns>
[Admin]
[HttpPost]
public bool CardChangeEnable(string code, string pw, bool isenable)
{
Song.Entities.LearningCard card = Business.Do<ILearningCard>().CardSingle(code, pw);
if(card==null) throw new Exception("未查询到学习卡,卡号或密码错误");
try
{
card.Lc_IsEnable = isenable;
Business.Do<ILearningCard>().CardSave(card);
return true;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 学员的学习卡
/// <summary>
/// 学员的学习卡
/// </summary>
/// <param name="acid">学员账号id</param>
/// <param name="isused">是否使用的学习卡,true取使用的,false取所有</param>
/// <param name="isback">是否回滚的</param>
/// <param name="isdisable">是否禁用的</param>
/// <param name="code">学习卡卡号</param>
/// <param name="index"></param>
/// <param name="size"></param>
/// <returns></returns>
public ListResult AccountCards(int acid, bool isused, bool isback, bool isdisable, string code, int index, int size)
{
//总记录数
int count = 0;
Song.Entities.LearningCard[] entities = null;
bool? isUsed = isused ? (bool?)true : null;
bool? isBack = isback ? (bool?)true : null;
bool? isEnable = !isdisable ? null : (bool?)false;
entities = Business.Do<ILearningCard>().AccountCards(acid, isUsed, isBack, isEnable, code, index, size, out count);
Song.ViewData.ListResult result = new ListResult(entities);
result.Index = index;
result.Size = size;
result.Total = count;
return result;
}
#endregion
#region 导出
private static string _output_item = "LearningCard";
/// <summary>
/// 生成导出的Excel文件
/// </summary>
/// <param name="id">学习卡设置项id</param>
/// <returns>name:学习卡主题,file:文件名,url:下载地址,date:创建时间</returns>
[HttpPost][Admin]
public JObject ExcelOutput(int id)
{
Song.Entities.LearningCardSet set = Business.Do<ILearningCard>().SetSingle(id);
DateTime date = DateTime.Now;
string filename = string.Format("{0}_{1}.xls", set.Lcs_ID.ToString(), date.ToString("yyyy-MM-dd hh-mm-ss"));
string filePath = WeiSha.Core.Upload.Get[_output_item].Physics + filename;
filePath = Business.Do<ILearningCard>().Card4Excel(filePath, set.Org_ID, id);
JObject jo = new JObject();
jo.Add("name", set.Lcs_Theme);
jo.Add("file", filename);
jo.Add("url", WeiSha.Core.Upload.Get[_output_item].Virtual + filename);
jo.Add("date", date);
return jo;
}
/// <summary>
/// 删除Excel文件
/// </summary>
/// <param name="filename">文件名,带后缀名,不带路径</param>
/// <returns></returns>
[HttpDelete]
[Admin]
public bool ExcelDelete(string filename)
{
string filePath = WeiSha.Core.Upload.Get[_output_item].Physics + filename;
if (System.IO.File.Exists(filePath))
{
System.IO.File.Delete(filePath);
return true;
}
return false;
}
/// <summary>
/// 删除某个学习卡的所有导出文件
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpDelete]
[Admin]
public int ExcelDeleteAll(int id)
{
string path = WeiSha.Core.Upload.Get[_output_item].Physics;
if (!System.IO.Directory.Exists(path)) return 0;
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(path);
int i = 0;
foreach (System.IO.FileInfo f in dir.GetFiles("*.xls"))
{
if (f.Name.IndexOf("_") < 0) continue;
string pre = f.Name.Substring(0, f.Name.IndexOf("_"));
if (id.ToString().Equals(pre, StringComparison.OrdinalIgnoreCase))
{
f.Delete();
i++;
}
}
return i;
}
/// <summary>
/// 已经生成的Excel文件
/// </summary>
/// <param name="id">学习卡设置项id</param>
/// <returns>name:学习卡主题,file:文件名,url:下载地址,date:创建时间</returns>
public JArray ExcelFiles(int id)
{
Song.Entities.LearningCardSet set = Business.Do<ILearningCard>().SetSingle(id);
List<System.IO.FileInfo> list = new List<System.IO.FileInfo>();
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(WeiSha.Core.Upload.Get[_output_item].Physics);
foreach (System.IO.FileInfo f in dir.GetFiles("*.xls"))
{
if (f.Name.IndexOf("_") < 0) continue;
string pre = f.Name.Substring(0, f.Name.IndexOf("_"));
if (id.ToString().Equals(pre, StringComparison.OrdinalIgnoreCase))
list.Add(f);
}
JArray jarr = new JArray();
IEnumerable<System.IO.FileInfo> query = from items in list orderby items.CreationTime descending select items;
string url = WeiSha.Core.Upload.Get[_output_item].Virtual;
foreach (var f in query)
{
System.IO.FileInfo file = (System.IO.FileInfo)f;
JObject jo = new JObject();
jo.Add("name", set.Lcs_Theme);
jo.Add("file", file.Name);
jo.Add("url", url + file.Name);
jo.Add("date", file.CreationTime);
jo.Add("size", file.Length);
jarr.Add(jo);
}
return jarr;
}
#endregion
#region 私有方法,处理对象的关联信息
/// <summary>
/// 处理课程信息,图片转为全路径,并生成clone对象
/// </summary>
/// <param name="cour">课程对象的clone</param>
/// <returns></returns>
private Song.Entities.Course _tran(Song.Entities.Course cour)
{
if (cour == null) return cour;
string pathKey = "Course";
string virPath = WeiSha.Core.Upload.Get[pathKey].Virtual;
string phyPath = WeiSha.Core.Upload.Get[pathKey].Physics;
Song.Entities.Course curr = cour.Clone<Song.Entities.Course>();
if (System.IO.File.Exists(phyPath + curr.Cou_Logo))
curr.Cou_Logo = virPath + curr.Cou_Logo;
else
curr.Cou_Logo = "";
if (System.IO.File.Exists(phyPath + curr.Cou_LogoSmall))
curr.Cou_LogoSmall = virPath + curr.Cou_LogoSmall;
else
curr.Cou_LogoSmall = "";
return curr;
}
#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 によって変換されたページ (->オリジナル) /