Exemplo n.º 1
0
        public bool IsSessionService(string pluginId, string serviceId)
        {
            // TODO: Cache
            PluginPackage pluginPackage = (from x in mPluginPackages where x.PluginId == pluginId select x).SingleOrDefault();

            pluginPackage.LoadServicesFromJSON();
            PluginServiceInfo pluginServiceInfo = (from x in pluginPackage.Services where x.ServiceId == serviceId select x).SingleOrDefault();

            return(pluginServiceInfo.IsSession);
        }
Exemplo n.º 2
0
        // We search the plug in for all files it can edit if this plugin implemented capability of text editor
        //        public List<PlugInTextFileEditorBase> TextEditors()
        //        {
        //            List<PlugInTextFileEditorBase> list = new List<PlugInTextFileEditorBase>();
        //            //TODO:: Need to be handled once PACT implementation is done
        //            //foreach (PlugInCapability c in PlugIn.Capabilities())
        //            //{
        //            //    if (c is PlugInTextFileEditorBase)
        //            //    {
        //            //        list.Add((PlugInTextFileEditorBase)c);
        //            //    }
        //            //}
        //            return list;
        //        }

        //        public List<string> GetExtentionsByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.Extensions;
        //                }
        //            }
        //            return null;
        //        }

        //        public PlugInTextFileEditorBase GetPlugInTextFileEditorBaseByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB;
        //                }
        //            }
        //            return null;
        //        }

        //        public string GetTemplateContentByEditorID(string plugInEditorID, string plugInExtension)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.GetTemplatesByExtensions("." + plugInExtension);
        //                }
        //            }
        //            return null;
        //        }


        public System.Diagnostics.Process StartService(string pluginId, string serviceID)
        {
            Console.WriteLine("Starting Service: " + serviceID + " from Plugin: " + pluginId);
            if (string.IsNullOrEmpty(pluginId))
            {
                throw new ArgumentNullException(nameof(pluginId));
            }
            PluginPackage pluginPackage = (from x in mPluginPackages where x.PluginId == pluginId select x).SingleOrDefault();

            Console.WriteLine("Loading Plugin Services from JSON...");

            // TODO: only once !!!!!!!!!!!!!!!!!!!!!!!!! temp
            pluginPackage.LoadServicesFromJSON();

            if (pluginPackage == null)
            {
                throw new Exception("PluginPackage not found in solution PluginId=" + pluginId);
            }
            if (string.IsNullOrEmpty(pluginPackage.StartupDLL))
            {
                throw new Exception("StartupDLL is missing in the Ginger.PluginPackage.json for: " + pluginId);
            }

            string dll = Path.Combine(pluginPackage.Folder, pluginPackage.StartupDLL);

            Console.WriteLine("Plug-in dll path: " + dll);
            string nodeFileName = CreateNodeConfigFile(pluginId, serviceID);

            Console.WriteLine("nodeFileName: " + nodeFileName);

            string cmd = "\"" + dll + "\" \"" + nodeFileName + "\"";

            Console.WriteLine("Creating Process..");

            System.Diagnostics.Process proc = OSHelper.Current.Dotnet(cmd);

            mProcesses.Add(new PluginProcessWrapper(pluginId, serviceID, proc));
            Console.WriteLine("Plug-in Running on the Process ID: " + proc.Id);
            return(proc);
            //TODO: delete the temp file - or create temp files tracker with auto delete
        }
Exemplo n.º 3
0
        // We search the plug in for all files it can edit if this plugin implemented capability of text editor
        //        public List<PlugInTextFileEditorBase> TextEditors()
        //        {
        //            List<PlugInTextFileEditorBase> list = new List<PlugInTextFileEditorBase>();
        //            //TODO:: Need to be handled once PACT implementation is done
        //            //foreach (PlugInCapability c in PlugIn.Capabilities())
        //            //{
        //            //    if (c is PlugInTextFileEditorBase)
        //            //    {
        //            //        list.Add((PlugInTextFileEditorBase)c);
        //            //    }
        //            //}
        //            return list;
        //        }

        //        public List<string> GetExtentionsByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.Extensions;
        //                }
        //            }
        //            return null;
        //        }

        //        public PlugInTextFileEditorBase GetPlugInTextFileEditorBaseByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB;
        //                }
        //            }
        //            return null;
        //        }

        //        public string GetTemplateContentByEditorID(string plugInEditorID, string plugInExtension)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.GetTemplatesByExtensions("." + plugInExtension);
        //                }
        //            }
        //            return null;
        //        }


        public System.Diagnostics.Process StartService(string pluginId, string serviceID)
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                throw new ArgumentNullException(nameof(pluginId));
            }
            PluginPackage pluginPackage = (from x in mPluginPackages where x.PluginId == pluginId select x).SingleOrDefault();

            // TODO: only once !!!!!!!!!!!!!!!!!!!!!!!!! temp
            pluginPackage.LoadServicesFromJSON();


            if (pluginPackage == null)
            {
                throw new Exception("PluginPackage not found in solution PluginId=" + pluginId);
            }
            if (string.IsNullOrEmpty(pluginPackage.StartupDLL))
            {
                throw new Exception("StartupDLL is missing in the Ginger.PluginPackage.json for: " + pluginId);
            }

            string dll = Path.Combine(pluginPackage.Folder, pluginPackage.StartupDLL);

            string nodeFileName = NodeConfigFile.CreateNodeConfigFile(pluginId + "1", serviceID);  // TODO: check if 1 exist then try 2,3 in case more than one same id service start
            string cmd          = "dotnet \"" + dll + "\" \"" + nodeFileName + "\"";

            System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + cmd);
            procStartInfo.UseShellExecute = true;

            // TODO: Make it config not to show the console window
            // procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;
            proc.Start();
            mProcesses.Add(new PluginProcessWrapper(pluginId, serviceID, proc));
            return(proc);
            //TODO: delete the temp file - or create temp files tracker with auto delete
        }
