示例#1
0
 public void Plug(/*String s*/IModuleExchange exchange)
 {
     moduleExchange = exchange;
     StartService();
 }
示例#2
0
 public void Unplug()
 {
     moduleExchange = null;
 }
示例#3
0
        public bool Plug(IModuleExchange exchange)
        {
            moduleExchange = exchange;

            EEGStudioModuleMode = GetEEGStudioMode();//GetEEGStudioModeFromConfig();

            InitEEGStudioModule(EEGStudioModuleMode);

            System.Threading.Tasks.Task.Factory.StartNew(() => { StartService(); });

            return true;
        }
示例#4
0
        private bool OpenFile(IModuleExchange parent, IFileData fileData, Guid contextID, XafApplication app)
        {
            bool result = false;

            switch (System.IO.Path.GetExtension(fileData.FileName))
            {
                case ".eeg":
                    {
                        result = true;

                        string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("B"));
                        System.IO.Directory.CreateDirectory(tempDirectory);
                        string tempFileName = Path.Combine(tempDirectory, fileData.FileName);
                        try
                        {
                            using (FileStream stream = new FileStream(tempFileName, FileMode.CreateNew))
                            {
                                fileData.SaveToStream(stream);
                            }

                            RegistryKey key = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, "");
                            RegistryKey target_key = key.OpenSubKey(keyPath);
                            if (target_key != null ? target_key.GetValueNames().Contains(keyName) : false)
                            {
                                String path = Convert.ToString(target_key.GetValue(keyName)) + appName;

                                Process process = new Process();
                                ProcessStartInfo ps = new ProcessStartInfo(path);
                                ps.Arguments = String.Format(@"""{0}""", tempFileName);
                                process.StartInfo = ps;

                                process.Exited += (object sender, EventArgs args) =>
                                {
                                    parent.ProcessMessage(contextID, "Stop");
                                };
                                process.Start();
                                process.EnableRaisingEvents = true;
                            }
                        }
                        catch
                        {
                            Tracing.Tracer.LogValue("tempFileName", tempFileName);
                            throw;
                        }
                    }
                    break;

                case ".mef":
                    {
                        result = true;
                        string tempDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("B"));
                        System.IO.Directory.CreateDirectory(tempDirectory);
                        string tempFileName = Path.Combine(tempDirectory, fileData.FileName);
                        try
                        {
                            using (FileStream stream = new FileStream(tempFileName, FileMode.CreateNew))
                            {
                                fileData.SaveToStream(stream);
                            }

                            RegistryKey key = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, "");
                            RegistryKey target_key = key.OpenSubKey(keyPath);
                            if (target_key != null ? target_key.GetValueNames().Contains("MainEegPath") : false)
                            {
                                String path = Convert.ToString(target_key.GetValue("MainEegPath")) + "eeg.exe";

                                Process process = new Process();

                                ProcessStartInfo ps = new ProcessStartInfo(path);
                                ps.Arguments = String.Format(@"""{0}""", tempFileName);
                                process.StartInfo = ps;
                                process.Exited += (object sender, EventArgs args) =>
                                {
                                    parent.ProcessMessage(contextID, "Stop");
                                };
                                process.Start();
                                process.EnableRaisingEvents = true;
                            }
                        }
                        catch
                        {
                            Tracing.Tracer.LogValue("tempFileName", tempFileName);
                            throw;
                        }

                    }

                    break;
            }

            return result;
        }
示例#5
0
 public void Plug(/*String s*/IModuleExchange exchange)
 {
     moduleExchange = exchange;
 }
示例#6
0
        public bool Plug(IModuleExchange exchange)
        {
            moduleExchange = exchange;
            InitEEGSynapsePath();

            if (File.Exists(eegSynapseExecPath) == true)
            {
                // реальное название программы с которой работаем забираем из атрибутов изполняемого файла
                var info = GetFileVersionInfo(eegSynapseExecPath);
                if (info != null)
                {
                    string caption = info.ProductName;
                    string image = string.Empty;
                    if (caption == "ЭЭГ-2000")
                        image = "EEG2000";
                    else if (caption == "EEG Synapse")
                        image = "Synapse";

                    moduleInformation = new ModuleActionInformation
                    {
                        Id = "",
                        Caption = caption,
                        ImageName = image,
                        Data = ExecuteCommand.Open
                    };
                }
            }
            else
            {
                CanCreate = false;
                moduleInformation = new ModuleActionInformation
                {
                    Caption = "APPLICATION_NOT_FOUND",
                    ImageName = "",
                    Data = ExecuteCommand.Null
                };
            }
            return true;
        }