private void Connect() { try { if (_serverInfo == null) { _serverInfo = _serverDal.Get(); } if (_serverInfo == null) { return; } Uri target = new Uri($"ws://{_serverInfo.UrlServer}"); IEndpoint endpoint = new URLEndpoint(target); ReplicatorConfiguration replicationConfig = new ReplicatorConfiguration(_dataBaseGetter.Get(), endpoint) { Continuous = true, ReplicatorType = ReplicatorType.PushAndPull, Authenticator = new BasicAuthenticator(_serverInfo.Login, _serverInfo.Password) }; _replicator = new Replicator(replicationConfig); if (CrossConnectivity.IsSupported && CrossConnectivity.Current.IsConnected) { _replicator.Start(); } _token = _replicator.AddChangeListener(_replicator_StatusChanged); } catch (Exception e) { #if DEBUG #endif } }
public ReplicatorGetter(IDataBaseGetter dataBaseGetter, IServerDal serverDal, ISynchroExDal synchroExDal) { _dataBaseGetter = dataBaseGetter; _synchroExDal = synchroExDal; _serverDal = serverDal; MessagingCenter.Subscribe <ConnectivityMessage>(this, "CONNECTIVITY_STATUS", OnConnectivityChanged); MessagingCenter.Subscribe <ReplicatorStatusMessage>(this, "REPLICATOR_RESTART", Restart); _serverInfo = _serverDal.Get(); }
protected void ServerGrid_OnRowUpdating(object sender, GridViewUpdateEventArgs e) { GridError.Text = string.Empty; var id = ServerGrid?.DataKeys[e.RowIndex]?.Value; if (id == null) { return; } var newName = e.NewValues["ServerName"].ToString(); var server = _serverDal.Get((int)id); if (server.ServerName == newName) { ServerGrid.EditIndex = -1; return; } server.ServerName = newName; try { _serverDal.Update(server); } catch (ValidationException ex) { GridError.Text = ex.Message; } catch (NotFoundException ex) { GridError.Text = ex.Message; } catch (Exception) { GridError.Text = "An error occured while updating the server."; } finally { ServerGrid.EditIndex = -1; RefreshGrid(); } }
private void RefreshGrid() { var serverId = int.Parse(Request.QueryString[QueryStringParameters.ServerId]); var server = _serverDal.Get(serverId); var userId = Context.User.Identity.GetUserId(); var user = _userCache.Get(userId); if (server.CompanyId != user.CompanyId) { return; } ServerName.Text = $"<h1 style=\"padding-left:10px\">{server.ServerName}</h1>"; var addedDepts = server.Departments?.ToList() ?? new List <Department>(); var notAdded = _departmentDal.GetByCompany(server.CompanyId) ?.Except(addedDepts, new DepartmentComparer(CompareSetting.CompareIds)).ToList() ?? new List <Department>(); if (!string.IsNullOrEmpty(AllSearchText.Text)) { notAdded = notAdded.Where(s => s.DepartmentName.ToLower().Contains(AllSearchText.Text.ToLower())).ToList(); } if (!string.IsNullOrEmpty(AddedSearchText.Text)) { addedDepts = addedDepts.Where(s => s.DepartmentName.ToLower().Contains(AddedSearchText.Text.ToLower())).ToList(); } AllGrid.DataSource = notAdded; AllGrid.DataBind(); AddedGrid.DataSource = addedDepts; AddedGrid.DataBind(); }