public static void Invoke() { TaskUpdateConfigDataAction.Invoke(); var cfg = App.DataBase.GetCollection <AlgorithmConfig>().FindOne(a => a.IsPrimary); var completed = App.Algorithm.CheckTransportSystems(cfg); if (!completed) { ComponentUtils.ShowMessage("Проверка данных показала отрицательный ответ \n" + "У транспортных сетей нету необходимой связности для работы алгоритма", MessageBoxImage.Information); return; } var algorithmResult = App.Algorithm.Run(cfg); if (algorithmResult == null) { ComponentUtils.ShowMessage("Выбранный метод работы алгоритма или тип алгоритма еще не поддерживается", MessageBoxImage.Information); return; } App.DataBase.GetCollection <AlgorithmResult>().Insert(algorithmResult); ComponentUtils.ShowMessage("Поставленная задача была выполнена, результаты выполнения, можно посмотреть во вкладке \"Результаты расчетов\"", MessageBoxImage.Information); }
public GenericSelectEntitiesDialog(string title, IDictionary <string, Func <T, object> > propertyMatcher, IEnumerable <T> entities) { _selectEntitiesDialog.Title = title; _selectEntitiesDialog.SelectButton.Click += (sender, args) => { if (_entityList.Selected == null) { ComponentUtils.ShowMessage("Выберите элемент(ы) из списка", MessageBoxImage.Error); return; } _selectEntitiesDialog.DialogResult = true; }; _entityList = new GenericEntityListControl <T>( "Список", propertyMatcher, t => { }); _selectEntitiesDialog.ListPanel.Children.Add(_entityList.GetUiElement()); _entityList.SetSource(entities); var isSelected = _selectEntitiesDialog.ShowDialog(); if (isSelected == true) { Selected = _entityList.SelectedAll(); } }
// support method for callback methods private static bool IsViable(string previousName) { if (_nameControl.Value == "") { ComponentUtils.ShowMessage("Введите не пустое название населенного пункта", MessageBoxImage.Error); return(false); } if (_citiesList.Select(с => с.Name).Contains(_nameControl.Value) && previousName != _nameControl.Value) { ComponentUtils.ShowMessage("Населенный пункт с таким названием уже существует", MessageBoxImage.Error); return(false); } if (!_transportSystemsControl.Value.Any()) { ComponentUtils.ShowMessage( "Населенный пункт должен принадлежать по крайней мере одной траснспортной системе", MessageBoxImage.Error); return(false); } return(true); }
// support method for callback methods private static bool IsViable() { if (_fromControl.Value == _toControl.Value) { ComponentUtils.ShowMessage("Поля \"Откуда\" и \"Куда\" должны представлять названия разных населенных пунктов", MessageBoxImage.Error); return(false); } if (!_nameToIdCitiesMap.ContainsKey(_fromControl.Value) || !_nameToIdCitiesMap.ContainsKey(_toControl.Value)) { ComponentUtils.ShowMessage("Поля \"Откуда\" и \"Куда\" должны представлять названия населенных пунктов", MessageBoxImage.Error); return(false); } if (!_availableRoadTypes.Values.Contains(new RoadType() { Name = _roadTypeControl.Value })) { ComponentUtils.ShowMessage("Поле \"Тип дороги\" должен представлять название одного из типа дорог которые были объявленны в глобальных параметрах сети", MessageBoxImage.Error); return(false); } return(true); }
// init methods private void InitCityTagsProperty() { _cityTagsControl = new GenericTableRowControl <CityTag>() { TitleValue = "Используемые типы населенных пунктов", TitleToolTip = "Представляет собой набор допустимых типов населенных пунктов в сети, используется при добавлении или обновлении населенного пункта", OnAdd = alreadyUsedCityTags => { var addDialog = new AddStringDialog() { Title = "Новый тип населенного пункта", IsViable = newCityTagName => { if (newCityTagName.Trim() == "") { ComponentUtils.ShowMessage("Введите не пустое название", MessageBoxImage.Error); return(false); } if (alreadyUsedCityTags.Contains(new CityTag() { Name = newCityTagName.Trim() })) { ComponentUtils.ShowMessage("Тип населенного пункта с таким названием уже существует", MessageBoxImage.Error); return(false); } return(true); }, RowControl = { TitleValue = "Введите название", Value = "" } }; if (addDialog.ShowDialog() != true) { return(null); } var created = new CityTag() { Name = addDialog.RowControl.Value }; return(new List <CityTag>() { created }); }, Value = _cityTags.Values }; _cityTagsControl.AddColumns(CityTag.PropertyMatcher()); PropertiesPanel.Children.Add(_cityTagsControl.GetUiElement); }
public void MatrixReport(AlgorithmResult res) { var fileName = EnterFileName("matrix-report", "Csv file (*.csv)|*.csv"); if (fileName == null) { return; } File.WriteAllText(fileName, ReportUtils.MatrixReport(res)); ComponentUtils.ShowMessage("Результат в файл успешно записан", MessageBoxImage.Information); }
public void FullReport(AlgorithmResult res) { var fileName = EnterFileName("full-report", "Txt file (*.txt)|*.txt"); if (fileName == null) { return; } File.WriteAllText(fileName, ReportUtils.FullReport(res)); ComponentUtils.ShowMessage("Результат в файл успешно записан", MessageBoxImage.Information); }
private static bool UpdateTransportSystem(TransportSystem selected) { if (!IsViable(null)) { return(false); } selected.Name = _nameControl.Value; App.DataBase.GetCollection <TransportSystem>().Update(selected); ComponentUtils.ShowMessage("Данная транспортная система была обновлена", MessageBoxImage.Information); return(true); }
private static bool UpdateCity(City selectedCity) { if (!IsViable(selectedCity.Name)) { return(false); } selectedCity.Name = _nameControl.Value; selectedCity.CostOfStaying = _costOfStayingControl.Value; selectedCity.Tags = _tagsControl.Value; selectedCity.TransportSystemIds = _transportSystemsControl.Value.Select(ts => ts.Id).ToList(); App.DataBase.GetCollection <City>().Update(selectedCity); ComponentUtils.ShowMessage("Данный населенный пункт был обновлен", MessageBoxImage.Information); return(true); }
// support method for callback methods private static bool IsViable(string previousName) { if (_nameControl.Value == "") { ComponentUtils.ShowMessage("Введите не пустое название транспортной системы", MessageBoxImage.Error); return(false); } if (_transportSystemsList.Select(с => с.Name).Contains(_nameControl.Value) && previousName != _nameControl.Value) { ComponentUtils.ShowMessage("Транспортная система с таким названием уже существует", MessageBoxImage.Error); return(false); } return(true); }
public static void Invoke() { var defaultFileName = AppResources.GetDefaultDataBasePath; try { App.DataBase.Open(defaultFileName); } catch (Exception) { ComponentUtils.ShowMessage("Файл базы данных по умолчанию (application-data.db) занят другим процессом или испорчен\n" + "Освободите его если он занят или удалите и создастся новый при повторном запуске приложения\n" + "Приложение будет закрыто", MessageBoxImage.Error); ExitAction.Invoke(); } AddNeededDataIfNotExistedBefore(); PrintDataState(); }
public static void Invoke() { TaskUpdateConfigDataAction.Invoke(); var cfg = App.DataBase.GetCollection <AlgorithmConfig>().FindOne(a => a.IsPrimary); var completed = App.Algorithm.CheckTransportSystems(cfg); if (!completed) { ComponentUtils.ShowMessage("Проверка отрицательная \n" + "У указанных в концигурации транспортных сетей нету необходимой связности для работы алгоритма", MessageBoxImage.Information); } else { ComponentUtils.ShowMessage("Проверка положительная\n" + "Поставленная задача корректна и может быть обработанна алгоритмом\n", MessageBoxImage.Information); } }
private static bool UpdateRoad(Road selectedRoad) { if (!IsViable()) { return(false); } selectedRoad.FromCityId = _nameToIdCitiesMap[_fromControl.Value]; selectedRoad.ToCityId = _nameToIdCitiesMap[_toControl.Value]; selectedRoad.Length = _lengthControl.Value; selectedRoad.Cost = _costControl.Value; selectedRoad.Time = _timeControl.Value; selectedRoad.RoadType.Name = _roadTypeControl.Value; selectedRoad.DepartureTimes = _departureTimeTableControl.Value; App.DataBase.GetCollection <Road>().Update(selectedRoad); ComponentUtils.ShowMessage("Данный маршрут был обновлен", MessageBoxImage.Information); return(true); }
public static void Invoke() { ComponentUtils.ShowMessage($"{Goal}\n\n{Description}\n\n{Developer}", MessageBoxImage.Information); }