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 void btnRegister_Click(object sender, EventArgs e)
        {
            log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".btnRegister_Click(): ");
            try {
                String bb_code = ddlBBoard.SelectedValue;
                //DataValueField.
                String bbRegPwd = txtBBRegPwd.Text;
                //String  proxy_folder = Request.ApplicationPath + Request.Path;
                String proxy_folder = Request.Path;
                proxy_folder = proxy_folder.ToLower().Replace("/admin/register.aspx", "");
                //remove prefixed "/"
//                if (proxy_folder.Length > 0) proxy_folder = proxy_folder.Substring(1);
                if (proxy_folder.Length != 0)
                {
                    if (proxy_folder.Substring(0, 1) != "/")
                    {
                        proxy_folder = "/" + proxy_folder;
                    }
                    if (proxy_folder.Substring(proxy_folder.Length - 1, 1) != "/")
                    {
                        proxy_folder += "/";
                    }
                }
                else
                {
                    proxy_folder = "/";
                }
                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))
//                if (!PtaUtil.GetProxyWebFolder().Equals(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.WSCall.RegisterTool(bb_code, bbRegPwd, false);
                lblRegisterResult.Text = "SUCCESS";
                if (!PtaUtil.GetProxyWebFolder().Equals(proxy_folder))
                {
                    lblRegisterResult.Text = lblRegisterResult.Text + ", but possibly bad AppSettings[\"PtaProxyWebFolder\"] = " + WebConfigurationManager.AppSettings["PtaProxyWebFolder"]
                                             + "; Calculated proxy_folder = " + proxy_folder + "; PtaUtil.GetProxyWebFolder(): " + PtaUtil.GetProxyWebFolder() + ". Check it if link redirection or BB actions will fail";
                }
                gvBBoard.DataBind();
            } catch (PtaRegisterToolException rte) {
                lblRegisterResult.Text = "ERROR: " + rte.Message;
            }
        }
/*
 *      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);
            }
        }
Пример #5
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 void btnSetPassword_Click(object sender, EventArgs e)
        {
            log4net.ILog   log     = PtaUtil.getLog4netLogger(this.GetType().FullName + ".btnSetPassword_Click(): ");
            MembershipUser oldUser = Membership.Provider.GetUser("pta_admin", false);

            if (oldUser != null)
            {
                bool res;
                res = Membership.Provider.ChangePassword("pta_admin", txtPtaOldPwd.Text, txtPtaNewPwd.Text);
                if (res)
                {
                    lblSetPassword.Text = "SUCCESS";
                }
                else
                {
                    lblSetPassword.Text = "ERROR";
                }
            }
            else
            {
                lblSetPassword.Text = "pta_admin does not exist, create it first";
            }

            /*
             * if (oldUser != null) {
             *  bool res;
             *  res = Membership.Provider.ChangePassword("pta_admin", txtPtaOldPwd.Text, txtPtaNewPwd.Text);
             *  if (res) lblSetPassword.Text = "SUCCESS";
             *  else lblSetPassword.Text = "ERROR";
             * } else {
             *  MembershipCreateStatus status;
             *  MembershipUser newUser =
             *              Membership.Provider.CreateUser("pta_admin", txtPtaNewPwd.Text, string.Empty, string.Empty, string.Empty, true, "admin", out status);
             *  if (newUser == null) {
             *      lblCreatePtaAdmin.Text = status.ToString();
             *  } else lblCreatePtaAdmin.Text = "SUCCESS";
             * }*/
        }
        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);
        }
        protected void btnCreatePtaAdmin_Click(object sender, EventArgs e)
        {
            log4net.ILog   log     = PtaUtil.getLog4netLogger(this.GetType().FullName + ".btnCreatePtaAdmin_Click(): ");
            MembershipUser oldUser = Membership.Provider.GetUser("pta_admin", false);

            if (oldUser == null)
            {
                MembershipCreateStatus status;
                MembershipUser         newUser =
                    Membership.Provider.CreateUser("pta_admin", txtPtaNewPwd.Text, string.Empty, string.Empty, string.Empty, true, "admin", out status);
                if (newUser == null)
                {
                    lblCreatePtaAdmin.Text = status.ToString();
                }
                else
                {
                    lblCreatePtaAdmin.Text = "SUCCESS";
                }
            }
            else
            {
                lblCreatePtaAdmin.Text = "pta_admin user already exists, it may be deleted by manual editing of pta_proxy\\App_Data\\users.xml and restarting of application.";
            }
        }
Пример #9
0
 protected override void Action()
 {
     log4net.ILog log = PtaUtil.getLog4netLogger(this.GetType().FullName + ".ActionInternal(): ");
     base.Action();
     Response.Output.Write(PtaServerConstants.SIMPLE_SUCCESS_RESPONSE);
 }