示例#1
0
        public SiteMembership()
        {
            String logMethodName = ".ctor()";

            _log.Info(logMethodName + " - Creating new static SiteMembership Instance");
            _log.Debug(logMethodName + " - Begin Constructor");

            try
            {
                _log.Debug(logMethodName + " - Retrieving IntegrationLoader.CurrentSecurityAdapter");
                _adapter = IntegrationLoader.CurrentSecurityAdapter;
            }
            catch (Exception ex)
            {
                String message = logMethodName + " - Unable to load security adapter, context init failure";
                _log.Fatal(message, ex);

                throw new WtfException(message, ex);
            }

            try
            {
                _log.Debug(logMethodName + " - Retrieving IntegrationLoader.CurrentContextDataProvider");
                _provider = IntegrationLoader.CurrentContextDataProvider;
            }
            catch (Exception ex)
            {
                String message = logMethodName + "Unable to load context data provider, context init failure";
                _log.Fatal(message, ex);

                throw new WtfException(message, ex);
            }

            _log.Debug(logMethodName + " - End Constructor");
        }
示例#2
0
        public static bool SendEmail(MailMessage message)
        {
            bool emailSent = false;

            String logMethodName = ".SendEmail(AskMeRequestModel requestModel) - ";

            _log.Debug(logMethodName + string.Format("Sending email to {0}, SMTPServer ={1}:{2}, subject={3}", message.To, Config.SMTPServer, Config.SMTPServerPort, message.Subject));

            try
            {
                using (System.Net.Mail.SmtpClient client = new SmtpClient(Config.SMTPServer, Config.SMTPServerPort))
                {
                    _log.Info("About to send Email to " + message.To);
                    client.Send(message);
                    emailSent = true;
                    _log.Info("Email sent to " + message.To);
                }
            }
            catch (Exception ex)
            {
                _log.Error(String.Format("Error sending email: {0}\n\n{1}", ex.InnerException));
            }

            return(emailSent);
        }
示例#3
0
        private void getNewAuthToken()
        {
            netForumXMLSoapClient xWebClient = null;
            string strAuthResult;
            String logMethodName = ".getNewAuthToken() - ";

            _log.Debug(logMethodName + "Begin Method");

            try
            {
                _log.Debug(logMethodName + "Creating xWebClient.");
                xWebClient = new netForumXMLSoapClient();

                _log.Debug(logMethodName + "successfully created xWebClient.");

                _log.Debug(logMethodName + "Authiencticating Client");
                _authToken = xWebClient.Authenticate(Config.XWebLogin, Config.XWebPassword, out strAuthResult);
                _log.Info(logMethodName + "The current xWeb AuthToken being used by this application is: " + _authToken.Token);
            }
            catch (TimeoutException te)
            {
                _log.Error(logMethodName + "TimeoutException on xWeb service call.  make sure endpoint is reachable and configured correctly.", te);
                if (!retryAuth(xWebClient))
                {
                    ProxyHelper.HandleServiceException(xWebClient);
                    throw te;
                }
            }
            ////we do not want to retry these. These are errors that will not be fixed by a retry, i.e. invalid credentials
            //catch (FaultException fe)
            //{
            //    _log.Error(logMethodName + "There has been an error for an xWeb Auth operation: ", fe);
            //    throw fe;
            //}
            catch (CommunicationException ce)
            {
                _log.Error(logMethodName + "CommunicationException on xWeb service call.  make sure endpoint is reachable and configured correctly... this may be due to Token expiration", ce);
                if (!retryAuth(xWebClient))
                {
                    ProxyHelper.HandleServiceException(xWebClient);
                    throw ce;
                }
            }
            finally
            {
                if (xWebClient.State != CommunicationState.Closed)
                {
                    ProxyHelper.CloseChannel(xWebClient);
                }
            }
            _log.Debug(logMethodName + "End Method");
        }
