示例#1
0
 public override void Validate(IUserConfiguration config)
 {
     if ((base.Types & UserConfigurationTypes.Dictionary) != (UserConfigurationTypes)0)
     {
         config.GetDictionary();
     }
 }
        private void ProcessAckFile(string folderName, string fileName, IUserConfiguration user, IFtpHelper ftpHelper)
        {
            string ftpFileName   = $@"{folderName}/{fileName}";
            string localFileName = $@"{new FilePathHelper(_configuration, user.Name).GetReportsFilesFolder()}\{fileName}";

            _logger.Debug($"Process ack file {ftpFileName}");

            ftpHelper.DownloadFile(ftpFileName, localFileName);

            if (File.Exists(localFileName))
            {
                if (user.HasDeleteFtp)
                {
                    ftpHelper.DeleteFile(ftpFileName);
                }

                try
                {
                    _logger.Debug($"Delete local file {fileName}");

                    File.Delete(localFileName);
                }
                catch (Exception e)
                {
                    _logger.Error($"Error trying to delete file {localFileName} -- {e}");
                }
            }
        }
 private AggregatedUserConfigurationPart(IUserConfiguration config)
 {
     this.memento = new AggregatedUserConfigurationPart.MementoClass
     {
         ConfigurationName = config.ConfigurationName,
         DataTypes         = config.DataTypes,
         FolderId          = config.FolderId,
         Id               = config.Id,
         VersionedId      = config.VersionedId,
         LastModifiedTime = config.LastModifiedTime.ToBinary()
     };
     if ((config.DataTypes & UserConfigurationTypes.Dictionary) != (UserConfigurationTypes)0)
     {
         using (StringWriter stringWriter = new StringWriter())
         {
             using (XmlWriter xmlWriter = AggregatedUserConfigurationPart.InternalGetXmlWriter(stringWriter))
             {
                 config.GetConfigurationDictionary().WriteXml(xmlWriter);
                 xmlWriter.Flush();
                 this.memento.DictionaryXmlString = stringWriter.ToString();
             }
         }
     }
     if ((config.DataTypes & UserConfigurationTypes.XML) != (UserConfigurationTypes)0)
     {
         using (Stream xmlStream = config.GetXmlStream())
         {
             using (StreamReader streamReader = new StreamReader(xmlStream))
             {
                 this.memento.XmlString = streamReader.ReadToEnd();
             }
         }
     }
 }
示例#4
0
        private void DeleteLocalFiles(IUserConfiguration user)
        {
            string path = new FilePathHelper(_configuration, user.Name).GetUserFolder();

            DateTime filterDate = DateTime.UtcNow.AddDays(-_configuration.CleanDays);

            var baseDirectory = new DirectoryInfo(path);

            if (baseDirectory.Exists)
            {
                DirectoryInfo[] directories = baseDirectory.GetDirectories();
                foreach (DirectoryInfo directory in directories)
                {
                    FileInfo[] files = directory.GetFiles().Where(f => f.CreationTimeUtc < filterDate).ToArray();
                    foreach (FileInfo file in files)
                    {
                        try
                        {
                            //_logger.Debug($"Delete local file {file.FullName}");

                            file.Delete();
                        }
                        catch (Exception e)
                        {
                            _logger.Error($"Error trying to delete file {file.FullName} -- {e}");
                        }
                    }
                }
            }
        }
        public static bool TryGetValue <T>(this IUserConfiguration config, Type section, string key, out T value)
        {
#pragma warning disable CS0612 // 'ConfigurationItem'은(는) 사용되지 않습니다.
            var configItem = new ConfigurationItem(section.Name, key);
#pragma warning restore CS0612 // 'ConfigurationItem'은(는) 사용되지 않습니다.
            if (config.Contains(configItem) == true)
            {
                try
                {
                    if (ConfigurationBase.CanSupportType(typeof(T)) == true)
                    {
                        value = (T)config[configItem];
                        return(true);
                    }
                    else
                    {
                        var text = (string)config[configItem];
                        value = XmlSerializerUtility.ReadString <T>(text.Decrypt());
                        return(true);
                    }
                }
                catch
                {
                }
            }

            value = default;
            return(false);
        }
示例#6
0
 public ViewModelsFactory(ISQLiteConnector sqLiteConnector, IUserConfiguration config,
                          IProperPulseRangeCounter properPulseRangeCounter)
 {
     this.sqLiteConnector         = sqLiteConnector;
     userConfig                   = config;
     this.properPulseRangeCounter = properPulseRangeCounter;
 }