Exemplo n.º 4
0
        // We search the plug in for all files it can edit if this plugin implemented capability of text editor
        //        public List<PlugInTextFileEditorBase> TextEditors()
        //        {
        //            List<PlugInTextFileEditorBase> list = new List<PlugInTextFileEditorBase>();
        //            //TODO:: Need to be handled once PACT implementation is done
        //            //foreach (PlugInCapability c in PlugIn.Capabilities())
        //            //{
        //            //    if (c is PlugInTextFileEditorBase)
        //            //    {
        //            //        list.Add((PlugInTextFileEditorBase)c);
        //            //    }
        //            //}
        //            return list;
        //        }

        //        public List<string> GetExtentionsByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.Extensions;
        //                }
        //            }
        //            return null;
        //        }

        //        public PlugInTextFileEditorBase GetPlugInTextFileEditorBaseByEditorID(string plugInEditorID)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB;
        //                }
        //            }
        //            return null;
        //        }

        //        public string GetTemplateContentByEditorID(string plugInEditorID, string plugInExtension)
        //        {
        //            foreach (PlugInTextFileEditorBase PITFEB in TextEditors())
        //            {
        //                if (PITFEB.EditorID == plugInEditorID)
        //                {
        //                    return PITFEB.GetTemplatesByExtensions("." + plugInExtension);
        //                }
        //            }
        //            return null;
        //        }


        public System.Diagnostics.Process StartService(string pluginId, string serviceID)
        {
            Console.WriteLine("Staring Service...");
            if (string.IsNullOrEmpty(pluginId))
            {
                throw new ArgumentNullException(nameof(pluginId));
            }
            PluginPackage pluginPackage = (from x in mPluginPackages where x.PluginId == pluginId select x).SingleOrDefault();

            Console.WriteLine("Loading Plugin Services from JSON...");
            // TODO: only once !!!!!!!!!!!!!!!!!!!!!!!!! temp
            pluginPackage.LoadServicesFromJSON();

            if (pluginPackage == null)
            {
                throw new Exception("PluginPackage not found in solution PluginId=" + pluginId);
            }
            if (string.IsNullOrEmpty(pluginPackage.StartupDLL))
            {
                throw new Exception("StartupDLL is missing in the Ginger.PluginPackage.json for: " + pluginId);
            }

            string dll = Path.Combine(pluginPackage.Folder, pluginPackage.StartupDLL);

            string nodeFileName = CreateNodeConfigFile(pluginId, serviceID);
            string cmd          = "dotnet \"" + dll + "\" \"" + nodeFileName + "\"";

            Console.WriteLine("Creating Process..");

            // TODO: move to GingerUtils to start a process !!!!!!!!!!!!!!!!
            System.Diagnostics.ProcessStartInfo procStartInfo = null;

            if (GingerUtils.OperatingSystem.IsWindows())
            {
                procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + cmd);
                procStartInfo.UseShellExecute = true;
            }
            else if (GingerUtils.OperatingSystem.IsLinux())
            {
                cmd = "-c \"gnome-terminal -x bash -ic 'cd $HOME; dotnet " + dll + " " + nodeFileName + "'\"";
                Console.WriteLine("Command: " + cmd);
                procStartInfo = new System.Diagnostics.ProcessStartInfo("/bin/bash", " " + cmd + " ");
                procStartInfo.UseShellExecute        = false;
                procStartInfo.CreateNoWindow         = false;
                procStartInfo.RedirectStandardOutput = true;
            }

            // TODO: Make it config not to show the console window
            // procStartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            proc.StartInfo = procStartInfo;

            Console.WriteLine("Staring Process..");
            proc.Start();

            mProcesses.Add(new PluginProcessWrapper(pluginId, serviceID, proc));
            Console.WriteLine("Plugin Running on the Process ID:" + proc.Id);
            return(proc);
            //TODO: delete the temp file - or create temp files tracker with auto delete
        }