Example #1
0
        /// <summary>
        /// makes logout, and navigates to Login View
        /// </summary>
        public void Logout()
        {
            using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {
                try {
                    WSClient.Logout(_Token);
                    _Token       = string.Empty;
                    LoggedInUser = null;

                    Messenger.Default.Send <AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());
                    Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                        View = ViewEnum.Login
                    });
                }
                catch (FaultException <ExceptionDetail> exc) {
                    // this is OK, the session is expired, or not available
                    if (ExceptionHandler.IsSessionNotAvailableException(exc))
                    {
                        Messenger.Default.Send <AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());
                        Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                            View = ViewEnum.Login, UserState = "SessionExpired"
                        });
                    }
                    else
                    {
                        // otherwise throw the exception
                        throw;
                    }
                }
            }
        }
Example #2
0
 public void RegisterPerson(NewPerson personinst)
 {
     using (JolTudomEWSClient client = new JolTudomEWSClient()) {
         try {
             client.NewUser(_Token, personinst.UserName, personinst.Prefix, personinst.LastName, personinst.MiddleName, personinst.FirstName, personinst.Password, personinst.RoleId);
             if (_Token == null)
             {
                 Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                     View = ViewEnum.Login
                 });
             }
             else
             {
                 Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                     View = ViewEnum.Admin, UserState = "NewPerson"
                 });
             }
         }
         catch (FaultException <ExceptionDetail> exc) {
             if (ExceptionHandler.IsSessionNotAvailableException(exc))
             {
                 throw new SessionExpiredException();
             }
             else if (ExceptionHandler.IsSqlException(exc))
             {
                 throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
             }
             else
             {
                 throw;
             }
         }
     }
 }