示例#7
0
        protected override void ProcessFilesForReports(List <string> files, IUserConfiguration user)
        {
            if (files.Count == 0)
            {
                return;
            }

            var ftpHelper      = user.Ftp.GetFtpHelper(_logger);
            var filePathHelper = new FilePathHelper(_configuration, user.Name);

            foreach (string file in files)
            {
                _logger.Debug($"Create report file with {file} for user {user.Name}.");

                var report = new ExcelReport(_logger, _reportTypeConfiguration);
                report.SourceFile = file;
                report.Separator  = _reportTypeConfiguration.FieldSeparator;
                report.ReportPath = filePathHelper.GetReportsFilesFolder();
                report.ReportGMT  = user.UserGMT;
                report.UserId     = user.Credentials.AccountId;

                string reportFileName = report.Generate();

                if (!string.IsNullOrEmpty(reportFileName) && File.Exists(reportFileName))
                {
                    string renameFile = file.Replace(".sent", ".report");
                    File.Move(file, renameFile);
                    UploadFileToFtp(reportFileName, ((UserApiConfiguration)user).Reports.Folder, ftpHelper);
                }
            }
        }
示例#8
0
        public static IHostBuilder CreateHostBuilder <TApp>(string[] args, ConfigureLocalServices <TApp> localServiceConfiguration = null) where TApp : class
        {
            IUserConfiguration userConfiguration = ConfigFactory.Initialize <TApp>();

            IHostBuilder hostBuilder = Host.CreateDefaultBuilder(args)
                                       .ConfigureServices((hostingContext, services) =>
            {
                localServiceConfiguration?.Invoke(hostingContext, services);

                services
                .AddTransient <TApp>()
                .AddSingleton <IApplicationRequirements <TApp>, ApplicationRequirements <TApp> >()
                .AddSingleton <IUserConfiguration> (sp =>
                {
                    return(userConfiguration);
                })
                .BuildServiceProvider();
            })
                                       .ConfigureLogging((hostingContext, logging) =>
            {
                ConfigureCustomLogging(hostingContext, logging, userConfiguration);
            });

            return(hostBuilder);
        }
示例#9
0
        public MainViewModel(IThePirateBaySource thePirateBaySource,
                             ILogService logger,
                             ILeetxSource leetxSource,
                             IRargbSource rargbSource,
                             IKickassSource kickassSource,
                             TorrentInfoDialogViewModel torrentInfoDialogViewModel,
                             IUserConfiguration userConfiguration,
                             IAutoCompleteService autoCompleteService)
        {
            _torrentSourceDictionary = new Dictionary <TorrentSource, SourceInformation>();

            _unfilteredTorrentEntries = new List <TorrentEntry>();

            _logger = logger ?? throw new ArgumentNullException(nameof(logger));

            _torrentInfoDialogViewModel = torrentInfoDialogViewModel ?? throw new ArgumentNullException(nameof(torrentInfoDialogViewModel));
            _userConfiguration          = userConfiguration ?? throw new ArgumentNullException(nameof(userConfiguration));
            _autoCompleteService        = autoCompleteService;

            AddTorrentSource(TorrentSource.ThePirateBay, thePirateBaySource, startPage: 0, siteName: "The Pirate Bay");
            AddTorrentSource(TorrentSource.Leetx, leetxSource, startPage: 1, siteName: "1337X");
            AddTorrentSource(TorrentSource.Kickass, kickassSource, startPage: 1, siteName: "Kickass Torrents");

            InitializeViewModel();

            LoadSettings();

            SetSourceAvailablitiesAsync();
        }
示例#10
0
        protected override void ProcessFilesForReports(List <string> files, IUserConfiguration user)
        {
            if (files.Count == 0)
            {
                return;
            }

            _logger.Debug($"Crete Edesur report for user {user.Name}.");

            var ftpHelper      = user.Ftp.GetFtpHelper(_logger);
            var filePathHelper = new FilePathHelper(_configuration, user.Name);

            var report = new EdesurReport(_logger, _reportTypeConfiguration);

            report.SourceFiles = files;
            report.Separator   = _reportTypeConfiguration.FieldSeparator;
            report.ReportPath  = filePathHelper.GetReportsFilesFolder();
            report.ReportGMT   = user.UserGMT;
            report.UserId      = user.Credentials.AccountId;

            string reportFileName = report.Generate();

            if (File.Exists(reportFileName))
            {
                UploadFileToFtp(reportFileName, ((UserApiConfiguration)user).Reports.Folder, ftpHelper);
            }
        }
