/// <summary> /// 多媒体插入一条记录 /// </summary> /// <param name="input"></param> /// <returns></returns> public string InsertMultimedia(MultimediaAttachmentInput input) { AttachmentEntity att = new AttachmentEntity { Id = Guid.NewGuid().ToString(), FKey = input.FKey, PhysicalName = input.PhysicalName, LogicName = input.LogicName, FileSize = input.FileSize, Extension = input.Extension, Sn = input.Sn, iState = 1, CreateTime = DateTime.Now, CreateName = input.CreateName, PhysicalPath = input.PhysicalPath, HttpPath = input.HttpPath, TypeCode = input.TypeCode }; try { return(_iAttachmentRepository.InsertAndGetId(att)); } catch (Exception) { return(null); } }
/// <summary> /// 通过外键获取附件列表 /// </summary> /// <param name="fkid"></param> /// <returns></returns> public List <MultimediaOutput> GetAllList(ModuleInfoInput input) { var att = _iAttachmentRepository.GetAll().Where(q => q.FKey == input.FKey); var query = _iMultimediaTypeRepository.Query(q => q.GroupJoin(att, m => m.Id, a => a.TypeCode, (m, a) => new { m, a })); var ret = query.Where(q => q.m.ModuleType == input.ModuleType).ToList(); List <MultimediaOutput> list = new List <MultimediaOutput>(); if (ret.Count > 0) { ret.ForEach((x) => { MultimediaOutput output = new MultimediaOutput(); List <MultimediaAttachmentInput> mlist = new List <MultimediaAttachmentInput>(); if (x.a.Count() > 0) { foreach (var tb in x.a) { MultimediaAttachmentInput mul = new MultimediaAttachmentInput(); mul.Id = tb.Id; mul.FKey = tb.FKey; mul.PhysicalName = tb.PhysicalName; mul.LogicName = tb.LogicName; mul.PhysicalPath = tb.PhysicalPath; mul.HttpPath = tb.HttpPath; mul.FileSize = tb.FileSize; mul.Extension = tb.Extension; mul.TypeCode = tb.TypeCode; mlist.Add(mul); } } output.Id = x.m.Id; output.Name = x.m.Name; output.ModuleType = x.m.ModuleType; output.Children = mlist; list.Add(output); }); } return(list); }