Exemple #1
0
//        static public void PerformAction(ActionPage a_page) {
        //this way it may get overriden in Actions.Config, but still does not look like comfortable enough design
        public virtual void PerformAction(ActionPage a_page)
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(typeof(ActionPage).FullName + ".PerformAction(): ");
            try {
                a_page.Action();
            } catch (System.Threading.ThreadAbortException) {
                //this is normal processing of Server.Transfer() and Response.End()
                throw;
            } catch (Exception e) {
                PtaUtil.LogExceptionAndFormParameters(log, e);
                HttpContext.Current.Response.Output.Write(PtaServerConstants.SIMPLE_ERROR_RESPONSE);
            } finally {
                PtaUtil.CloseDataReader(a_page.bboardDR);
            }
        }
 /*
  * Just some code that may be useful in the future
  * //Microsoft.Web.Services3.WebServicesClientProtocol
  * //http://msdn.microsoft.com/en-us/library/microsoft.web.services3.webservicesclientprotocol.aspx
  * //Thread Safety
  * //Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
  * //caching of established/initialized/authenticated webservices does not seem important task by this time
  * static Hashtable webservices = new Hashtable();
  * static ContextWS GetContextWS(String bbHostURL) {
  *  String ws_key = bbHostURL + "/" + typeof(ContextWS).FullName;
  *  ContextWS ctx;
  *  lock (webservices) {
  *      ctx = (ContextWS)webservices[ws_key];
  *      if (ctx == null) {
  *              ctx = new  ContextWS();
  *              webservices.Add(ws_key, ctx);
  *      }
  *  }
  *  return ctx;
  * }
  */
 /// <summary>
 /// Conditionally initializes connection to Blackboard
 /// (this is not of some practical use by this moment as long as there are no series of calls to Blackboard - just register() one)
 /// and performs centrilized exception handling and resources cleanup for calls of Blackboard webservices by PtaProxy.
 /// Caught exceptions are logged and re-thrown.
 /// </summary>
 static public void DoCall(WSCall ws_call)
 {
     log4net.ILog log = PtaUtil.getLog4netLogger(typeof(WSCall).FullName + ".DoCall(): ");
     //try {
     try {
         if (ws_call.NeedsInitialize() && !ws_call.wsWrapper.IsInitialized())
         {
             ws_call.wsWrapper.initialize();
         }
         ws_call.Call();
     } catch (Exception e) {
         PtaUtil.LogExceptionAndFormParameters(log, e);
         throw;
     } finally {
         PtaUtil.CloseDataReader(ws_call.wsWrapper.GetBBoardDR());
     }
 }
        /// <summary>
        /// Standard entry point of IHttpHandler, main processing flow.
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".ProcessRequest(): ");
            try {
                this.context = context;
                String guid = context.Request.Form["ourguid"];
                bboardDR = PtaUtil.GetBBoardDataReaderByGuid(guid);
                onErrorServerTransfer = PtaUtil.GetDBReaderStringField(bboardDR, "OnErrorServerTransfer");
                RequestValidator rv = new RequestValidator(bboardDR);
                rv.Validate(context.Request);
                Redirect();
            } catch (System.Threading.ThreadAbortException) {
                //this is normal processing of Server.Transfer() and Response.End()
                throw;
            } catch (Exception e) {
                PtaUtil.LogExceptionAndFormParameters(log, e);
                //String on_err_st = onErrorServerTransfer;
                //if (on_err_st == null) on_err_st = PtaUtil.GetProxyWebFolder() + "ErrorPages/PtaDefaultErrPage.aspx";
                //context.Server.Transfer(on_err_st, true);
                String back_link = context.Request.Form["tcbaseurl"] + context.Request.Form["returnurl"];
                String err_page  = PtaUtil.GenerateSimpleErrorPage(back_link);
                context.Response.Write(err_page);
                log.Debug("onErrorServerTransfer: " + onErrorServerTransfer);
                if (onErrorServerTransfer != null)
                {
                    context.Server.Transfer(onErrorServerTransfer, true);
                }

                /*                else {
                 *                  back_link = context.Request.Form["tcbaseurl"] + context.Request.Form["returnurl"];
                 *                  context.Response.Write("Your request could not be processed. <br/>");
                 *                  context.Response.Write("Back to Blackboard: " + "<a href=\"" + back_link + "\">" + back_link + "</a><br/>");
                 *              }*/

                //throw;
            } finally {
                PtaUtil.CloseDataReader(drParam);
                PtaUtil.CloseDataReader(drMenuLink);
                PtaUtil.CloseDataReader(bboardDR);
            }
        }