public void GetPrintTemplateByCriteriaTest() { PrintTemplateDto criteria = new PrintTemplateDto(); criteria.Type = 1; var printTemplate = _reportPrintService.GetPrintTemplateByCriteria(criteria, "", ""); Assert.IsNotNull(printTemplate); Assert.AreEqual(_printTemplateID, printTemplate[0].UniqueID); Assert.AreEqual("TemplateName1", printTemplate[0].TemplateName); }
public List <PrintTemplateDto> GetPrintTemplateByCriteria(PrintTemplateDto criteria, string domain, string site) { criteria.Site = site; //domain; criteria.Domain = domain; //site; //site var printTemplates = _PrintTemplateRepository .Get(p => (criteria.Type == null || p.Type == criteria.Type) && (criteria.Version == null || p.Version == criteria.Version) && (string.IsNullOrEmpty(criteria.ModalityType) || p.ModalityType == criteria.ModalityType) && (p.Site == criteria.Site) && (criteria.IsDefaultByModality == null || p.IsDefaultByModality == (int?)(criteria.IsDefaultByModality.Value ? 1 : 0)) && (string.IsNullOrEmpty(criteria.PropertyTag) || p.PropertyTag.Contains(criteria.PropertyTag))) .ToList().Select(d => Mapper.Map <PrintTemplate, PrintTemplateDto>(d)).ToList(); if (printTemplates.Count > 0) { return(printTemplates); } else { //site printTemplates = _PrintTemplateRepository .Get(p => (criteria.Type == null || p.Type == criteria.Type) && (criteria.Version == null || p.Version == criteria.Version) && (string.IsNullOrEmpty(criteria.ModalityType) || p.ModalityType == criteria.ModalityType) && (p.Domain == criteria.Domain) && (p.Site == null || p.Site == "") && (criteria.IsDefaultByModality == null || p.IsDefaultByModality == (int?)(criteria.IsDefaultByModality.Value ? 1 : 0)) && (string.IsNullOrEmpty(criteria.PropertyTag) || p.PropertyTag.Contains(criteria.PropertyTag))) .ToList().Select(d => Mapper.Map <PrintTemplate, PrintTemplateDto>(d)).ToList(); if (printTemplates.Count > 0) { return(printTemplates); } else { printTemplates = _PrintTemplateRepository .Get(p => (criteria.Type == null || p.Type == criteria.Type) && (criteria.Version == null || p.Version == criteria.Version) && (string.IsNullOrEmpty(criteria.ModalityType) || p.ModalityType == criteria.ModalityType) && (p.Domain == null) && (p.Site == null) && (criteria.IsDefaultByModality == null || p.IsDefaultByModality == (int?)(criteria.IsDefaultByModality.Value ? 1 : 0)) && (string.IsNullOrEmpty(criteria.PropertyTag) || p.PropertyTag.Contains(criteria.PropertyTag))) .ToList().Select(d => Mapper.Map <PrintTemplate, PrintTemplateDto>(d)).ToList(); if (printTemplates.Count > 0) { return(printTemplates); } } } return(null); }
public IHttpActionResult GetPrintTemplateByCriteria(PrintTemplateDto json) { if (json == null) { json = new PrintTemplateDto(); } var user = base.CurrentUser(); var result = _ReportPrintService.GetPrintTemplateByCriteria(json, user.Domain, user.Site); if (result != null) { return(Ok(result)); } return(NotFound()); }
private string getPrintTemplateForBaseInfo(string domain, string site) { PrintTemplateDto criteria = new PrintTemplateDto { Type = 0, TemplateName = "baseinfo" }; List <PrintTemplateDto> printTemplateDtoList = GetPrintTemplateByCriteria(criteria, domain, site); if (printTemplateDtoList == null || printTemplateDtoList.Count == 0) { return(""); } PrintTemplateDto printTemplateDto = printTemplateDtoList[0]; string templateInfo = ReportUtils.GetUnicodeStringFromBytes(printTemplateDto.TemplateInfo); return(templateInfo); }