示例#11
0
        public override bool GenerateForcedReport(List <string> files, IUserConfiguration user)
        {
            List <string> filteredFiles = FilterFilesByTemplate(files, user);

            if (filteredFiles.Count == 0)
            {
                return(false);
            }

            _logger.Debug($"Crete Edesur report for user {user.Name}.");

            var ftpHelper      = user.Ftp.GetFtpHelper(_logger);
            var filePathHelper = new FilePathHelper(_configuration, user.Name);

            var report = new EdesurReport(_logger, _reportTypeConfiguration)
            {
                SourceFiles = files,
                Separator   = _reportTypeConfiguration.FieldSeparator,
                ReportPath  = filePathHelper.GetForcedReportsFolder(),
                ReportGMT   = user.UserGMT,
                UserId      = user.Credentials.AccountId
            };

            report.Generate();

            return(true);
        }
        private void Load(out IUserConfiguration initConfig, out AggregatedUserConfiguration.MementoClass initMemento, out Dictionary <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart> initParts, out Dictionary <string, SerializableDataBase> initTypeBag)
        {
            initConfig  = null;
            initMemento = null;
            initParts   = null;
            Func <IUserConfiguration> read    = () => this.manager.GetMailboxConfiguration(this.descriptor.Name, UserConfigurationTypes.XML);
            Func <IUserConfiguration> rebuild = delegate()
            {
                this.manager.DeleteMailboxConfigurations(new string[]
                {
                    this.descriptor.Name
                });
                return(this.manager.CreateMailboxConfiguration(this.descriptor.Name, UserConfigurationTypes.XML));
            };

            this.TryInternalLoadConfiguration(read, rebuild, delegate(IUserConfiguration c)
            {
            }, out initConfig);
            initMemento = this.ReadMemento(initConfig);
            initParts   = new Dictionary <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart>();
            foreach (KeyValuePair <UserConfigurationDescriptor.MementoClass, AggregatedUserConfigurationPart.MementoClass> keyValuePair in initMemento.Parts)
            {
                AggregatedUserConfigurationPart value = AggregatedUserConfigurationPart.FromMemento(keyValuePair.Value);
                initParts.Add(keyValuePair.Key, value);
            }
            initTypeBag = initMemento.TypeBag;
        }
示例#13
0
        /// <summary>
        /// Returns the connection string for the specified database context
        /// </summary>
        /// <typeparam name="T">DbContext derived class</typeparam>
        /// <returns>Connection string associated with the DbContext</returns>
        public static string ConnectionString <T>() where T : class
        {
            IUserConfiguration config       = Initialize <T>();
            string             DatabaseName = typeof(T).Name.Replace("Context", "");

            return(config.ConnectionString(DatabaseName));
        }