示例#4
0
        internal static void RegisterApplication(AsaMvcApplication application)
        {
            String logMethodName = ".RegisterApplication(AsaMvcApplication application) - ";

            _log.Debug(logMethodName + "Begin Method");

            //Wire into key application events to control preloading/testing/diagnostics/cleanup/etc
            application.AfterApplicationStart += (o, e) => { _log.Info(logMethodName + "====== ASA Web Application Component Startup ======"); };
            application.AfterApplicationEnd   += (o, e) => { _log.Info(logMethodName + "====== ASA Web Application Component Shut Down ======"); };

            application.AfterSessionStart += (o, e) => { _log.Info(logMethodName + "======= Starting Session " + HttpContext.Current.Session.SessionID.ToString() + " ========"); };
            application.AfterSessionEnd   += (o, e) => { _log.Info(logMethodName + "======= Ending Session ========"); };

            //Order here represents the oreder in which these events fire during request processing
            application.AfterRequestStart            += new EventHandler(ASAContextLoader.HttpRequestStart);
            application.AfterApplicationRequestStart += new EventHandler(ASAContextLoader.ApplicationRequestStart);
            application.AfterApplicationRequestEnd   += new EventHandler(ASAContextLoader.ApplicationRequestComplete);
            application.AfterRequestEnd += new EventHandler(ASAContextLoader.HttpRequestComplete);

            //application.BeginRequest += new EventHandler(ASAContextLoader.HttpRequestStart);
            //application.MapRequestHandler += new EventHandler(ASAContextLoader.ApplicationRequestStart);
            //application.PostRequestHandlerExecute += new EventHandler(ASAContextLoader.ApplicationRequestComplete);
            //application.EndRequest += new EventHandler(ASAContextLoader.HttpRequestComplete);

            _log.Debug(logMethodName + "End Method");
        }
