/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public IActionResult Index(string id) { if (!ZeroApplication.Config.TryGetConfig(id, out var config)) { config = ZeroApplication.Config.Stations.FirstOrDefault(p => p.StationType == ZeroStationType.Api); } StationDocument doc; if (config == null) { doc = new StationDocument { Name = id, Caption = "无文档", Description = "无文档" }; } else if (!SystemManager.Instance.LoadDocument(config.StationName, out doc)) { doc = new StationDocument { Name = config.Name, Caption = config.Caption, Description = config.Description }; } return(View(doc)); }
/// <summary> /// 下载文档 /// </summary> /// <returns></returns> public bool LoadDocument(string name, out StationDocument doc) { ZeroResultData result; try { result = CallCommand("doc", name); if (!result.InteractiveSuccess || result.State != ZeroOperatorStateType.Ok) { ZeroTrace.WriteError("LoadDocument", result); doc = null; return(false); } } catch (Exception e) { ZeroTrace.WriteException("LoadDocument", e); doc = null; return(false); } if (!result.TryGetValue(ZeroFrameType.Status, out var json)) { ZeroTrace.WriteError("LoadDocument", "Empty"); doc = null; return(false); } try { doc = JsonConvert.DeserializeObject <StationDocument>(json); return(true); } catch (Exception e) { ZeroTrace.WriteException("LoadDocument", e, json); doc = null; return(false); } }