Пример #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="domainID">Domain ID</param>
        public DomainWeb(string domainID)
        {
            Store store = Store.GetStore();

            this.ID = domainID;
            Domain domain = store.GetDomain(domainID);

            this.Name        = domain.Name;
            this.Description = domain.Description;
            this.Host        = Locate.Resolve(domainID);
            this.UserID      = store.GetUserIDFromDomainID(domainID);
            this.IsDefault   = domainID.Equals(store.DefaultDomain);


            Simias.POBox.POBox poBox = Simias.POBox.POBox.FindPOBox(store,
                                                                    domainID,
                                                                    UserID);

            if (poBox != null)
            {
                this.POBoxID = poBox.ID;
            }

            this.UserName  = domain.GetMemberByID(this.UserID).Name;
            this.IsSlave   = domain.Role.Equals(Simias.Sync.SyncRoles.Slave);
            this.IsEnabled = new Simias.Domain.DomainAgent().IsDomainActive(domainID);
        }
Пример #2
0
 private void Init()
 {
     hostAddress = MyDns.GetHostName();
        Store store = Store.GetStore();
        try
        {
     Uri localUri = Manager.LocalServiceUrl;
     Simias.Storage.Domain rDomain = store.GetDomain( ID );
     if (rDomain == null)
     {
      rDomain =
       new Simias.Storage.Domain(
        store,
        this.domainName,
        Simias.Gaim.GaimDomain.ID,
        this.description,
        Simias.Sync.SyncRoles.Master,
        Simias.Storage.Domain.ConfigurationType.Workgroup );
      rDomain.SetType( rDomain, "Workgroup" );
      string storedUserID = GetGaimUserID();
      if (storedUserID != null)
      {
       log.Debug("Creating the Gaim Domain with a saved UserID");
       userID = storedUserID;
      }
      else
      {
       log.Debug("Creating the Gaim Domain with a NEW UserID");
       userID = Guid.NewGuid().ToString();
      }
      Member member =
       new Member(
        userName,
        userID,
        Access.Rights.Admin );
      member.IsOwner = true;
      if (localUri == null)
      {
       localUri = Manager.LocalServiceUrl;
       if (localUri != null)
       {
        Simias.Storage.Property p = new Property("Gaim:SimiasURL", localUri.ToString());
        p.LocalProperty = true;
        member.Properties.AddProperty(p);
       }
       else
       {
        log.Debug("Manager.LocalServiceUrl returned NULL!");
       }
      }
      if (aliasName != null && aliasName.Length > 0)
      {
       Simias.Storage.Property p = new Property("Gaim:Alias", aliasName);
       p.LocalProperty = true;
       member.FN = string.Format("{0} ({1})", aliasName, hostName);
      }
      rDomain.Commit( new Node[] { rDomain, member } );
      store.AddDomainIdentity( rDomain.ID, member.UserID );
      GaimService.RegisterDomainProvider();
     }
     Member pMember;
     Simias.POBox.POBox poBox = null;
     string poBoxName = "POBox:" + Simias.Gaim.GaimDomain.ID + ":" + userID;
     try
     {
      poBox = Simias.POBox.POBox.FindPOBox( store, Simias.Gaim.GaimDomain.ID, userID );
     }
     catch{}
     if (poBox == null)
     {
      poBox = new Simias.POBox.POBox( store, poBoxName, ID );
      pMember =
       new Member( userName, userID, Access.Rights.ReadWrite );
      pMember.IsOwner = true;
      poBox.Commit(new Node[] { poBox, pMember });
     }
     else
     {
      pMember = poBox.GetMemberByID( userID );
      if (pMember == null)
      {
       pMember =
        new Member( userName, userID, Access.Rights.ReadWrite );
       pMember.IsOwner = true;
       poBox.Commit(new Node[] { pMember });
      }
     }
     poBoxID = poBox.ID;
        }
        catch( Exception e1 )
        {
     log.Error(e1.Message);
     log.Error(e1.StackTrace);
     throw e1;
        }
 }