Esempio n. 1
0
        public void Send(string id, T message)
        {
            var node = Mailboxes
                       .ReadOrWrite(id, () => Root.Add(id, () => RemoveMailboxFromDictionary(id)));

            node.Mailbox.Write(message);
        }
Esempio n. 2
0
 public void Setup(BenchmarkContext context)
 {
     _system                = ActorSystem.Create($"GetMailboxTypeSpec{Counter.GetAndIncrement()}");
     _messageDispatcher     = _system.Dispatchers.Lookup(EchoActor.Props.Dispatcher);
     _mailboxes             = new Mailboxes(_system);
     _createActorThroughput = context.GetCounter(CreateThroughputCounter);
 }
Esempio n. 3
0
    internal IActor CreateChildActor(Type actorType, IActor parent)
    {
        var actor = (Actor)Activator.CreateInstance(actorType);

        actor.Parent = parent;
        actor.System = this;
        Mailboxes.Add(actor, actor.Mailbox);
        return(actor);
    }
Esempio n. 4
0
        public List<Mailbox> Get(Mailboxes request)
        {
            var mailboxes =
                Directory.GetDirectories(this.Config.MailFolder).Select(m =>
                    {
                        string name = new DirectoryInfo(m).Name;
                        return new Mailbox() { Name = name, Links = new List<Link>(new[] { this.GetMailboxLink(name) }) };
                    }).ToList();

            return mailboxes;
        }
Esempio n. 5
0
        /// <summary>
        /// Adds a new mailbox to the user.
        /// The firstly added Mailbox will be the default one.
        /// </summary>
        /// <param name="properties">MailBoxProperties struct with the necessary data to initialize a new mailbox</param>
        public Mailbox AddMailbox(MailBoxProperties properties)
        {
            var newMailbox = new Mailbox(properties);

            Mailboxes.Add(newMailbox);
            if (Mailboxes.Count == 1)
            {
                CurrentMailbox = newMailbox;
            }
            return(newMailbox);
        }
Esempio n. 6
0
        private void init(int port)
        {
            lock (this)
            {
                if (!initDone)
                {
                    connections = new Dictionary <String, OtpCookedConnection>();

                    sched    = new OtpActorSched();
                    mboxes   = new Mailboxes(this, sched);
                    acceptor = new Acceptor(this, port);
                    initDone = true;
                }
            }
        }
Esempio n. 7
0
 private void  init(bool acceptConnections, int port)
 {
     lock (this)
     {
         if (!initDone)
         {
             connections = new System.Collections.Hashtable(17, (float)0.95);
             mboxes      = new Mailboxes(this);
             if (acceptConnections)
             {
                 acceptor = new Acceptor(this, port);
             }
             listenPort = port;
             initDone   = true;
         }
     }
 }
Esempio n. 8
0
 private void ConfigureMailboxes()
 {
     _mailboxes = new Mailboxes(this);
 }
Esempio n. 9
0
        private void init(int port)
        {
            lock (this)
            {
                if (!initDone)
                {
                    connections = new Dictionary<String, OtpCookedConnection>();

                    sched = new OtpActorSched();
                    mboxes = new Mailboxes(this, sched);
                    acceptor = new Acceptor(this, port);
                    initDone = true;
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Establish the connection
        /// </summary>
        /// <returns></returns>
        async private System.Threading.Tasks.Task RunAsync()
        {
            _traceListener = new ClassTraceListener();

            IsDisposed = false;

            EwsToken = await EWSConstants.AcquireTokenAsync();

            Messenger = new MessageManager(CancellationTokenSource);

            ServiceCredentials = new OAuthCredentials(EwsToken.AccessToken);

            _reconnect     = true;
            _groups        = new Dictionary <string, GroupInfo>();
            _mailboxes     = new Mailboxes(ServiceCredentials, _traceListener);
            _subscriptions = new List <SubscriptionCollection>();
            _connections   = new Dictionary <string, StreamingSubscriptionConnection>();


            var impersonationId = EWSConstants.Config.Exchange.ImpersonationAcct;

            try
            {
                var list = new List <EWSFolderInfo>();
                using (EWSDbContext context = new EWSDbContext(EWSConstants.Config.Database))
                {
                    foreach (var room in context.RoomListRoomEntities.Where(w => !string.IsNullOrEmpty(w.Identity)))
                    {
                        var mailboxId = room.SmtpAddress;

                        try
                        {
                            var roomService = new EWService(EwsToken);
                            roomService.SetImpersonation(ConnectingIdType.SmtpAddress, mailboxId);
                            var folderId = new FolderId(WellKnownFolderName.Calendar, mailboxId);
                            var info     = new EWSFolderInfo()
                            {
                                SmtpAddress = mailboxId,
                                Service     = roomService,
                                Folder      = folderId
                            };
                            list.Add(info);
                        }
                        catch (Exception srex)
                        {
                            _traceListener.Trace("SyncProgram", $"Failed to ProcessChanges{srex.Message}");
                            throw new Exception($"ProcessChanges for {mailboxId} with MSG:{srex.Message}");
                        }
                    }
                }

                // Parallel ForEach (on RoomMailbox Grouping and SyncFolders)
                await System.Threading.Tasks.Task.Run(() =>
                {
                    ParallelOptions options = new ParallelOptions
                    {
                        MaxDegreeOfParallelism = maxConcurrency
                    };

                    // Fireoff folder sync in background thread
                    Parallel.ForEach(list, options,
                                     (bodyInfo) =>
                    {
                        ProcessChanges(bodyInfo);
                    });
                });


                var tasks = new List <System.Threading.Tasks.Task>();


                if (EWSConstants.Config.Exchange.PullEnabled)
                {
                    // Upon completion tick repeater to poll subscriptions
                    tasks.Add(PullSubscriptionChangesAsync(impersonationId));
                }
                else
                {
                    // Upon completion kick of streamingsubscription
                    tasks.Add(CreateStreamingSubscriptionGroupingAsync(impersonationId));
                }

                System.Threading.Tasks.Task.WaitAll(tasks.ToArray());
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.Message);
            }
        }
Esempio n. 11
0
		private void  init(bool acceptConnections, int port)
		{
			lock(this)
			{
				if (!initDone)
				{
					connections = new System.Collections.Hashtable(17, (float) 0.95);
					mboxes = new Mailboxes(this);
                    if (acceptConnections)
					    acceptor = new Acceptor(this, port);
                    listenPort = port;
					initDone = true;
				}
			}
		}
Esempio n. 12
0
 private void OnShowUnsubscribedMailboxes(object obj)
 {
     IsManagingMailboxes = true;
     Mailboxes.ForEach(x => x.IsEditing = true);
     IsExpanded = true;
 }
Esempio n. 13
0
 private void OnHideUnsubscribedMailboxes(object obj)
 {
     IsManagingMailboxes = false;
     Mailboxes.ForEach(x => x.IsEditing = false);
 }
Esempio n. 14
0
 public void RemoveMailboxFromDictionary(string id)
 {
     Mailboxes.Remove(id);
 }
Esempio n. 15
0
 /// <summary>
 /// Deletes the current mailbox
 /// </summary>
 public void DeleteMailbox()
 {
     CurrentMailbox.Control.StopGettingEmails();
     Mailboxes.Remove(CurrentMailbox);
     CurrentMailbox = null;
 }