public SingleResult <bool> shenhe(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var kyxm     = entity.cgKeYanXiangMu;
            var zuzuo    = entity.cgZuZhuo;
            var jiaocai  = entity.cgJiaoCai;
            var lunwen   = entity.cgLunWen;
            var ruanjian = entity.CgRuanJianYuZhuanLi;
            var qita     = entity.cgQiTa;
            var yijian   = entity.CgShenHeYiJian;
            var sh       = entity.CgShenHe;

            try
            {
                if (kyxm != null)
                {
                    if (_dbContext.CgKeYanXiangMu.Any(x => x.Id == kyxm.Id))
                    {
                        SaveShenHe(kyxm.Id, sh, status);
                        var query_kyxm = _dbContext.CgKeYanXiangMu.SingleOrDefault(x => x.Id == kyxm.Id);
                        query_kyxm.ShenHeJiaKouFen   = kyxm.ShenHeJiaKouFen;
                        query_kyxm.JiaKouFenShuoMing = kyxm.JiaKouFenShuoMing;
                        query_kyxm.ShenHeDeFen       = kyxm.ShenHeDeFen;
                        query_kyxm.ShiJiDeFen        = kyxm.ShiJiDeFen;



                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == kyxm.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_kyxm.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }
                else if (zuzuo != null)
                {
                    if (_dbContext.CgZuZhuo.Any(x => x.Id == zuzuo.Id))
                    {
                        SaveShenHe(zuzuo.Id, sh, status);
                        var query_zuzuo = _dbContext.CgZuZhuo.SingleOrDefault(x => x.Id == zuzuo.Id);
                        query_zuzuo.ShenHeJiaKouFen   = zuzuo.ShenHeJiaKouFen;
                        query_zuzuo.JiaKouFenShuoMing = zuzuo.JiaKouFenShuoMing;
                        query_zuzuo.ShenHeDeFen       = zuzuo.ShenHeDeFen;
                        query_zuzuo.ShiJiDeFen        = zuzuo.ShiJiDeFen;

                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == zuzuo.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_zuzuo.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }
                else if (jiaocai != null)
                {
                    if (_dbContext.CgJiaoCai.Any(x => x.Id == jiaocai.Id))
                    {
                        SaveShenHe(jiaocai.Id, sh, status);
                        var query_jiaocai = _dbContext.CgJiaoCai.SingleOrDefault(x => x.Id == jiaocai.Id);
                        query_jiaocai.ShenHeJiaKouFen   = jiaocai.ShenHeJiaKouFen;
                        query_jiaocai.JiaKouFenShuoMing = jiaocai.JiaKouFenShuoMing;
                        query_jiaocai.ShenHeDeFen       = jiaocai.ShenHeDeFen;
                        query_jiaocai.ShiJiDenFen       = jiaocai.ShiJiDenFen;

                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == jiaocai.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_jiaocai.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }
                else if (lunwen != null)
                {
                    if (_dbContext.CgLunWen.Any(x => x.Id == lunwen.Id))
                    {
                        SaveShenHe(lunwen.Id, sh, status);
                        var query_lunwen = _dbContext.CgLunWen.SingleOrDefault(x => x.Id == lunwen.Id);
                        query_lunwen.ShenHeJiaKouFen   = lunwen.ShenHeJiaKouFen;
                        query_lunwen.JiaKouFenShuoMing = lunwen.JiaKouFenShuoMing;
                        query_lunwen.ShenHeDeFen       = lunwen.ShenHeDeFen;
                        query_lunwen.ShiJiDeFen        = lunwen.ShiJiDeFen;

                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == lunwen.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_lunwen.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }
                else if (ruanjian != null)
                {
                    if (_dbContext.CgRuanJianYuZhuanLi.Any(x => x.Id == ruanjian.Id))
                    {
                        SaveShenHe(ruanjian.Id, sh, status);
                        var query_ruanjian = _dbContext.CgRuanJianYuZhuanLi.SingleOrDefault(x => x.Id == ruanjian.Id);
                        query_ruanjian.ShenHeJiaKouFen   = ruanjian.ShenHeJiaKouFen;
                        query_ruanjian.JiaKouFenShuoMing = ruanjian.JiaKouFenShuoMing;
                        query_ruanjian.ShenHeDeFen       = ruanjian.ShenHeDeFen;
                        query_ruanjian.ShiJiDeFen        = ruanjian.ShiJiDeFen;

                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == ruanjian.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_ruanjian.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }
                else if (qita != null)
                {
                    if (_dbContext.CgQiTa.Any(x => x.Id == qita.Id))
                    {
                        SaveShenHe(qita.Id, sh, status);
                        var query_qita = _dbContext.CgQiTa.SingleOrDefault(x => x.Id == qita.Id);
                        query_qita.ShenHeJiaKouFen   = qita.ShenHeJiaKouFen;
                        query_qita.JiaKouFenShuoMing = qita.JiaKouFenShuoMing;
                        query_qita.ShenHeDeFen       = qita.ShenHeDeFen;
                        query_qita.ShiJiDeFen        = qita.ShiJiDeFen;

                        var query = _dbContext.CgJiLu.SingleOrDefault(x => x.CgId == qita.Id);
                        if (status == 3)
                        {
                            query.IsKeYanChuShenHe = 1;
                        }
                        query.ShenHeFen        = query_qita.ShenHeDeFen;
                        query.Status           = status + 1;
                        query.LastUpdateDate   = DateTime.Now;
                        query.ShangJiShenHeRen = _fapContext.CurrentUser.Name;
                    }
                }

                singleResult.Result = _dbContext.SaveChanges() > 0;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }
        /// <summary>
        /// 添加cgkyxm
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="zt">状态</param>
        /// <param name="status"></param>
        /// <returns></returns>
        public SingleResult <bool> AddCgkyxm(Request_CG_Bag entity, int zt, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var  currentUser = _fapContext.CurrentUser;
            var  kyxm        = entity.cgKeYanXiangMu;
            var  canyuzes    = entity.canyuzes;
            var  fm          = entity.fengmianList;
            var  file        = entity.fileList;
            var  article     = entity.articleList;
            var  wenjian     = entity.wenjianList;
            var  jilu        = entity.jilu;
            bool result      = false;

            try
            {
                //科研项目
                kyxm.Id               = Guid.NewGuid();
                kyxm.UserName         = currentUser.Name;
                kyxm.UserId           = currentUser.Id;
                kyxm.XiangMuZhuangTai = zt;
                kyxm.Status           = status;
                kyxm.CreateDate       = kyxm.LastUpdateDate = DateTime.Now;
                kyxm.BuMenId          = OrgHelper.GetBuMenId(currentUser);
                kyxm.BuMenMingCheng   = OrgHelper.GetBuMenMingCheng(currentUser);
                _dbContext.CgKeYanXiangMu.Add(kyxm);

                //参与者
                if (canyuzes != null)
                {
                    for (int i = 0; i < canyuzes.Count; i++)
                    {
                        var cgCanYuZhe = new CgCanYuZhe();
                        cgCanYuZhe.Id   = Guid.NewGuid();
                        cgCanYuZhe.CgId = kyxm.Id;
                        cgCanYuZhe.Name = canyuzes[i].name;
                        if (canyuzes[i].isbenyuan == "是")
                        {
                            cgCanYuZhe.IsBenYuan = 0;
                        }
                        else
                        {
                            cgCanYuZhe.IsBenYuan = 1;
                        }
                        cgCanYuZhe.PaiXu          = i;
                        cgCanYuZhe.IsTongXunZuoZe = 1;
                        cgCanYuZhe.Status         = 0;
                        cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                        _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                    }
                }
                //附件
                if (fm != null)
                {
                    for (int i = 0; i < fm.Count; i++)
                    {
                        fm[i].Id             = Guid.NewGuid();
                        fm[i].ChengGuoId     = kyxm.Id;
                        fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                        fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                        fm[i].PaiXu          = i.ToString();
                        _dbContext.FuJian.Add(fm[i]);
                    }
                }
                if (file != null)
                {
                    for (int i = 0; i < file.Count; i++)
                    {
                        file[i].Id             = Guid.NewGuid();
                        file[i].ChengGuoId     = kyxm.Id;
                        file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                        file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                        file[i].PaiXu          = i.ToString();
                        _dbContext.FuJian.Add(file[i]);
                    }
                }
                if (article != null)
                {
                    for (int i = 0; i < article.Count; i++)
                    {
                        article[i].Id             = Guid.NewGuid();
                        article[i].ChengGuoId     = kyxm.Id;
                        article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                        article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                        article[i].PaiXu          = i.ToString();
                        _dbContext.FuJian.Add(article[i]);
                    }
                }
                if (wenjian != null)
                {
                    for (int i = 0; i < wenjian.Count; i++)
                    {
                        wenjian[i].Id             = Guid.NewGuid();
                        wenjian[i].ChengGuoId     = kyxm.Id;
                        wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                        wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                        wenjian[i].PaiXu          = i.ToString();
                        _dbContext.FuJian.Add(wenjian[i]);
                    }
                }

                result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(kyxm, jilu, canyuzes, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误", ex);
            }
            return(singleResult);
        }
        public SingleResult <bool> SaveCGkyxm(Request_CG_Bag entity, string zhuangtai1, string zhuangtai2, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var kyxm        = entity.cgKeYanXiangMu;
            var canyuzes    = entity.canyuzes;
            var fm          = entity.fengmianList;
            var file        = entity.fileList;
            var article     = entity.articleList;
            var wenjian     = entity.wenjianList;
            var jilu        = entity.jilu;
            var result      = false;

            try
            {
                if (kyxm.Id == Guid.Empty)
                {
                    if (Convert.ToInt32(zhuangtai2) == -1)
                    {
                        AddCgkyxm(entity, Convert.ToInt32(zhuangtai1), status);
                    }
                    else
                    {
                        AddCgkyxm(entity, Convert.ToInt32(zhuangtai1), status);
                        AddCgkyxm(entity, Convert.ToInt32(zhuangtai2), status);
                    }
                }
                else
                {
                    var query_kyxm = _dbContext.CgKeYanXiangMu.SingleOrDefault(x => x.Id == kyxm.Id);
                    query_kyxm.PiZunLiXiangBuMen         = kyxm.PiZunLiXiangBuMen;
                    query_kyxm.LiXiangShiJian            = kyxm.LiXiangShiJian;
                    query_kyxm.JiHuaWanChengShiJian      = kyxm.JiHuaWanChengShiJian;
                    query_kyxm.GongBuJieXiangShiJian     = kyxm.GongBuJieXiangShiJian;
                    query_kyxm.XiangMuJiBie              = kyxm.XiangMuJiBie;
                    query_kyxm.XiangMuLeiBie             = kyxm.XiangMuLeiBie;
                    query_kyxm.YuanNeiXiangMuBianHao     = kyxm.YuanNeiXiangMuBianHao;
                    query_kyxm.YuanWaiXiangMuBianHao     = kyxm.YuanWaiXiangMuBianHao;
                    query_kyxm.XiangMuZiZuZongE          = kyxm.XiangMuZiZuZongE;
                    query_kyxm.BenRenShuMingPaiXu        = kyxm.BenRenShuMingPaiXu;
                    query_kyxm.XiangMuZhuangTai          = kyxm.XiangMuZhuangTai;
                    query_kyxm.IsYuanKeYanZuGuanBmgl     = kyxm.IsYuanKeYanZuGuanBmgl;
                    query_kyxm.IsBenRenZhiDao            = kyxm.IsBenRenZhiDao;
                    query_kyxm.XiangMuHuoJiangJiBie      = kyxm.XiangMuHuoJiangJiBie;
                    query_kyxm.XiangMuHuoJiangTime       = kyxm.XiangMuHuoJiangTime;
                    query_kyxm.XiangMuHuoJiangZhengShuId = kyxm.XiangMuHuoJiangZhengShuId;
                    query_kyxm.XiangMuChengGuoCaiNaJiBie = kyxm.XiangMuChengGuoCaiNaJiBie;
                    query_kyxm.XiangMuChengGuoCaiNaTime  = kyxm.XiangMuChengGuoCaiNaTime;
                    query_kyxm.KeYanKaoHeDeFen           = kyxm.KeYanKaoHeDeFen;
                    query_kyxm.LastUpdateDate            = DateTime.Now;
                    query_kyxm.XiangMuHuoJiangMingCheng  = kyxm.XiangMuHuoJiangMingCheng;
                    query_kyxm.ShiJiDeFen             = kyxm.ShiJiDeFen;
                    query_kyxm.XiangMuLaiYuan         = kyxm.XiangMuLaiYuan;
                    query_kyxm.XueShengJieXiangDengJi = kyxm.XueShengJieXiangDengJi;
                    query_kyxm.Status = status;
                    query_kyxm.YuanNeiBenRenShuMingPaiXu = kyxm.YuanNeiBenRenShuMingPaiXu;
                    query_kyxm.XiangMuMingCheng          = kyxm.XiangMuMingCheng;
                    query_kyxm.SuoShuNianDu = kyxm.SuoShuNianDu;
                    //_mapper.Map(query_kyxm,kyxm, typeof(CgKeYanXiangMu), typeof(CgKeYanXiangMu));


                    var query_cyz = _dbContext.CgCanYuZhe.Where(x => x.CgId == kyxm.Id);
                    _dbContext.CgCanYuZhe.RemoveRange(query_cyz);
                    //参与者
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = kyxm.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == kyxm.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);
                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = kyxm.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }

                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = kyxm.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }

                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = kyxm.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }

                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = kyxm.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }

                    SaveCgjl(kyxm, jilu, canyuzes, status);
                }

                singleResult.Result = _dbContext.SaveChanges() > 0;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误", ex);
            }
            return(singleResult);
        }
Esempio n. 4
0
        public SingleResult <bool> SaveCgJiaoCai(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var jiaocai     = entity.cgJiaoCai;
            // var canyuzes = entity.canyuzes;
            var fm      = entity.fengmianList;
            var file    = entity.fileList;
            var article = entity.articleList;
            var wenjian = entity.wenjianList;
            var banquan = entity.banquanlist;
            var jilu    = entity.jilu;

            try
            {
                if (jiaocai.Id == Guid.Empty)
                {
                    jiaocai.Id             = Guid.NewGuid();
                    jiaocai.UserId         = currentUser.Id;
                    jiaocai.UserName       = currentUser.Name;
                    jiaocai.Status         = status;
                    jiaocai.CreateDate     = jiaocai.LastUpdateDate = DateTime.Now;
                    jiaocai.BuMenId        = OrgHelper.GetBuMenId(currentUser);
                    jiaocai.BuMenMingCheng = OrgHelper.GetBuMenMingCheng(currentUser);
                    _dbContext.CgJiaoCai.Add(jiaocai);

                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = jiaocai.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }

                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = jiaocai.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }

                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = jiaocai.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }

                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = jiaocai.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = jiaocai.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                }
                else
                {
                    //教材
                    var query_jiaocai = _dbContext.CgJiaoCai.SingleOrDefault(x => x.Id == jiaocai.Id);
                    query_jiaocai.JiaoCaiMingCheng       = jiaocai.JiaoCaiMingCheng;
                    query_jiaocai.Isbn                   = jiaocai.Isbn;
                    query_jiaocai.ChuBanShe              = jiaocai.ChuBanShe;
                    query_jiaocai.ChuBanSheJiBie         = jiaocai.ChuBanSheJiBie;
                    query_jiaocai.ChuBanShiJian          = jiaocai.ChuBanShiJian;
                    query_jiaocai.CanBianQingKuang       = jiaocai.CanBianQingKuang;
                    query_jiaocai.IsBiaoZhuXueYuan       = jiaocai.IsBiaoZhuXueYuan;
                    query_jiaocai.QuanShuZiShu           = jiaocai.QuanShuZiShu;
                    query_jiaocai.CanBianZhangJie        = jiaocai.CanBianZhangJie;
                    query_jiaocai.CanBianZiShu           = jiaocai.CanBianZiShu;
                    query_jiaocai.JiaoCaiHuoJiangJiBie   = jiaocai.JiaoCaiHuoJiangJiBie;
                    query_jiaocai.JiaoCaiHuoJiangShiJian = jiaocai.JiaoCaiHuoJiangShiJian;
                    query_jiaocai.KeYanKaoHeDeFen        = jiaocai.KeYanKaoHeDeFen;
                    query_jiaocai.LastUpdateDate         = DateTime.Now;
                    query_jiaocai.HuoJiangMingCheng      = jiaocai.HuoJiangMingCheng;
                    query_jiaocai.ShiJiDenFen            = jiaocai.ShiJiDenFen;
                    query_jiaocai.Status                 = status;
                    query_jiaocai.SuoShuNianDu           = jiaocai.SuoShuNianDu;

                    //附件
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == jiaocai.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);
                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = jiaocai.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }

                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = jiaocai.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }

                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = jiaocai.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }

                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = jiaocai.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = jiaocai.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                }
                var result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(jiaocai, jilu, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }
        public SingleResult <bool> SaveCgZhuzuo(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var zhuzuo      = entity.cgZuZhuo;
            var canyuzes    = entity.canyuzes;
            var fm          = entity.fengmianList;
            var file        = entity.fileList;
            var article     = entity.articleList;
            var wenjian     = entity.wenjianList;
            var banquan     = entity.banquanlist;
            var jilu        = entity.jilu;

            try
            {
                if (zhuzuo.Id == Guid.Empty)
                {
                    zhuzuo.Id             = Guid.NewGuid();
                    zhuzuo.UserId         = currentUser.Id;
                    zhuzuo.UserName       = currentUser.Name;
                    zhuzuo.Status         = status;
                    zhuzuo.CreateDate     = zhuzuo.LastUpdateDate = DateTime.Now;
                    zhuzuo.BuMenId        = OrgHelper.GetBuMenId(currentUser);
                    zhuzuo.BuMenMingCheng = OrgHelper.GetBuMenMingCheng(currentUser);
                    _dbContext.CgZuZhuo.Add(zhuzuo);
                    //作者
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = zhuzuo.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }


                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = zhuzuo.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }

                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = zhuzuo.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }

                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = zhuzuo.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }

                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = zhuzuo.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }

                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = zhuzuo.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                }
                else
                {
                    var query_zuzhuo = _dbContext.CgZuZhuo.SingleOrDefault(x => x.Id == zhuzuo.Id);
                    query_zuzhuo.ZuZuoMingCheng             = zhuzuo.ZuZuoMingCheng;
                    query_zuzhuo.Isbn                       = zhuzuo.Isbn;
                    query_zuzhuo.LeiBie                     = zhuzuo.LeiBie;
                    query_zuzhuo.ChuBanSe                   = zhuzuo.ChuBanSe;
                    query_zuzhuo.ChuBanSeJiBie              = zhuzuo.ChuBanSeJiBie;
                    query_zuzhuo.ChuBanShiJian              = zhuzuo.ChuBanShiJian;
                    query_zuzhuo.FengMianBenRenShuMingPaiXu = zhuzuo.FengMianBenRenShuMingPaiXu;
                    query_zuzhuo.YuanNeiBenRenShuMingPaiXu  = zhuzuo.YuanNeiBenRenShuMingPaiXu;
                    query_zuzhuo.IsBiaoZhuXueYuan           = zhuzuo.IsBiaoZhuXueYuan;
                    query_zuzhuo.QuanShuZiShu               = zhuzuo.QuanShuZiShu;
                    query_zuzhuo.GongGaoZhangJie            = zhuzuo.GongGaoZhangJie;
                    query_zuzhuo.GongGaoZiShu               = zhuzuo.GongGaoZiShu;
                    query_zuzhuo.ZuZhuoHuoJiangJiBie        = zhuzuo.ZuZhuoHuoJiangJiBie;
                    query_zuzhuo.ZuZhuoHuoJiangShiJian      = zhuzuo.ZuZhuoHuoJiangShiJian;
                    query_zuzhuo.KeYanKaoHeDeFen            = zhuzuo.KeYanKaoHeDeFen;
                    query_zuzhuo.LastUpdateDate             = DateTime.Now;
                    query_zuzhuo.HuoJiangMingCheng          = zhuzuo.HuoJiangMingCheng;
                    query_zuzhuo.ShiJiDeFen                 = zhuzuo.ShiJiDeFen;
                    query_zuzhuo.Status                     = status;
                    query_zuzhuo.SuoShuNianDu               = zhuzuo.SuoShuNianDu;

                    //作者
                    var query_cyz = _dbContext.CgCanYuZhe.Where(x => x.CgId == zhuzuo.Id);
                    _dbContext.CgCanYuZhe.RemoveRange(query_cyz);
                    //作者
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = zhuzuo.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }


                    //附件
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == zhuzuo.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);
                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = zhuzuo.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }

                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = zhuzuo.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }

                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = zhuzuo.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }

                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = zhuzuo.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }

                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = zhuzuo.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                }
                var result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(zhuzuo, jilu, canyuzes, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }
        public SingleResult <bool> SaveCgLunWen(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var lunwen      = entity.cgLunWen;
            var canyuzes    = entity.canyuzes;
            var fm          = entity.fengmianList;
            var file        = entity.fileList;
            var article     = entity.articleList;
            var wenjian     = entity.wenjianList;
            var banquan     = entity.banquanlist;
            var zhengshu    = entity.zhengshulist;
            var baozhi      = entity.baozhilist;
            var jilu        = entity.jilu;

            try
            {
                if (lunwen.Id == Guid.Empty)
                {
                    lunwen.Id         = Guid.NewGuid();
                    lunwen.UserId     = currentUser.Id;
                    lunwen.UserName   = currentUser.Name;
                    lunwen.Status     = status;
                    lunwen.CreateDate = lunwen.LastUpdateDate = DateTime.Now;
                    lunwen.YuanNeiBenRenShuMingPaiXu = lunwen.BenRenShuMingPaiXu;
                    lunwen.BuMenId        = OrgHelper.GetBuMenId(currentUser);
                    lunwen.BuMenMingCheng = OrgHelper.GetBuMenMingCheng(currentUser);
                    _dbContext.CgLunWen.Add(lunwen);
                    //作者
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = lunwen.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }

                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = lunwen.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = lunwen.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = lunwen.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = lunwen.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = lunwen.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                    if (zhengshu != null)
                    {
                        for (int i = 0; i < zhengshu.Count; i++)
                        {
                            zhengshu[i].Id             = Guid.NewGuid();
                            zhengshu[i].ChengGuoId     = lunwen.Id;
                            zhengshu[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.证书;
                            zhengshu[i].CreateDateTime = zhengshu[i].LastUpdateTime = DateTime.Now;
                            zhengshu[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(zhengshu[i]);
                        }
                    }
                    if (baozhi != null)
                    {
                        for (int i = 0; i < baozhi.Count; i++)
                        {
                            baozhi[i].Id             = Guid.NewGuid();
                            baozhi[i].ChengGuoId     = lunwen.Id;
                            baozhi[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.报纸;
                            baozhi[i].CreateDateTime = baozhi[i].LastUpdateTime = DateTime.Now;
                            baozhi[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(baozhi[i]);
                        }
                    }
                }
                else
                {
                    var query_lunwen = _dbContext.CgLunWen.SingleOrDefault(x => x.Id == lunwen.Id);
                    query_lunwen.LunWenMingCheng           = lunwen.LunWenMingCheng;
                    query_lunwen.LunWenLeiBie              = lunwen.LunWenLeiBie;
                    query_lunwen.FaBiaoQiKan               = lunwen.FaBiaoQiKan;
                    query_lunwen.DangNianQiHao             = lunwen.DangNianQiHao;
                    query_lunwen.LunWenRenDingJiFenLeiXing = lunwen.LunWenRenDingJiFenLeiXing;
                    query_lunwen.ShouLuQiangKuang          = lunwen.ShouLuQiangKuang;
                    query_lunwen.FaBiaoNianDu              = lunwen.FaBiaoNianDu;
                    query_lunwen.BenRenShuMingPaiXu        = lunwen.BenRenShuMingPaiXu;
                    query_lunwen.YuanNeiBenRenShuMingPaiXu = lunwen.YuanNeiBenRenShuMingPaiXu;
                    query_lunwen.IsBiaoZhuXueYuan          = lunwen.IsBiaoZhuXueYuan;
                    query_lunwen.LunWenZiShu               = lunwen.LunWenZiShu;
                    query_lunwen.IsYuHangYeLianHeFaBiao    = lunwen.IsYuHangYeLianHeFaBiao;
                    query_lunwen.IsYuDiFangLianHeFaBiao    = lunwen.IsYuDiFangLianHeFaBiao;
                    query_lunwen.IsYuGuoJiLianHeFaBiao     = lunwen.IsYuGuoJiLianHeFaBiao;
                    query_lunwen.IsKuaXueKeLunWen          = lunwen.IsKuaXueKeLunWen;
                    query_lunwen.LunWenHuoJiangJiBie       = lunwen.LunWenHuoJiangJiBie;
                    query_lunwen.LunWenHuoJiangShiJian     = lunwen.LunWenHuoJiangShiJian;
                    query_lunwen.KeYanKaoHeDeFen           = lunwen.KeYanKaoHeDeFen;
                    query_lunwen.LastUpdateDate            = DateTime.Now;
                    query_lunwen.HuoJiangMingCheng         = lunwen.HuoJiangMingCheng;
                    query_lunwen.ShiJiDeFen       = lunwen.ShiJiDeFen;
                    query_lunwen.ZaiTiLeiXing     = lunwen.ZaiTiLeiXing;
                    query_lunwen.ZaiTiMingCheng   = lunwen.ZaiTiMingCheng;
                    query_lunwen.GuoJiBiaoZhunHao = lunwen.GuoJiBiaoZhunHao;
                    query_lunwen.ChuBanSe         = lunwen.ChuBanSe;
                    query_lunwen.Status           = status;
                    query_lunwen.SuoShuNianDu     = lunwen.SuoShuNianDu;

                    //作者
                    var query_cyz = _dbContext.CgCanYuZhe.Where(x => x.CgId == lunwen.Id);
                    _dbContext.CgCanYuZhe.RemoveRange(query_cyz);

                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = lunwen.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }


                    //附件
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == lunwen.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);

                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = lunwen.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = lunwen.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = lunwen.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = lunwen.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (banquan != null)
                    {
                        for (int i = 0; i < banquan.Count; i++)
                        {
                            banquan[i].Id             = Guid.NewGuid();
                            banquan[i].ChengGuoId     = lunwen.Id;
                            banquan[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.版权页面;
                            banquan[i].CreateDateTime = banquan[i].LastUpdateTime = DateTime.Now;
                            banquan[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(banquan[i]);
                        }
                    }
                    if (zhengshu != null)
                    {
                        for (int i = 0; i < zhengshu.Count; i++)
                        {
                            zhengshu[i].Id             = Guid.NewGuid();
                            zhengshu[i].ChengGuoId     = lunwen.Id;
                            zhengshu[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.证书;
                            zhengshu[i].CreateDateTime = zhengshu[i].LastUpdateTime = DateTime.Now;
                            zhengshu[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(zhengshu[i]);
                        }
                    }
                    if (baozhi != null)
                    {
                        for (int i = 0; i < baozhi.Count; i++)
                        {
                            baozhi[i].Id             = Guid.NewGuid();
                            baozhi[i].ChengGuoId     = lunwen.Id;
                            baozhi[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.报纸;
                            baozhi[i].CreateDateTime = baozhi[i].LastUpdateTime = DateTime.Now;
                            baozhi[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(baozhi[i]);
                        }
                    }
                }
                var result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(lunwen, jilu, canyuzes, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }
        public SingleResult <bool> SaveCgRuanJian(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var ruanjian    = entity.CgRuanJianYuZhuanLi;
            var canyuzes    = entity.canyuzes;
            var zhuanlis    = entity.zhuanlis;
            var fm          = entity.fengmianList;
            var file        = entity.fileList;
            var article     = entity.articleList;
            var wenjian     = entity.wenjianList;
            var zhengshu    = entity.zhengshulist;
            var jilu        = entity.jilu;

            try
            {
                if (ruanjian.Id == Guid.Empty)
                {
                    ruanjian.Id         = Guid.NewGuid();
                    ruanjian.UserId     = currentUser.Id;
                    ruanjian.UserName   = currentUser.Name;
                    ruanjian.Status     = status;
                    ruanjian.CreateDate = ruanjian.LastUpdateDate = DateTime.Now;
                    ruanjian.YuanNeiBenRenShuMingPaiXu = ruanjian.BenRenShuMingPaiXu;
                    ruanjian.BuMenId        = OrgHelper.GetBuMenId(currentUser);
                    ruanjian.BuMenMingCheng = OrgHelper.GetBuMenMingCheng(currentUser);
                    _dbContext.CgRuanJianYuZhuanLi.Add(ruanjian);
                    //作者
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = ruanjian.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }
                    if (zhuanlis != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = ruanjian.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 1;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }


                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = ruanjian.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = ruanjian.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = ruanjian.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = ruanjian.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (zhengshu != null)
                    {
                        for (int i = 0; i < zhengshu.Count; i++)
                        {
                            zhengshu[i].Id             = Guid.NewGuid();
                            zhengshu[i].ChengGuoId     = ruanjian.Id;
                            zhengshu[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.证书;
                            zhengshu[i].CreateDateTime = zhengshu[i].LastUpdateTime = DateTime.Now;
                            zhengshu[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(zhengshu[i]);
                        }
                    }
                }
                else
                {
                    var query_ruanjian = _dbContext.CgRuanJianYuZhuanLi.SingleOrDefault(x => x.Id == ruanjian.Id);
                    query_ruanjian.MingCheng                 = ruanjian.MingCheng;
                    query_ruanjian.LeiXing                   = ruanjian.LeiXing;
                    query_ruanjian.BenRenShuMingPaiXu        = ruanjian.BenRenShuMingPaiXu;
                    query_ruanjian.YuanNeiBenRenShuMingPaiXu = ruanjian.YuanNeiBenRenShuMingPaiXu;
                    query_ruanjian.IsHangYeLianHeZhuanLi     = ruanjian.IsHangYeLianHeZhuanLi;
                    query_ruanjian.KeYanKaoHeDeFen           = ruanjian.KeYanKaoHeDeFen;
                    query_ruanjian.LastUpdateDate            = DateTime.Now;
                    query_ruanjian.HuoJiangMingCheng         = ruanjian.HuoJiangMingCheng;
                    query_ruanjian.ShiJiDeFen                = ruanjian.ShiJiDeFen;
                    query_ruanjian.ZhuanLiHao                = ruanjian.ZhuanLiHao;
                    query_ruanjian.ZhuanLiShenQingRi         = ruanjian.ZhuanLiShenQingRi;
                    query_ruanjian.ShouQuanGongGaoRi         = ruanjian.ShouQuanGongGaoRi;
                    query_ruanjian.DengJiHao                 = ruanjian.DengJiHao;
                    query_ruanjian.KaiFaWanChengRiQi         = ruanjian.KaiFaWanChengRiQi;
                    query_ruanjian.QuanLiQuDeFangShi         = ruanjian.QuanLiQuDeFangShi;
                    query_ruanjian.QuanLiFanWei              = ruanjian.QuanLiFanWei;
                    query_ruanjian.Status       = status;
                    query_ruanjian.SuoShuNianDu = ruanjian.SuoShuNianDu;


                    var query_cyz = _dbContext.CgCanYuZhe.Where(x => x.CgId == ruanjian.Id);
                    _dbContext.CgCanYuZhe.RemoveRange(query_cyz);
                    if (canyuzes != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = ruanjian.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 0;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }
                    if (zhuanlis != null)
                    {
                        for (int i = 0; i < canyuzes.Count; i++)
                        {
                            var cgCanYuZhe = new CgCanYuZhe();
                            cgCanYuZhe.Id   = Guid.NewGuid();
                            cgCanYuZhe.CgId = ruanjian.Id;
                            cgCanYuZhe.Name = canyuzes[i].name;
                            if (canyuzes[i].isbenyuan == "是")
                            {
                                cgCanYuZhe.IsBenYuan = 0;
                            }
                            else
                            {
                                cgCanYuZhe.IsBenYuan = 1;
                            }
                            cgCanYuZhe.PaiXu          = i;
                            cgCanYuZhe.IsTongXunZuoZe = 1;
                            cgCanYuZhe.Status         = 1;
                            cgCanYuZhe.CreateDate     = cgCanYuZhe.LastUpdateDate = DateTime.Now;
                            _dbContext.CgCanYuZhe.Add(cgCanYuZhe);
                        }
                    }

                    //附件
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == ruanjian.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);

                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = ruanjian.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = ruanjian.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = ruanjian.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = ruanjian.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                    if (zhengshu != null)
                    {
                        for (int i = 0; i < zhengshu.Count; i++)
                        {
                            zhengshu[i].Id             = Guid.NewGuid();
                            zhengshu[i].ChengGuoId     = ruanjian.Id;
                            zhengshu[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.证书;
                            zhengshu[i].CreateDateTime = zhengshu[i].LastUpdateTime = DateTime.Now;
                            zhengshu[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                }
                var result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(ruanjian, jilu, canyuzes, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }
Esempio n. 8
0
        /// <summary>
        /// 保存 成果 其他
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public SingleResult <bool> SaveCgQita(Request_CG_Bag entity, int status)
        {
            SingleResult <bool> singleResult = new SingleResult <bool>();
            var currentUser = _fapContext.CurrentUser;
            var qita        = entity.cgQiTa;
            var canyuzes    = entity.canyuzes;
            var fm          = entity.fengmianList;
            var file        = entity.fileList;
            var article     = entity.articleList;
            var wenjian     = entity.wenjianList;
            var jilu        = entity.jilu;

            try
            {
                if (qita.Id == Guid.Empty)
                {
                    qita.Id             = Guid.NewGuid();
                    qita.UserId         = currentUser.Id;
                    qita.UserName       = currentUser.Name;
                    qita.Status         = status;
                    qita.CreateDate     = qita.LastUpdateDate = DateTime.Now;
                    qita.BuMenId        = OrgHelper.GetBuMenId(currentUser);
                    qita.BuMenMingCheng = OrgHelper.GetBuMenMingCheng(currentUser);
                    _dbContext.CgQiTa.Add(qita);
                    //附件
                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = qita.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = qita.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = qita.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = qita.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                }
                else
                {
                    var query_qita = _dbContext.CgQiTa.SingleOrDefault(x => x.Id == qita.Id);
                    query_qita.MingCheng            = qita.MingCheng;
                    query_qita.ChengGuoNianDu       = qita.ChengGuoNianDu;
                    query_qita.KeYanChengGuoJianJie = qita.KeYanChengGuoJianJie;
                    query_qita.LastUpdateDate       = DateTime.Now;
                    query_qita.HuoJiangMingCheng    = qita.HuoJiangMingCheng;
                    query_qita.ShiJiDeFen           = query_qita.ShiJiDeFen;
                    query_qita.Status       = status;
                    query_qita.SuoShuNianDu = qita.SuoShuNianDu;

                    //附件
                    var query_fj = _dbContext.FuJian.Where(x => x.ChengGuoId == qita.Id);
                    _dbContext.FuJian.RemoveRange(query_fj);

                    if (fm != null)
                    {
                        for (int i = 0; i < fm.Count; i++)
                        {
                            fm[i].Id             = Guid.NewGuid();
                            fm[i].ChengGuoId     = qita.Id;
                            fm[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊封面;
                            fm[i].CreateDateTime = fm[i].LastUpdateTime = DateTime.Now;
                            fm[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(fm[i]);
                        }
                    }
                    if (file != null)
                    {
                        for (int i = 0; i < file.Count; i++)
                        {
                            file[i].Id             = Guid.NewGuid();
                            file[i].ChengGuoId     = qita.Id;
                            file[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.期刊目录;
                            file[i].CreateDateTime = file[i].LastUpdateTime = DateTime.Now;
                            file[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(file[i]);
                        }
                    }
                    if (article != null)
                    {
                        for (int i = 0; i < article.Count; i++)
                        {
                            article[i].Id             = Guid.NewGuid();
                            article[i].ChengGuoId     = qita.Id;
                            article[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文章页面;
                            article[i].CreateDateTime = article[i].LastUpdateTime = DateTime.Now;
                            article[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(article[i]);
                        }
                    }
                    if (wenjian != null)
                    {
                        for (int i = 0; i < wenjian.Count; i++)
                        {
                            wenjian[i].Id             = Guid.NewGuid();
                            wenjian[i].ChengGuoId     = qita.Id;
                            wenjian[i].WenJianLeiXing = (int)MeiJuUtils.chengGuoFuJianLeiXing.文件附件;
                            wenjian[i].CreateDateTime = wenjian[i].LastUpdateTime = DateTime.Now;
                            wenjian[i].PaiXu          = i.ToString();
                            _dbContext.FuJian.Add(wenjian[i]);
                        }
                    }
                }
                var result = _dbContext.SaveChanges() > 0;
                if (result)
                {
                    SaveCgjl(qita, jilu, status);
                }
                singleResult.Result = result;
            }
            catch (Exception ex)
            {
                _loggerService.LogException(_fapContext.CurrentUser, null, "", ex);
                singleResult.Error = new Error("系统未知错误");
            }
            return(singleResult);
        }