/// <summary> /// 目录下移 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool NodeItemOrderDown(string id) { ReportTemplateDirec reportTemplateDirecD = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UniqueID == id).FirstOrDefault(); if (reportTemplateDirecD != null) { if (!string.IsNullOrEmpty(reportTemplateDirecD.ParentID)) { var indexs = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ParentID == reportTemplateDirecD.ParentID && p.ItemOrder > reportTemplateDirecD.ItemOrder).Select(p => p.ItemOrder).ToList(); if (indexs == null || indexs.Count < 1) { return(false); } int index = (int)indexs.Min(); ReportTemplateDirec reportTemplateDirecU = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ParentID == reportTemplateDirecD.ParentID && p.ItemOrder == index).FirstOrDefault(); if (reportTemplateDirecU != null) { int distance = index - (int)reportTemplateDirecD.ItemOrder; reportTemplateDirecD.ItemOrder = reportTemplateDirecD.ItemOrder + distance; reportTemplateDirecU.ItemOrder = reportTemplateDirecU.ItemOrder - distance; } } } _dbContext.SaveChanges(); return(true); }
/// <summary> /// delete template /// </summary> /// <param name="id"></param> /// <returns></returns> public bool DeleteTemplateByID(string id) { ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UniqueID == id).FirstOrDefault(); if (reportTemplateDirec == null) { reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.TemplateID == id).FirstOrDefault(); } if (reportTemplateDirec != null) { var dirList = new List <ReportTemplateDirec>(); var tplList = new List <ReportTemplate>(); dirList.Add(reportTemplateDirec); var descendants = descendantNode(id); if (descendants.Count > 0) { dirList.AddRange(descendants); } foreach (var node in dirList) { var tpl = _dbContext.Set <ReportTemplate>().Where(p => p.UniqueID == node.TemplateID).FirstOrDefault(); if (tpl != null) { tplList.Add(tpl); } } _dbContext.Set <ReportTemplateDirec>().RemoveRange(dirList); _dbContext.Set <ReportTemplate>().RemoveRange(tplList); } _dbContext.SaveChanges(); return(true); }
/// <summary> /// 模板目录修改 /// </summary> /// <param name="reportTemplateDto"></param> /// <param name="userID"></param> /// <returns></returns> public ReportTemplateDirecDto UpdateReportTemplateDirec(ReportTemplateDirecDto templateDirecDto, string userID) { ReportTemplateDirec reportTemplateDirec = null; if (templateDirecDto.Type == 1)//用户目录修改自己的 { reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UniqueID == templateDirecDto.UniqueID && p.UserID == userID).FirstOrDefault(); } else { reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UniqueID == templateDirecDto.UniqueID).FirstOrDefault(); } if (reportTemplateDirec != null) { reportTemplateDirec.ItemName = templateDirecDto.ItemName; ReportTemplateDirec reportTemplateDirecDup = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ParentID == templateDirecDto.ParentID && p.ItemName == templateDirecDto.ItemName).FirstOrDefault(); if (reportTemplateDirecDup != null) { if (reportTemplateDirecDup.UniqueID != reportTemplateDirec.UniqueID) { return(null); } } _dbContext.SaveChanges(); return(Mapper.Map <ReportTemplateDirec, ReportTemplateDirecDto>(reportTemplateDirec)); } return(null); }
public void UpdateToRisTemplate(ReportTemplateDto template) { try { var tmpdirc = new ReportTemplateDirec(); var tmp = new ReportTemplate(); var dirc = GetRisReportTemplateDircParentId(template.ModalityType, template.BodyPart); tmpdirc = _dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.TemplateID == template.UniqueID); if (tmpdirc == null) { AddToRisTemplate(template); } else { tmpdirc.ItemName = template.TemplateName; tmpdirc.ParentID = dirc.UniqueID; tmp = _dbContext.Set <ReportTemplate>().FirstOrDefault(t => t.UniqueID == tmpdirc.TemplateID); tmp.TemplateName = template.TemplateName; tmp.BodyPart = template.BodyPart; tmp.ModalityType = template.ModalityType; _dbContext.SaveChanges(); } } catch (Exception ex) { // ignored } }
public ReportTemplateDto UpdateReportTemplate(ReportTemplateDto reportTemplateDto, string userID) { ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.TemplateID == reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplateDto.IsPositive == null) { reportTemplateDto.IsPositive = 0; } if (reportTemplateDirec != null) { reportTemplateDirec.ItemName = reportTemplateDto.TemplateName; ReportTemplateDirec reportTemplateDirecDup = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UserID == reportTemplateDirec.UserID && p.ItemName == reportTemplateDto.TemplateName).FirstOrDefault(); if (reportTemplateDirecDup != null) { if (reportTemplateDirecDup.UniqueID != reportTemplateDirec.UniqueID) { return(null); } } ReportTemplate reportTemplateOld = _dbContext.Set <ReportTemplate>().Where(p => p.UniqueID == reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplateOld != null) { //reportTemplateOld.TemplateName = reportTemplateDto.TemplateName; //reportTemplateOld.ModalityType = reportTemplateDto.ModalityType; //reportTemplateOld.BodyPart = reportTemplateDto.BodyPart; //reportTemplateOld.Gender = reportTemplateDto.Gender; //reportTemplateOld.WYS = ReportMapper.GetBytes(reportTemplateDto.WYSText); //reportTemplateOld.WYG = ReportMapper.GetBytes(reportTemplateDto.WYGText); reportTemplateOld.TemplateName = reportTemplateDto.TemplateName; reportTemplateOld.ModalityType = reportTemplateDto.ModalityType; reportTemplateOld.BodyPart = reportTemplateDto.BodyPart; reportTemplateOld.Gender = reportTemplateDto.Gender; reportTemplateOld.WYS = ReportMapper.GetBytes(reportTemplateDto.WYSText == null ? "" : reportTemplateDto.WYSText); reportTemplateOld.WYG = ReportMapper.GetBytes(reportTemplateDto.WYGText == null ? "" : reportTemplateDto.WYSText); reportTemplateOld.ShortcutCode = reportTemplateDto.ShortcutCode == null ? reportTemplateOld.ShortcutCode : reportTemplateDto.ShortcutCode; reportTemplateOld.ACRCode = reportTemplateDto.ACRCode == null ? reportTemplateOld.ACRCode : reportTemplateDto.ACRCode; reportTemplateOld.DoctorAdvice = reportTemplateDto.DoctorAdvice == null ? reportTemplateOld.DoctorAdvice : reportTemplateDto.DoctorAdvice; reportTemplateOld.BodyCategory = reportTemplateDto.BodyCategory == null ? reportTemplateOld.BodyCategory : reportTemplateDto.BodyCategory; reportTemplateOld.IsPositive = reportTemplateDto.IsPositive == null ? reportTemplateOld.IsPositive : reportTemplateDto.IsPositive; reportTemplateOld.CheckItemName = string.IsNullOrEmpty(reportTemplateDto.CheckItemName)? reportTemplateOld.CheckItemName: reportTemplateDto.CheckItemName; _dbContext.SaveChanges(); } } ReportTemplate reportTemplate = _dbContext.Set <ReportTemplate>().Where(p => p.UniqueID == reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplate != null) { return(Mapper.Map <ReportTemplate, ReportTemplateDto>(reportTemplate)); } return(null); }
/// <summary> /// 创建全局模板 /// </summary> /// <param name="reportTemplateDto"></param> /// <param name="userID"></param> /// <returns></returns> public ReportTemplateDto CreatePublicReportTemplate(ReportTemplateDto reportTemplateDto, string userID) { reportTemplateDto.UniqueID = Guid.NewGuid().ToString(); if (reportTemplateDto.IsPositive == null) { reportTemplateDto.IsPositive = 0; } ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UserID == userID && p.ItemName == reportTemplateDto.TemplateName).FirstOrDefault(); if (reportTemplateDirec == null) { ReportTemplateDirec reportTemplateDirecNew = new ReportTemplateDirec(); reportTemplateDirecNew.UniqueID = Guid.NewGuid().ToString(); reportTemplateDirecNew.ParentID = reportTemplateDto.ParentID; reportTemplateDirecNew.TemplateID = reportTemplateDto.UniqueID; reportTemplateDirecNew.UserID = ""; reportTemplateDirecNew.ItemName = reportTemplateDto.TemplateName; reportTemplateDirecNew.Leaf = 1; reportTemplateDirecNew.DirectoryType = "report"; reportTemplateDirecNew.Domain = reportTemplateDto.Domain; reportTemplateDirecNew.Type = reportTemplateDto.Type;//0 reportTemplateDirecNew.Depth = -1; reportTemplateDirecNew.ItemOrder = 0; List <ReportTemplateDirec> reportTemplateDirecList = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ParentID == reportTemplateDto.ParentID).OrderByDescending(p => p.ItemOrder).ToList(); if (reportTemplateDirecList.Count > 0) { if (reportTemplateDirecList[0].ItemOrder.HasValue) { reportTemplateDirecNew.ItemOrder = reportTemplateDirecList[0].ItemOrder + 1; } } var report = Mapper.Map <ReportTemplateDto, ReportTemplate>(reportTemplateDto); _dbContext.Set <ReportTemplate>().Add(report); _dbContext.Set <ReportTemplateDirec>().Add(reportTemplateDirecNew); _dbContext.SaveChanges(); } else { return(null); } ReportTemplate reportTemplate = _dbContext.Set <ReportTemplate>().Where(p => p.UniqueID == reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplate != null) { return(Mapper.Map <ReportTemplate, ReportTemplateDto>(reportTemplate)); } return(null); }
public bool IsDuplicatedTemplateName(ReportTemplateDto reportTemplateDto, string userID) { ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UserID == userID && p.ItemName == reportTemplateDto.TemplateName).FirstOrDefault(); if (reportTemplateDto.UniqueID == null) { reportTemplateDto.UniqueID = ""; } if (reportTemplateDirec != null && reportTemplateDirec.TemplateID.ToLower() != reportTemplateDto.UniqueID.ToLower()) { return(true); } return(false); }
/// <summary> /// Save SR report template into ris report tempalte /// </summary> /// <param name="template"></param> public void AddToRisTemplate(ReportTemplateDto template) { try { var tmpdirc = new ReportTemplateDirec(); var tmp = new ReportTemplate(); var dirc = GetRisReportTemplateDircParentId(template.ModalityType, template.BodyPart); if (dirc != null) { _dbContext.Set <ReportTemplateDirec>().Add(tmpdirc); tmpdirc.ItemName = template.TemplateName; tmpdirc.UniqueID = Guid.NewGuid().ToString(); tmpdirc.ParentID = dirc.UniqueID; tmpdirc.Depth = 0; tmpdirc.ItemOrder = GetRisReportTemplateDirecMaxOrderNumber(dirc.UniqueID) + 1; tmpdirc.Leaf = 1; tmpdirc.TemplateID = Guid.NewGuid().ToString(); tmpdirc.DirectoryType = "report"; tmpdirc.Domain = dirc.Domain; tmpdirc.Type = 0; _dbContext.Set <ReportTemplate>().Add(tmp); tmp.UniqueID = tmpdirc.TemplateID; tmp.TemplateName = template.TemplateName; tmp.ModalityType = template.ModalityType; tmp.BodyPart = template.BodyPart; tmp.WYG = new byte[0]; tmp.WYS = new byte[0]; tmp.AppendInfo = new byte[0]; tmp.TechInfo = new byte[0]; tmp.CheckItemName = ""; tmp.BodyCategory = ""; tmp.Domain = tmpdirc.Domain; tmp.Gender = ""; tmp.IsPositive = 0; _dbContext.SaveChanges(); } } catch (Exception ex) { // ignored } }
/// <summary> /// 创建模板验证 /// </summary> /// <param name="reportTemplateDto"></param> /// <param name="userID"></param> /// <returns></returns> public bool CreateReportTemplateExist(ReportTemplateDirecDto reportTemplateDto, string userID) { if (reportTemplateDto.Type == 0 || reportTemplateDto.Type == 2) { if (string.IsNullOrEmpty(reportTemplateDto.UniqueID)) { ReportTemplateDirec reportTemplateDirec1 = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ItemName == reportTemplateDto.ItemName).FirstOrDefault(); if (reportTemplateDirec1 != null) { return(false); } } else { ReportTemplateDirec reportTemplateDirec1 = _dbContext.Set <ReportTemplateDirec>().Where(p => p.ItemName == reportTemplateDto.ItemName && p.UniqueID != reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplateDirec1 != null) { return(false); } } } if (string.IsNullOrEmpty(reportTemplateDto.UniqueID)) { ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UserID == userID && p.ItemName == reportTemplateDto.ItemName).FirstOrDefault(); if (reportTemplateDirec != null) { return(false); } } else { ReportTemplateDirec reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().Where(p => p.UserID == userID && p.ItemName == reportTemplateDto.ItemName && p.UniqueID != reportTemplateDto.UniqueID).FirstOrDefault(); if (reportTemplateDirec != null) { return(false); } } return(true); }
public static void ClassInitialize(TestContext context) { _reportRepository = new MockReportRepository(_MockRisProContext); _reportFileRepository = new MockReportFileRepository(_MockRisProContext); _printTemplateRepository = new MockPrintTemplateRepository(_MockRisProContext); _printTemplateFieldsRepository = new MockPrintTemplateFieldsRepository(_MockRisProContext); _reportTemplateDirecRepository = new MockReportTemplateDirecRepository(_MockRisProContext); _reportTemplateRepository = new MockReportTemplateRepository(_MockRisProContext); _reportPrintLogRepository = new MockReportPrintLogRepository(_MockRisProContext); _reportPrintService = new ReportPrintService ( _reportRepository, _reportFileRepository, _printTemplateRepository, _printTemplateFieldsRepository, _reportPrintLogRepository, _MockRisProContext ); _reportLockService = new ReportLockService ( _MockRisProContext ); _reportTemplateService = new ReportTemplateService ( _reportTemplateRepository, _reportTemplateDirecRepository, _MockRisProContext ); _reportService = new ReportService ( _reportRepository, _reportFileRepository, _MockRisProContext, _reportPrintService ); _userID = Guid.NewGuid().ToString(); _user = new User { UniqueID = _userID, LoginName = "1", Password = "******" }; _siteName = Guid.NewGuid().ToString(); _site = new Site { SiteName = _siteName, PacsWebServer = "http://10.184.193.236/masterview/mv.jsp?server_name=FIR&user_name={user_name}&password={password}&patient_id=&accession_number={tbRegOrder__AccNo}&close_on_exit=true" }; _reportID = Guid.NewGuid().ToString(); _report1 = new Report { UniqueID = _reportID.ToString(), ReportName = "ReportName1", ReportText = "ReportText1", PrintTemplateID = "dd5e991d-b595-4ed2-9958-126d1ea82b10" }; _report2 = new Report { UniqueID = Guid.NewGuid().ToString(), ReportName = "ReportName2", ReportText = "ReportText2" }; _report3 = new Report { UniqueID = Guid.NewGuid().ToString(), ReportName = "ReportName3", ReportText = "ReportText3" }; //order _patientID = Guid.NewGuid().ToString(); _patient1 = new Patient { UniqueID = _patientID.ToString(), LocalName = "LocalName1" }; //order _orderID = Guid.NewGuid().ToString(); _order1 = new Order { UniqueID = _orderID.ToString(), PatientID = _patientID, ExamSite = _siteName }; //procedure _procedureID = Guid.NewGuid().ToString(); _procedureID2 = Guid.NewGuid().ToString(); _procedure1 = new Procedure { UniqueID = _procedureID.ToString(), ReportID = _reportID.ToString(), OrderID = _orderID, Status = 50 }; _procedure2 = new Procedure { UniqueID = _procedureID2.ToString() }; //reportfile _reportFileID = Guid.NewGuid().ToString(); _reportFile1 = new ReportFile { UniqueID = _reportFileID.ToString(), ReportID = _reportID.ToString(), FileName = "ReportFileName1" }; //PrintTemplate _printTemplateID = Guid.NewGuid().ToString(); _printTemplate1 = new PrintTemplate { UniqueID = _printTemplateID.ToString(), TemplateName = "TemplateName1", Type = 1 }; string templateInfo = @"<?xml version='1.0' encoding='utf-8'?><Reports><Report version='4.6.20131.54624'>" + "<Name>Template</Name>" + "<ReportInfo>" + "<Author>10027008</Author>" + "</ReportInfo>" + "<DataSource>" + @"<ConnectionString>C:\Documents and Settings\Administrator\Local Settings\Apps\2.0\YW0P4GHB.B7T\6P43HV32.GD3\care..tion_324c4122a6cd491e_0002.0001_781aa2e02dbf3870\PrintTemplateFiles\SystemFiles\2052\Basic_Field.xml</ConnectionString>" + "<RecordSource>Fields</RecordSource>" + "<DataProvider>0</DataProvider>" + "</DataSource>" + "<Layout>" + "<Width>9120</Width>" + " <Orientation>1</Orientation>" + "</Layout>" + "<Font>" + " <Name>Times New Roman</Name>" + " <Size>9</Size>" + "</Font>" + "<CompatibilityOptions />" + "<Groups />" + "<Sections>" + " <Section>" + "<Name>Detail</Name>" + "<Type>0</Type>" + "<Height>1200</Height>" + "</Section>" + "<Section>" + "<Name>Header</Name>" + "<Type>1</Type>" + "<Height>20</Height>" + "</Section>" + "<Section>" + "<Name>Footer</Name>" + "<Type>2</Type>" + "<Visible>0</Visible>" + "</Section>" + "<Section>" + "<Name>PageHeader</Name>" + "<Type>3</Type>" + "</Section>" + "<Section>" + "<Name>PageFooter</Name>" + "<Type>4</Type>" + " <Height>20</Height>" + " </Section>" + "</Sections>" + "<Fields>" + " <Field>" + "<Name>CityCtl1</Name>" + "<Section>0</Section>" + "<Text>tbRegPatient__LocalName</Text>" + "<Calculated>-1</Calculated>" + "<Left>1000</Left>" + "<Top>300</Top>" + "<Width>2280</Width>" + "<Height>300</Height>" + "<Align>6</Align>" + "<Font>" + "<Name>Arial</Name>" + " <Size>9</Size>" + " </Font>" + "</Field>" + "<Field>" + " <Name>CityLbl1</Name>" + " <Section>0</Section>" + " <Text>病人姓名</Text>" + "<Left>150</Left>" + " <Top>300</Top>" + " <Width>885</Width>" + " <Height>300</Height>" + " <Align>6</Align>" + "<ForeColor>128</ForeColor>" + " <WordWrap>0</WordWrap>" + " <Font>" + " <Name>Arial</Name>" + " <Size>9</Size>" + " </Font>" + "</Field>" + "</Fields>" + "</Report>" + "</Reports>"; _printTemplate2 = new PrintTemplate { UniqueID = "dd5e991d-b595-4ed2-9958-126d1ea82b10", TemplateName = "baseinfo", Type = 0, Version = 0, TemplateInfo = System.Text.Encoding.Unicode.GetBytes(templateInfo) }; //PrintTemplateFields _printTemplateFieldsID = Guid.NewGuid().ToString(); _printTemplateFields1 = new PrintTemplateFields { UniqueID = _printTemplateFieldsID.ToString(), FieldName = "FieldName1" }; // Report template _reportTemplateID = Guid.NewGuid().ToString(); _reportTemplate = new ReportTemplate { UniqueID = _reportTemplateID, TemplateName = "templateName1" }; _reportTemplateDirecID = Guid.NewGuid().ToString(); _reportTemplateDirecParentID = Guid.NewGuid().ToString(); _reportTemplateDirecUserID = Guid.NewGuid().ToString(); _reportTemplateDirec = new ReportTemplateDirec { UniqueID = _reportTemplateDirecID, TemplateID = _reportTemplateID, ParentID = _reportTemplateDirecParentID, UserID = _reportTemplateDirecUserID, DirectoryType = "report", Type = 1, ItemOrder = 0 }; //history _reportList = new ReportList { UniqueID = Guid.NewGuid().ToString(), ReportID = _reportID, OperationTime = DateTime.Now, Creater = _userID, Mender = _userID }; }
/// <summary> /// Get Ris ReportTemplatedirc ParentId /// </summary> /// <param name="modalitytype"></param> /// <param name="bodypart"></param> /// <returns></returns> private ReportTemplateDirec GetRisReportTemplateDircParentId(string modalitytype, string bodypart) { string modalitytypeid = string.Empty; string parentid = string.Empty; try { var reportTemplateDirec = _dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.ItemName == modalitytype && t.ParentID == "GlobalTemplate"); var domain = _dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.ParentID == "GlobalTemplate"); if (reportTemplateDirec != null) { modalitytypeid = reportTemplateDirec.UniqueID; } else { var tmpdirc = new ReportTemplateDirec(); _dbContext.Set <ReportTemplateDirec>().Add(tmpdirc); tmpdirc.ItemName = modalitytype; tmpdirc.UniqueID = Guid.NewGuid().ToString(); tmpdirc.ParentID = "GlobalTemplate"; tmpdirc.Depth = 0; tmpdirc.ItemOrder = 0; tmpdirc.Leaf = 0; tmpdirc.TemplateID = ""; tmpdirc.DirectoryType = "report"; if (domain != null) { tmpdirc.Domain = domain.Domain; } _dbContext.SaveChanges(); modalitytypeid = tmpdirc.UniqueID; } var reportTemplateDirec2 = _dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.ItemName == bodypart && t.ParentID == modalitytypeid); if (reportTemplateDirec2 != null) { return(reportTemplateDirec2); } else { var temp = _dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.ItemName == modalitytype && t.ParentID == "GlobalTemplate"); var tmpdirc = new ReportTemplateDirec(); _dbContext.Set <ReportTemplateDirec>().Add(tmpdirc); tmpdirc.ItemName = bodypart; tmpdirc.UniqueID = Guid.NewGuid().ToString(); tmpdirc.ParentID = temp.UniqueID; tmpdirc.Depth = 0; tmpdirc.ItemOrder = 0; tmpdirc.Leaf = 0; tmpdirc.TemplateID = ""; tmpdirc.DirectoryType = "report"; if (domain != null) { tmpdirc.Domain = domain.Domain; } _dbContext.SaveChanges(); return(_dbContext.Set <ReportTemplateDirec>().FirstOrDefault(t => t.ItemName == bodypart && t.ParentID == modalitytypeid)); } } catch (Exception ex) { return(null); } }