public static bool AddNewProject(UserProject userProject)
 {
     try
     {
         ISession session = GetNHibernateSession();
         DataModels.Object.Project project = new DataModels.Object.Project
         {
             projectName = userProject.projectName,
             projectContext = userProject.projectContext,
             projectPublishTime = userProject.projectPublishTime,
             projectState = userProject.projectState
         };
         session.Save(project);
         int pr_id = (from p in session.Query<DataModels.Object.Project>()
                      orderby p.id descending
                      select p.id).First();
         foreach (ProjectRole r in userProject.roles)
         {
             ProjectRole role = new ProjectRole
             {
                 projectId = pr_id,
                 role = r.role,
                 userName = r.userName,
                 state = r.state
             };
             session.Save(role);
         }
         session.Flush();
         return true;
     }
     catch
     {
         return false;
     }
 }
        public void DbConnectionTest()
        {
            //
            // TODO: 在此处添加测试逻辑
            //
            Configuration cfg = new Configuration();
            cfg.AddAssembly("DataModels");
            ISessionFactory factory = cfg.BuildSessionFactory();
            ISession session = factory.OpenSession();
            ITransaction tx = session.BeginTransaction();

            Project Project1 = new Project();
            Project1 = session.Get<Project>(7);

            tx.Commit();
            session.Close();
            factory.Close();
            Assert.AreEqual(Project1.projectName,"2");
        }