示例#5
0
        public QASearchResult ValidateAddress(QASearch search)
        {
            _log.Info("InvokeQasService.ValidateAddress() starting ...");
            QAPortTypeClient client = null;
            QASearchResult   result = null;

            try
            {
                client = new QAPortTypeClient();
                _log.Info("InvokeQasService.ValidateAddress() client created ...");
                int retryCount = 0;
                result = client.DoSearch(search);
                if (result == null && retryCount == 0)
                {
                    // retry once
                    result = client.DoSearch(search);
                    retryCount++;
                }
                _log.Info("InvokeQasService.ValidateAddress() result was returned from service ...");
            }
            catch (TimeoutException timeout)
            {
                _log.Error("InvokeQasService.ValidateAddress() Timeout Exception:" + timeout.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (CommunicationException comm)
            {
                _log.Error("InvokeQasService.ValidateAddress() Communication Exception:" + comm.Message);
                ProxyHelper.HandleServiceException(client);
            }
            catch (Exception e)
            {
                _log.Error("InvokeQasService.ValidateAddress() Exception:" + e.Message);
            }
            finally
            {
                if (client != null && client.State != CommunicationState.Closed)
                {
                    ProxyHelper.CloseChannel(client);
                }
            }

            _log.Info("InvokeQasService.ValidateAddress() ending ...");
            return(result);
        }
示例#6
0
        protected override void OnException(ExceptionContext filterContext)
        {
            _log.Info("AsaController.OnException START");
            base.OnException(filterContext);

            WriteErrorToLog(filterContext);

            // Output a nice error page
            if (filterContext != null && filterContext.HttpContext != null && filterContext.HttpContext.IsCustomErrorEnabled)
            {
                filterContext.ExceptionHandled = true;
                HandleErrorInfo errorInfo = new HandleErrorInfo(
                    GetException(filterContext),
                    GetErrorRouteValue(filterContext, "controller"),
                    GetErrorRouteValue(filterContext, "action"));

                ////this.View("Error", errorInfo).ExecuteResult(this.ControllerContext);
            }
            _log.Info("AsaController.OnException END");
        }
示例#7
0
 public static void CloseChannel <T>(T client) where T : ICommunicationObject
 {
     _log.Debug("CloseChannel<T> start");
     try
     {
         client.Close();
     }
     catch (TimeoutException timeout)
     {
         _log.Info("Caught a timeout exception", timeout);
         if (client != null)
         {
             _log.Debug("client.Abort");
             client.Abort();
         }
     }
     catch (Exception e)
     {
         _log.Info("Caught an exception that wasn't a Timeout", e);
     }
     _log.Debug("CloseChannel<T> end");
 }
示例#8
0
 public Search()
 {
     _log.Info("ASA.Web.Services.SearchService.Search() object being created ...");
     if (ASA.Web.Services.Common.Config.Testing)
     {
         _memberAdapter = null;
         _searchAdapter = new MockSearchAdapter();
     }
     else
     {
         _memberAdapter = new AsaMemberAdapter();
         _searchAdapter = new SearchAdapter();
     }
 }
示例#9
0
        /// <summary>
        /// Class Constructor - Best pratice is not to override or use this.
        /// Keep in mind if you do that this is called with every request and your
        /// context at this state is uncertian without doing pre-checking of multiple values
        /// </summary>
        public AsaMvcApplication()
        {
            String logMethodName = ".ctor() - ";

            BeginRequest              += (o, e) => { OnAfterRequestStart(e); };
            EndRequest                += (o, e) => { OnAfterRequestEnd(e); };
            MapRequestHandler         += (o, e) => { OnAfterApplicationRequestStart(e); };
            PostRequestHandlerExecute += (o, e) => { OnAfterApplicationRequestEnd(e); };

            CurrentAppState = ApplicationState.NotStarted;

            if (!_loggingStarted)
            {
                //We load logging first and foremost so we can start tracking the
                //application load process as early as possible. Further this way
                //if logging load fails we can simply ingore it and move on
                //while a failure in filters or routes will cause the application startup to
                //abort.
                try
                {
                    log4net.Config.XmlConfigurator.Configure();
                    _log.Info(logMethodName + "ASA MVC Web Application Logger Started - APPLICATION LOGGING START");
                }
                catch (Exception ex)
                {
                    //There is nothing we can do here, there is no way to log this failue
                    //and we don't want to abort the application just because logging won't load
                    _log.Info(logMethodName + "Exception caught. Message: " + ex.Message);
                }

                _loggingStarted = true;
            }


            //NOTE: Logging statements from this method will not show up on initial load.
            //post application launch they will behave normally

            _log.Debug(logMethodName + "Begin Method");

            if (_configuration == null)
            {
                try
                {
                    _log.Debug(logMethodName + "Getting ASAIntegration Config");
                    _configuration = (ASAIntegration)ConfigurationManager.GetSection("asaIntegration");
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + "Unable to load integration configuration", ex);
                    throw new MVCIntegrationException("Unable to load integration configuration", ex);
                }
            }
            //ASAContextLoader handles lower level lifecycle concerns
            //like preloading integration/content, and providing application
            //level context for integration interactions.
            //This call give the context loader an easy way to hook into the application lifecycle
            //at the earliest possible point.
            ASAContextLoader.RegisterApplication(this);
            _log.Debug(logMethodName + "End Method");
        }
示例#10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Survey"/> class.
 /// </summary>
 public Survey()
 {
     _log.Info("ASA.Web.Services.SurveyService.Survey() object being created ...");
     _surveyAdapter = new SurveyAdapter();
 }
示例#11
0
        /// <summary>
        /// This method will be called just before the main application code begins to load.
        /// </summary>
        /// <param name="sender">AsaMvcApplication</param>
        /// <param name="e">EventArgs</param>
        /// This is the reccomended way to hook into keey application events. It is not reccomened
        /// or desirable to override key application lifecycle event methods unless completly neccassary
        /// it is very easy to break the lifecycle or introduce stability/security flaws when overriding
        /// lifecycle events.
        /// This method serves as an example and an easy way for the SALT application to have a friendly
        /// log header.
        private void PreApplicationStart(Object sender, EventArgs e)
        {
            String logMethodName = ".PreApplicationStart(Object sender, EventArgs e) - ";

            _log.Debug(logMethodName + "Begin Method");

            _log.Info("=====================================================================");
            _log.Info("====== American Student Assistance - SALT Web Application v1.0 ======");
            _log.Info("=====================================================================");
            _log.Info("~~ Designed and developed  by ASA's ISD Web Devlopment Team ~~");
            _log.Info("-----========= SALT Web Application STARTING =======-----");

            AfterApplicationEnd += new EventHandler(PostApplicationStart);
            _log.Debug(logMethodName + "End Method");
        }