예제 #1
0
        public void Execute(string PluginId, string ServiceId, NewPayLoad payLoad)
        {
            GingerGrid gingerGrid = WorkSpace.Instance.LocalGingerGrid;

            // string PID = GA.InputParams["PluginID"].GetValueAsString();
            PluginPackage p = (from x in mPluginPackages where x.PluginID == PluginId select x).SingleOrDefault();

            if (p == null)
            {
                throw new Exception("Plugin id not found: " + PluginId);
                // GA.AddError("Execute", "Plugin id not found: " + PID);
                // return;
            }

            //TODO: use nameof after ActPlugin move to common
            // string serviceID = GA.InputParams["PluginActionID"].GetValueAsString();


            GingerNodeInfo GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault();

            //run script only if service is not up
            if (GNI == null)
            {
                string script = CommandProcessor.CreateLoadPluginScript(p.Folder);

                // hard coded!!!!!!!!!!  - use ServiceId
                script += CommandProcessor.CreateStartServiceScript("PACTService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port);
                // script += CommandProcessor.CreateStartServiceScript("ExcelService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port);


                Task t = new Task(() =>
                {
                    // GingerConsoleHelper.Execute(script);  // keep it for regular service dll load
                    string StarterDLL = Path.Combine(p.Folder, "GingerPACTPluginConsole.dll");
                    StartService(StarterDLL);
                });
                t.Start();
            }

            int counter = 0;

            while (GNI == null && counter < 30)
            {
                Thread.Sleep(1000);
                GNI = (from x in gingerGrid.NodeList where x.Name == "PACT" select x).FirstOrDefault();
                counter++;
            }
            if (GNI == null)
            {
                // GA.AddError("Execute", "Cannot execute action beacuse Service was not found or was not abale to start: " + p.PluginID);
            }

            GingerNodeProxy GNA = new GingerNodeProxy(GNI);

            GNA.Reserve();
            GNA.GingerGrid = gingerGrid;

            //GNA.RunAction(GA);
        }
예제 #2
0
        public void Execute(GingerAction GA)
        {
            GingerGrid gingerGrid = WorkSpace.Instance.LocalGingerGrid;

            string        PID = GA.InputParams["PluginID"].GetValueAsString();
            PluginPackage p   = (from x in mPluginPackages where x.PluginID == PID select x).SingleOrDefault();

            if (p == null)
            {
                GA.AddError("Execute", "Plugin id not found: " + PID);
                return;
            }

            //TODO: use nameof after ActPlugin move to common
            string serviceID = GA.InputParams["PluginActionID"].GetValueAsString();

            GingerNodeInfo GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault();

            //run script only if service is not up
            if (GNI == null)
            {
                string script = CommandProcessor.CreateLoadPluginScript(p.Folder);

                // hard coded!!!!!!!!!!
                script += CommandProcessor.CreateStartServiceScript("ExcelService", p.PluginID, SocketHelper.GetLocalHostIP(), gingerGrid.Port);

                Task t = new Task(() =>
                {
                    GingerConsoleHelper.Execute(script);
                });
                t.Start();
            }

            int counter = 0;

            while (GNI == null && counter < 30)
            {
                Thread.Sleep(1000);
                GNI = (from x in gingerGrid.NodeList where x.Name == p.PluginID select x).FirstOrDefault();
                counter++;
            }


            GingerNodeProxy GNA = new GingerNodeProxy(GNI);

            GNA.Reserve();
            GNA.GingerGrid = gingerGrid;

            GNA.RunAction(GA);
        }