public void Start() { if (_isArchivedInstalled("DMSArchiv")) { DMS.Session.Init("DMSArchiv"); } else { Connection conn = new Connection(SimpleServerExtensionMethods.GetDataPath("DMSArchiv"), "DMSArchiv"); Start(); } var hostConfig = new HostConfiguration { UrlReservations = new UrlReservations { CreateAutomatically = true }, }; if (hostUrl == null) { hostUrl = "http://localhost:8089/"; } hostNancy = new NancyHost(hostConfig, new Uri(hostUrl)); hostNancy.Start(); }
public View() { Get["/View/GetConfig"] = _ => { var config = DMS.Session.GetConfig(); return(config); }; Get["/View/LoadDocument"] = _ => { string path = Request.Query["path"]; string objid = Request.Query["id"]; int type = int.Parse(Request.Query["type"]); string hexValue = SimpleServerExtensionMethods.GetHexValue(objid); string folder = SimpleServerExtensionMethods.GetHexFolder(objid); string file = string.Empty; if (path != null && path != string.Empty) { file = path; } else if (type == 258) //pdf { file = SimpleServerExtensionMethods.GetFilePath(objid); } else if (type == 255) { string preview = SimpleServerExtensionMethods.GetFilePath(objid, scope: "preview"); if (File.Exists(preview)) { file = preview; } else { file = new Office("DMSArchiv", SimpleServerExtensionMethods.GetFilePath(objid, "docx"), SimpleServerExtensionMethods.GetHexValue(objid), SimpleServerExtensionMethods.GetHexFolder(objid)).CreatePDF(); } } byte[] byteArrayData = objid == "9999" ? new byte[] { } : File.ReadAllBytes(file); string mimeType = MimeMapping.GetMimeMapping(file); return(Response.FromByteArray(byteArrayData, mimeType)); }; }
/// <summary> /// Check If Archive Database Exists or Not /// </summary> /// <returns></returns> private bool _isArchivedInstalled(string archiveName) { string rootPath = Path.Combine(SimpleServerExtensionMethods.GetDataPath(archiveName), "db-" + archiveName, "DMSArchiv.sqlite"); return(File.Exists(rootPath)); }