Beispiel #1
0
        public void Process()
        {
            if (client == null)
            {
                return;
            }

            client.Process();

            if (client.IsConnected && DateTime.Now.Subtract(lastRefreshTime) > new TimeSpan(0, 0, 10))
            {
                int addCount = 0;

                foreach (DaemonLogic.CloudObject cloudObject in Objects)
                {
                    if (!InjectedObjects.Contains(cloudObject.CloudObjectId))
                    {
                        InjectOrUpdateObject(cloudObject);

                        addCount++;
                        if (addCount > 10)
                        {
                            break;
                        }
                    }
                }

                List <DaemonLogic.CloudObject> modifiedOjects = (from o in entityContext.CloudObject where o.Bubble.BubbleId == bubble.BubbleId && o.Modified > lastRefreshTime select o).ToList <DaemonLogic.CloudObject>();

                foreach (DaemonLogic.CloudObject cloudObject in modifiedOjects)
                {
                    entityContext.Refresh(System.Data.Objects.RefreshMode.StoreWins, cloudObject);

                    if (cloudObject.Enabled)
                    {
                        DaemonLogic.ObjectType  objectType  = QueryUtil.First <DaemonLogic.ObjectType>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.ObjectType);
                        DaemonLogic.Participant participant = QueryUtil.First <DaemonLogic.Participant>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.Participant);

                        InjectOrUpdateObject(cloudObject);
                    }
                    else
                    {
                        if (Objects.Contains(cloudObject))
                        {
                            EjectObject(cloudObject);
                        }
                    }
                }

                lastRefreshTime = DateTime.Now;
            }
        }
Beispiel #2
0
        public DaemonParticipant(
            string serverAddress,
            int serverPort,
            Guid bubbleId,
            string daemonIdentifier,
            string daemonSecret
            )
        {
            this.serverAddress    = serverAddress;
            this.serverPort       = serverPort;
            this.bubbleId         = bubbleId;
            this.DaemonIdentifier = daemonIdentifier;
            this.DaemonSecret     = daemonSecret;
            String programName         = "Cloud Daemon Participant";
            byte   programMajorVersion = 0;
            byte   programMinorVersion = 1;

            bubble = QueryUtil.First <Bubble>((from b in entityContext.Bubble where b.BubbleId == bubbleId select b));

            Objects = (from o in entityContext.CloudObject where o.Bubble.BubbleId == bubble.BubbleId && o.Enabled == true select o).ToList <DaemonLogic.CloudObject>();

            lastRefreshTime = DateTime.Now;

            if (Objects.Count == 0)
            {
                return;
            }

            client = new CloudView(100, programName, programMajorVersion, programMinorVersion);

            client.ServerInteractRequest += OnInteractRequest;

            foreach (DaemonLogic.CloudObject cloudObject in Objects)
            {
                DaemonLogic.ObjectType  objectType  = QueryUtil.First <DaemonLogic.ObjectType>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.ObjectType);
                DaemonLogic.Participant participant = QueryUtil.First <DaemonLogic.Participant>(from o in entityContext.CloudObject where o.CloudObjectId == cloudObject.CloudObjectId select o.Participant);
                IdObjectDictionary.Add(cloudObject.CloudObjectId, cloudObject);
            }
        }