protected void Page_Load(object sender, EventArgs e)
 {
     log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".Page_Load(): ");
     if (!"Save".Equals(Request.Form["btnSave"]))
     {
         try {
             log.Debug("Request.ContentEncoding.EncodingName: " + Request.ContentEncoding.EncodingName);
             log.Debug("Response.ContentEncoding.EncodingName: " + Response.ContentEncoding.EncodingName);
             Request.ContentEncoding  = System.Text.Encoding.UTF8;
             Response.ContentEncoding = System.Text.Encoding.UTF8;
             hfGuid.Value             = Request[PtaServerConstants.OURGUID_KEY];
             bboardDR = PtaUtil.GetBBoardDataReaderByGuid(hfGuid.Value);
             RequestValidator rv = new RequestValidator(bboardDR);
             rv.Validate(Request);
             if (!"_1_1".Equals(Request[PtaServerConstants.USERID_KEY]))
             {
                 throw new PtaException("Access is allowed only for Blackboard Administrator (userid = \"_1_1\"). Current user_id: " + Request[PtaServerConstants.USERID_KEY]);
             }
             hlBackToBB.NavigateUrl = Request.Form["tcbaseurl"] + Request.Form["returnurl"];
             lblSaveXMLResult.Text  = "";
             //throw new PtaException("test how error will be processed on remote config");
             String bb_code = PtaUtil.GetDBReaderStringField(bboardDR, "BBoardCode");
             txtXML.Text = PtaUtil.GetBBMenuLinkParamXML(bb_code);
         } catch (Exception exc) {
             PtaUtil.LogExceptionAndFormParameters(log, exc);
             String err_page = PtaUtil.GenerateSimpleErrorPage(hlBackToBB.NavigateUrl);
             Response.Write(err_page);
             Response.End();
         } finally {
             PtaUtil.CloseDataReader(bboardDR);
         }
     }
 }
        protected override void Action()
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".ActionInternal(): ");
            base.Action();
            System.String bb_code = PtaUtil.GetDBReaderStringField(bboardDR, "BBoardCode");
            String        sql     = "UPDATE BBoard SET IsRegistered = 'N', ProxyState=NULL, SharedSecret=NULL, GUID=NULL WHERE BBoardCode = @BBoardCode";

            log.Info("sql: " + sql);
            SqlParameter[] update_bb_params = new SqlParameter[] {
                new SqlParameter("@BBoardCode", bb_code)
            };
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(PtaUtil.GetSqlConnection(),
                                                                       System.Data.CommandType.Text, sql, update_bb_params);
            Response.Output.Write(PtaServerConstants.SIMPLE_SUCCESS_RESPONSE);
        }
/*
 *      protected override void Action() {
 *          log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".Action(): ");
 *          try {
 *              if (!"Save".Equals(Request.Form["btnSave"])) {
 *                  backLink = Request.Form["tcbaseurl"] + Request.Form["returnurl"];
 *                  lblSaveXMLResult.Text = "";
 *                  hlBackToBB.NavigateUrl = backLink;
 *                  base.Action();
 *                  //throw new PtaException("test how error will be processed on remote config");
 *                  String bb_url = PtaUtil.GetDBReaderStringField(bboardDR, "BBoardURL");
 *                  txtXML.Text = PtaUtil.GetBBMenuLinkParamXML(bb_url);
 *              }
 *          } catch (Exception exc) {
 *              PtaUtil.LogExceptionAndFormParameters(log, exc);
 *              String err_page = PtaUtil.GenerateSimpleErrorPage(backLink);
 *              Response.Write(err_page);
 *              Response.End();
 *          }
 *      }
 */
        protected void btnSave_Click(object sender, EventArgs e)
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".btnSave_Click(): ");
            try {
                bboardDR = PtaUtil.GetBBoardDataReaderByGuid(hfGuid.Value);
                PtaUtil.SetBBMenuLinkParamXML(PtaUtil.GetDBReaderStringField(bboardDR, "BBoardCode"), txtXML.Text);
                lblSaveXMLResult.Text = "SUCCESS";
            } catch (Exception exc) {
                PtaUtil.LogExceptionAndFormParameters(log, exc);
                String err_page = PtaUtil.GenerateSimpleErrorPage(hlBackToBB.NavigateUrl);
                //this may not be super secure, but assuming that Blackboard Administrator
                //is checked person and he may really need exception details upon save error
                err_page += PtaUtil.GetExceptionAndEnvHtml(exc);
                Response.Write(err_page);
                Response.End();
            } finally {
                PtaUtil.CloseDataReader(bboardDR);
            }
        }
Esempio n. 4
0
        protected override void Action()
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".ActionInternal(): ");
            base.Action();

            System.String proxy_state = Request[PtaServerConstants.STATE_KEY];
            System.String bb_code     = PtaUtil.GetDBReaderStringField(bboardDR, "BBoardCode");
            String        sql         = "UPDATE BBoard SET ProxyState = @ProxyState WHERE BBoardCode = @BBoardCode";

            log.Info("sql: " + sql);
            SqlParameter[] update_bb_params = new SqlParameter[] {
                new SqlParameter("@ProxyState", proxy_state),
//                     new SqlParameter("@IsRegistered", is_reg) ,
                new SqlParameter("@BBoardCode", bb_code)
            };
            log.Info("proxy_state: " + proxy_state);
            log.Info("bb_code: " + bb_code);
            Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteNonQuery(PtaUtil.GetSqlConnection(),
                                                                       System.Data.CommandType.Text, sql, update_bb_params);
            Response.Output.Write(PtaServerConstants.SIMPLE_SUCCESS_RESPONSE);
        }
        protected override void Action()
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".ActionInternal(): ");
            base.Action();
            String bb_code  = PtaUtil.GetDBReaderStringField(bboardDR, "BBoardCode");
            String bbRegPwd = Request.Form[PtaServerConstants.REGISTRATION_PASSWORD_KEY];

            String proxy_folder = Request.Path;

            log.Debug("proxy_folder before Replace(): " + proxy_folder);
            proxy_folder = proxy_folder.ToLower().Replace("/actions/reregister.aspx", "");
            //remove prefixed "/"
            proxy_folder = proxy_folder.Substring(1);
            log.Debug("Request.ApplicationPath: " + Request.ApplicationPath + "; Request.Path: " + Request.Path + "; proxy_folder: " + proxy_folder);
            //if (proxy_folder.Length != 0) proxy_folder = proxy_folder.Substring(1);
            if (!PtaUtil.GetProxyWebFolder().Contains(proxy_folder))
            {
                throw new Idla.PtaProxy.PtaException("Possibly bad AppSettings[\"PtaProxyWebFolder\"] = " + WebConfigurationManager.AppSettings["PtaProxyWebFolder"]
                                                     + "; Calculated proxy_folder = " + proxy_folder + "; PtaUtil.GetProxyWebFolder(): " + PtaUtil.GetProxyWebFolder());
            }
            Idla.PtaProxy.RegisterToolWSCall.RegisterTool(bb_code, bbRegPwd, true);
            Response.Output.Write(PtaServerConstants.SIMPLE_SUCCESS_RESPONSE);
        }