public ActionResult Author(string user, int?p, int?commend, string order) { var iscommend = commend ?? 0; var pager = new Pager { PageNo = p ?? 1, PageSize = Configinfo.CatePagerCount }; pager = MyService.GetAuthorArticlePaging(pager, 1, user, iscommend, order); var archivesViewModel = new ArchivesViewModel { WebPath = "[Author] " + user, ArticlePagerInfo = pager }; var articleListParasInfo = new AjaxArticleListParamsModel { ArticleListType = "author", AuthorName = user, Commend = iscommend, Order = order }; ViewBag.ArticleListParasInfo = articleListParasInfo; return(View("Archives", archivesViewModel)); }
public ActionResult Archives(int year, int?month, int?day, int?p, int?commend, string order) { var iscommend = commend ?? 0; var pager = new Pager { PageNo = p ?? 1, PageSize = Configinfo.CatePagerCount }; pager = MyService.GetArchivesArticlePaging(pager, 1, year, month ?? 0, day ?? 0, iscommend, order); var archivesViewModel = new ArchivesViewModel { WebPath = "[" + res.Archive + "] " + year + (month != null ? "/" + month : string.Empty) + (day != null ? "/" + day : string.Empty), ArticlePagerInfo = pager }; var articleListParasInfo = new AjaxArticleListParamsModel { ArticleListType = "archives", Year = year, Month = month ?? 0, Day = day ?? 0, Commend = iscommend, Order = order }; ViewBag.ArticleListParasInfo = articleListParasInfo; return(View(archivesViewModel)); }
public ActionResult Search(string key, int?p, int?commend, string order) { var iscommend = commend ?? 0; var pager = new Pager { PageNo = p ?? 1, PageSize = Configinfo.CatePagerCount }; pager = MyService.GetKeySearchPaging(pager, 1, key, iscommend, order); var archivesViewModel = new ArchivesViewModel { WebPath = "[" + res.SearchKey + "] " + key, ArticlePagerInfo = pager }; var articleListParasInfo = new AjaxArticleListParamsModel { ArticleListType = "search", SearchKey = key, Commend = iscommend, Order = order }; ViewBag.ArticleListParasInfo = articleListParasInfo; return(View("Archives", archivesViewModel)); }
public void GetBucketsDescending_AreDescending() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "TestAppDatabase") .Options; var stub = Substitute.For <IHostingEnvironment>(); ApplicationDbContext context = new ApplicationDbContext(options, stub); context.Database.EnsureCreated(); context.Posts.AddRange(GenerateDoublePosts()); context.SaveChanges(); IBlogPostRepository repo = new EFBlogPostRepository(context); ArchivesViewModel model = new ArchivesViewModel(repo); var buckets = model.BucketsOfPostsDescending; Assert.IsTrue(buckets.Count > 0); Assert.IsTrue(buckets.Count == 9); for (int i = 0; i < buckets.Count - 1; i++) { Assert.IsTrue(buckets[i].MonthAndYear > buckets[i + 1].MonthAndYear); } context.Database.EnsureDeleted(); }
/// <summary> /// Get the model to use /// </summary> /// <returns></returns> private ArchivesViewModel GetModel() { // Get archives links var model = new ArchivesViewModel { Archives = _dataService.GetArchives() }; return(model); }
public void GetBucketsDescending_SingleGroup_CountIsRight() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "TestAppDatabase") .Options; var stub = Substitute.For <IHostingEnvironment>(); ApplicationDbContext context = new ApplicationDbContext(options, stub); context.Database.EnsureCreated(); context.Posts.AddRange(GenerateSinglePosts()); context.SaveChanges(); IBlogPostRepository repo = new EFBlogPostRepository(context); ArchivesViewModel model = new ArchivesViewModel(repo); var buckets = model.BucketsOfPostsDescending; Assert.IsTrue(buckets.Count == 9); context.Database.EnsureDeleted(); }
public MainViewModel(IUserInterfaceRoot uiRoot, IWindowSystem windowSystem, List <Color> colors, ICommandSenderHostSettable commandSenderHostSettable, ITargetAddressHost targetAddressHost, IMultiLoggerWithStackTrace <int> debugLogger, ILoggerRegistrationPoint loggerRegistrationPoint, INotifySendingEnabledRaisable notifySendingEnabled, IParameterLogger paramLogger, IAinsCounterRaisable ainsCounterRaisable, ICycleThreadHolder cycleThreadHolder, IAinSettingsReader ainSettingsReader, IAinSettingsReadNotify ainSettingsReadNotify, IAinSettingsReadNotifyRaisable ainSettingsReadNotifyRaisable, IAinSettingsWriter ainSettingsWriter, IAinSettingsStorage ainSettingsStorage, IAinSettingsStorageSettable ainSettingsStorageSettable, IAinSettingsStorageUpdatedNotify storageUpdatedNotify, ReadCycleModel bsEthernetReadCycleModel, IEngineSettingsReader engineSettingsReader, IEngineSettingsWriter engineSettingsWriter, IEngineSettingsReadNotify engineSettingsReadNotify, IEngineSettingsReadNotifyRaisable engineSettingsReadNotifyRaisable, IEngineSettingsStorage engineSettingsStorage, IEngineSettingsStorageSettable engineSettingsStorageSettable, IEngineSettingsStorageUpdatedNotify engineSettingsStorageUpdatedNotify) { _uiRoot = uiRoot; _colors = colors; _commandSenderHostSettable = commandSenderHostSettable; _commandSenderHost = commandSenderHostSettable; _targetAddressHost = targetAddressHost; _isPortOpened = false; // Лог программы: _debugLogger = debugLogger; _loggerRegistrationPoint = loggerRegistrationPoint; // разрешение к отправке (COM-порт открыт/закрыт) _notifySendingEnabled = notifySendingEnabled; ProgramLogVm = new ProgramLogViewModel(_uiRoot, _debugLogger, new DateTimeFormatter(" > ")); _logger = new RelayLogger(ProgramLogVm); _loggerRegistrationPoint.RegisterLoggegr(_logger); GetPortsAvailable(); OpenPortCommand = new RelayCommand(OpenPort, () => !_isPortOpened); ClosePortCommand = new RelayCommand(ClosePort, () => _isPortOpened); GetPortsAvailableCommand = new RelayCommand(GetPortsAvailable); _paramLogger = paramLogger; _ainsCounterRaisable = ainsCounterRaisable; _cycleThreadHolder = cycleThreadHolder; _ainSettingsReader = ainSettingsReader; _ainSettingsReadNotify = ainSettingsReadNotify; _ainSettingsWriter = ainSettingsWriter; // Блоки АИН в системе: AinsCountInSystem = new List <int> { 1, 2, 3 }; SelectedAinsCount = AinsCountInSystem.First(); var ainSettingsReadedWriter = new AinSettingsReaderWriter(_ainSettingsReader, _ainSettingsWriter); _engineSettingsReader = engineSettingsReader; _engineSettingsWriter = engineSettingsWriter; _engineSettingsReadNotify = engineSettingsReadNotify; _engineSettingsReadNotifyRaisable = engineSettingsReadNotifyRaisable; _engineSettingsStorage = engineSettingsStorage; _engineSettingsStorageSettable = engineSettingsStorageSettable; _engineSettingsStorageUpdatedNotify = engineSettingsStorageUpdatedNotify; AinCommandAndCommonTelemetryVm = new AinCommandAndCommonTelemetryViewModel( new AinCommandAndMinimalCommonTelemetryViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 0, ainSettingsStorage, storageUpdatedNotify), new TelemetryCommonViewModel(), _commandSenderHost, _targetAddressHost, _uiRoot, _notifySendingEnabled); _cycleThreadHolder.RegisterAsCyclePart(AinCommandAndCommonTelemetryVm); TelemtryVm = new TelemetryViewModel(_uiRoot, _commandSenderHost, _targetAddressHost, _logger, _cycleThreadHolder, _ainsCounterRaisable, _paramLogger, _notifySendingEnabled); SettingsVm = new SettingsViewModel(_uiRoot, _logger, ainSettingsReadedWriter, _ainSettingsReadNotify, ainSettingsReadNotifyRaisable, ainSettingsStorage, ainSettingsStorageSettable, storageUpdatedNotify, _ainsCounterRaisable, _commandSenderHost, _targetAddressHost, _notifySendingEnabled, _engineSettingsReader, _engineSettingsWriter, _engineSettingsReadNotify, _engineSettingsReadNotifyRaisable, _engineSettingsStorage, _engineSettingsStorageSettable, _engineSettingsStorageUpdatedNotify, _debugLogger); // TODO: can be moved to app.xaml.cs if needed ArchiveVm = new ArchivesViewModel( new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 0), new ArchiveViewModel(_commandSenderHost, _targetAddressHost, _uiRoot, _logger, _notifySendingEnabled, 1)); MnemonicChemeVm = new MnemonicChemeViewModel(Path.Combine(Environment.CurrentDirectory, "mnemoniccheme.png")); OldLookVm = new OldLookViewModel(_uiRoot, windowSystem, _commandSenderHost, _targetAddressHost, _notifySendingEnabled, this, _logger, _debugLogger, _cycleThreadHolder, _ainsCounterRaisable, _paramLogger, ainSettingsStorage, storageUpdatedNotify); _ain1StateColor = Colors.Gray; _ain2StateColor = Colors.Gray; _ain3StateColor = Colors.Gray; _ain1IsUsed = true; _ain2IsUsed = false; _ain3IsUsed = false; _ainsCounterRaisable.AinsCountInSystemHasBeenChanged += ainsCount => { switch (ainsCount) { case 1: Ain1IsUsed = true; Ain2IsUsed = false; Ain3IsUsed = false; break; case 2: Ain1IsUsed = true; Ain2IsUsed = true; Ain3IsUsed = false; break; case 3: Ain1IsUsed = true; Ain2IsUsed = true; Ain3IsUsed = true; break; default: throw new Exception("Такое число АИН в системе не поддерживается"); } }; AinCommandAndCommonTelemetryVm.AinsLinkInformationHasBeenUpdated += (ain1Error, ain2Error, ain3Error) => { Ain1StateColor = ain1Error.HasValue ? ain1Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; Ain2StateColor = ain2Error.HasValue ? ain2Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; Ain3StateColor = ain3Error.HasValue ? ain3Error.Value ? Colors.Red : Colors.YellowGreen : Colors.Gray; }; _notifySendingEnabled.SendingEnabledChanged += isEnabled => { // TODO: execution in ui thread Ain1StateColor = Colors.Gray; Ain2StateColor = Colors.Gray; Ain3StateColor = Colors.Gray; }; EngineAutoSetupVm = new EngineAutoSetupViewModel( new TableViewModel("Начальные значения:", _logger), new TableViewModel("После тестирования:", _logger), _notifySendingEnabled, _ainSettingsReader, _ainSettingsReadNotify, _ainSettingsWriter, _uiRoot, _logger, _commandSenderHost, _targetAddressHost, bsEthernetReadCycleModel); _logger.Log("Программа загружена"); }
public IViewComponentResult Invoke() { ArchivesViewModel model = new ArchivesViewModel(blogRepository); return(View(model)); }