Example #3
0
        public NewTest GetNewTest(int count, List <int> topicid)
        {
            using (JolTudomEWSClient client = new JolTudomEWSClient()) {
                try {
                    var result = client.StartTest(_Token, count, topicid);
                    App.Current.Properties["CurrentTestID"] = result.TestID;

                    return(result);
                }
                catch (FaultException <ExceptionDetail> exc) {
                    if (ExceptionHandler.IsSessionNotAvailableException(exc))
                    {
                        throw new SessionExpiredException();
                    }
                    else if (ExceptionHandler.IsSqlException(exc))
                    {
                        throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Example #4
0
        public void CheckAnswer(int personid, int testid, int questionid, int?answerid, bool iscomplete)
        {
            using (JolTudomEWSClient client = new JolTudomEWSClient()) {
                try {
                    client.CheckAnswer(_Token, personid, testid, questionid, answerid, iscomplete);
                    if (iscomplete)
                    {
                        App.Current.Properties["CurrentTestID"] = null;

                        Messenger.Default.Send <TestExecutionRunningMessage>(new TestExecutionRunningMessage {
                            IsTestRunning = false
                        });

                        Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                            View = ViewEnum.Student
                        });
                    }
                }
                catch (FaultException <ExceptionDetail> exc) {
                    if (ExceptionHandler.IsSessionNotAvailableException(exc))
                    {
                        throw new SessionExpiredException();
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Example #5
0
        public List <PersonRole> GetUsers(int?roletosearch)
        {
            using (JolTudomEWSClient client = new JolTudomEWSClient()) {
                try {
                    var userlist = client.GetUsers(_Token, roletosearch ?? null);

                    List <PersonRole> rolelist = new List <PersonRole>();
                    var ownperson = LoggedInUser;
                    ownperson.IsSelected = true;

                    rolelist.Add(new PersonRole {
                        RoleName = "Saját", IsExpanded = true, Children = new List <PersonDetails>()
                        {
                            ownperson
                        }
                    });
                    if (roletosearch == null || roletosearch == 1)
                    {
                        rolelist.Add(new PersonRole {
                            RoleName = "Diák",
                            Children = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Student).Select(p => p).ToList()
                        });
                    }

                    if (roletosearch == null)
                    {
                        var teacherlist = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Teacher).Select(p => p);
                        if (teacherlist.Count() > 0)
                        {
                            rolelist.Add(new PersonRole {
                                RoleName = "Tanár",
                                Children = teacherlist.ToList()
                            });
                        }

                        // need to exclude the Admin, because it is visible in the Sajat category
                        var adminlist = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Admin && p.PersonID != LoggedInUser.PersonID).Select(p => p);
                        if (adminlist.Count() > 0)
                        {
                            rolelist.Add(new PersonRole {
                                RoleName = "Admin",
                                Children = adminlist.ToList()
                            });
                        }
                    }

                    return(rolelist);
                }
                catch (FaultException <ExceptionDetail> exc) {
                    if (ExceptionHandler.IsSessionNotAvailableException(exc))
                    {
                        throw new SessionExpiredException();
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Example #6
0
 public List <TestDetails> GetTestDetails(int testid, int?personid)
 {
     using (JolTudomEWSClient client = new JolTudomEWSClient()) {
         try {
             return(client.GetTestDetails(_Token, testid, personid));
         }
         catch (FaultException <ExceptionDetail> exc) {
             if (ExceptionHandler.IsSessionNotAvailableException(exc))
             {
                 throw new SessionExpiredException();
             }
             else
             {
                 throw;
             }
         }
     }
 }
Example #7
0
 public List <Topics> GetTopics(int courseid)
 {
     using (JolTudomEWSClient client = new JolTudomEWSClient()) {
         try {
             return(client.GetTopics(_Token, courseid));
         }
         catch (FaultException <ExceptionDetail> exc) {
             if (ExceptionHandler.IsSessionNotAvailableException(exc))
             {
                 throw new SessionExpiredException();
             }
             else
             {
                 throw;
             }
         }
     }
 }
Example #8
0
 public IEnumerable <Statistics> GetStatistics(int?personid)
 {
     using (JolTudomEWSClient client = new JolTudomEWSClient()) {
         try {
             var result = client.GetStatistics(_Token, personid);
             return(result.OrderByDescending(s => s.Generated));
         }
         catch (FaultException <ExceptionDetail> exc) {
             if (ExceptionHandler.IsSessionNotAvailableException(exc))
             {
                 throw new SessionExpiredException();
             }
             else
             {
                 throw;
             }
         }
     }
 }
Example #9
0
    /// <summary>
    /// makes logout
    /// normally this is called from window (application) close
    /// </summary>
    public void ClearSession() {
      using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {

        try {
          if (!string.IsNullOrEmpty(_Token)) {
            WSClient.Logout(_Token);

            _Token = string.Empty;
            LoggedInUser = null;
          }
        }
        catch (FaultException<ExceptionDetail> exc) {
          // this is OK, the session is expired, or not available
          if (!ExceptionHandler.IsSessionNotAvailableException(exc)) {
            // otherwise throw the exception
            throw;
          }
        }
      }
    }
Example #10
0
    public bool Login(string username, string password, out string ErrorMess) {
      
      ErrorMess = string.Empty;

      using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {
        try {
          PersonDetails pd = new PersonDetails();
          _Token = WSClient.Login(out pd, username, password);
          LoggedInUser = pd;

          Messenger.Default.Send<AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());

          Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Student });

        }
        catch (FaultException fe) {
          ErrorMess = fe.Message;
        }
      }
      return ErrorMess == string.Empty;
    }
Example #11
0
 public void NewTopic(int courseid, string name, string description)
 {
     using (JolTudomEWSClient client = new JolTudomEWSClient()) {
         try {
             client.AddNewTopic(_Token, courseid, name, description);
         }
         catch (FaultException <ExceptionDetail> exc) {
             if (ExceptionHandler.IsSessionNotAvailableException(exc))
             {
                 throw new SessionExpiredException();
             }
             else if (ExceptionHandler.IsSqlException(exc))
             {
                 throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
             }
             else
             {
                 throw;
             }
         }
     }
 }
Example #12
0
        public bool Login(string username, string password, out string ErrorMess)
        {
            ErrorMess = string.Empty;

            using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {
                try {
                    PersonDetails pd = new PersonDetails();
                    _Token       = WSClient.Login(out pd, username, password);
                    LoggedInUser = pd;

                    Messenger.Default.Send <AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());

                    Messenger.Default.Send <NavigationMessage>(new NavigationMessage {
                        View = ViewEnum.Student
                    });
                }
                catch (FaultException fe) {
                    ErrorMess = fe.Message;
                }
            }
            return(ErrorMess == string.Empty);
        }
Example #13
0
        /// <summary>
        /// makes logout
        /// normally this is called from window (application) close
        /// </summary>
        public void ClearSession()
        {
            using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {
                try {
                    if (!string.IsNullOrEmpty(_Token))
                    {
                        WSClient.Logout(_Token);

                        _Token       = string.Empty;
                        LoggedInUser = null;
                    }
                }
                catch (FaultException <ExceptionDetail> exc) {
                    // this is OK, the session is expired, or not available
                    if (!ExceptionHandler.IsSessionNotAvailableException(exc))
                    {
                        // otherwise throw the exception
                        throw;
                    }
                }
            }
        }
Example #14
0
    /// <summary>
    /// makes logout, and navigates to Login View
    /// </summary>
    public void Logout() {
      using (JolTudomEWSClient WSClient = new JolTudomEWSClient()) {

        try {
          WSClient.Logout(_Token);
          _Token = string.Empty;
          LoggedInUser = null;

          Messenger.Default.Send<AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());
          Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Login });

        }
        catch (FaultException<ExceptionDetail> exc) {
          // this is OK, the session is expired, or not available
          if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
            Messenger.Default.Send<AfterLoginLogoutMessage>(new AfterLoginLogoutMessage());
            Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Login, UserState = "SessionExpired" });
          }
          else
            // otherwise throw the exception
            throw;
        }
      }
    }
Example #15
0
 public void NewTopic(int courseid, string name, string description) {
   using (JolTudomEWSClient client = new JolTudomEWSClient()) {
     try {
       client.AddNewTopic(_Token, courseid, name, description);
     }
     catch (FaultException<ExceptionDetail> exc) {
       if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
         throw new SessionExpiredException();
       }
       else if (ExceptionHandler.IsSqlException(exc)) {
         throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
       }
       else
         throw;
     }
   }
 }