示例#14
0
        private void SendEndProcessEmail(string file, IUserConfiguration user, ProcessResult result)
        {
            if (user.AdminEmail != null && user.AdminEmail.HasEndEmail && user.AdminEmail.Emails.Count > 0)
            {
                _logger.Debug($"Send end process email for file {file}");

                var smtpClient = new SmtpClient(_configuration.SmtpHost, _configuration.SmtpPort);
                smtpClient.Credentials = new NetworkCredential(_configuration.AdminUser, _configuration.AdminPass);

                var mailMessage = new MailMessage();
                mailMessage.Subject = "Doppler Relay - Complete process";
                mailMessage.From    = new MailAddress("*****@*****.**", "Doppler Relay Support");
                foreach (string email in user.AdminEmail.Emails)
                {
                    mailMessage.To.Add(email);
                }

                string body = File.ReadAllText($@"{AppDomain.CurrentDomain.BaseDirectory}\EmailTemplates\FinishProcess.es.html");

                mailMessage.Body = string.Format(body, Path.GetFileName(file), user.GetUserDateTime().DateTime, result.ProcessedCount, result.ErrorsCount);

                try
                {
                    smtpClient.Send(mailMessage);
                }
                catch (Exception e)
                {
                    _logger.Error($"Error trying to send end process email -- {e}");
                }
            }
        }
        private void GenerateForcedReport(IUserConfiguration user)
        {
            var directoryInfo = new DirectoryInfo(new FilePathHelper(_configuration, user.Name).GetForcedReportsFolder());

            FileInfo[] files = directoryInfo.GetFiles("*.report");

            if (files.Count() > 0)
            {
                _logger.Debug($"Force report generation for use {user.Name}");

                foreach (ReportTypeConfiguration reportType in user.Reports.ReportsList)
                {
                    ReportProcessor reportProcessor = reportType.GetReportProcessor(_configuration, _logger);

                    if (reportProcessor.GenerateForcedReport(files.Select(x => x.FullName).ToList(), user))
                    {
                        break;
                    }
                }

                foreach (FileInfo fileInfo in files)
                {
                    File.Delete(fileInfo.FullName);
                }
            }
        }
        private bool GetFileFromFTP(string file, IUserConfiguration user, IFtpHelper ftpHelper, ProcessResult result)
        {
            var filePathHelper = new FilePathHelper(_configuration, user.Name);

            string localFileName;

            if (!ValidateFile(file, filePathHelper, result, out localFileName))
            {
                return(false);
            }

            _logger.Debug($"Start to download {file} for user {user.Name}");

            bool downloadResult = ftpHelper.DownloadFile(file, localFileName);

            if (downloadResult && File.Exists(localFileName))
            {
                if (Path.GetExtension(file).Equals(".zip", StringComparison.InvariantCultureIgnoreCase))
                {
                    if (UnzipFile(localFileName, filePathHelper.GetDownloadsFolder()) == 0)
                    {
                        string message = $"{DateTime.UtcNow}:Problems to unzip the file {file}.";
                        result.Type = ResulType.UNZIP;
                        result.WriteError(message);
                        return(false);
                    }

                    try
                    {
                        File.Delete(localFileName); // Delete zip file
                    }
                    catch { }
                }
                else
                {
                    string newFileName = localFileName.Replace(".downloading", ".processing");

                    File.Move(localFileName, newFileName);
                }
            }
            else
            {
                string message = $"{DateTime.UtcNow}:Problems to download the file {file}.";
                result.Type = ResulType.DOWNLOAD;
                result.WriteError(message);
                _logger.Error($"Download problems with file {file}.");

                try
                {
                    // Delete wrong file to retry.
                    File.Delete(localFileName);
                }
                catch { }

                return(false);
            }

            return(true);
        }
示例#17
0
 public void Init()
 {
     mocks   = new MockRepository();
     config  = mocks.StrictMock <IUserConfiguration>();
     factory = mocks.Stub <IViewFactory>();
     view    = MockRepository.GenerateStub <ISettingsView>();
     ClientServiceLocator.Register(config);
 }
示例#18
0
 public void Init()
 {
     mocks = new MockRepository();
     config = mocks.StrictMock<IUserConfiguration>();
     view = mocks.DynamicMock<IProfileView>();
     manager = mocks.DynamicMock<IDataManager>();
     ClientServiceLocator.Register(config);
 }
示例#19
0
 public void Init()
 {
     mocks   = new MockRepository();
     config  = mocks.StrictMock <IUserConfiguration>();
     factory = mocks.Stub <IViewFactory>();
     view    = mocks.DynamicMock <IWelcomeView>();
     ClientServiceLocator.Register(config);
 }
示例#20
0
 public void Init()
 {
     mocks   = new MockRepository();
     config  = mocks.StrictMock <IUserConfiguration>();
     view    = mocks.DynamicMock <IProfileView>();
     manager = mocks.DynamicMock <IDataManager>();
     ClientServiceLocator.Register(config);
 }
示例#21
0
 public void Init()
 {
     mocks = new MockRepository();
     config = mocks.StrictMock<IUserConfiguration>();
     factory = mocks.Stub<IViewFactory>();
     view = MockRepository.GenerateStub<ISettingsView>();
     ClientServiceLocator.Register(config);
 }
示例#22
0
        private Settings GetUserSettings()
        {
            var kernel = new StandardKernel();

            kernel.Load(Assembly.GetExecutingAssembly());
            _config = kernel.Get <IUserConfiguration>();
            return(_config.GetConfiguration());
        }
示例#23
0
        public static void Serialize(IUserConfiguration config)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(UserConfiguration));

            using (XmlWriter writer = XmlWriter.Create(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "user.xml")))
            {
                serializer.Serialize(writer, config);
            }
        }
        private void RemoveFileFromFtp(string file, IUserConfiguration user, IFtpHelper ftpHelper)
        {
            if (user.HasDeleteFtp)
            {
                _logger.Debug($"Remove file {file} from FTP ");

                ftpHelper.DeleteFile(file);
            }
        }
