Пример #1
0
        private ZhiweiDataModel GetZhiwei(string zhiweiName, string gongsiName)
        {
            ZhiweiDataModel model = null;

            using (ISession session = NHibernateHelper.OpenSession())
            {
                model = session.QueryOver <ZhiweiDataModel>()
                        .Where(z => z.Name == zhiweiName && z.GongsiName == gongsiName)
                        .List()
                        .FirstOrDefault();
            }

            return(model);
        }
Пример #2
0
        public void Save(string zhiweiContent)
        {
            string          zhiweiName = this.GetZhiweiName(zhiweiContent);
            string          gongsiName = this.GetGongsiName(zhiweiContent);
            ZhiweiDataModel model      = this.GetZhiwei(zhiweiName, gongsiName);

            if (model == null)
            {
                model               = new ZhiweiDataModel();
                model.Id            = Guid.NewGuid().ToString();
                model.Name          = this.GetZhiweiName(zhiweiContent);
                model.GongsiName    = this.GetGongsiName(zhiweiContent);
                model.Lianjie       = this.GetZhiweiLianjie(zhiweiContent);
                model.Mingxi        = this.GetZhiweiMingxi(model.Lianjie);
                model.CreatedTime   = DateTime.Now;
                model.GongzuoDidian = this.GetGongzuoDidian(zhiweiContent);
                model.ZuidiGongzi   = this.GetZuidiGongzi(zhiweiContent);
                model.ZuigaoGongzi  = this.GetZuigaoGongzi(zhiweiContent);
                model.FabuTime      = this.GetFabuTime(zhiweiContent);

                using (ISession session = NHibernateHelper.OpenSession())
                {
                    session.Save(model);
                    session.Flush();
                }
            }
            else
            {
                model.GongzuoDidian = this.GetGongzuoDidian(zhiweiContent);
                model.ZuidiGongzi   = this.GetZuidiGongzi(zhiweiContent);
                model.ZuigaoGongzi  = this.GetZuigaoGongzi(zhiweiContent);
                model.FabuTime      = this.GetFabuTime(zhiweiContent);
                model.Lianjie       = this.GetZhiweiLianjie(zhiweiContent);

                using (ISession session = NHibernateHelper.OpenSession())
                {
                    session.Update(model);
                    session.Flush();
                }
            }
        }