Example #16
0
 public void RegisterPerson(NewPerson personinst) {
   using (JolTudomEWSClient client = new JolTudomEWSClient()) {
     try {
       client.NewUser(_Token, personinst.UserName, personinst.Prefix, personinst.LastName, personinst.MiddleName, personinst.FirstName, personinst.Password, personinst.RoleId);
       if (_Token == null) {
         Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Login });
       }
       else {
         Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Admin, UserState="NewPerson" });
       }
     }
     catch (FaultException<ExceptionDetail> exc) {
       if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
         throw new SessionExpiredException();
       }
       else if (ExceptionHandler.IsSqlException(exc)) {
         throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
       }
       else
         throw;
     }
   }
 }
Example #17
0
    public void CheckAnswer(int personid, int testid, int questionid, int? answerid, bool iscomplete) {
      using (JolTudomEWSClient client = new JolTudomEWSClient()) {

        try {
          client.CheckAnswer(_Token, personid, testid, questionid, answerid, iscomplete);
          if (iscomplete) {
            App.Current.Properties["CurrentTestID"] = null;

            Messenger.Default.Send<TestExecutionRunningMessage>(new TestExecutionRunningMessage { IsTestRunning = false });
            
            Messenger.Default.Send<NavigationMessage>(new NavigationMessage { View = ViewEnum.Student });
          }
        }
        catch (FaultException<ExceptionDetail> exc) {
          if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
            throw new SessionExpiredException();
          }
          else
            throw;
        }
      }
    }
Example #18
0
 public List<TestDetails> GetTestDetails(int testid, int? personid) {
   using (JolTudomEWSClient client = new JolTudomEWSClient()) {
     try {
       return client.GetTestDetails(_Token, testid, personid);
     }
     catch (FaultException<ExceptionDetail> exc) {
       if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
         throw new SessionExpiredException();
       }
       else
         throw;
     }
   }
 }
Example #19
0
    public NewTest GetNewTest(int count, List<int> topicid) {
      using (JolTudomEWSClient client = new JolTudomEWSClient()) {

        try {
          var result = client.StartTest(_Token, count, topicid);
          App.Current.Properties["CurrentTestID"] = result.TestID;

          return result;
        }
        catch (FaultException<ExceptionDetail> exc) {
          if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
            throw new SessionExpiredException();
          }
          else if (ExceptionHandler.IsSqlException(exc)) {
            throw new TranslatedException(ExceptionHandler.GetUserFriendlyErrorMessage(exc));
          }
          else
            throw;
        }
      }

    }
Example #20
0
    public List<PersonRole> GetUsers(int? roletosearch) {
      using (JolTudomEWSClient client = new JolTudomEWSClient()) {

        try {
          var userlist = client.GetUsers(_Token, roletosearch ?? null);

          List<PersonRole> rolelist = new List<PersonRole>();
          var ownperson = LoggedInUser;
          ownperson.IsSelected = true;

          rolelist.Add(new PersonRole { RoleName = "Saját", IsExpanded = true, Children = new List<PersonDetails>() { ownperson } });
          if (roletosearch == null || roletosearch == 1) {
            rolelist.Add(new PersonRole {
              RoleName = "Diák",
              Children = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Student).Select(p => p).ToList()
            });
          }

          if (roletosearch == null) {
            var teacherlist = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Teacher).Select(p => p);
            if (teacherlist.Count() > 0) {
              rolelist.Add(new PersonRole {
                RoleName = "Tanár",
                Children = teacherlist.ToList()
              });
            }

            // need to exclude the Admin, because it is visible in the Sajat category
            var adminlist = userlist.Where(p => p.RoleEnum == PersonRoleEnum.Admin && p.PersonID != LoggedInUser.PersonID).Select(p => p);
            if (adminlist.Count() > 0) {
              rolelist.Add(new PersonRole {
                RoleName = "Admin",
                Children = adminlist.ToList()
              });
            }
          }

          return rolelist;
        }
        catch (FaultException<ExceptionDetail> exc) {
          if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
            throw new SessionExpiredException();
          }
          else
            throw;
        }
      }

    }
Example #21
0
 public List<Courses> GetCourses() {
   using (JolTudomEWSClient client = new JolTudomEWSClient()) {
     try {
       return client.GetCourses(_Token);
     }
     catch (FaultException<ExceptionDetail> exc) {
       if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
         throw new SessionExpiredException();
       }
       else
         throw;
     }
   }
 }
Example #22
0
 public IEnumerable<Statistics> GetStatistics(int? personid) {
   using (JolTudomEWSClient client = new JolTudomEWSClient()) {
     try {
       var result = client.GetStatistics(_Token, personid);
       return result.OrderByDescending(s => s.Generated);
     }
     catch (FaultException<ExceptionDetail> exc) {
       if (ExceptionHandler.IsSessionNotAvailableException(exc)) {
         throw new SessionExpiredException();
       }
       else
         throw;
     }
   }
 }