public bool Exist(string qycode, string md5) { var month = DateTime.Now.ToString("yyyyMM"); Document value = new DocumentB().GetEntities(D => D.Qycode == qycode && D.Md5 == md5).FirstOrDefault(); return(value != null); }
void Caller() { BaseDocument doc = new DocumentB() { dal = new DalThroughEF() }; doc.Create(); }
public Document Fetch(string zyid) { Document doc = new DocumentB().GetEntities(d => d.ID == zyid || d.Md5 == zyid).FirstOrDefault(); if (doc == null) { return(null); } return(doc); }
public IEnumerable <dynamic> Fetch(string qyCode, string[] md5s) { var docs = new DocumentB().GetEntities(d => (md5s.Contains(d.ID) || md5s.Contains(d.Md5))); return(docs.Select(o => new { md5 = o.Md5, contenttype = o.ContentType, name = Path.GetFileNameWithoutExtension(o.FileName), extension = o.Extension.TrimStart('.'), rdate = o.RDate, file = o.FullPath, })); }
/// <summary> /// 获取文档资源 /// </summary> /// <param name="context"></param> /// <param name="msg"></param> /// <param name="P1"></param> /// <param name="P2"></param> /// <param name="UserInfo"></param> public void GETWDZY(JObject context, Msg_Result msg, string P1, string P2, JH_Auth_UserB.UserInfo UserInfo) { Document ff = new DocumentB().GetEntities(p => p.ID == P1).FirstOrDefault(); if (ff != null) { msg.Result = ff.FileName; msg.Result1 = ff.ylinfo; } else { msg.ErrorMsg = "此文件不存在或您没有权限!"; } }
void Caller() { IDocument doc = null; doc = new DocumentA(); doc.Create(); doc = new DocumentB(); doc.Create(); BaseDocument document = new DocumentB(); document.Save(); }
void Caller() { BaseDocument doc = null; doc = new DocumentA() { RenderingStrategy = new RenderingStrategyTabbed() }; doc.Render(); doc = new DocumentB() { RenderingStrategy = new RenderingStrategySinglePage() }; doc.Render(); }
///<summary></summary> public static void Update(Document doc) { try { if (RemotingClient.OpenDentBusinessIsLocal) { DocumentB.Update(doc); } else { DtoDocumentUpdate dto = new DtoDocumentUpdate(); dto.Doc = doc; RemotingClient.ProcessCommand(dto); } } catch (Exception e) { MessageBox.Show(e.Message); } }
public dynamic Fetch(string qyCode, string md5) { var doc = new DocumentB().GetEntities(d => (d.ID == md5 || d.Md5 == md5)).FirstOrDefault(); if (doc == null) { return(null); } return(new { md5 = doc.Md5, contenttype = doc.ContentType, name = Path.GetFileNameWithoutExtension(doc.FileName), extension = doc.Extension.TrimStart('.'), rdate = doc.RDate, file = doc.FullPath, }); }
public System.Dynamic.ExpandoObject Exist(string qyCode, string md5) { dynamic re = new System.Dynamic.ExpandoObject(); try { var result = _documentRepository.Exist(qyCode, md5); if (result) { var doc = new DocumentB().GetEntities(d => d.Qycode == qyCode && d.Md5 == md5).FirstOrDefault(); doc.RDate = DateTime.Now; doc.LDate = DateTime.Now; doc.ID = Guid.NewGuid().ToString("N"); doc.fileinfo = ""; new DocumentB().Insert(doc); re.zyid = doc.ID; } re.result = result; if (!result) { //不存在,寻找分片内容。 string chunkPath = Path.Combine(rootPath2, md5); if (Directory.Exists(chunkPath)) { re.chunkMd5s = Directory.GetFiles(chunkPath).Select(o => { return(Path.GetFileName((string)o).Split('.')[1]); }).ToList(); } } } catch (Exception ex) { Logger.LogError(ex.Message.ToString()); } return(re); }
///<summary>Inserts a new document into db, creates a filename based on Cur.DocNum, and then updates the db with this filename. Also attaches the document to the current patient.</summary> public static void Insert(Document doc, Patient pat) { int insertID = 0; try { if (RemotingClient.OpenDentBusinessIsLocal) { insertID = DocumentB.Insert(doc, pat.LName + pat.FName, pat.PatNum); } else { DtoDocumentInsert dto = new DtoDocumentInsert(); dto.Doc = doc; dto.PatLF = pat.LName + pat.FName; dto.PatNum = pat.PatNum; insertID = RemotingClient.ProcessCommand(dto); } } catch (Exception e) { MessageBox.Show(e.Message); } doc.DocNum = insertID; }
public FileAPIHandler() : base() { DocumentDomain documentDomain = new DocumentDomain(new DocumentRepository()); userlog log = new userlog(); Before += ctx => { // new userlogB().Insert(new userlog { }); log.ip = ctx.Request.UserHostAddress; log.loginfo = ctx.Request.Path; log.remark = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); return(ctx.Response); }; Post["/document/checkauth"] = p => { // new DocumentRepository().SaveDocument("3b31d546f6f94a8029f966a8d71c7c66", "SWXX", "123123", ".png", "image/png", @"D:\FileCenter\SWXX\201601\3b31d546f6f94a8029f966a8d71c7c66.png", DateTime.Now); string code = this.Request.Form.code; string secret = this.Request.Form.secret; Qycode space = new QycodeB().GetEntities(d => d.Code == code && d.secret == secret).FirstOrDefault(); return(space == null ? "N" : "Y"); }; Post["/document/fileupload"] = p => { //借助上传组件工具上传 try { string size = this.Request.Form.size; string chunks = this.Request.Form.chunks; string strchunk = this.Request.Form.chunk; string fileMd5 = this.Request.Form.fileMd5; string spacecode = this.Request.Form.code; string upinfo = this.Request.Form.upinfo; if (!string.IsNullOrEmpty(spacecode)) { spacecode = spacecode.Trim('\''); int chunkcount = 0, chunk; if (!string.IsNullOrEmpty(chunks) && int.TryParse(chunks, out chunkcount) && chunkcount > 1 && int.TryParse(strchunk, out chunk)) { //属于分片文件 var file = this.Request.Files.FirstOrDefault(); if (file != null) { var md5 = documentDomain.PushChunk(fileMd5, chunk, file.Name, Path.GetExtension(file.Name), file.ContentType, file.Value); return(Response.AsJson(md5)); } } else { var file = this.Request.Files.FirstOrDefault(); if (file != null) { var md5 = documentDomain.Push(file.Name, System.IO.Path.GetExtension(file.Name), file.ContentType, file.Value, spacecode, upinfo); return(Response.AsJson(md5)); } } } return(Response.AsRedirect("/document")); } catch (Exception ex) { Logger.LogError(ex.Message.ToString()); return(Response.AsRedirect("/document")); } }; Post["/document/fileupload/{qycode}/{upinfo}"] = p => { //后台上传 try { string qycode = p.qycode; string upinfo = p.upinfo; var file = this.Request.Files.FirstOrDefault(); if (file != null) { var md5 = documentDomain.Push(file.Name, System.IO.Path.GetExtension(file.Name), file.ContentType, file.Value, qycode, upinfo); return(Response.AsText(md5)); } return(Response.AsRedirect("/document")); } catch (Exception ex) { Logger.LogError(ex.Message.ToString()); return(Response.AsRedirect("/document")); } }; Post["/document/fileupload/{qycode}"] = p => { //后台上传 try { string qycode = p.qycode; var file = this.Request.Files.FirstOrDefault(); if (file != null) { var md5 = documentDomain.Push(file.Name, System.IO.Path.GetExtension(file.Name), file.ContentType, file.Value, qycode, ""); return(Response.AsText(md5)); } return(Response.AsRedirect("/document")); } catch (Exception ex) { Logger.LogError(ex.Message.ToString()); return(Response.AsRedirect("/document")); } }; Post["/document/fileupload/checkwholefile"] = p => { var md5Client = this.Request.Form.md5; string spacecode = this.Request.Form.code; //MD5值验证 string md5 = md5Client.Value.ToLower(); var result = documentDomain.Exist(spacecode, md5); return(Response.AsJson(result)); }; Post["/document/fileupload/fileMerge"] = p => { string fileMd5 = this.Request.Form.fileMd5; string ext = this.Request.Form.ext; string name = this.Request.Form.name; string contentType = this.Request.Form.contentType; string spacecode = this.Request.Form.code; string upinfo = this.Request.Form.upinfo; if (!ext.StartsWith(".")) { ext = "." + ext; } string strID = "0"; var result = documentDomain.FileMerge(fileMd5, name, contentType, ext, spacecode, upinfo); return(Response.AsJson(result)); }; Get["/{qycode}/document/fileupload"] = p => { string strCode = p.qycode; Qycode space = new QycodeB().GetEntities(d => d.Code == strCode).FirstOrDefault(); return(View["FileUpload"]); }; Get["/document/info/{id}"] = p => { string idS = p.id; string[] ids = idS.Trim(',').Split(','); List <Document> spaces = new DocumentB().GetEntities(d => d.Qycode == "-1").ToList(); foreach (string id in ids) { Document space = new DocumentB().GetEntities(d => d.ID == id).FirstOrDefault(); if (space != null) { spaces.Add(space); } } return(Response.AsJson(spaces)); }; //下一版废弃 Get["/{qycode}/document/{id}"] = p => { log.useraction = "下载文件"; string id = p.id; string qycode = p.qycode; if (!string.IsNullOrEmpty(id) && id.Contains(",")) { var md5s = id.Split(','); var documents = documentDomain.Fetch("", md5s); if (documents != null && documents.Any()) { //压缩,并返回 var mimeType = "application/zip"; var extension = "zip"; var name = "打包下载的文件"; var file = documentDomain.Compress(documents); return(Response.AsFileV1(file, mimeType, extension, name)); } else { return("找不到该文件" + p.id); } } else { var document = documentDomain.Fetch("", p.id); if (document == null) { return("找不到该文件 " + p.id); } string mimeType = document.contenttype; string extension = document.extension; string file = document.file; string name = document.name; return(Response.AsFileV1(file, mimeType, extension, name)); } }; Get["/document/{id}"] = p => { log.useraction = "下载文件"; string id = p.id; if (!string.IsNullOrEmpty(id) && id.Contains(",")) { var md5s = id.Split(','); var documents = documentDomain.Fetch("", md5s); if (documents != null && documents.Any()) { //压缩,并返回 var mimeType = "application/zip"; var extension = "zip"; var name = "打包下载的文件"; var file = documentDomain.Compress(documents); return(Response.AsFileV1(file, mimeType, extension, name)); } else { return("找不到该文件" + p.id); } } else { var document = documentDomain.Fetch("", p.id); if (document == null) { return("找不到该文件 " + p.id); } string mimeType = document.contenttype; string extension = document.extension; string file = document.file; string name = document.name; return(Response.AsFileV1(file, mimeType, extension, name)); } }; Get["/document/zipfile/{md5}"] = p => { string md5 = p.md5; var filename = documentDomain.GetZipFile(md5); var mimeType = "application/zip"; var extension = "zip"; var name = "打包下载的文件"; return(Response.AsFileV1(filename, mimeType, extension, name)); }; Get["/{qycode}/document/image/{id}"] = p => { log.useraction = "预览图片"; string id = p.id; string qycode = p.qycode; var document = documentDomain.Fetch(qycode, p.id); if (document == null) { return("找不到该文件" + p.id); } string mimeType = document.contenttype; string extension = document.extension; string file = document.file; string name = document.name; return(Response.AsPreviewFile(file, mimeType, extension, name)); }; //修改缩略图接口 Get["/{qycode}/document/image/{id}/{width?0}/{height?0}"] = p => { log.useraction = "预览压缩图片"; string id = p.id; string qycode = p.qycode; var document = documentDomain.Fetch(qycode, p.id); if (document == null) { return("找不到该文件 " + p.id); } int width = p.width; int height = p.height; string mimeType = document.contenttype; string extension = document.extension; string file = document.file; string name = document.name; var smallImg = ImageCLass.GenSmallImg(file, width, height); return(Response.AsPreviewFile(smallImg, mimeType, extension, name)); }; Get["/{qycode}/document/unzip/{id}"] = p => { string qycode = p.qycode; var document = documentDomain.Fetch(qycode, p.id); if (document == null) { return("找不到该文档 " + p.id); } string extension = document.extension; if (extension == "zip") { SubFolderModel model = documentDomain.UnCompress(document, p.qycode); return(Response.AsJson(model)); } return(Response.AsJson("")); }; Post["/{qycode}/document/zipfolder"] = p => { var data = Request.Form.data; string qycode = p.qycode; string md5 = ""; if (data) { SubFolderModel subFolderModel = Newtonsoft.Json.JsonConvert.DeserializeObject <SubFolderModel>(data); var zipItems = subFolderModel.GetZipEntryItems().ToArray(); var md5s = zipItems.Select(o => o.Item1).ToArray(); var documents = documentDomain.Fetch(qycode, md5s); if (documents != null && documents.Any()) { md5 = documentDomain.CompressNestedFolder(documents, zipItems); } } return(md5); }; Get["/{qycode}/document/zipfile/{md5}"] = p => { string md5 = p.md5; var filename = documentDomain.GetZipFile(md5); var mimeType = "application/zip"; var extension = "zip"; var name = "打包下载的文件"; return(Response.AsFileV1(filename, mimeType, extension, name)); }; Post["/{qycode}/document/nestedfolder"] = p => { var data = Request.Form.data; string qycode = p.qycode; if (data) { SubFolderModel subFolderModel = Newtonsoft.Json.JsonConvert.DeserializeObject <SubFolderModel>(data); var zipItems = subFolderModel.GetZipEntryItems().ToArray(); var md5s = zipItems.Select(o => o.Item1).ToArray(); var documents = documentDomain.Fetch(qycode, md5s); if (documents != null && documents.Any()) { //压缩,并返回 var mimeType = "application/zip"; var extension = "zip"; var name = subFolderModel.Name; string file = documentDomain.CompressNestedFolder(documents, zipItems); return(Response.AsFileV1(file, mimeType, extension, name)); } else { return("找不到该文档 " + subFolderModel.Name); } } return(""); }; #region 多媒体相关接口 Get["/document/officecov/{id}"] = p => { string strReturn = "0,0"; string id = p.id; Document document = documentDomain.Fetch(p.id); if (document == null) { return("找不到该文件" + p.id); } else { strReturn = document.isyl + "," + document.ylinfo; if (document.isyl == "0") { string extension = document.Extension.TrimStart('.'); string file = document.FullPath; //OfficeConverter Converter = new OfficeConverter(); //if (new List<string>() { "pdf" }.Contains(extension.ToLower())) //{ // Converter.PdfToImage(file, file.Substring(0, file.LastIndexOf('.')), 0, 0, 400); //} //if (new List<string>() { "doc", "docx" }.Contains(extension.ToLower())) //{ // Converter.WordToImage(document, file.Substring(0, file.LastIndexOf('.')), 0, 0, null, 400); //} //if (new List<string>() { "ppt", "pptx" }.Contains(extension.ToLower())) //{ // Converter.PPTToImage(file, file.Substring(0, file.LastIndexOf('.')), 0, 0, 400); //} } //if (new List<string>() { "xls", "xlsx" }.Contains(extension.ToLower())) //{ // strReturn = Converter.YLExcel(file); // return Response.AsRedirect(strReturn); //} return(strReturn); } }; //返回office预览文件 Get["/document/YL/{id}"] = p => { log.useraction = "预览OFFICE文件"; Document document = documentDomain.Fetch(p.id); if (document == null) { return("找不到可预览的文件 " + p.id); } else if (document.isyl != "2") { return("预览文件正在准备中 " + p.id); } else { string strFileName = document.FileName.Substring(0, document.FileName.LastIndexOf('.')); string strReturn = "/Web/Html/doc.html?ID=" + p.id + "&size=" + document.ylinfo + "&title=" + HttpUtility.UrlEncode(strFileName); return(Response.AsRedirect(strReturn)); } }; //获取可用的视频播放路径 Get["/document/viedo/{id}"] = p => { Document document = documentDomain.Fetch(p.id); string tempfile = document.Directory.TrimEnd('\\') + "\\" + document.Md5 + "\\" + document.Md5; if (document == null) { return("找不到文件 " + p.id); } if (document.isyl != "2") { return("正在生成可预览文件 "); } else { string mimeType = "video/mp4"; string extension = ".mp4"; string file = tempfile + "_low.mp4"; string name = file; string[] range_info = (string[])Request.Headers["Range"]; if (range_info.Length == 0) { return(Response.AsFileV1(file, mimeType, extension, document.ID.ToString() + "_low.mp4")); } else { string strRange = range_info[0].ToString(); return(Response.AsVideoFile(document.FullPath, mimeType, extension, name, strRange)); } } }; //获取视频封面 Get["/document/viedo/img/{id}"] = p => { Document document = documentDomain.Fetch(p.id); string tempfile = document.Directory.TrimEnd('\\') + "\\" + document.Md5 + "\\" + document.Md5; if (document == null) { return("找不到文件 " + p.id); } if (document.isyl != "2") { return("正在生成可预览文件 "); } else { string mimeType = "image/jpeg"; string extension = ".jpg"; string file = tempfile + ".jpg"; string name = file; return(Response.AsPreviewFile(file, mimeType, extension, name)); } }; //获取office转换后的图片 Get["/document/YL/{id}/{index}"] = p => { log.useraction = "预览OFFICE图片"; string strReturn = "无法预览"; string id = p.id; string index = p.index; Document document = documentDomain.Fetch(p.id); if (document == null) { return("找不到可预览的文件 " + p.id); } else { if (document.isyl == "1") { strReturn = "预览准备中"; } if (document.isyl == "2") { string ylfile = document.FullPath; ylfile = ylfile.Substring(0, ylfile.LastIndexOf('.')) + "/" + document.Md5 + "_" + index + ".png"; string strName = document.Md5 + "_" + index + ".png"; if (new List <string>() { ".ppt", ".pptx", ".doc", ".docx", ".pdf" }.Contains(document.Extension.ToLower())) { if (File.Exists(ylfile)) { return(Response.AsPreviewFile(ylfile, "image/png", ".png", strName)); } } } } return(strReturn); }; After += ctx => { //添加日志 new userlogB().Insert(log); }; #endregion }
public static int ProcessCommand(DtoCommandBase dto) { if (dto.GetType() == typeof(DtoDefInsert)) { return(DefB.Insert(((DtoDefInsert)dto).DefCur)); } else if (dto.GetType() == typeof(DtoDefUpdate)) { return(DefB.Update(((DtoDefUpdate)dto).DefCur)); } else if (dto.GetType() == typeof(DtoDocumentInsert)) { return(DocumentB.Insert(((DtoDocumentInsert)dto).Doc, ((DtoDocumentInsert)dto).PatLF, ((DtoDocumentInsert)dto).PatNum)); } else if (dto.GetType() == typeof(DtoDocumentUpdate)) { return(DocumentB.Update(((DtoDocumentUpdate)dto).Doc)); } else if (dto.GetType() == typeof(DtoEmailMessageUpdate)) { return(EmailMessageB.Update(((DtoEmailMessageUpdate)dto).Message)); } else if (dto.GetType() == typeof(DtoGeneralNonQ)) { return(GeneralB.NonQ(((DtoGeneralNonQ)dto).Command, ((DtoGeneralNonQ)dto).GetInsertID)); } else if (dto.GetType() == typeof(DtoLogin)) { return(OpenDentalService.Login(((DtoLogin)dto).Database, ((DtoLogin)dto).OdUser, ((DtoLogin)dto).OdPassHash)); } else if (dto.GetType() == typeof(DtoMiscDataMakeABackup)) { return(MiscDataB.MakeABackup()); } else if (dto.GetType() == typeof(DtoProcedureInsert)) { return(ProcedureB.Insert(((DtoProcedureInsert)dto).Proc)); } else if (dto.GetType() == typeof(DtoProcedureUpdate)) { return(ProcedureB.Update(((DtoProcedureUpdate)dto).Proc, ((DtoProcedureUpdate)dto).OldProc)); } else if (dto.GetType() == typeof(DtoProcedureDelete)) { return(ProcedureB.Delete(((DtoProcedureDelete)dto).ProcNum)); } else if (dto.GetType() == typeof(DtoProcedureUpdateAptNum)) { return(ProcedureB.UpdateAptNum(((DtoProcedureUpdateAptNum)dto).ProcNum, ((DtoProcedureUpdateAptNum)dto).NewAptNum)); } else if (dto.GetType() == typeof(DtoProcedureUpdatePlannedAptNum)) { return(ProcedureB.UpdatePlannedAptNum(((DtoProcedureUpdatePlannedAptNum)dto).ProcNum, ((DtoProcedureUpdatePlannedAptNum)dto).NewPlannedAptNum)); } else if (dto.GetType() == typeof(DtoProcedureUpdatePriority)) { return(ProcedureB.UpdatePriority(((DtoProcedureUpdatePriority)dto).ProcNum, ((DtoProcedureUpdatePriority)dto).NewPriority)); } else if (dto.GetType() == typeof(DtoProcedureUpdateFee)) { return(ProcedureB.UpdateFee(((DtoProcedureUpdateFee)dto).ProcNum, ((DtoProcedureUpdateFee)dto).NewFee)); } else { throw new Exception("OpenDentServer.BusinessLayer.ProcessCommand(dto) is missing a case for " + dto.GetType().ToString()); } }