/// <summary> /// 收藏 /// PrintExpressOrder /// PrintInvoice /// </summary> /// <param name="appId"></param> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.OrderPrintTemplate> GetExpressOrderTemplateExt(System.Guid appId) { var opts = new List <OrderPrintTemplate>(); var eots = (from c in ExpressTemplateCollection.ObjectSet() where c.AppId == appId join e in ExpressOrderTemplate.ObjectSet() on c.TemplateId equals e.Id select e).ToList(); if (eots == null || eots.Count == 0) { return(opts); } var etIds = eots.Select(r => r.Id).ToList(); var eotps = (from p in ExpressOrderTemplateProperty.ObjectSet() join t in etIds on p.TemplateId equals t select p).ToList(); if (eotps != null && eotps.Count > 0) { eots.ForEach(r => { var attrs = eotps.FindAll(p => p.TemplateId == r.Id); opts.Add(new OrderPrintTemplate() { Template = r.ToEntityData(), Property = attrs != null ? new ExpressOrderTemplateProperty().ToEntityDataList(attrs) : new List <ExpressOrderTemplatePropertyDTO>() }); }); } return(opts); }
public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO SavePropertyExt(System.Guid templateId, System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.ExpressOrderTemplatePropertyDTO> propertyList) { ResultDTO result = new ResultDTO() { isSuccess = true }; if (propertyList == null || templateId == Guid.Empty) { result.isSuccess = false; result.Message = "参数不能为空"; return(result); } try { var oldItems = ExpressOrderTemplateProperty.ObjectSet().Where(e => e.TemplateId == templateId).ToList(); foreach (var item in oldItems) { item.EntityState = EntityState.Deleted; ContextFactory.CurrentThreadContext.SaveObject(item); } foreach (var item in propertyList) { item.Id = Guid.NewGuid(); item.TemplateId = templateId; item.ModifiedOn = DateTime.Now; var model = new ExpressOrderTemplateProperty().FromEntityData(item); model.EntityState = EntityState.Added; ContextFactory.CurrentThreadContext.SaveObject(model); } ContextFactory.CurrentThreadContext.SaveChanges(); } catch (Exception ex) { result.isSuccess = false; result.Message = "保存失败"; LogHelper.Error("保存模板打印信息异常", ex); } return(result); }
public Jinher.AMP.BTP.Deploy.CustomDTO.ResultDTO RemoveExt(Jinher.AMP.BTP.Deploy.ExpressOrderTemplateDTO dto) { ResultDTO result = new ResultDTO() { isSuccess = true }; if (dto == null || dto.Id == Guid.Empty || dto.AppId == Guid.Empty) { result.isSuccess = false; result.Message = "参数不能为空"; return(result); } try { var model = ExpressOrderTemplate.ObjectSet().Where(s => s.Id == dto.Id && s.AppId == dto.AppId).FirstOrDefault(); if (model != null) { model.EntityState = EntityState.Deleted; ContextFactory.CurrentThreadContext.SaveObject(model); var items = ExpressOrderTemplateProperty.ObjectSet().Where(e => e.TemplateId == model.Id).ToList(); foreach (var item in items) { item.EntityState = EntityState.Deleted; ContextFactory.CurrentThreadContext.SaveObject(item); } ContextFactory.CurrentThreadContext.SaveChanges(); } } catch (Exception ex) { result.isSuccess = false; result.Message = "删除失败"; LogHelper.Error("删除模板异常", ex); } return(result); }
/// <summary> /// 系统和自定义 /// </summary> /// <param name="appId"></param> /// <returns></returns> public System.Collections.Generic.List <Jinher.AMP.BTP.Deploy.CustomDTO.ExpressTemplateDTO> GetExpressOrderTemplateByAppIdExt(System.Guid appId) { var opts = new List <ExpressTemplateDTO>(); var eots = ExpressOrderTemplate.ObjectSet().Where(r => ((r.AppId == appId && r.TemplateType == 1) || r.TemplateType == 0) && r.Status == 0).ToList(); if (eots == null || eots.Count == 0) { return(opts); } var etIds = eots.Select(r => r.Id).ToList(); var eotps = (from p in ExpressOrderTemplateProperty.ObjectSet() join t in etIds on p.TemplateId equals t select p).ToList(); if (eotps != null && eotps.Count > 0) { eots.ForEach(r => { var attrs = eotps.FindAll(p => p.TemplateId == r.Id); opts.Add(new ExpressTemplateDTO() { Id = r.Id, TemplateName = r.TemplateName, TemplateType = r.TemplateType, ExpressImage = r.ExpressImage, Width = r.Width, Height = r.Height, ExpCode = r.ExpressCode, Property = attrs != null ? new ExpressOrderTemplateProperty().ToEntityDataList(attrs) : new List <ExpressOrderTemplatePropertyDTO>() }); }); } return(opts); }