private static void ValidatePreferences(IPreferenceSet prefs) { // MessageLevel int level = prefs.Get <int>(Preference.MessageLevel); if (level < 4) { level = 4; } else if (level > 5) { level = 5; } prefs.Set(Preference.MessageLevel, level); const int defaultInterval = 15; // ClientRetrievalTask.Interval var clientRetrievalTask = prefs.Get <Preferences.Data.ClientRetrievalTask>(Preference.ClientRetrievalTask); if (!Validate.Minutes(clientRetrievalTask.Interval)) { clientRetrievalTask.Interval = defaultInterval; prefs.Set(Preference.ClientRetrievalTask, clientRetrievalTask); } // WebGenerationTask.Interval var webGenerationTask = prefs.Get <Preferences.Data.WebGenerationTask>(Preference.WebGenerationTask); if (!Validate.Minutes(webGenerationTask.Interval)) { webGenerationTask.Interval = defaultInterval; prefs.Set(Preference.WebGenerationTask, webGenerationTask); } }
/// <summary> /// Show the HFM.NET log file /// </summary> public string ShowHfmLogFile() { string logFilePath = Path.Combine(_prefs.Get <string>(Preference.ApplicationDataFolderPath), Constants.HfmLogFileName); string errorMessage = String.Format(CultureInfo.CurrentCulture, "An error occured while attempting to show the HFM.log file.{0}{0}Please check the current Log File Viewer defined in the Preferences.", Environment.NewLine); return(RunProcess(_prefs.Get <string>(Preference.LogFileViewer), WrapInQuotes(logFilePath), errorMessage)); }
// ReSharper disable InconsistentNaming private void frmBenchmarks_Shown(object sender, EventArgs e) { UpdateClientsComboBinding(); UpdateProjectListBoxBinding(ProjectId); lstColors.DataSource = _graphColors; GraphLayoutType = _prefs.Get <GraphLayoutType>(Preference.BenchmarksGraphLayoutType); pnlClientLayout.DataSource = this; pnlClientLayout.ValueMember = "GraphLayoutType"; // Issue 154 - make sure focus is on the projects list box listBox1.Select(); }
public void Load(IPreferenceSet prefs) { ServerSecure = prefs.Get<bool>(Preference.EmailReportingServerSecure); ToAddress = prefs.Get<string>(Preference.EmailReportingToAddress); FromAddress = prefs.Get<string>(Preference.EmailReportingFromAddress); ServerAddress = prefs.Get<string>(Preference.EmailReportingServerAddress); ServerPort = prefs.Get<int>(Preference.EmailReportingServerPort); ServerUsername = prefs.Get<string>(Preference.EmailReportingServerUsername); ServerPassword = prefs.Get<string>(Preference.EmailReportingServerPassword); ReportingEnabled = prefs.Get<bool>(Preference.EmailReportingEnabled); ReportEuePause = prefs.Get<bool>(Preference.ReportEuePause); ReportHung = prefs.Get<bool>(Preference.ReportHung); }
public void Load(IPreferenceSet prefs) { ServerSecure = prefs.Get <bool>(Preference.EmailReportingServerSecure); ToAddress = prefs.Get <string>(Preference.EmailReportingToAddress); FromAddress = prefs.Get <string>(Preference.EmailReportingFromAddress); ServerAddress = prefs.Get <string>(Preference.EmailReportingServerAddress); ServerPort = prefs.Get <int>(Preference.EmailReportingServerPort); ServerUsername = prefs.Get <string>(Preference.EmailReportingServerUsername); ServerPassword = prefs.Get <string>(Preference.EmailReportingServerPassword); ReportingEnabled = prefs.Get <bool>(Preference.EmailReportingEnabled); ReportEuePause = prefs.Get <bool>(Preference.ReportEuePause); ReportHung = prefs.Get <bool>(Preference.ReportHung); }
public void Load(IPreferenceSet prefs) { EocUserId = prefs.Get <int>(Preference.EocUserId); StanfordId = prefs.Get <string>(Preference.StanfordId); TeamId = prefs.Get <int>(Preference.TeamId); ProjectDownloadUrl = prefs.Get <string>(Preference.ProjectDownloadUrl); ProxyServer = prefs.Get <string>(Preference.ProxyServer); ProxyPort = prefs.Get <int>(Preference.ProxyPort); UseProxy = prefs.Get <bool>(Preference.UseProxy); ProxyUser = prefs.Get <string>(Preference.ProxyUser); ProxyPass = prefs.Get <string>(Preference.ProxyPass); UseProxyAuth = prefs.Get <bool>(Preference.UseProxyAuth); }
public void Load(IPreferenceSet prefs) { EocUserId = prefs.Get<int>(Preference.EocUserId); StanfordId = prefs.Get<string>(Preference.StanfordId); TeamId = prefs.Get<int>(Preference.TeamId); ProjectDownloadUrl = prefs.Get<string>(Preference.ProjectDownloadUrl); ProxyServer = prefs.Get<string>(Preference.ProxyServer); ProxyPort = prefs.Get<int>(Preference.ProxyPort); UseProxy = prefs.Get<bool>(Preference.UseProxy); ProxyUser = prefs.Get<string>(Preference.ProxyUser); ProxyPass = prefs.Get<string>(Preference.ProxyPass); UseProxyAuth = prefs.Get<bool>(Preference.UseProxyAuth); }
public QueryParametersContainer(IPreferenceSet prefs) { var path = prefs != null?prefs.Get <string>(Preference.ApplicationDataFolderPath) : null; if (!String.IsNullOrEmpty(path)) { FileName = System.IO.Path.Combine(path, Constants.QueryCacheFileName); } }
public ProteinBenchmarkService(IPreferenceSet prefs) { var path = prefs != null?prefs.Get <string>(Preference.ApplicationDataFolderPath) : null; if (!String.IsNullOrEmpty(path)) { FileName = System.IO.Path.Combine(path, Constants.BenchmarkCacheFileName); } _cacheLock = new ReaderWriterLockSlim(); }
public void Calculate() { Protein value = _proteinService.Get(SelectedProject); if (value == null) { return; } Protein protein = CopyProtein(value); if (PreferredDeadlineChecked) { protein.PreferredDays = PreferredDeadline; } if (FinalDeadlineChecked) { protein.MaximumDays = FinalDeadline; } if (KFactorChecked) { protein.KFactor = KFactor; } TimeSpan frameTime = TimeSpan.FromMinutes(TpfMinutes).Add(TimeSpan.FromSeconds(TpfSeconds)); TimeSpan totalTimeByFrame = TimeSpan.FromSeconds(frameTime.TotalSeconds * protein.Frames); TimeSpan totalTimeByUser = totalTimeByFrame; if (TotalWuTimeEnabled) { totalTimeByUser = TimeSpan.FromMinutes(TotalWuTimeMinutes).Add(TimeSpan.FromSeconds(TotalWuTimeSeconds)); // user time is less than total time by frame, not permitted if (totalTimeByUser < totalTimeByFrame) { totalTimeByUser = totalTimeByFrame; } } var decimalPlaces = _prefs.Get <int>(Preference.DecimalPlaces); var noBonusValues = protein.GetProductionValues(frameTime, TimeSpan.Zero); var bonusByUserSpecifiedTimeValues = protein.GetProductionValues(frameTime, totalTimeByUser); var bonusByFrameTimeValues = protein.GetProductionValues(frameTime, totalTimeByFrame); CoreName = protein.Core; SlotType = protein.Core.ToSlotType().ToString(); NumberOfAtoms = protein.NumberOfAtoms; CompletionTime = Math.Round((TotalWuTimeEnabled ? totalTimeByUser.TotalDays : totalTimeByFrame.TotalDays), decimalPlaces); PreferredDeadline = protein.PreferredDays; FinalDeadline = protein.MaximumDays; KFactor = protein.KFactor; BonusMultiplier = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.Multiplier : bonusByFrameTimeValues.Multiplier), decimalPlaces); BaseCredit = noBonusValues.Credit; TotalCredit = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.Credit : bonusByFrameTimeValues.Credit), decimalPlaces); BasePpd = noBonusValues.PPD; TotalPpd = Math.Round((TotalWuTimeEnabled ? bonusByUserSpecifiedTimeValues.PPD : bonusByFrameTimeValues.PPD), decimalPlaces); }
public UserStatsDataModel(IPreferenceSet prefs, IXmlStatsDataContainer dataContainer) { _updateTimer = new System.Timers.Timer(); _updateTimer.Elapsed += UpdateTimerElapsed; _prefs = prefs; _prefs.PreferenceChanged += (s, e) => { if (e.Preference == Preference.EnableUserStats) { ControlsVisible = _prefs.Get <bool>(Preference.EnableUserStats); if (ControlsVisible) { _dataContainer.GetEocXmlData(false); StartTimer(); } else { StopTimer(); } } }; _dataContainer = dataContainer; _dataContainer.XmlStatsDataChanged += delegate { AutoMapper.Mapper.Map(_dataContainer.XmlStatsData, this); OnPropertyChanged(null); }; // apply data container to the model ControlsVisible = _prefs.Get <bool>(Preference.EnableUserStats); if (ControlsVisible) { DateTime nextUpdateTime = _dataContainer.GetNextUpdateTime(); if (nextUpdateTime < DateTime.UtcNow) { _dataContainer.GetEocXmlData(false); } StartTimer(); } AutoMapper.Mapper.Map(_dataContainer.XmlStatsData, this); }
public MainGridModel(IPreferenceSet prefs, ISynchronizeInvoke syncObject, IClientConfiguration clientConfiguration) { _prefs = prefs; _syncObject = syncObject; _clientConfiguration = clientConfiguration; _slotList = new SlotModelSortableBindingList(_syncObject); _slotList.OfflineClientsLast = _prefs.Get <bool>(Preference.OfflineLast); _slotList.Sorted += (sender, e) => { SortColumnName = e.Name; _prefs.Set(Preference.FormSortColumn, SortColumnName); SortColumnOrder = e.Direction; _prefs.Set(Preference.FormSortOrder, SortColumnOrder); }; _bindingSource = new BindingSource(); _bindingSource.DataSource = _slotList; _bindingSource.CurrentItemChanged += (sender, args) => SelectedSlot = (SlotModel)_bindingSource.Current; #if DEBUG _slotList.ListChanged += (s, e) => Debug.WriteLine("BindingList: " + e.ListChangedType); _bindingSource.ListChanged += (s, e) => Debug.WriteLine("BindingSource: " + e.ListChangedType); #endif // Subscribe to PreferenceSet events _prefs.PreferenceChanged += (s, e) => { switch (e.Preference) { case Preference.OfflineLast: _slotList.OfflineClientsLast = _prefs.Get <bool>(Preference.OfflineLast); Sort(); break; case Preference.PpdCalculation: case Preference.DecimalPlaces: case Preference.BonusCalculation: ResetBindings(); break; } }; // Subscribe to ClientDictionary events _clientConfiguration.DictionaryChanged += (sender, args) => ResetBindings(); }
public UserStatsDataModel(IPreferenceSet prefs, IXmlStatsDataContainer dataContainer) { _updateTimer = new System.Timers.Timer(); _updateTimer.Elapsed += UpdateTimerElapsed; _prefs = prefs; _prefs.PreferenceChanged += (s, e) => { if (e.Preference == Preference.EnableUserStats) { ControlsVisible = _prefs.Get<bool>(Preference.EnableUserStats); if (ControlsVisible) { _dataContainer.GetEocXmlData(false); StartTimer(); } else { StopTimer(); } } }; _dataContainer = dataContainer; _dataContainer.XmlStatsDataChanged += delegate { AutoMapper.Mapper.Map(_dataContainer.XmlStatsData, this); OnPropertyChanged(null); }; // apply data container to the model ControlsVisible = _prefs.Get<bool>(Preference.EnableUserStats); if (ControlsVisible) { DateTime nextUpdateTime = _dataContainer.GetNextUpdateTime(); if (nextUpdateTime < DateTime.UtcNow) { _dataContainer.GetEocXmlData(false); } StartTimer(); } AutoMapper.Mapper.Map(_dataContainer.XmlStatsData, this); }
public XmlStatsDataContainer(IPreferenceSet prefs) { _prefs = prefs; var path = prefs != null?prefs.Get <string>(Preference.ApplicationDataFolderPath) : null; if (!String.IsNullOrEmpty(path)) { FileName = System.IO.Path.Combine(path, Constants.UserStatsCacheFileName); } }
public void Load(IPreferenceSet prefs) { ApplicationPath = prefs.Get <string>(Preference.ApplicationPath); CssFile = prefs.Get <string>(Preference.CssFile); WebOverview = prefs.Get <string>(Preference.WebOverview); WebMobileOverview = prefs.Get <string>(Preference.WebMobileOverview); WebSummary = prefs.Get <string>(Preference.WebSummary); WebMobileSummary = prefs.Get <string>(Preference.WebMobileSummary); WebSlot = prefs.Get <string>(Preference.WebSlot); }
public ProteinService(IPreferenceSet prefs, IProjectSummaryDownloader downloader) { _dictionary = new ProteinDictionary(); _downloader = downloader; _projectsNotFound = new Dictionary <int, DateTime>(); var path = prefs != null?prefs.Get <string>(Preference.ApplicationDataFolderPath) : null; if (!String.IsNullOrEmpty(path)) { FileName = Path.Combine(path, Constants.ProjectInfoFileName); } }
//public void RunWebGeneration() //{ // _taskManager.Run(WebTaskKey, false); //} private void ClientRetrievalAction(CancellationToken ct) { // get flag synchronous or asynchronous - we don't want this flag to change on us // in the middle of a retrieve, so grab it now and use the local copy var mode = _prefs.Get <ProcessingMode>(Preference.ClientRetrievalTaskType); ct.ThrowIfCancellationRequested(); var clientsEnumerable = _clientConfiguration.GetClients(); var clients = clientsEnumerable as IList <IClient> ?? clientsEnumerable.ToList(); if (mode == ProcessingMode.Serial) { // do the individual retrieves on a single thread foreach (var client in clients) { ct.ThrowIfCancellationRequested(); client.Retrieve(); } } else { // fire individual threads to do the their own retrieve simultaneously Parallel.ForEach(clients, x => { ct.ThrowIfCancellationRequested(); x.Retrieve(); }); } if (_prefs.Get <bool>(Preference.WebGenerationTaskEnabled) && _prefs.Get <bool>(Preference.WebGenerationTaskAfterClientRetrieval)) { ct.ThrowIfCancellationRequested(); _taskManager.Run(WebTaskKey, false); } }
public void Load(IPreferenceSet prefs) { RunMinimized = prefs.Get <bool>(Preference.RunMinimized); StartupCheckForUpdate = prefs.Get <bool>(Preference.StartupCheckForUpdate); DefaultConfigFile = prefs.Get <string>(Preference.DefaultConfigFile); UseDefaultConfigFile = prefs.Get <bool>(Preference.UseDefaultConfigFile); LogFileViewer = prefs.Get <string>(Preference.LogFileViewer); FileExplorer = prefs.Get <string>(Preference.FileExplorer); }
public BenchmarksForm(IPreferenceSet prefs, IProteinService proteinService, IProteinBenchmarkService benchmarkService, IClientConfiguration clientConfiguration, IMessageBoxView messageBoxView, IExternalProcessStarter processStarter) { _prefs = prefs; _proteinService = proteinService; _benchmarkService = benchmarkService; _graphColors = _prefs.Get <List <Color> >(Preference.GraphColors); _clientConfiguration = clientConfiguration; _messageBoxView = messageBoxView; _processStarter = processStarter; _zedGraphManager = new ZedGraphManager(); InitializeComponent(); StartPosition = FormStartPosition.Manual; }
public void Load(IPreferenceSet prefs) { ApplicationPath = prefs.ApplicationPath; CssFile = prefs.Get<string>(Preference.CssFile); WebOverview = prefs.Get<string>(Preference.WebOverview); WebMobileOverview = prefs.Get<string>(Preference.WebMobileOverview); WebSummary = prefs.Get<string>(Preference.WebSummary); WebMobileSummary = prefs.Get<string>(Preference.WebMobileSummary); WebSlot = prefs.Get<string>(Preference.WebSlot); }
/// <summary> /// Downloads the project information. /// </summary> /// <remarks>Access to the Download method is synchronized.</remarks> public void Download(Stream stream, IProgress <ProgressInfo> progress) { IWebOperation httpWebOperation = WebOperation.Create(_prefs.Get <string>(Preference.ProjectDownloadUrl)); if (progress != null) { httpWebOperation.ProgressChanged += (sender, e) => { int progressPercentage = Convert.ToInt32(e.Length / (double)e.TotalLength * 100); string message = String.Format(CultureInfo.CurrentCulture, "Downloading {0} of {1} bytes...", e.Length, e.TotalLength); progress.Report(new ProgressInfo(progressPercentage, message)); }; } httpWebOperation.WebRequest.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore); httpWebOperation.WebRequest.Proxy = _prefs.GetWebProxy(); httpWebOperation.Download(stream); }
/// <summary> /// Gets the points per day format string based on preference settings. /// </summary> public static string GetPpdFormatString(this IPreferenceSet prefs) { var decimalPlaces = prefs.Get <int>(Preference.DecimalPlaces); var sb = new StringBuilder("###,###,##0"); if (decimalPlaces > 0) { sb.Append("."); for (int i = 0; i < decimalPlaces; i++) { sb.Append("0"); } } return(sb.ToString()); }
public void Generate(ICollection <SlotModel> slots) { if (slots == null) { throw new ArgumentNullException("slots"); } XmlFilePaths = null; HtmlFilePaths = null; var copyHtml = _prefs.Get <bool>(Preference.WebGenCopyHtml); var copyXml = _prefs.Get <bool>(Preference.WebGenCopyXml); if (copyHtml) { // GenerateHtml calls GenerateXml - these two // calls are mutually exclusive GenerateHtml(slots); } else if (copyXml) { GenerateXml(slots); } }
private static bool InitializePreferences(IPreferenceSet prefs, ILogger logger, bool reset) { try { if (reset) { prefs.Reset(); } else { prefs.Initialize(); } } catch (Exception ex) { ShowStartupError(ex, Properties.Resources.UserPreferencesFailed); return(false); } // set logging level from prefs ((Core.Logging.Logger)logger).Level = (LoggerLevel)prefs.Get <int>(Preference.MessageLevel); return(true); }
/// <summary> /// Gets a WebProxy object based on preference settings. /// </summary> public static IWebProxy GetWebProxy(this IPreferenceSet prefs) { if (prefs == null || !prefs.Get <bool>(Preference.UseProxy)) { return(null); } IWebProxy proxy = new WebProxy(prefs.Get <string>(Preference.ProxyServer), prefs.Get <int>(Preference.ProxyPort)); if (prefs.Get <bool>(Preference.UseProxyAuth)) { proxy.Credentials = NetworkCredentialFactory.Create(prefs.Get <string>(Preference.ProxyUser), prefs.Get <string>(Preference.ProxyPass)); } return(proxy); }
public UnitInfoDatabase(IPreferenceSet prefs, IProteinService proteinService, ILogger logger) { if (proteinService == null) { throw new ArgumentNullException("proteinService"); } _proteinService = proteinService; if (logger != null) { _logger = logger; } SQLiteFunction.RegisterFunction(typeof(ToSlotType)); SQLiteFunction.RegisterFunction(typeof(GetProduction)); ForceDateTimesToUtc = true; var path = prefs != null?prefs.Get <string>(Preference.ApplicationDataFolderPath) : null; if (!String.IsNullOrEmpty(path)) { DatabaseFilePath = System.IO.Path.Combine(path, Constants.SqLiteFilename); } }
public void Load(IPreferenceSet prefs, IQueryParametersContainer queryContainer) { _bonusCalculation = prefs.Get <BonusCalculationType>(Preference.HistoryBonusCalculation); _showEntriesValue = prefs.Get <int>(Preference.ShowEntriesValue); FormLocation = prefs.Get <Point>(Preference.HistoryFormLocation); FormSize = prefs.Get <Size>(Preference.HistoryFormSize); SortColumnName = prefs.Get <string>(Preference.HistorySortColumnName); SortOrder = prefs.Get <ListSortDirection>(Preference.HistorySortOrder); FormColumns = prefs.Get <ICollection <string> >(Preference.HistoryFormColumns); _queryList.Clear(); _queryList.Add(new QueryParameters()); foreach (var query in queryContainer.Get()) { // don't load Select All twice if (query.Name != QueryParameters.SelectAll.Name) { _queryList.Add(query); } } _queryList.Sort(); ResetBindings(true); }
private static bool InitializePreferences(IPreferenceSet prefs, ILogger logger, bool reset) { try { if (reset) { prefs.Reset(); } else { prefs.Initialize(); } } catch (Exception ex) { ShowStartupError(ex, Properties.Resources.UserPreferencesFailed); return false; } // set logging level from prefs ((Core.Logging.Logger)logger).Level = (LoggerLevel)prefs.Get<int>(Preference.MessageLevel); return true; }
public void Load(IPreferenceSet prefs) { var clientRetrievalTask = prefs.Get<ClientRetrievalTask>(Preference.ClientRetrievalTask); SyncTimeMinutes = clientRetrievalTask.Interval; SyncOnSchedule = clientRetrievalTask.Enabled; SyncOnLoad = clientRetrievalTask.ProcessingMode == ProcessingMode.Serial; AllowRunningAsync = prefs.Get<bool>(Preference.AllowRunningAsync); var webGenerationTask = prefs.Get<WebGenerationTask>(Preference.WebGenerationTask); GenerateWeb = webGenerationTask.Enabled; GenerateInterval = webGenerationTask.Interval; WebGenAfterRefresh = webGenerationTask.AfterClientRetrieval; WebGenType = prefs.Get<WebDeploymentType>(Preference.WebDeploymentType); WebRoot = prefs.Get<string>(Preference.WebDeploymentRoot); WebGenServer = prefs.Get<string>(Preference.WebGenServer); WebGenPort = prefs.Get<int>(Preference.WebGenPort); WebGenUsername = prefs.Get<string>(Preference.WebGenUsername); WebGenPassword = prefs.Get<string>(Preference.WebGenPassword); CopyHtml = prefs.Get<bool>(Preference.WebGenCopyHtml); CopyXml = prefs.Get<bool>(Preference.WebGenCopyXml); CopyFAHlog = prefs.Get<bool>(Preference.WebGenCopyFAHlog); FtpMode = prefs.Get<FtpMode>(Preference.WebGenFtpMode); LimitLogSize = prefs.Get<bool>(Preference.WebGenLimitLogSize); LimitLogSizeLength = prefs.Get<int>(Preference.WebGenLimitLogSizeLength); }
public void Load(IPreferenceSet prefs) { OfflineLast = prefs.Get<bool>(Preference.OfflineLast); ColorLogFile = prefs.Get<bool>(Preference.ColorLogFile); AutoSaveConfig = prefs.Get<bool>(Preference.AutoSaveConfig); PpdCalculation = prefs.Get<PpdCalculationType>(Preference.PpdCalculation); DecimalPlaces = prefs.Get<int>(Preference.DecimalPlaces); CalculateBonus = prefs.Get<BonusCalculationType>(Preference.CalculateBonus); EtaDate = prefs.Get<bool>(Preference.EtaDate); DuplicateProjectCheck = prefs.Get<bool>(Preference.DuplicateProjectCheck); DuplicateUserIdCheck = prefs.Get<bool>(Preference.DuplicateUserIdCheck); ShowXmlStats = prefs.Get<bool>(Preference.ShowXmlStats); MessageLevel = (LoggerLevel)prefs.Get<int>(Preference.MessageLevel); FormShowStyle = prefs.Get<FormShowStyleType>(Preference.FormShowStyle); }
private void RestoreViewPreferences() { // Would like to do this here in lieu of in frmMain_Shown() event. // There is some drawing error that if Minimized here, the first time the // Form is restored from the system tray, the DataGridView is drawn with // a big black box on the right hand side. Like it didn't get initialized // properly when the Form was created. //if (_prefs.Get<bool>(Preference.RunMinimized)) //{ // WindowState = FormWindowState.Minimized; //} // Look for start position var location = _prefs.Get <Point>(Preference.FormLocation); var size = _prefs.Get <Size>(Preference.FormSize); if (location.X != 0 && location.Y != 0) { _view.SetManualStartPosition(); _view.Location = WindowPosition.Normalize(location, size); } // Look for view size if (size.Width != 0 && size.Height != 0) { // make sure values coming from the prefs are at least the minimums - Issue 234 if (size.Width < _view.MinimumSize.Width) { size.Width = _view.MinimumSize.Width; } if (size.Height < _view.MinimumSize.Height) { size.Height = _view.MinimumSize.Height; } if (!_prefs.Get <bool>(Preference.FormLogWindowVisible)) { size = new Size(size.Width, size.Height + _prefs.Get <int>(Preference.FormLogWindowHeight)); } _view.Size = size; // make sure split location from the prefs is at least the minimum panel size - Issue 234 var formSplitLocation = _prefs.Get <int>(Preference.FormSplitterLocation); if (formSplitLocation < _view.SplitContainer.Panel2MinSize) { formSplitLocation = _view.SplitContainer.Panel2MinSize; } _view.SplitContainer.SplitterDistance = formSplitLocation; } if (!_prefs.Get <bool>(Preference.FormLogWindowVisible)) { ShowHideLogWindow(false); } if (!_prefs.Get <bool>(Preference.QueueWindowVisible)) { ShowHideQueue(false); } _view.FollowLogFileChecked = _prefs.Get <bool>(Preference.FollowLog); _gridModel.SortColumnName = _prefs.Get <string>(Preference.FormSortColumn); _gridModel.SortColumnOrder = _prefs.Get <ListSortDirection>(Preference.FormSortOrder); try { // Restore the columns' state var columns = _prefs.Get <ICollection <string> >(Preference.FormColumns); if (columns != null) { var colsList = columns.ToList(); colsList.Sort(); for (int i = 0; i < colsList.Count && i < MainForm.NumberOfDisplayFields; i++) { string[] tokens = colsList[i].Split(','); int index = Int32.Parse(tokens[3]); _view.DataGridView.Columns[index].DisplayIndex = Int32.Parse(tokens[0]); if (_view.DataGridView.Columns[index].AutoSizeMode.Equals(DataGridViewAutoSizeColumnMode.Fill) == false) { _view.DataGridView.Columns[index].Width = Int32.Parse(tokens[1]); } _view.DataGridView.Columns[index].Visible = Boolean.Parse(tokens[2]); } } } catch (NullReferenceException) { // This happens when the FormColumns setting is empty } }
public void DeployWebsite(IEnumerable <string> htmlFilePaths, IEnumerable <string> xmlFilePaths, IEnumerable <SlotModel> slots) { Debug.Assert(_prefs.Get <bool>(Preference.WebGenerationTaskEnabled)); var webGenType = _prefs.Get <WebDeploymentType>(Preference.WebDeploymentType); var webRoot = _prefs.Get <string>(Preference.WebDeploymentRoot); var copyHtml = _prefs.Get <bool>(Preference.WebGenCopyHtml); var copyXml = _prefs.Get <bool>(Preference.WebGenCopyXml); if (webGenType.Equals(WebDeploymentType.Ftp)) { var server = _prefs.Get <string>(Preference.WebGenServer); var port = _prefs.Get <int>(Preference.WebGenPort); var username = _prefs.Get <string>(Preference.WebGenUsername); var password = _prefs.Get <string>(Preference.WebGenPassword); if (copyHtml && htmlFilePaths != null) { FtpHtmlUpload(server, port, webRoot, username, password, htmlFilePaths, slots); } if (copyXml && xmlFilePaths != null) { FtpXmlUpload(server, port, webRoot, username, password, xmlFilePaths); } } else // WebGenType.Path { // Create the web folder (just in case) if (!Directory.Exists(webRoot)) { Directory.CreateDirectory(webRoot); } if (copyHtml && htmlFilePaths != null) { var cssFile = _prefs.Get <string>(Preference.CssFile); // Copy the CSS file to the output directory string cssFilePath = Path.Combine(Path.Combine(_prefs.ApplicationPath, Constants.CssFolderName), cssFile); if (File.Exists(cssFilePath)) { File.Copy(cssFilePath, Path.Combine(webRoot, cssFile), true); } foreach (string filePath in htmlFilePaths) { File.Copy(filePath, Path.Combine(webRoot, Path.GetFileName(filePath)), true); } if (_prefs.Get <bool>(Preference.WebGenCopyFAHlog)) { foreach (var slot in slots) { string cachedFahlogPath = Path.Combine(_prefs.CacheDirectory, slot.Settings.CachedFahLogFileName()); if (File.Exists(cachedFahlogPath)) { File.Copy(cachedFahlogPath, Path.Combine(webRoot, slot.Settings.CachedFahLogFileName()), true); } } } } if (copyXml && xmlFilePaths != null) { foreach (string filePath in xmlFilePaths) { File.Copy(filePath, Path.Combine(webRoot, Path.GetFileName(filePath)), true); } } } }
public MainGridModel(IPreferenceSet prefs, ISynchronizeInvoke syncObject, IClientDictionary clientDictionary) { _prefs = prefs; _syncObject = syncObject; _clientDictionary = clientDictionary; _slotList = new SlotModelSortableBindingList(_syncObject); _slotList.OfflineClientsLast = _prefs.Get<bool>(Preference.OfflineLast); _slotList.Sorted += (sender, e) => { SortColumnName = e.Name; _prefs.Set(Preference.FormSortColumn, SortColumnName); SortColumnOrder = e.Direction; _prefs.Set(Preference.FormSortOrder, SortColumnOrder); }; _bindingSource = new BindingSource(); _bindingSource.DataSource = _slotList; _bindingSource.CurrentItemChanged += delegate { SelectedSlot = (SlotModel)_bindingSource.Current; }; #if DEBUG _slotList.ListChanged += (s, e) => { Debug.WriteLine("BindingList: " + e.ListChangedType); }; _bindingSource.ListChanged += (s, e) => { Debug.WriteLine("BindingSource: " + e.ListChangedType); }; #endif // Subscribe to PreferenceSet events _prefs.OfflineLastChanged += delegate { _slotList.OfflineClientsLast = _prefs.Get<bool>(Preference.OfflineLast); Sort(); }; _prefs.PpdCalculationChanged += delegate { ResetBindings(); }; _prefs.DecimalPlacesChanged += delegate { ResetBindings(); }; _prefs.CalculateBonusChanged += delegate { ResetBindings(); }; // Subscribe to ClientDictionary events _clientDictionary.DictionaryChanged += delegate { ResetBindings(); }; _clientDictionary.ClientDataInvalidated += delegate { ResetBindings(); }; }
public void Load(IPreferenceSet prefs, IQueryParametersCollection queryCollection) { _bonusCalculation = prefs.Get<BonusCalculationType>(Preference.HistoryBonusCalculation); _showEntriesValue = prefs.Get<int>(Preference.ShowEntriesValue); FormLocation = prefs.Get<Point>(Preference.HistoryFormLocation); FormSize = prefs.Get<Size>(Preference.HistoryFormSize); SortColumnName = prefs.Get<string>(Preference.HistorySortColumnName); SortOrder = prefs.Get<ListSortDirection>(Preference.HistorySortOrder); FormColumns = prefs.Get<ICollection<string>>(Preference.HistoryFormColumns); _queryList.Clear(); _queryList.Add(new QueryParameters()); foreach (var query in queryCollection) { // don't load Select All twice if (query.Name != QueryParameters.SelectAll.Name) { _queryList.Add(query); } } _queryList.Sort(); ResetBindings(true); }
public MainGridModel(IPreferenceSet prefs, ISynchronizeInvoke syncObject, IClientConfiguration clientConfiguration) { _prefs = prefs; _syncObject = syncObject; _clientConfiguration = clientConfiguration; _slotList = new SlotModelSortableBindingList(_syncObject); _slotList.OfflineClientsLast = _prefs.Get<bool>(Preference.OfflineLast); _slotList.Sorted += (sender, e) => { SortColumnName = e.Name; _prefs.Set(Preference.FormSortColumn, SortColumnName); SortColumnOrder = e.Direction; _prefs.Set(Preference.FormSortOrder, SortColumnOrder); }; _bindingSource = new BindingSource(); _bindingSource.DataSource = _slotList; _bindingSource.CurrentItemChanged += (sender, args) => SelectedSlot = (SlotModel)_bindingSource.Current; #if DEBUG _slotList.ListChanged += (s, e) => Debug.WriteLine("BindingList: " + e.ListChangedType); _bindingSource.ListChanged += (s, e) => Debug.WriteLine("BindingSource: " + e.ListChangedType); #endif // Subscribe to PreferenceSet events _prefs.PreferenceChanged += (s, e) => { switch (e.Preference) { case Preference.OfflineLast: _slotList.OfflineClientsLast = _prefs.Get<bool>(Preference.OfflineLast); Sort(); break; case Preference.PpdCalculation: case Preference.DecimalPlaces: case Preference.BonusCalculation: ResetBindings(); break; } }; // Subscribe to ClientDictionary events _clientConfiguration.DictionaryChanged += (sender, args) => ResetBindings(); }
public RetrievalModel(IPreferenceSet prefs, IClientConfiguration clientConfiguration, Lazy <IMarkupGenerator> markupGenerator, Lazy <IWebsiteDeployer> websiteDeployer) { _prefs = prefs; _clientConfiguration = clientConfiguration; _markupGenerator = markupGenerator; _websiteDeployer = websiteDeployer; _taskManager = new TaskManager(); _taskManager.Changed += (s, e) => ReportAction(e); _prefs.PreferenceChanged += (s, e) => { switch (e.Preference) { case Preference.ClientRetrievalTask: if (_prefs.Get <bool>(Preference.ClientRetrievalTaskEnabled)) { if (_clientConfiguration.Count != 0) { _taskManager.Restart(ClientTaskKey, ClientInterval); } } else { _taskManager.Stop(ClientTaskKey); } break; case Preference.WebGenerationTask: if (_prefs.Get <bool>(Preference.WebGenerationTaskEnabled) && _prefs.Get <bool>(Preference.WebGenerationTaskAfterClientRetrieval) == false) { if (_clientConfiguration.Count != 0) { _taskManager.Restart(WebTaskKey, WebInterval); } } else { _taskManager.Stop(WebTaskKey); } break; } }; _clientConfiguration.ConfigurationChanged += (s, e) => { if (e.ChangedType == ConfigurationChangedType.Remove || e.ChangedType == ConfigurationChangedType.Clear) { // Disable timers if no hosts if (_taskManager.Enabled && _clientConfiguration.Count == 0) { Logger.Info("No clients... stopping all scheduled tasks"); //_taskManager.Stop(); _taskManager.Cancel(); } } else if (e.ChangedType == ConfigurationChangedType.Add) { var clientTaskEnabled = _prefs.Get <bool>(Preference.ClientRetrievalTaskEnabled); if (e.Client == null) { // no client specified - retrieve all _taskManager.Run(ClientTaskKey, ClientInterval, clientTaskEnabled); } else if (clientTaskEnabled) { _taskManager.Start(ClientTaskKey, ClientInterval); } if (_prefs.Get <bool>(Preference.WebGenerationTaskEnabled) && _prefs.Get <bool>(Preference.WebGenerationTaskAfterClientRetrieval) == false) { _taskManager.Start(WebTaskKey, WebInterval); } } }; _taskManager.Add(ClientTaskKey, ClientRetrievalAction, ClientInterval); _taskManager.Add(WebTaskKey, WebGenerationAction, WebInterval); }
public void Load(IPreferenceSet prefs) { SyncTimeMinutes = prefs.Get<int>(Preference.SyncTimeMinutes); SyncOnSchedule = prefs.Get<bool>(Preference.SyncOnSchedule); SyncOnLoad = prefs.Get<bool>(Preference.SyncOnLoad); AllowRunningAsync = prefs.Get<bool>(Preference.AllowRunningAsync); WebGenType = prefs.Get<WebGenType>(Preference.WebGenType); GenerateInterval = prefs.Get<int>(Preference.GenerateInterval); WebGenAfterRefresh = prefs.Get<bool>(Preference.WebGenAfterRefresh); WebRoot = prefs.Get<string>(Preference.WebRoot); WebGenServer = prefs.Get<string>(Preference.WebGenServer); WebGenPort = prefs.Get<int>(Preference.WebGenPort); WebGenUsername = prefs.Get<string>(Preference.WebGenUsername); WebGenPassword = prefs.Get<string>(Preference.WebGenPassword); CopyHtml = prefs.Get<bool>(Preference.WebGenCopyHtml); CopyXml = prefs.Get<bool>(Preference.WebGenCopyXml); CopyFAHlog = prefs.Get<bool>(Preference.WebGenCopyFAHlog); FtpMode = prefs.Get<FtpType>(Preference.WebGenFtpMode); LimitLogSize = prefs.Get<bool>(Preference.WebGenLimitLogSize); LimitLogSizeLength = prefs.Get<int>(Preference.WebGenLimitLogSizeLength); GenerateWeb = prefs.Get<bool>(Preference.GenerateWeb); }
public void Load(IPreferenceSet prefs) { OfflineLast = prefs.Get <bool>(Preference.OfflineLast); ColorLogFile = prefs.Get <bool>(Preference.ColorLogFile); AutoSaveConfig = prefs.Get <bool>(Preference.AutoSaveConfig); PpdCalculation = prefs.Get <PpdCalculationType>(Preference.PpdCalculation); DecimalPlaces = prefs.Get <int>(Preference.DecimalPlaces); CalculateBonus = prefs.Get <BonusCalculationType>(Preference.BonusCalculation); EtaDate = prefs.Get <bool>(Preference.DisplayEtaAsDate); DuplicateProjectCheck = prefs.Get <bool>(Preference.DuplicateProjectCheck); DuplicateUserIdCheck = prefs.Get <bool>(Preference.DuplicateUserIdCheck); ShowXmlStats = prefs.Get <bool>(Preference.EnableUserStats); MessageLevel = (LoggerLevel)prefs.Get <int>(Preference.MessageLevel); FormShowStyle = prefs.Get <MinimizeToOption>(Preference.MinimizeTo); }
public void Load(IPreferenceSet prefs) { var clientRetrievalTask = prefs.Get <ClientRetrievalTask>(Preference.ClientRetrievalTask); SyncTimeMinutes = clientRetrievalTask.Interval; SyncOnSchedule = clientRetrievalTask.Enabled; SyncOnLoad = clientRetrievalTask.ProcessingMode == ProcessingMode.Serial; AllowRunningAsync = prefs.Get <bool>(Preference.AllowRunningAsync); var webGenerationTask = prefs.Get <WebGenerationTask>(Preference.WebGenerationTask); GenerateWeb = webGenerationTask.Enabled; GenerateInterval = webGenerationTask.Interval; WebGenAfterRefresh = webGenerationTask.AfterClientRetrieval; WebGenType = prefs.Get <WebDeploymentType>(Preference.WebDeploymentType); WebRoot = prefs.Get <string>(Preference.WebDeploymentRoot); WebGenServer = prefs.Get <string>(Preference.WebGenServer); WebGenPort = prefs.Get <int>(Preference.WebGenPort); WebGenUsername = prefs.Get <string>(Preference.WebGenUsername); WebGenPassword = prefs.Get <string>(Preference.WebGenPassword); CopyHtml = prefs.Get <bool>(Preference.WebGenCopyHtml); CopyXml = prefs.Get <bool>(Preference.WebGenCopyXml); CopyFAHlog = prefs.Get <bool>(Preference.WebGenCopyFAHlog); FtpMode = prefs.Get <FtpMode>(Preference.WebGenFtpMode); LimitLogSize = prefs.Get <bool>(Preference.WebGenLimitLogSize); LimitLogSizeLength = prefs.Get <int>(Preference.WebGenLimitLogSizeLength); }
public BenchmarksForm(IPreferenceSet prefs, IProteinService proteinService, IProteinBenchmarkCollection benchmarkCollection, IClientConfiguration clientConfiguration, IMessageBoxView messageBoxView, IExternalProcessStarter processStarter) { _prefs = prefs; _proteinService = proteinService; _benchmarkCollection = benchmarkCollection; _graphColors = _prefs.Get<List<Color>>(Preference.GraphColors); _clientConfiguration = clientConfiguration; _messageBoxView = messageBoxView; _processStarter = processStarter; _zedGraphManager = new ZedGraphManager(); InitializeComponent(); StartPosition = FormStartPosition.Manual; }
public BenchmarksForm(IPreferenceSet prefs, IProteinDictionary proteinDictionary, IProteinBenchmarkCollection benchmarkCollection, IClientDictionary clientDictionary, IMessageBoxView messageBoxView, IExternalProcessStarter processStarter) { _prefs = prefs; _proteinDictionary = proteinDictionary; _benchmarkCollection = benchmarkCollection; _graphColors = _prefs.Get<List<Color>>(Preference.GraphColors); _clientDictionary = clientDictionary; _messageBoxView = messageBoxView; _processStarter = processStarter; _zedGraphManager = new ZedGraphManager(); InitializeComponent(); }