示例#1
0
        protected virtual void Initialize()
        {
            MyLogger.LogText(String.Format("{0} SCHEMAS FOUND", (Schemas == null) ? 0 : Schemas.Count), "ServiceBase::OnStart");

            StartTimer();
        }
示例#2
0
        public static void TreatException(Exception ex, object[] parameters)
        {
            MyLogger.LogText(ex.Message + ex.StackTrace, GetCaller(ex));

            if (ex is Npgsql.NpgsqlException)
            {
                if (ex.InnerException != null)
                {
                    TreatException(ex.InnerException);
                }
                else
                {
                    MyLogger.LogText(ex.Message, GetCaller(ex));
                    ThrowExceptionByCode(ex as Npgsql.NpgsqlException, parameters);
                }
            }
            else if (ex is NHibernate.ADOException)
            {
                //DB Exception
                if ((ex.InnerException != null) && (ex.InnerException is NHibernate.ADOException))
                {
                    TreatException(ex.InnerException);
                }
                else
                {
                    MyLogger.LogText(ex.Message, GetCaller(ex));
                    ThrowExceptionByCode(ex as NHibernate.ADOException, parameters);
                }
            }
            else if ((ex is Csla.DataPortalException) || (ex is Csla.Server.CallMethodException))
            {
                if (ex.InnerException != null)
                {
                    TreatException(ex.InnerException);
                }
                else
                {
                    MyLogger.LogText(ex.Message, GetCaller(ex));
                    throw new iQException(GetAllMessages(ex));
                }
            }
            else if (ex is System.Net.Sockets.SocketException)
            {
                MyLogger.LogText(ex.Message, GetCaller(ex));
                //Conexion Exception
                throw new iQException(Resources.Errors.SERVER_NOT_FOUND, ex.Message, iQExceptionCode.SERVER_NOT_FOUND);
            }
            else if (ex is iQAuthorizationException)
            {
                //User Authorization
                throw ex;
            }
            else if (ex is Csla.Validation.ValidationException)
            {
                //Object Validation
                throw new iQValidationException(Resources.Errors.GENERIC_VALIDATION_FAIL, (ex as Csla.Validation.ValidationException).Message);
            }
            else if (ex is iQLockException)
            {
                //Code Validation
                throw ex;
            }
            else if (ex is iQDuplicateCodeException)
            {
                //Code Validation
                throw ex;
            }
            else if (ex is iQValidationException)
            {
                //Child Validation
                if (((iQValidationException)ex).Field == string.Empty)
                {
                    throw new iQValidationException(string.Empty, (ex as iQValidationException).Message, ((iQValidationException)ex).SysMessage);
                }
                else
                {
                    throw ex;
                }
            }
            else if (ex is System.NullReferenceException)
            {
                MyLogger.LogText(ex.Message, GetCaller(ex));
                //Rules checking
                throw new iQException(Resources.Errors.RULES_CHECK + Environment.NewLine + iQExceptionHandler.GetAllMessages(ex));
            }
            else if (ex is System.Web.HttpException)
            {
                //Code Validation
                string msg = string.IsNullOrEmpty(((System.Web.HttpException)ex).GetHtmlErrorMessage())
                                                                        ? string.Empty
                                                                        : ((System.Web.HttpException)ex).GetHtmlErrorMessage();

                throw new iQException(msg,
                                      iQExceptionHandler.GetAllMessages(ex, true),
                                      iQExceptionCode.HTTP_ERROR,
                                      new object[] { ex });
            }
            else
            {
                MyLogger.LogText(ex.Message, GetCaller(ex));
                throw new iQException(GetAllMessages(ex as Exception));
            }
        }
示例#3
0
        protected Thread ExecuteTask(ICronJob cronjob, object parameter)
        {
            if (cronjob == null)
            {
                return(null);
            }

            try
            {
                switch (cronjob.CheckStatus((ISchemaInfo)parameter))
                {
                case EComponentStatus.DISABLED:
                {
                    if (LogLevel == ELogLevel.ALL)
                    {
                        MyLogger.LogText(string.Format("{0} DISABLED", cronjob.ID), "ServiceBase::ExecuteTask");
                    }
                    return(null);
                }

                case EComponentStatus.WORKING:
                {
                    if (LogLevel == ELogLevel.ALL || LogLevel == ELogLevel.WARN)
                    {
                        MyLogger.LogText(string.Format("{0} STILL BUSY", cronjob.ID), "ServiceBase::ExecuteTask");
                    }
                    return(null);
                }

                case EComponentStatus.UNAVAILABLE:
                {
                    if (LogLevel == ELogLevel.ALL)
                    {
                        MyLogger.LogText(string.Format("{0} OUT OF DATE ", cronjob.ID), "ServiceBase::ExecuteTask");
                    }
                    return(null);
                }

                case EComponentStatus.READY:
                {
                    if (LogLevel == ELogLevel.ALL || LogLevel == ELogLevel.WARN)
                    {
                        MyLogger.LogText(string.Format("{0} STARTED ", cronjob.ID), "ServiceBase::ExecuteTask");
                    }
#if DEBUG
                    cronjob.Run(parameter);
                    return(null);
#else
                    Thread taskthread = new Thread(new ParameterizedThreadStart(cronjob.Run));
                    taskthread.Start(parameter);
                    return(taskthread);
#endif
                }
                }

                return(null);
            }
            catch (Exception ex)
            {
                MyLogger.LogException(ex, "ServiceBase::ExecuteTask");
                return(null);
            }
        }