Пример #1
0
        void OnLogSettingHandler(OnLogSetting onLogSetting)
        {
            _state.Log = onLogSetting.Log;
            _state.LogFile = onLogSetting.File;
            // TT - Save the state on changes to Log settings
            SaveState(_state);

            if (_state.Log)
            {
                try
                {
                    Uri file = new Uri(_state.LogFile);

                    // TT Dec-2006 - Not required in V1.0
                    //fs.FileStoreConstructorPort fsConstructor = (fs.FileStoreConstructorPort)
                    //    Environment.InternalServicePortTable[Contracts.FileStoreConstructor];


                    fs.FileStoreCreate fsCreate = new fs.FileStoreCreate(file, new fs.FileStorePort());
                    // TT Dec-2006 - Update for V1.0
                    // fsConstructor.Post(fsCreate);
                    FileStoreConstructorPort.Post(fsCreate);
                    Activate(
                        Arbiter.Choice(
                            fsCreate.ResultPort,
                            delegate(fs.FileStorePort fsp)
                            {
                                LogInfo("Started Logging");
                                lock (_fspLock)
                                {
                                    _fileStorePort = fsp;
                                }
                            },
                            delegate(Exception ex)
                            {
                                WinFormsServicePort.FormInvoke(delegate()
                                    {
                                        _driveControl.ErrorLogging(ex);
                                    }
                                );

                            }
                        )
                    );
                }
                catch (Exception e)
                {
                    WinFormsServicePort.FormInvoke(delegate()
                        {
                            _driveControl.ErrorLogging(e);
                        }
                    );
                }
            }
            else if (_fileStorePort != null)
            {
                LogInfo("Stop Logging");
                lock(_fspLock)
                {
                    fs.FileStorePort fsp = _fileStorePort;

                    LogInfo("Flush Log");
                    fsp.Post(new fs.Flush());

                    Activate(
                        Arbiter.Receive(false, TimeoutPort(1000),
                            delegate(DateTime signal)
                            {
                                LogInfo("Stop Log");
                                fsp.Post(new Shutdown());
                            }
                        )
                    );
                    
                    _fileStorePort = null;
                }
            }
        }
Пример #2
0
        void OnLogSettingHandler(OnLogSetting onLogSetting)
        {
            _state.Log     = onLogSetting.Log;
            _state.LogFile = onLogSetting.File;

            if (_state.Log)
            {
                try
                {
                    Uri file = new Uri(_state.LogFile);


                    fs.FileStoreCreate fsCreate = new fs.FileStoreCreate(file, new fs.FileStorePort());
                    FileStoreConstructorPort.Post(fsCreate);
                    Activate(
                        Arbiter.Choice(
                            fsCreate.ResultPort,
                            delegate(fs.FileStorePort fsp)
                    {
                        LogInfo("Started Logging");
                        lock (_fspLock)
                        {
                            _fileStorePort = fsp;
                        }
                    },
                            delegate(Exception ex)
                    {
                        WinFormsServicePort.FormInvoke(delegate()
                        {
                            _driveControl.ErrorLogging(ex);
                        }
                                                       );
                    }
                            )
                        );
                }
                catch (Exception e)
                {
                    WinFormsServicePort.FormInvoke(delegate()
                    {
                        _driveControl.ErrorLogging(e);
                    }
                                                   );
                }
            }
            else if (_fileStorePort != null)
            {
                LogInfo("Stop Logging");
                lock (_fspLock)
                {
                    fs.FileStorePort fsp = _fileStorePort;

                    LogInfo("Flush Log");
                    fsp.Post(new fs.Flush());

                    Activate(
                        Arbiter.Receive(false, TimeoutPort(1000),
                                        delegate(DateTime signal)
                    {
                        LogInfo("Stop Log");
                        fsp.Post(new Shutdown());
                    }
                                        )
                        );

                    _fileStorePort = null;
                }
            }
        }
Пример #3
0
        void OnLogSettingHandler(OnLogSetting onLogSetting)
        {
            _state.Log = onLogSetting.Log;
            _state.LogFile = onLogSetting.File;

            if (_state.Log)
            {
                try
                {
                    Uri file = new Uri(_state.LogFile);

                    fs.FileStoreCreate fsCreate = new fs.FileStoreCreate(file, new fs.FileStorePort());
                    FileStoreConstructorPort.Post(fsCreate);
                    Activate(
                        Arbiter.Choice(
                            fsCreate.ResultPort,
                            delegate(fs.FileStorePort fsp)
                            {
                                LogInfo("Started Logging");
                                lock (_fspLock)
                                {
                                    _fileStorePort = fsp;
                                }
                            },
                            delegate(Exception ex)
                            {
                                WinFormsServicePort.FormInvoke(delegate()
                                    {
                                        _driveControl.ErrorLogging(ex);
                                    }
                                );

                            }
                        )
                    );
                }
                catch (Exception e)
                {
                    WinFormsServicePort.FormInvoke(delegate()
                        {
                            _driveControl.ErrorLogging(e);
                        }
                    );
                }
            }
            else if (_fileStorePort != null)
            {
                LogInfo("Stop Logging");
                lock(_fspLock)
                {
                    fs.FileStorePort fsp = _fileStorePort;

                    LogInfo("Flush Log");
                    fsp.Post(new fs.Flush());

                    Activate(
                        Arbiter.Receive(false, TimeoutPort(1000),
                            delegate(DateTime signal)
                            {
                                LogInfo("Stop Log");
                                fsp.Post(new Shutdown());
                            }
                        )
                    );

                    _fileStorePort = null;
                }
            }
        }