Esempio n. 1
0
        public DocumentInfo GetDocumentDescriptor(string id)
        {
            //load dictionaries
            XDocument dictionaries = null;

            using (ListCoordinator listCoordinator = new ListCoordinator())
            {
                dictionaries = listCoordinator.GetDictionaries();
            }

            //load file descriptor
            XDocument descriptor = null;

            using (RepositoryCoordinator repoCoordinator = new RepositoryCoordinator())
            {
                descriptor = repoCoordinator.LoadBusinessObject(XDocument.Parse(String.Format(CultureInfo.InvariantCulture,
                                                                                              "<root><type>FileDescriptor</type><id>{0}</id></root>", id)));
            }

            //get the date from descriptor
            DateTime descriptorDate = DateTime.Parse(descriptor.Root.Element("fileDescriptor").Element("modificationDate").Value, CultureInfo.InvariantCulture);

            descriptorDate = new DateTime(descriptorDate.Year, descriptorDate.Month, descriptorDate.Day, descriptorDate.Hour, descriptorDate.Minute, descriptorDate.Second);

            //get content type
            var mimeType = (from node in dictionaries.Root.Element("mimeType").Elements()
                            where node.Element("id").Value == descriptor.Root.Element("fileDescriptor").Element("mimeTypeId").Value
                            select node.Element("name").Value).ElementAt(0);

            var name = descriptor.Root.Element("fileDescriptor").Element("originalFilename").Value;

            var repoUlr = this.GetRepositoryUrl(descriptor, dictionaries);

            return(new DocumentInfo(name, id, mimeType, descriptorDate, repoUlr));
        }
