Пример #1
0
        public void Zhiding()
        {
            ZhishiXinxi zhishiXinxi = new ZhishiXinxi(this);

            ZhishiDataModel model = NHibernateHelper.CurrentSession.Get<ZhishiDataModel>(this.Id);

            model.Shunxu = 1;
            model.Zhidingde = true;

            NHibernateHelper.CurrentSession.Update(model);
            NHibernateHelper.CurrentSession.Flush();

            this.Shunxu = 1;
            this.Zhidingde = true;

            if (this.Xiugaihou != null)
            {
                XiugaihouEventArgs<ZhishiXinxi> args = new XiugaihouEventArgs<ZhishiXinxi>();
                args.XiugaiqianXinxi = zhishiXinxi;
                this.Xiugaihou(this, args);
            }
        }
Пример #2
0
        public void Xiugai(string wenti, int? shunxu, string yijiDaanNeirong, List<FujianXinxi> yijiDaanFujian,
            string erjiDaanNeirong, List<FujianXinxi> erjiDaanFujian, string sanjiDaanNeirong, List<FujianXinxi> sanjiDaanFujian,
            string sijiDaanNeirong, List<FujianXinxi> sijiDaanFujian, string wujiDaanNeirong, List<FujianXinxi> wujiDaanFujian, 
            bool shengjiBanben, string xiugairen)
        {
            wenti = wenti.Trim();
            if (this.Mulu.GetZhishiList().Any(x => x.Wenti.Equals(wenti, StringComparison.InvariantCultureIgnoreCase) && x != this))
            {
                throw new Exception("修改失败,知识问题重复");
            }
            if (string.IsNullOrEmpty(yijiDaanNeirong) && string.IsNullOrEmpty(erjiDaanNeirong) &&
                string.IsNullOrEmpty(sanjiDaanNeirong) && string.IsNullOrEmpty(sijiDaanNeirong) &&
                string.IsNullOrEmpty(wujiDaanNeirong))
            {
                throw new Exception("修改失败,至少填写一个答案");
            }
            ZhishiXinxi zhishiXinxi = new ZhishiXinxi(this);

            ZhishiDataModel model = NHibernateHelper.CurrentSession.Get<ZhishiDataModel>(this.Id);

            Mulu mulu = Mulu;
            bool youYijiDaanGuanliQuanxian = mulu.YouDaanGuanliQuanxian(xiugairen, QuanxianZhi.YijiDaan);
            bool youErjiDaanGuanliQuanxian = mulu.YouDaanGuanliQuanxian(xiugairen, QuanxianZhi.ErjiDaan);
            bool youSanjiDaanGuanliQuanxian = mulu.YouDaanGuanliQuanxian(xiugairen, QuanxianZhi.SanjiDaan);
            bool youSijiDaanGuanliQuanxian = mulu.YouDaanGuanliQuanxian(xiugairen, QuanxianZhi.SijiDaan);
            bool youWujiDaanGuanliQuanxian = mulu.YouDaanGuanliQuanxian(xiugairen, QuanxianZhi.WujiDaan);

            if (shengjiBanben)
            {
                this.ChuangjianLishi(xiugairen);
                Daan yijiDaan = youYijiDaanGuanliQuanxian
                                    ? Zhishiku.ChuangjianDaan(yijiDaanNeirong, yijiDaanFujian)
                                    : Zhishiku.ChuangjianDaan(YijiDaan.Neirong, YijiDaan.FujianList);
                Daan erjiDaan = youErjiDaanGuanliQuanxian
                                    ? Zhishiku.ChuangjianDaan(erjiDaanNeirong, erjiDaanFujian)
                                    : Zhishiku.ChuangjianDaan(ErjiDaan.Neirong, ErjiDaan.FujianList);
                Daan sanjiDaan = youSanjiDaanGuanliQuanxian
                                     ? Zhishiku.ChuangjianDaan(sanjiDaanNeirong, sanjiDaanFujian)
                                     : Zhishiku.ChuangjianDaan(SanjiDaan.Neirong, SanjiDaan.FujianList);
                Daan sijiDaan = youSijiDaanGuanliQuanxian
                                    ? Zhishiku.ChuangjianDaan(sijiDaanNeirong, sijiDaanFujian)
                                    : Zhishiku.ChuangjianDaan(SijiDaan.Neirong, SijiDaan.FujianList);
                Daan wujiDaan = youWujiDaanGuanliQuanxian
                                    ? Zhishiku.ChuangjianDaan(wujiDaanNeirong, wujiDaanFujian)
                                    : Zhishiku.ChuangjianDaan(WujiDaan.Neirong, WujiDaan.FujianList);

                YijiDaan = yijiDaan;
                ErjiDaan = erjiDaan;
                SanjiDaan = sanjiDaan;
                SijiDaan = sijiDaan;
                WujiDaan = wujiDaan;

                model.YijiDaan = yijiDaan.Id;
                model.ErjiDaan = erjiDaan.Id;
                model.SanjiDaan = sanjiDaan.Id;
                model.SijiDaan = sijiDaan.Id;
                model.WujiDaan = wujiDaan.Id;
                model.Banben++;
            }
            else
            {
                if (youYijiDaanGuanliQuanxian)
                {
                    this.YijiDaan.Xiugai(yijiDaanNeirong, yijiDaanFujian);
                }
                if (youErjiDaanGuanliQuanxian)
                {
                    this.ErjiDaan.Xiugai(erjiDaanNeirong, erjiDaanFujian);
                }
                if (youSanjiDaanGuanliQuanxian)
                {
                    this.SanjiDaan.Xiugai(sanjiDaanNeirong, sanjiDaanFujian);
                }
                if (youSijiDaanGuanliQuanxian)
                {
                    this.SijiDaan.Xiugai(sijiDaanNeirong, sijiDaanFujian);
                }
                if (youWujiDaanGuanliQuanxian)
                {
                    this.WujiDaan.Xiugai(wujiDaanNeirong, wujiDaanFujian);
                }
            }
            //model.Shunxu = shunxu;
            model.Wenti = wenti;
            model.Xiugairen = xiugairen;
            model.XiugaiShijian = DateTime.Now;

            NHibernateHelper.CurrentSession.Update(model);
            NHibernateHelper.CurrentSession.Flush();

            this.Wenti = wenti;
            this.Banben = model.Banben;
            //this.Shunxu = shunxu;
            this.Xiugairen = xiugairen;
            this.XiugaiShijian = model.XiugaiShijian;

            if (this.Xiugaihou != null)
            {
                XiugaihouEventArgs<ZhishiXinxi> args = new XiugaihouEventArgs<ZhishiXinxi>();
                args.XiugaiqianXinxi = zhishiXinxi;
                this.Xiugaihou(this, args);
            }
        }