public MassiveConfigureDevicePart(StationModel station) { if (station == null) { return; } StationName = string.IsNullOrEmpty(station.NameOficial) ? $"{station.Name} {station.Description}" : $"{station.NameOficial} {station.Description}"; StationId = station.Id; IpAddress = station.InformationTable?.IpDevice ?? ""; UserName = station.InformationTable?.UserNameDevice ?? ""; Password = station.InformationTable?.PasswordDevice ?? ""; IsChecked = false; }
public MonitoringViewModel(StationModel station, List <Event> eventsByStation, List <Event> errorEvents) { StationId = station?.Id ?? ""; StationNameAndDescription = $"{station?.Name ?? ""} {station?.Description ?? ""}"; ForecastSource = string.Equals(station?.Id ?? "0", "0", new StringComparison()) ? (string.IsNullOrEmpty(station?.IdForRnis) ? "Нет поставщика данных" : "Поставщиком является только РНИС") : (string.IsNullOrEmpty(station?.IdForRnis) ? "Поставщик Умный транспорт" : "Данные получены от Умного транспорта и РНИС"); var lastEventDateTime = eventsByStation?.OrderBy(e => e.Date) .LastOrDefault() ?.Date ?? DateTime.MinValue; if (DateTime.Equals(lastEventDateTime, DateTime.MinValue) || DateTime.Now - lastEventDateTime > TimeSpan.FromMinutes(5)) { AnaliticFunctionalityString = "Табло не работает(мин. 1 день)"; AnaliticFunctionality = AnaliticFunctionality.NOT_WORK; lastEventDateTime = errorEvents.OrderBy(e => e.Date).LastOrDefault() ?.Date ?? DateTime.MinValue; LastStationActivity = lastEventDateTime.ToString($"yyyy/MM/dd HH:mm:ss", new CultureInfo("All")); } else if (DateTime.Now - lastEventDateTime > TimeSpan.FromSeconds(60.0) && DateTime.Now - lastEventDateTime < TimeSpan.FromMinutes(5)) { AnaliticFunctionalityString = "Есть проблемы!"; AnaliticFunctionality = AnaliticFunctionality.BAD_WORK; lastEventDateTime = errorEvents.OrderBy(e => e.Date).LastOrDefault() ?.Date ?? DateTime.MinValue; LastStationActivity = lastEventDateTime.ToString($"yyyy/MM/dd HH:mm:ss", new CultureInfo("All")); } else if (DateTime.Now - lastEventDateTime < TimeSpan.FromSeconds(60.0)) { AnaliticFunctionalityString = "Табло работает нормально!"; AnaliticFunctionality = AnaliticFunctionality.NORMAL_WORK; LastStationActivity = lastEventDateTime.ToString($"yyyy/MM/dd HH:mm:ss", new CultureInfo("All")); } LastError = errorEvents == null ? "Табло не работает!" : (errorEvents.Any() ? (errorEvents.LastOrDefault()?.Description ?? "") : "Без ошибок"); }
public StationModelViewModel(StationModel station) { if (station == null) { return; } StationId = station.Id; VisualName = string.IsNullOrEmpty(station.NameOficial) ? station.Name + " (не офиц.)" : station.NameOficial; DistrictOfTheCity = station.DistrictOfTheCity; StrFunction = station.Name + " " + station.Description; Geo = "Geo"; Red = "Red"; //Contents = ""; //if (station?.InformationTable?.Contents != null) //{ // foreach (var item in station.InformationTable.Contents) // { // Contents += (item?.ContentType.ToString() + " " ?? ""); // } //} }
public OptionsViewModel(StationModel station, List <ModuleType> moduleTypes, List <ContentType> contentTypes, string selectedModuleTypeId) { if (station == null) { return; } ContentAddViewModel = new ContentAddViewModel(station.Id, new Content() { Id = Guid.NewGuid() .ToString(), ContentType = ContentType.TEXT, InnerContent = "", TimeOut = 0 }, contentTypes); InformationTableId = station.InformationTable ?.Id ?? ""; StationName = station.Name; StationId = station.Id; WidthWithModules = station.InformationTable ?.WidthWithModule ?? 0; HeightWithModules = station.InformationTable ?.HeightWithModule ?? 0; RowCount = station.InformationTable ?.RowCount ?? 0; IpAddress = station.InformationTable?.IpDevice ?? ""; UserName = station.InformationTable?.UserNameDevice ?? ""; Password = station.InformationTable?.PasswordDevice ?? ""; var list = new List <SelectListItem>(); foreach (var item in moduleTypes) { var itemSelectList = new SelectListItem() { Text = item.Id, Value = item.Id }; list.Add(itemSelectList); } if (selectedModuleTypeId == null) { SelectListItem first = null; foreach (var item in list) { first = item; break; } if (first != null) { first.Selected = true; } } else if (list.Any(l => l.Value == selectedModuleTypeId)) { SelectListItem first = null; foreach (var l in list) { if (l.Value == selectedModuleTypeId) { first = l; break; } } if (first != null) { first.Selected = true; } } else { SelectListItem first = null; foreach (var item in list) { first = item; break; } if (first != null) { first.Selected = true; } } ModuleTypes = new SelectList(list); ContentOptions = new List <ContentOption>(); var contents = station.InformationTable?.Contents; if (contents != null) { foreach (var item in contents) { var optionContentItem = new ContentOption(item, contentTypes, ((int)item.ContentType).ToString(), (station.Id ?? ""));//, (station.InformationTable // ?.Id ?? "")); ContentOptions.Add(optionContentItem); } } }
public OptionsAndPreviewViewModel(StationModel station, List <ModuleType> moduleTypes, List <ContentType> contentTypes, string selectedModuleTypeId) { Options = new OptionsViewModel(station, moduleTypes, contentTypes, selectedModuleTypeId); InformationTablePreview = new InformationTableViewModel(station?.InformationTable, station?.Id ?? "-1", station?.InformationTable ?.RowCount ?? 0); }