示例#25
0
 /// <summary>
 /// Ctor to use in simple cases
 /// </summary>
 /// <param name="runner">The runner</param>
 /// <param name="userConfig">The user configuration</param>
 /// <param name="pluginIds">The pluginIds of those that should be started and stopped when the cluster is started or stopped. 
 /// The first one is considered the "main" (note this has no impact on the way start/stop are handled)</param>
 public PluginCluster( ISimplePluginRunner runner, IUserConfiguration userConfig, params Guid[] pluginIds )
 {
     if( pluginIds.Length == 0 ) throw new ArgumentException( "A PluginCluster cannot be created without pluginIds. It need at least one" );
     _mainPluginId = pluginIds[0];
     List<Guid> plugins = pluginIds.ToList();
     _startWithPlugin = plugins;
     _stopWithPlugin = plugins;
     _runner = runner;
     _userConfig = userConfig;
 }
示例#26
0
 public UserDefinitionManager(IUserConfiguration userConfiguration,
                              IRepository <User, long> userRepository,
                              ISettingManager settingManager,
                              IRepository <Role> roleRepository)
 {
     _userConfiguration = userConfiguration;
     _userRepository    = userRepository;
     _settingManager    = settingManager;
     _roleRepository    = roleRepository;
 }
示例#27
0
        public void LoadUserConfiguration()
        {
            config = UserSerializer.Deserialize();
            if (config == null)
            {
                config = new UserConfiguration();
                access.DisplayWelcomeDialog();
            }

            access.SetUserConfig(config);
        }
示例#28
0
        public IUserConfiguration GetConfiguration(IUserConfigurationManager manager)
        {
            IUserConfiguration result   = null;
            StoreObjectId      folderId = this.GetFolderId(manager.MailboxSession);

            if (folderId != null)
            {
                result = manager.GetFolderConfiguration(this.ConfigurationName, this.Types, folderId);
            }
            return(result);
        }
示例#29
0
 private static void AddUserConfiguration(string AssemblyName, IUserConfiguration UserConfiguration)
 {
     lock (locker)
     {
         // Ensure key doesn't already exist
         if (!_userConfiguration.ContainsKey(AssemblyName))
         {
             _userConfiguration.Add(AssemblyName, UserConfiguration);
         }
     }
 }
示例#30
0
        public static DbContextOptionsBuilder ConfigureSqlServer <T>(this DbContextOptionsBuilder optionsBuilder) where T : DbContext
        {
            if (!optionsBuilder.IsConfigured)
            {
                IUserConfiguration userConfiguration = ConfigFactory.Initialize <T>();
                string             DatabaseName      = typeof(T).Name.Replace("Context", "");
                optionsBuilder.UseSqlServer(userConfiguration.ConnectionString(DatabaseName));
            }

            return(optionsBuilder);
        }
        private void InitializeMissingParts()
        {
            bool flag = false;
            IEnumerable <UserConfigurationDescriptor> enumerable = Enumerable.Empty <UserConfigurationDescriptor>();

            if (this.aggregatedConfiguration != null)
            {
                enumerable = from d in this.descriptor.Sources
                             where !this.parts.ContainsKey(d.ToMemento(this.manager.MailboxSession))
                             select d;
            }
            using (IEnumerator <UserConfigurationDescriptor> enumerator = enumerable.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    AggregatedUserConfiguration.< > c__DisplayClass1c CS$ < > 8__locals1 = new AggregatedUserConfiguration.< > c__DisplayClass1c();
                    CS$ < > 8__locals1.< > 4__this       = this;
                    CS$ < > 8__locals1.missingDescriptor = enumerator.Current;
                    UserConfigurationDescriptor.MementoClass missingDescriptorMemento = CS$ < > 8__locals1.missingDescriptor.ToMemento(this.manager.MailboxSession);
                    if (this.memento.FailedToLoad.Contains(missingDescriptorMemento))
                    {
                        ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] failed to load once already and will not be initialized again", CS$ < > 8__locals1.missingDescriptor.ConfigurationName);
                    }
                    else
                    {
                        IUserConfiguration userConfiguration = null;
                        try
                        {
                            if (!this.TryInternalLoadConfiguration(() => CS$ < > 8__locals1.missingDescriptor.GetConfiguration(CS$ < > 8__locals1.< > 4__this.manager), null, delegate(IUserConfiguration c)
                            {
                                CS$ < > 8__locals1.missingDescriptor.Validate(c);
                            }, out userConfiguration))
                            {
                                ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] failed to load", CS$ < > 8__locals1.missingDescriptor.ConfigurationName);
                                this.memento.FailedToLoad.Add(missingDescriptorMemento);
                                flag = true;
                            }
                            else
                            {
                                AggregatedUserConfigurationPart aggregatedUserConfigurationPart = AggregatedUserConfigurationPart.FromConfiguration(userConfiguration);
                                this.parts[missingDescriptorMemento] = aggregatedUserConfigurationPart;
                                if (this.memento.Pending.Exists((AggregatedUserConfiguration.PendingUpdate p) => missingDescriptorMemento.Equals(p.DescriptorMemento)))
                                {
                                    ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "the missing configuration part with name=[{0}] will not be persisted because it has a pending update", CS$ < > 8__locals1.missingDescriptor.ConfigurationName);
                                }
                                else
                                {
                                    ExTraceGlobals.StorageTracer.TraceDebug <string>((long)this.GetHashCode(), "adding missing part {0} to the persisted aggregated configuration", CS$ < > 8__locals1.missingDescriptor.ConfigurationName);
                                    flag = true;
                                    this.memento.Parts.Add(missingDescriptorMemento, aggregatedUserConfigurationPart.Memento);
                                }
                            }
                        }
