/// <summary> /// 发送项目起始界面 /// </summary> public void SendProjectStartFile(Client client, string httpVersion, string realPath, string rootPath) { XmlHelper xmlHelper = new XmlHelper(); XmlNode node = xmlHelper.GetServerContext(rootPath + "\\conf\\server.xml"); string docBase = node.Attributes["docBase"].Value; string file = node.Attributes["default"].Value; string path = rootPath + "\\webapps"; string temp = rootPath + "\\webapps" + Init.Instance.DocBase; DirectoryInfo dirInfo1 = new DirectoryInfo(temp); DirectoryInfo dirInfo2 = new DirectoryInfo(realPath); if (dirInfo1.Exists && dirInfo2.Exists) { if (dirInfo1.FullName == dirInfo2.FullName || dirInfo1.Parent.FullName == dirInfo2.FullName) { path += docBase; } else { path += "\\ROOT"; } } else { path += "\\ROOT"; } if (!string.IsNullOrEmpty(file)) { path += "\\" + file; } else { path += "\\index.html"; } FileManager fileManager = new FileManager(); fileManager.SendFileToBroswer(client, httpVersion, "text/html", path, rootPath); }
/// <summary> /// 获取MIME类型 /// </summary> /// <param name="path"></param> /// <returns></returns> public string GetMimeType(string path, string rootPath) { string type = string.Empty; if (path.Contains(".")) { int pos = path.LastIndexOf('.'); string suffex = path.Substring(pos); XmlHelper xmlHelper = new XmlHelper(); string mimePath = rootPath + "\\conf\\Mimes.xml"; List<string> mimeList = xmlHelper.GetMimes(mimePath); foreach (string str in mimeList) { string[] strArr = str.Split(';'); if (strArr == null || strArr.Length == 0) continue; if (suffex == strArr[0]) { type = strArr[1]; break; } } } return type; }
/// <summary> /// 初始化数据 /// </summary> private void InitData() { HandlerBusinuess hb = new HandlerBusinuess(); string rootPath = GetRootPath(); XmlHelper xmlHelper = new XmlHelper(); XmlNode node = xmlHelper.GetServerContext(rootPath + "\\conf\\server.xml"); string docBase = node.Attributes["docBase"].Value; string file = node.Attributes["default"].Value; Init.Instance.DocBase = docBase; }