public IHttpActionResult AddGanWu(AddGanWuModel model)
        {
            var ganWu = new Zs_GanWu();
            var result = new GanWuViewModel();

            if (!ModelState.IsValid) return BadRequest(ModelState);
            //初始化实体
            ganWu = sysFun.InitialEntity<AddGanWuModel, Zs_GanWu>(model, ganWu);
            //添加事历
            ganWu = bGanWu.Add(ganWu);
            //更新附件列表
            result = UpdateAttList(ganWu);

            if (ganWu.GwID > 0)
            {
                return Ok(result);
            }
            else
            {
                return Ok("添加失败");
            }
        }
        public IHttpActionResult UpdateGanWu(UpdateGanWuModel model)
        {
            var ganWu = new Zs_GanWu();
            var result = new GanWuViewModel();

            if (!ModelState.IsValid) return BadRequest(ModelState);
            //初始化实体
            ganWu = bGanWu.Find(model.GwID);
            ganWu = sysFun.InitialEntity<UpdateGanWuModel, Zs_GanWu>(model, ganWu);
            //更新事历
            ganWu = bGanWu.UpdateEntity(ganWu);
            //更新附件列表
            result = UpdateAttList(ganWu);

            return Ok(result);
        }
        /// <summary>
        /// 更新附件列表
        /// </summary>
        /// <param name="ganWu"></param>
        private GanWuViewModel UpdateAttList(Zs_GanWu ganWu)
        {
            var result = new GanWuViewModel();

            //实体列表
            var ganWuAttList = bGanWuAtt.Entities.Where(f => f.CreateDate < ganWu.CreateDate && f.GWID == 0);
            //遍历删除本地资源
            foreach (var item in ganWuAttList) sysFun.DeleteFile(item.AttType, item.AttUrl);
            //批量删除
            if (ganWuAttList.Count() > 0) bGanWuAtt.Delete(ganWuAttList);
            //批量更新
            bGanWuAtt.Update(f => f.MID == ganWu.MID, f => new Zs_GanWuAtt { GWID = ganWu.GwID });
            //实体列表
            ganWuAttList = bGanWuAtt.Entities.Where(f => f.MID == ganWu.MID);

            result.GanWu = ganWu;
            result.GanWuAtt = ganWuAttList.ToList();

            return result;
        }
        public IHttpActionResult GetGanWuById([FromUri]long id)
        {
            var ganWu = new Zs_GanWu();
            var ganWuAtt = new List<Zs_GanWuAtt>();
            var result = new GanWuViewModel();

            ganWu = bGanWu.Find(id);
            ganWuAtt = bGanWuAtt.Entities.Where(f => f.GWID == ganWu.GwID).ToList();
            result.GanWu = ganWu;
            result.GanWuAtt = ganWuAtt;

            return Ok(result);
        }