public void ReceiveCompleted(String body) { if (String.IsNullOrEmpty(body)) { return; } try { var result = new PageBuilder().BuildPage(body, 0); NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(result); result = doc.OuterHtml(); Signal_Excute("GlobalHub", x => { x.Invoke("CompileEvent", 0, result); }); } catch (Exception ex) { Signal_Excute("GlobalHub", x => { x.Invoke("CompileEvent", 1, ex.Message); }); } }
public void ReceiveCompleted(String body) { var Tasks = DB.yy_Page_Build_Task.Where(a => a.Status == 0).ToList(); if (Tasks == null || Tasks.Count < 1) { return; } var Builder = new PageBuilder(); StringBuilder sb = new StringBuilder(); foreach (var v in Tasks) { sb.AppendLine(v.FullName); try { //状态变更 ChangeStatus(v.ID, 1); //获取模板ID集合 Int64[] IDs = JsonConvert.DeserializeObject<Int64[]>(v.BuildEntity); if (v.BuildCount > 0 && v.BuildCount >= IDs.Length) { v.BuildCount = IDs.Length - 1; } for (Int64 vv = v.BuildCount; vv < IDs.Length; vv++) { try { Builder.Build(v.PageID, IDs[vv], (_PageIndex, _PageCount) => { ChangeProcess(v.ID, 1, _PageCount); return true; }); ChangeStatus(v.ID, 2); sb.AppendLine("OK"); } catch (Exception _ex) { String errorInfo = JsonConvert.SerializeObject(new { PageId = v.PageID, DBID = IDs[vv], Msg = _ex.Message, Source = _ex.Source, StackTrace = _ex.StackTrace, Time = DateTime.Now.ToString() }); sb.AppendLine(errorInfo); AddLog(v.ID,errorInfo+ ","); ChangeStatus(v.ID, 3); ChangeProcess(v.ID, 1); } Thread.Sleep(1); } Signal_Excute("GlobalHub", x => { x.Invoke("notify", 0, "页面["+v.FullName + "]生成完成。"); }); } catch (Exception ex) { String errorInfo = JsonConvert.SerializeObject(new { PageId = v.PageID, DBID = 0, Msg = ex.Message, Source = ex.Source, StackTrace = ex.StackTrace, Time = DateTime.Now.ToString() }); sb.AppendLine(errorInfo); AddLog(v.ID, errorInfo + ","); ChangeStatus(v.ID, 3); ChangeProcess(v.ID, 1); } } SendMail("站点生成完成!", sb.ToString()); }