Ejemplo n.º 1
0
 public static void HandleError(ErrorEventHandler errorHandler, iQException ex)
 {
     if (errorHandler != null)
     {
         errorHandler(null, new ErrorEventArgs(ex));
     }
     else
     {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        public static iQException ConvertToiQException(Exception ex, iQExceptionCode exCode)
        {
            if (ex is iQException)
            {
                return((iQException)ex);
            }
            if (ex == null)
            {
                return(new iQException(string.Empty, exCode));
            }

            iQException iQ_ex = GetiQException(ex);

            if (iQ_ex != null)
            {
                return(iQ_ex);
            }

            iQ_ex            = new iQException(ex.Message);
            iQ_ex.Code       = exCode;
            iQ_ex.SysMessage = GetAllMessages(ex);

            return(iQ_ex);
        }
Ejemplo n.º 3
0
 protected static void HandleError(iQException ex)
 {
     iQExceptionHandler.HandleError(ErrorHandler, ex);
 }
Ejemplo n.º 4
0
 public ErrorEventArgs(iQException exception)
 {
     this.Exception = exception;
 }
Ejemplo n.º 5
0
        public static bool Login(string username, string password, string server)
        {
            List <string> servers = new List <string>();

            if (server != string.Empty)
            {
                servers.Add(server);
            }
            //servers.Add(GetActiveServer());
            if (SettingsMng.Instance.GetLANServer() != string.Empty)
            {
                servers.Add(SettingsMng.Instance.GetLANServer());
            }
            if (SettingsMng.Instance.GetWANServer() != string.Empty)
            {
                servers.Add(SettingsMng.Instance.GetWANServer());
            }
            servers.Add(nHManager.Instance.Host);

            for (int i = 1; i <= servers.Count; i++)
            {
                try
                {
                    nHManager.Instance.SetCredentials(User.MapToDBUsername(username), password, string.Empty, servers[i - 1]);

                    if (DoLogin(username, password))
                    {
                        SettingsMng.Instance.SetDBUser(username);
                        SettingsMng.Instance.SetDBPassword(password);

                        return(true);
                    }
                    else
                    {
                        ClearCredentials(username);
                    }

                    return(false);
                }
                catch (Exception ex)
                {
                    iQException iQex = iQExceptionHandler.ConvertToiQException(ex);

                    switch (iQex.Code)
                    {
                    case iQExceptionCode.SERVER_NOT_FOUND:
                        if (i == servers.Count)
                        {
                            throw iQex;
                        }
                        break;

                    case iQExceptionCode.DB_VERSION_MISSMATCH:
                        throw iQex;

                    case iQExceptionCode.PASSWORD_FAILED:
                        throw new iQAuthorizationException(moleQule.Library.Resources.Errors.LOGIN_FAILED,
                                                           iQex.SysMessage,
                                                           iQex.Code);

                    case iQExceptionCode.LOCKED_USER:
                        throw new iQAuthorizationException(string.Format(moleQule.Library.Resources.Errors.USER_LOCKED, username),
                                                           iQex.SysMessage,
                                                           iQex.Code);

                    case iQExceptionCode.LOCKED_ROW:
                        throw new iQLockException(string.Format(moleQule.Library.Resources.Errors.USER_LOGGED, username));

                    default:
                        throw iQex;
                    }
                }
            }

            return(false);
        }