Esempio n. 2
0
        public DocumentInfo AddDocumentDescriptor(string documentName, string documentId)
        {
            XDocument dictionaries = null;


            using (ListCoordinator listCoordinator = new ListCoordinator())
            {
                dictionaries = listCoordinator.GetDictionaries();
            }

            string repoId = (from node in dictionaries.Root.Element("repository").Elements()
                             where node.Element("url").Value == this.Url
                             select node.Element("id").Value).ElementAt(0);

            string extension = documentName.Substring(documentName.LastIndexOf('.') + 1);

            var mimeTypeNode = (from node in dictionaries.Root.Element("mimeType").Elements()
                                where node.Element("extensions").Value.Contains(extension) == true
                                select node).First();

            using (RepositoryCoordinator repoCoordinator = new RepositoryCoordinator())
            {
                XDocument fileDescriptor = repoCoordinator.CreateNewBusinessObject(XDocument.Parse("<root><type>FileDescriptor</type></root>"));
                fileDescriptor.Root.Element("fileDescriptor").Element("repositoryId").Value = repoId;
                fileDescriptor.Root.Element("fileDescriptor").Element("id").Value           = documentId;
                fileDescriptor.Root.Element("fileDescriptor").Element("mimeTypeId").Value   = mimeTypeNode.Element("id").Value;
                fileDescriptor.Root.Element("fileDescriptor").Add(new XElement("originalFilename", documentName));

                XDocument responseXml      = repoCoordinator.SaveBusinessObject(fileDescriptor);
                var       modificationDate = DateTime.Parse(responseXml.Root.Element("modificationDate").Value, CultureInfo.InvariantCulture);

                return(new DocumentInfo(documentName, documentId, mimeTypeNode.Element("name").Value, modificationDate, this.Url));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes plugin.
        /// </summary>
        /// <param name="pluginPhase">Coordinator plugin phase.</param>
        /// <param name="coordinator">Coordinator to attach the plugin.</param>
        public static void Initialize(CoordinatorPluginPhase pluginPhase, RepositoryCoordinator coordinator)
        {
            if (pluginPhase != CoordinatorPluginPhase.SaveObject)
            {
                return;
            }

            coordinator.Plugins.Add(new FileDescriptorPlugin());
        }
Esempio n. 4
0
        public Orchestration(DashBoard dashBoard, string MQTTClientId, IRepository repository, IScenarioEngine engine)
        {
            deviceManager     = Context.ActorOf(DeviceManagerCoordinator.Props("patano", MQTTClientId, engine), "physicaldevice");
            dashboardManager  = Context.ActorOf(DashdoardCoordinator.Props("dashboard", dashBoard), "dashboard");
            repositoryManager = Context.ActorOf(RepositoryCoordinator.Props(repository), "repo");

            Receive <GatewayCreated>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalCreated);
                dashboardManager.Tell(msg.GatewayDashBoardCreated);
                repositoryManager.Tell(msg.GatewayRepositoryCreated);
            });

            Receive <DeviceCreated>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalCreated);
                dashboardManager.Tell(msg.DeviceDashBoardCreated);
                repositoryManager.Tell(msg.DeviceRepositoryCreated);
            });

            Receive <GatewayDroped>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalDroped);
                dashboardManager.Tell(msg.GatewayDashBoardDroped);
                repositoryManager.Tell(msg.GatewayRepositoryDroped);
            });

            Receive <DeviceDroped>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalDroped);
                dashboardManager.Tell(msg.DeviceDashBoardDroped);
                repositoryManager.Tell(msg.DeviceRepositoryDroped);
            });

            Receive <GatewaySended>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalSended);
                dashboardManager.Tell(msg.GatewayDashBoardSended);
                repositoryManager.Tell(msg.GatewayRepositorySended);
            });

            Receive <DeviceSended>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalSended);
                dashboardManager.Tell(msg.DeviceDashBoardSended);
                repositoryManager.Tell(msg.DeviceRepositorySended);
            });

            Receive <GatewayStarted>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalStarted);
                dashboardManager.Tell(msg.GatewayDashBoardStarted);
                repositoryManager.Tell(msg.GatewayRepositoryStarted);
            });

            Receive <DeviceStarted>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalStarted);
                dashboardManager.Tell(msg.DeviceDashBoardStarted);
                repositoryManager.Tell(msg.DeviceRepositoryStarted);
            });

            Receive <GatewayDisconnected>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalDisconnected);
                dashboardManager.Tell(msg.GatewayDashBoardDisconnected);
                repositoryManager.Tell(msg.GatewayRepositoryDisconnected);
            });

            Receive <DeviceDisconnected>(msg =>
            {
                deviceManager.Tell(msg.DeviceDashBoardDisconnected);
                dashboardManager.Tell(msg.DeviceDashBoardDisconnected);
                repositoryManager.Tell(msg.DeviceRepositoryDisconnected);
            });

            Receive <GatewaySet>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalSet);
                dashboardManager.Tell(msg.GatewayDashBoardSet);
                repositoryManager.Tell(msg.GatewayRepositorySet);
            });

            Receive <DeviceSet>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalSet);
                dashboardManager.Tell(msg.DeviceDashBoardSet);
                repositoryManager.Tell(msg.DeviceRepositorySet);
            });

            Receive <GatewayUpdate>(msg =>
            {
                dashboardManager.Tell(msg.GatewayDashBoardUpdate);
                repositoryManager.Tell(msg.GatewayRepositoryUpdate);
            });

            Receive <DeviceUpdate>(msg =>
            {
                dashboardManager.Tell(msg.DeviceDashBoardUpdate);
                repositoryManager.Tell(msg.DeviceRepositoryUpdate);
            });

            Receive <GatewayStatus>(msg =>
            {
                deviceManager.Tell(msg.GatewayPhysicalStatus);
            });

            Receive <DeviceStatus>(msg =>
            {
                deviceManager.Tell(msg.DevicePhysicalStatus);
            });

            Receive <GetGatewaysBoard>(msg =>
            {
                var result = dashboardManager.Ask <List <GatewayDashBoard> >(msg).Result;
                Sender.Tell(result);
            });

            Receive <StatusChanged>(msg => { dashBoard.HasChange(); });

            Receive <SystemStart>(msg => InitSystem());

            Receive <Evalutate>(msg => deviceManager.Tell(msg.EvalutatePhysical));

            Receive <PhysicalSetEnd>(msg
                                     => Self.Tell(new Evalutate()));
        }