private void tlSecurityClient_GetTokenCompleted(object sender, GetTokenCompletedEventArgs e) { try { if (e.Result.ResponseState == TimelogSecurityService.ExecutionStatus.Success) { if (!String.IsNullOrEmpty(e.Result.Return[0].ToString())) { TimelogSession tlSession = TimelogSession.Instance; tlSession.SecurityToken = e.Result.Return[0]; } tlViewModel.ChangeState(ETimelogState.Successfull, ETimelogOperation.Login, String.Empty); } else if (e.Error != null) { tlViewModel.ChangeState(ETimelogState.Error, ETimelogOperation.Login, e.Error.Message); } else { tlViewModel.ChangeState(ETimelogState.Error, ETimelogOperation.Login, String.Empty); } } catch (Exception ex) { if (e.Error != null) { tlViewModel.ChangeState(ETimelogState.Error, ETimelogOperation.Login, e.Error.Message); } else { tlViewModel.ChangeState(ETimelogState.Error, ETimelogOperation.Login, ex.Message); } } }
public void GetTimelogTasks() { tlViewModel.ChangeState(ETimelogState.Running, ETimelogOperation.GetTasks, String.Empty); TimelogSession tlSession = TimelogSession.Instance; ProjectManagementServiceClient tlProjectClient = tlSession.ProjectManagementClient; tlProjectClient.GetTasksAllocatedToEmployeeCompleted += tlProjectClient_GetTasksCompleted; tlProjectClient.GetTasksAllocatedToEmployeeAsync(tlSession.ProjectManagementToken.Initials, tlSession.ProjectManagementToken); }
public void LoginTimelog(string url, string initials, string password) { tlViewModel.ChangeState(ETimelogState.Running, ETimelogOperation.Login, String.Empty); TimelogSession tlSession = TimelogSession.Instance; tlSession.SessionUrl = url; SecurityServiceClient tlSecurityClient = tlSession.SecurityClient; tlSecurityClient.GetTokenCompleted += tlSecurityClient_GetTokenCompleted; tlSecurityClient.GetTokenAsync(initials, password); }
public bool IsValidSecurityToken() { TimelogSession tlSession = TimelogSession.Instance; if (tlSession.SecurityToken != null) { if (tlSession.SecurityToken.Expires > DateTime.UtcNow) { return(true); } else { return(false); } } else { return(false); } }
public void UploadWorkunits(ObservableCollection <WorkUnit> insertUnits, ObservableCollection <WorkUnit> updateUnits) { tlViewModel.ChangeState(ETimelogState.Running, ETimelogOperation.UploadWorkunits, String.Empty); TimelogSession tlSession = TimelogSession.Instance; ProjectManagementServiceClient tlProjectClient = tlSession.ProjectManagementClient; tlProjectClient.InsertWorkCompleted += tlProjectClient_InsertWorkCompleted; tlProjectClient.UpdateWorkCompleted += tlProjectClient_UpdateWorkCompleted; if (insertUnits.Count > 0) { tlProjectClient.InsertWorkAsync(insertUnits, 0, tlSession.ProjectManagementToken); } if (updateUnits.Count > 0) { tlProjectClient.UpdateWorkAsync(updateUnits, 0, tlSession.ProjectManagementToken); } }