public virtual void SetDiplomacy(Group tribe, TribeDiplomate diplomacy, ISession session)
        {
            if ((this.TribePermission & TribePermission.DiplomateOfficer) != TribePermission.DiplomateOfficer)
                return;
            if (this.Group == tribe)
                return;

            if (diplomacy == TribeDiplomate.NoRelation)
            {
                object[] objects = { this.Group, tribe };
                NHibernate.Type.IType[] types = { NHibernate.NHibernateUtil.GuessType(typeof(Group)), NHibernate.NHibernateUtil.GuessType(typeof(Group)) };
                session.Delete(" from TribeRelation r where r.CurrentTribe=:current and r.DiplomaticTribe=:tribe", objects, types);
                return;
            }

            TribeRelation oldRelation = (from tribeRelation in session.Linq<TribeRelation>()
                                         where tribeRelation.CurrentTribe == this.Group
                                         && tribeRelation.DiplomaticTribe == tribe
                                         select tribeRelation).SingleOrDefault<TribeRelation>();

            if (oldRelation != null)
                return;

            TribeRelation relation = new TribeRelation();
            relation.CurrentTribe = this.Group;
            relation.DiplomaticTribe = tribe;
            relation.Diplomacy = diplomacy;
            session.Save(relation);
        }
 public virtual void CreateTribe(string tag, string name, ISession session)
 {
     beans.Group group = new Group();
     group.Tag = tag;
     group.Name = name;
     group.Description = "";
     group.Introduction = "";
     this.Group = group;
     this.TribePermission = TribePermission.Duke;
     session.Save(group);
     session.Update(this);
 }
示例#3
0
 public static IList<ShoutboxData> GetShoutbox(Group group, int size, bool ascending, ISession session)
 {
     if (group == null)
     {
         IQuery query = session.CreateQuery("from ShoutboxData sd where sd.Group is null order by ID " + ((ascending) ? "asc" : "desc"));
         query.SetMaxResults(size);
         query.SetFirstResult(0);
         return query.List<ShoutboxData>();
     }
     else
     {
         ICriteria criteria = session.CreateCriteria(typeof(ShoutboxData));
         criteria.Add(Expression.Eq("Group", group));
         criteria.AddOrder(new Order("ID", ascending));
         criteria.SetFirstResult(0);
         criteria.SetMaxResults(size);
         return criteria.List<ShoutboxData>();
     }
 }
示例#4
0
 public void ChangeGroupInfo(Group g, NHibernate.ISession session)
 {
     throw new System.NotImplementedException();
 }