public ActionResult Create(TimeLineInfo info) { if (string.IsNullOrEmpty(info.Detail)) { return(Json(new APIJson(-1, "总得写点东西吧"))); } ResearchInfo infoResearch = ResearchBLL.GetList(a => a.ID == info.ResearchID).FirstOrDefault(); if (null == infoResearch || infoResearch.UserID != CurrentUser.ID) { return(Json(new APIJson(-1, "提交失败,数据有误"))); } info.CreateDate = DateTime.Now; string checkboxUser = Function.GetRequestString("checkboxUser"); info.UserInfo = new List <UserInfo>(); foreach (var item in checkboxUser.Split(',')) { int ID = Function.ConverToInt(item); if (ID <= 0) { continue; } UserInfo u = UserBLL.GetList(a => a.ID == ID).FirstOrDefault(); if (null != u && !info.UserInfo.Any(a => a.ID == ID)) { info.UserInfo.Add(u); } } if (TimeLineBLL.Create(info).ID > 0) { return(Json(new APIJson(0, "提交成功,分享到微信中时,你现在可以打开右上角菜单进行分享了", new { info.ID }))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }
public ActionResult Create(int ResearchID) { TimeLineInfo info = new TimeLineInfo(); info.ResearchID = ResearchID; return(View(info)); }
static async Task Demo_WorkerAsync() { TimeLineInfo tlinfo = new TimeLineInfo("job", _total_seconds); tlinfo.Run(_timer.Elapsed, TimeSpan.FromSeconds(3), 'B'); await Task.Delay(3000); tlinfo.Run(_timer.Elapsed, TimeSpan.FromSeconds(10), 'D'); }
static async Task Demo_CallerAsync() { TimeLineInfo tlinfo = new TimeLineInfo("caller", _total_seconds); tlinfo.Run(_timer.Elapsed, TimeSpan.FromSeconds(5), 'A'); var job = Demo_WorkerAsync(); tlinfo.Run(_timer.Elapsed, TimeSpan.FromSeconds(5), 'C'); await job; tlinfo.Run(_timer.Elapsed, TimeSpan.FromSeconds(10), 'E'); }
static void ScreenWorker() { TimeLineInfo timebar = new TimeLineInfo("clock", _total_seconds); while (_timer.Elapsed.TotalSeconds < _total_seconds) { timebar.Set(_timer.Elapsed, (((int)_timer.Elapsed.TotalSeconds + 1) % 5 == 0) ?'|':'='); Thread.Sleep(100); //Console.Clear(); Console.SetCursorPosition(0, 0); foreach (string tid in _chart.Keys) { Console.WriteLine($"{_chart[tid].Name.PadLeft(10)}: {new string(_chart[tid].Bar)}"); } } }
public ActionResult Create(TimeLineCommonInfo info) { TimeLineInfo infoTimeLine = TimeLineBLL.GetList(a => a.ID == info.TimeLineID).FirstOrDefault(); var infoCommonExist = infoTimeLine.TimeLineCommonInfo.FirstOrDefault(a => a.IsCommon == info.IsCommon && a.CreateUserID == CurrentUser.ID); var Result = infoTimeLine.TimeLineCommonInfo.OrderBy(c => c.ID).Select(c => new { c.ID, c.UserInfo.Name, c.IsCommon, c.Detail }); if (null != infoCommonExist && !info.IsCommon) { if (TimeLineCommonBLL.Delete(infoCommonExist)) { return(Json(new APIJson(0, "提交成功", Result))); } } info.CreateDate = DateTime.Now; info.CreateUserID = CurrentUser.ID; if (null == info.Detail) { info.Detail = string.Empty; } if (info.IsCommon && string.IsNullOrEmpty(info.Detail)) { return(Json(new APIJson(-1, "评论什么?至少写点东西吧"))); } if (TimeLineCommonBLL.Create(info).ID > 0) { info.UserInfo = CurrentUser; return(Json(new APIJson(0, "提交成功", Result))); } return(Json(new APIJson(-1, "提交失败,请重试"))); }
/// <summary> /// 得到B站的新番时间表 /// </summary> /// <param name="_MoeMushiDB">数据库连接</param> /// <returns></returns> private Task BILIBILI_Timeline_Global(MoeMushiContext _MoeMushiDB) { return(Task.Run(async() => { IsEnd = false; HttpHelpers httpHelpers = new HttpHelpers(); HttpItems httpItems = new HttpItems { Url = BILIBILI.BILIBILI_Timeline_Global(), Method = HttpMethod.Get.Method }; HttpResults results = httpHelpers.GetHtml(httpItems); HttpStatusCode code = results.StatusCode; if (code != HttpStatusCode.OK) { //这里放个提醒,嘿,链接可能失效 //这里写入数据库中比较好 } else { //将得到的数据转换 JObject json = JsonConvert.DeserializeObject <JObject>(results.Html); HashSet <int> hash = new HashSet <int>(); Dictionary <string, List <TimeLineInfo> > Data = new Dictionary <string, List <TimeLineInfo> >(); //是否成功?(success) string IsSuccess = json["message"].ToString(); //提取数据 JToken jToken = json["result"]; //开始遍历天 foreach (var Day in jToken) { List <TimeLineInfo> list = new List <TimeLineInfo>(); //开始遍历动画 foreach (var animeInfo in Day["seasons"]) { int season_id = (int)animeInfo["season_id"]; hash.Add(season_id); TimeLineInfo timeLineAnimeInfo = new TimeLineInfo { Date = DateTime.Parse((string)Day["date"]), Cover = (string)animeInfo["cover"], Ep_id = (int)animeInfo["ep_id"], Favorites = (int)animeInfo["favorites"], Is_published = (int)animeInfo["is_published"] > 0 ? true : false, Pub_index = (string)animeInfo["pub_index"], Pub_time = (string)animeInfo["pub_time"], Season_id = season_id, Square_cover = (string)animeInfo["square_cover"], Title = (string)animeInfo["title"], Delay = (int)animeInfo["delay"] > 0 ? true : false, Delay_index = (string)animeInfo["delay_index"], Delay_reason = (string)animeInfo["delay_reason"] }; list.Add(timeLineAnimeInfo); } Data.Add((string)Day["date"], list); } //先清除旧数据 _MoeMushiDB.TimeLines.FromSql("DELETE FROM TimeLineAnimeInfos"); foreach (var item in Data.Keys) { _MoeMushiDB.TimeLines.UpdateRange(Data[item]); } _MoeMushiDB.SaveChanges(); //先清除旧数据 _MoeMushiDB.AnimeInfoSeas.FromSql("DELETE FROM AnimeInfos"); //获取season_id的数据 foreach (int season_id in hash) { List <AnimeInfoSea> animeInfos = await Bilibili_Animeinfo(season_id, _MoeMushiDB); _MoeMushiDB.AnimeInfoSeas.UpdateRange(animeInfos); await Task.Delay(5000);//停5秒,防止过快被反爬虫 } _MoeMushiDB.SaveChanges(); } })); }
public TimeLineInfo(TimeLineInfo timelineInfo) { _timelineStartOffsetHNS = timelineInfo._timelineStartOffsetHNS; _timelineStartTimeStamp = timelineInfo._timelineStartTimeStamp; _isMonoIncrease = timelineInfo._isMonoIncrease; _90ktsoffset = timelineInfo._90ktsoffset; _last90kts = timelineInfo._last90kts; }