private void InvokeOpenInitDialog() { var result = _windowDialogService.ShowDialog("", InitDialogViewModel); if (result == null || !result.Value) { return; } // обработка полученных путей var adjacencyMatrix = DataLoaderService.LoadAdjacencyMatrix(InitDialogViewModel.AdjacencyMatrixFilePath); _network.AdjacencyMatrix = adjacencyMatrix; double[,] direcTravelersMatrix; if (InitDialogViewModel.HasDirectTravelersMatrix) { direcTravelersMatrix = DataLoaderService.LoadDirectTravelersMatrix(InitDialogViewModel.DirectTravelersMatrixFilePath); } else { var arrivals = DataLoaderService.LoadArrivals(InitDialogViewModel.ArrivalsFilePath); var departures = DataLoaderService.LoadDepartures(InitDialogViewModel.DeparturesFilePath); direcTravelersMatrix = Algorithms.FindCorrespMatrix(adjacencyMatrix, arrivals, departures); } _network.DirectTravelersMatrix = direcTravelersMatrix; DataLoaderService.LoadNodesAtrributes(InitDialogViewModel.NodesPositionsFilePath); }
static void Main(string[] args) { Startup(); var provider = GetServices().BuildServiceProvider(); var dataSaver = new DataSaverService(provider.GetService <IJudmentDocuments>(), provider.GetService <IMinisters>(), provider.GetService <IParties>(), provider.GetService <IVotes>()); var data = new DataLoaderService().Load(AppSettings.File); dataSaver.Save(data); }
private async void ApplicationBarIconButton_OnClick(object sender, EventArgs e) { if (IsBusy) { IsBusy = true; } StateService.ProgressIndicatorService.Show("Logging in..."); var offLineMode = false; LoginReply login = null; if (!Helpers.IsNetworkAvailable && StateService.Login == tbLogin.Text && StateService.Password == tbPassword.Password) { login = new LoginReply() { UserId = StateService.CurrentUserId, IsSuccess = true }; offLineMode = true; Helpers.LogEvent("Login", new Dictionary <string, string> { { "UserId", StateService.CurrentUserId.ToString() }, { "AppVersion", Helpers.GetAppVersion() } }); MessageBox.Show("Working in Offline mode. Data will be synched when internet connection becomes available"); } else { login = await new MyNetmeraClient().Login(tbLogin.Text, tbPassword.Password); } if (ApiResponseProcessor.Execute(login)) { StateService.CurrentUserType = (ESurveyorType)login.Type; Guid userId = login.UserId.Value; Helpers.LogEvent("Login", new Dictionary <string, string> { { "UserId", userId.ToString() }, { "AppVersion", Helpers.GetAppVersion() } }); if (StateService.PreviousUserId != userId) { if (SyncEngine.IsSyncing) { MessageBox.Show("Syncing now, wait"); StateService.ProgressIndicatorService.Hide(); IsBusy = false; return; } if (StateService.CurrentUserId == Guid.Empty) { StateService.CurrentUserId = userId; } PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Syncing previous user data"); await SyncEngine.Sync(true); PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Clearing database"); await new DbService().ClearDb(); if (StateService.IsQA) { var myQaAddresses = DataLoaderService.Convert <QAAddress, ServiceReference.QAAddress>(login.QaAddresses); await new DbService().Save(myQaAddresses); var myQaAddressesComments = DataLoaderService.Convert <QAAddressComment, ServiceReference.QAAddressComment>(login.QaAddressComments); await new DbService().Save(myQaAddressesComments); } StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Loading data"); bool isError = false; StateService.CurrentUserTimeStamp = login.Timestamp; StateService.CurrentUserId = userId; try { await new MyNetmeraClient().DownloadUserData(); } catch (Exception exc) { isError = true; Helpers.LogException(exc, "DownloadUserData"); MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while loading data. Try again" : exc.Message); } if (isError) { await new MyNetmeraClient().ClearDb(); } StateService.ProgressIndicatorService.Hide(); PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled; if (isError) { return; } StateService.PreviousUserId = userId; StateService.Login = tbLogin.Text; StateService.Password = tbPassword.Password; } else { bool isError = false; //Process timestamp if (!offLineMode && StateService.CurrentUserTimeStamp != login.Timestamp) { StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Refreshing user data"); try { await new MyNetmeraClient().RefreshUserData(); StateService.CurrentUserTimeStamp = login.Timestamp; } catch (Exception exc) { isError = true; Helpers.LogException(exc, "RefreshUserData"); MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while refreshing data. Try again" : exc.Message); } } try { if (!isError) { StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Processing address move"); await new MyNetmeraClient().RefreshAddressMoves(login.AddressMoves); } } catch (Exception exc) { isError = true; Helpers.LogException(exc, "RefreshAddressMoves"); MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while processing address moves. Try again" : exc.Message); } //update address properties try { StateService.ProgressIndicatorService.Hide(); StateService.ProgressIndicatorService.Show("Refreshing addresses properties"); if (!offLineMode) { await new MyNetmeraClient().RefreshAddressesProperties(); } } catch (Exception exc) { isError = true; Helpers.LogException(exc, "RefreshAddressesProperties"); MessageBox.Show(string.IsNullOrEmpty(exc.Message) ? "Error while refreshing data. Try again" : exc.Message); } // if (isError) { StateService.ProgressIndicatorService.Hide(); IsBusy = false; return; } SyncEngine.Sync(); } SyncEngine.InitializeTimer(); ExNavigationService.Navigate <SelectCustomersPage>(); } StateService.ProgressIndicatorService.Hide(); IsBusy = false; }
public COVID19Controller(DataLoaderService dataLoaderService) { _dataLoaderService = dataLoaderService; }
private void LoadNodesCoordsFile(string path) { _dataSource.NodesCoordsFilePath = path; _dataSource.NodesCoords = DataLoaderService.LoadNodesCoords(path); IsNodesCoordsCorrect = true; }
private void LoadDemandMatrixFile(string path) { _dataSource.DemandMatrixFilePath = path; _dataSource.DemandMatrix = DataLoaderService.LoadDirectTravelersMatrix(path); IsDemandMatrixCorrect = true; }
private void LoadArrivalsFile(string path) { _dataSource.ArrivalsFilePath = path; _dataSource.Arrivals = DataLoaderService.LoadArrivals(path); IsArrivalsCorrect = true; }
private void LoadDeparturesFile(string path) { _dataSource.DeparturesFilePath = path; _dataSource.Departures = DataLoaderService.LoadDepartures(path); IsDeparturesCorrect = true; }
private void LoadAdjacencyMatrixFile(string path) { _dataSource.AdjacencyMatrixFilePath = path; _dataSource.AdjacencyMatrix = DataLoaderService.LoadAdjacencyMatrix(path); IsAdjacencyMatrixCorrect = true; }