private void LoadLastWeeksRegistrationsFromServer() { LoadInProgress = true; // Fetch recent registrations on the server tlp.ProjectManagementServiceClient _prjClient = new tlp.ProjectManagementServiceClient(); _prjClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(_prjClient.Endpoint.Address.ToString().Replace("app.timelog.dk/local", App.IdentityViewModel.HostAddr)); DateTime _startdate = DateTime.Now.AddDays(-7).Date; DateTime _endDate = DateTime.Now.AddDays(1).Date; _prjClient.GetEmployeeWorkCompleted += new EventHandler<GetEmployeeWorkCompletedEventArgs>(_prjClient_GetEmployeeWorkCompleted); _prjClient.GetEmployeeWorkAsync(new tlp.GetEmployeeWorkRequest(App.IdentityViewModel.User, _startdate, _endDate, App.IdentityViewModel.ProjectToken)); LoadInProgress = false; }
void _secClient_GetTokenCompleted(object sender, GetTokenCompletedEventArgs e) { try { tlpSecurity.SecurityToken _token = e.Result.GetTokenResult.Return.FirstOrDefault(); if (_token == null) { throw new Exception("Unable to connect to the service: " + e.Result.GetTokenResult.Messages[0].Message); } tlp.SecurityToken _prjToken = new tlp.SecurityToken() { Expires = _token.Expires, Hash = _token.Hash, Initials = _token.Initials }; App.IdentityViewModel.ProjectToken = _prjToken; // Fetch all task from the server tlp.ProjectManagementServiceClient _prjClient = new tlp.ProjectManagementServiceClient(); _prjClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(_prjClient.Endpoint.Address.ToString().Replace("app.timelog.dk/local", App.IdentityViewModel.HostAddr)); _prjClient.GetTasksAllocatedToEmployeeCompleted += new EventHandler<tlp.GetTasksAllocatedToEmployeeCompletedEventArgs>(_prjClient_GetTasksAllocatedToEmployeeCompleted); _prjClient.GetTasksAllocatedToEmployeeAsync(new tlp.GetTasksAllocatedToEmployeeRequest(App.IdentityViewModel.User, _prjToken)); } catch (Exception ex) { ConnectionStatus = "Unable to connect: " + Environment.NewLine + ex.Message; } }