示例#32
0
        public void MergeUserConfiguration(IUserConfiguration user)
        {
            var u = new UserConfiguration
            {
                Username       = user.Username,
                Password       = user.Password,
                TwoFactorToken = user.TwoFactorToken
            };
            var key = u.Username.AdjustUserName();

            _users[key] = u;
        }
示例#33
0
        private void UploadErrosToFTP(string fileName, IUserConfiguration user, IFtpHelper ftpHelper)
        {
            if (user.Errors != null && File.Exists(fileName))
            {
                _logger.Debug($"Upload error file {fileName}");

                var filePathHelper = new FilePathHelper(_configuration, user.Name);

                string ftpFileName = $@"{user.Errors.Folder}/{Path.GetFileName(fileName)}";

                ftpHelper.UploadFile(fileName, ftpFileName);
            }
        }
示例#34
0
        /// <summary>
        /// Ctor to use when the plugins that should be started together with the main plugin are different from those that should be stopped together with the main plugin.
        /// </summary>
        /// <param name="runner">The runner</param>
        /// <param name="userConfig">The user configuration</param>
        /// <param name="mainPluginId">The Guid of the main plugin</param>
        /// <param name="startWithPlugin">The plugins to start together with the main plugin</param>
        /// <param name="stopWithPlugin">The plugins to stop together with the main plugin</param>
        public PluginCluster( ISimplePluginRunner runner, IUserConfiguration userConfig, Guid mainPluginId, IEnumerable<Guid> startWithPlugin, IEnumerable<Guid> stopWithPlugin )
        {
            _mainPluginId = mainPluginId;

            _startWithPlugin = new List<Guid>();
            _startWithPlugin.Add( mainPluginId );
            _startWithPlugin.AddRange( startWithPlugin );

            _stopWithPlugin = new List<Guid>();
            _stopWithPlugin.Add( mainPluginId );
            _stopWithPlugin.AddRange( stopWithPlugin );

            _runner = runner;
            _userConfig = userConfig;
        }
示例#35
0
        /// <summary>
        /// Ctor of a ConfigFeatureStarter.
        /// Be careful with the list of Guid passed as parameter.
        /// When stopped, ALL these plugins' user configuration will be set to Manual and receive a "Stop" LiveUserAction.
        /// Plugins that are used by other plugins/feature must not be added in this list. (use service requirements in the plugins when possible)
        /// </summary>
        /// <param name="configManager"></param>
        /// <param name="runner"></param>
        /// <param name="userConfig"></param>
        /// <param name="mainPluginIds"></param>
        public ConfigFeatureStarter( ConfigManager configManager, ISimplePluginRunner runner, IUserConfiguration userConfig, params Guid[] mainPluginIds )
            : base(configManager)
        {
            _pluginIds = mainPluginIds;
            _runner = runner;
            _userConfig = userConfig;

            _runner.PluginHost.StatusChanged += ( o, e ) =>
            {
                if( _pluginIds.Contains( e.PluginProxy.PluginKey.PluginId ) )
                {
                    NotifyOfPropertyChange( () => Start );
                    NotifyOfPropertyChange( () => Stop );
                    NotifyOfPropertyChange( () => IsRunning );
                    NotifyOfPropertyChange( () => IsRunnable );
                }
            };

            Start = new SimpleCommand( StartPlugin, CanStart );
            Stop = new SimpleCommand( StopPlugin );
        }