예제 #1
0
        public static UserService GetUserService()
        {
            UserService service = new UserService();

            string[] urls    = ConfigurationManager.AppSettings["UserService"].Split(',');
            string   timeout = ConfigurationManager.AppSettings["UserServiceTimeout"];
            int      time;

            if (Int32.TryParse(timeout, out time))
            {
                service.Timeout = time;
            }
            else
            {
                service.Timeout = 2000;
            }
            for (int i = 0; i < 2; i++)
            {
                foreach (string url in urls)
                {
                    try
                    {
                        service.Url = url;
                        service.IsConnected();
                        service.Timeout = 60 * 1000;
                        return(service);
                    }
                    catch { }
                }
            }
            throw new TimeoutException(Localizer.GetErrorText("UserServiceConnectFaild"));
        }
예제 #2
0
        public static AppException GetError(Exception exc)
        {
            Type type = exc.GetType();

            if (type == typeof(ValidationException))
            {
                return(new AppException(Localizer.GetErrorText((ValidationException)exc)));
            }
            if (type == typeof(AppException))
            {
                return((AppException)exc);
            }
            if (type == typeof(Comfy.Data.SqlException))
            {
                LogService.Error((Comfy.Data.SqlException)exc);
            }
            else
            {
                LogService.Fatal(exc);
            }
            return(new AppException(Localizer.GetErrorText("Error") + exc.Message, exc));
        }