Ejemplo n.º 1
0
        public void PerformRedirect_BeginRequest(object sender, System.EventArgs args)
        {
            // see if current URL matches any redirects
            System.Web.HttpApplication application = (System.Web.HttpApplication)sender;
            string url = application.Request.Path;                                        //get the url path -- want to grab the "/folder" from the URL and compare this to

            char last = url[url.Length - 1];                                              // make sure ends is "/"

            if (Convert.ToString(last) != "/")
            {
                url += "/";
            }

            qPtl_Redirect redirect = new qPtl_Redirect(url);

            if (redirect.RedirectID > 0)
            {
                if (!String.IsNullOrEmpty(redirect.RedirectURL))
                {
                    // add log
                    int    curr_user_id     = 0;
                    string email            = application.Context.Request.QueryString["email"];
                    string campaign         = application.Context.Request.QueryString["campaign"];
                    int    curr_campaign_id = 0;

                    // try and find a user with this email address
                    if (!String.IsNullOrEmpty(email))
                    {
                        qPtl_User user = new qPtl_User(email);

                        if (user.UserID > 0)
                        {
                            curr_user_id = user.UserID;
                        }
                    }

                    qPtl_LogAction logAction = new qPtl_LogAction("View");
                    qPtl_Log       log       = new qPtl_Log();
                    log.ActorID        = curr_user_id;
                    log.Created        = DateTime.Now;
                    log.CreatedBy      = curr_user_id;
                    log.LastModified   = DateTime.Now;
                    log.LastModifiedBy = curr_user_id;
                    log.ScopeID        = 1;
                    log.LogActionID    = logAction.LogActionID;
                    log.CampaignID     = curr_campaign_id;
                    log.ReferenceID    = redirect.RedirectID;
                    log.ReferenceData  = "Email=" + email + ", Entry URL=" + redirect.EntryURL + ", RedirectURL=" + redirect.RedirectURL + ", CampaignID=" + campaign;
                    log.IPAddress      = LogUtilities.GetIPAddress();
                    log.Insert();

                    // redirect to URL
                    (sender as HttpApplication).Response.Redirect(redirect.RedirectURL, true);
                }
            }
        }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        redirect_id = Convert.ToInt32(Request.QueryString["redirectID"]);
        qPtl_Redirect redirect = new qPtl_Redirect(redirect_id);
        redirect.DeleteRedirect(redirect.RedirectID);

        if (Request.QueryString["edit-mode"] == "in-place")
            Response.Redirect(Request.QueryString["returnURL"]);
        else
            Response.Redirect("redirects-list.aspx");
    }
    protected void btnSave_OnClick(object sender, System.EventArgs e)
    {
        Page.Validate("form");

        if (Page.IsValid)
        {

            int user_id = Convert.ToInt32(Context.Items["UserID"]);

            if (!String.IsNullOrEmpty(Request.QueryString["redirectID"]))
            {
                redirect_id = Convert.ToInt32(Request.QueryString["redirectID"]);
                qPtl_Redirect redirect = new qPtl_Redirect(redirect_id);
                redirect.EntryURL = "/" + txtWatchFor.Text + "/";
                redirect.RedirectURL = txtURL.Text;
                redirect.Available = rblAvailable.SelectedValue;
                redirect.Update();
            }
            else
            {
                qPtl_Redirect redirect = new qPtl_Redirect();
                redirect.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]);
                redirect.Created = DateTime.Now;
                redirect.CreatedBy = user_id;
                redirect.LastModified = DateTime.Now;
                redirect.LastModifiedBy = user_id;
                redirect.MarkAsDelete = 0;
                redirect.Available = rblAvailable.SelectedValue;
                redirect.EntryURL = "/" + txtWatchFor.Text + "/";
                redirect.RedirectURL = txtURL.Text;
                redirect.Insert();

                redirect_id = redirect.RedirectID;
            }

            if (!String.IsNullOrEmpty(Request.QueryString["redirectID"]))
            {
                lblMessage.Text = "*** Record Successfully Updated ***";
                lblMessageBottom.Text = "*** Record Successfully Updated ***";
                if (Request.QueryString["edit-mode"] == "in-place")
                    Response.Redirect(Request.QueryString["returnURL"]);
                else
                    Response.Redirect("redirects-list.aspx");
            }
            else
            {
                Response.Redirect(Request.Url.ToString() + "?mode=add-successful&redirectID=" + redirect_id);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            // configure library
            string[] library_path = new string[] { "~/resources/campaigns/" + campaign_id + "/" };
            fxpCampaignLibrary.Configuration.ViewPaths = library_path;
            fxpCampaignLibrary.Configuration.MaxUploadFileSize = 256000000;
            fxpCampaignLibrary.Configuration.UploadPaths = library_path;
            fxpCampaignLibrary.Configuration.DeletePaths = library_path;

            hplBackTop.NavigateUrl = "campaigns-list.aspx";
            hplBackBottom.NavigateUrl = "campaigns-list.aspx";

            hplRefreshBottom.NavigateUrl = Request.Url.ToString();
            //hplRefreshTop.NavigateUrl = Request.Url.ToString();

            if (!String.IsNullOrEmpty(Request.QueryString["campaignID"]))
            {
                campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]);
                qSoc_Campaign campaign = new qSoc_Campaign(campaign_id);
                txtCampaignName.Text = campaign.CampaignName;
                txtCampaignDescription.Text = campaign.Description;
                lblPostedTime.Text = Convert.ToString(campaign.Created);
                lblTitle.Text = "Edit Campaign (ID: " + campaign.CampaignID + ")";
                rblAvailableNew.Text = campaign.Available;
                lblNumberUserActivities.Text = Convert.ToString(campaign.NumUserActivities);
                lblTotalDays.Text = Convert.ToString(campaign.TotalDays);
                txtCode.Text = campaign.Code;
                txtKeyword.Text = campaign.Keyword;

                lblQuickLauchURL.Text = "<i>not created yet</i>";
                if (!String.IsNullOrEmpty(campaign.Code))
                {
                    qPtl_Redirect redirect = new qPtl_Redirect("/" + campaign.Code + "/");
                    if (redirect != null)
                    {
                        if (redirect.RedirectID > 0)
                        {
                            lblQuickLauchURL.Text = base_path + campaign.Code;
                            btnCreateCampaignRedirect.Text = "Delete URL";
                        }
                    }
                }
                else
                {
                    lblQuickLauchURL.Text = "<i>You must first save a registration code to create a quick launch url</i>";
                    btnCreateCampaignRedirect.Visible = false;
                }

                qPtl_User user = new qPtl_User(campaign.LastModifiedBy);
                user_id = user.UserID;
                username = user.UserName;

                qPtl_User reviewed_by = new qPtl_User(campaign.LastModifiedBy);
                lblPostedTime.Text = " at " + campaign.LastModified;
                plhMoreInfo.Visible = true;

                string delivery_options = string.Empty;
                if (campaign.SMS == "Yes")
                    delivery_options += "&nbsp;&nbsp;<i class=\"glyphicon-phone\"></i>&nbsp;&nbsp;Text Messaging (SMS)";
                if (campaign.Mobile == "Yes")
                {
                    if (!String.IsNullOrEmpty(delivery_options))
                        delivery_options += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    delivery_options += "<i class=\"glyphicon-iphone\"></i>&nbsp;&nbsp;Mobile App";
                }
                if (campaign.Browser == "Yes")
                {
                    if (!String.IsNullOrEmpty(delivery_options))
                        delivery_options += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    delivery_options += "<i class=\"glyphicon-display\"></i>&nbsp;&nbsp;Browser";
                }
                if (campaign.Email == "Yes")
                {
                    if (!String.IsNullOrEmpty(delivery_options))
                        delivery_options += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                    delivery_options += "<i class=\"icon-envelope\"></i></i>&nbsp;&nbsp;Email";
                }
                lblDeliveryModes.Text = delivery_options;
                if (campaign.Browser == "Yes")
                    chkBrowser.Enabled = true;
                else
                {
                    chkBrowser.Enabled = false;
                    chkBrowser.Text = "<i>Browser - Not Available for this campaign</i>";
                }
                if (campaign.Mobile == "Yes")
                    chkMobile.Enabled = true;
                else
                {
                    chkMobile.Enabled = false;
                    chkMobile.Text = "<i>Mobile App - Not Available for this campaign</i>";
                }
                if (campaign.SMS == "Yes")
                    chkSMS.Enabled = true;
                else
                {
                    chkSMS.Enabled = false;
                    chkSMS.Text = "<i>SMS - Not Available for this campaign</i>";
                }
                if (campaign.Email == "Yes")
                    chkEmail.Enabled = true;
                else
                {
                    chkEmail.Enabled = false;
                    chkEmail.Text = "<i>Email - Not Available for this campaign</i>";
                }
            }
            else
            {
                lblTitle.Text = "Create New Campaign";
                rblAvailableNew.Text = "Yes";
                plhMoreInfo.Visible = false;
                plhTools.Visible = false;
            }
        }
    }
    protected void btnCreateCampaignRedirect_Click(object sender, EventArgs e)
    {
        // see if redirect exists, if yes -- then delete, else -- create
        int campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]);
        qSoc_Campaign campaign = new qSoc_Campaign(campaign_id);
        qPtl_Redirect redirect = new qPtl_Redirect("/" + campaign.Code + "/");

        if (redirect != null)
        {
            if (redirect.RedirectID > 0)
            {
                redirect.DeleteRedirect(redirect.RedirectID);
            }
            else
            {
                int user_id = Convert.ToInt32(Context.Items["UserID"]);
                qPtl_Redirect n_redirect = new qPtl_Redirect();
                n_redirect.Available = "Yes";
                n_redirect.MarkAsDelete = 0;
                n_redirect.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]);
                n_redirect.Created = DateTime.Now;
                n_redirect.CreatedBy = user_id;
                n_redirect.LastModified = DateTime.Now;
                n_redirect.LastModifiedBy = user_id;
                n_redirect.EntryURL = "/" + campaign.Code + "/";
                n_redirect.RedirectURL = base_path + "/public/campaigns/campaign-start.aspx?campaignID=" + campaign_id + "&keyword=" + campaign.Keyword;
                n_redirect.Insert();

            }
            Response.Redirect("~/manage/site/learning/campaign-edit.aspx?campaignID=" + campaign_id);
        }
    }
        public void PerformRedirect_BeginRequest(object sender, System.EventArgs args)
        {
            // see if current URL matches any redirects
            System.Web.HttpApplication application = (System.Web.HttpApplication)sender;
            string url = application.Request.Path;                                          //get the url path -- want to grab the "/folder" from the URL and compare this to

            char last = url[url.Length - 1];                                              // make sure ends is "/"
            if (Convert.ToString(last) != "/")
            {
                url += "/";
            }

            qPtl_Redirect redirect = new qPtl_Redirect(url);

            if (redirect.RedirectID > 0)
            {
                if (!String.IsNullOrEmpty(redirect.RedirectURL))
                {
                    // add log
                    int curr_user_id = 0;
                    string email = application.Context.Request.QueryString["email"];
                    string campaign = application.Context.Request.QueryString["campaign"];
                    int curr_campaign_id = 0;

                    // try and find a user with this email address
                    if (!String.IsNullOrEmpty(email))
                    {
                        qPtl_User user = new qPtl_User(email);

                        if (user.UserID > 0)
                            curr_user_id = user.UserID;
                    }

                    qPtl_LogAction logAction = new qPtl_LogAction("View");
                    qPtl_Log log = new qPtl_Log();
                    log.ActorID = curr_user_id;
                    log.Created = DateTime.Now;
                    log.CreatedBy = curr_user_id;
                    log.LastModified = DateTime.Now;
                    log.LastModifiedBy = curr_user_id;
                    log.ScopeID = 1;
                    log.LogActionID = logAction.LogActionID;
                    log.CampaignID = curr_campaign_id;
                    log.ReferenceID = redirect.RedirectID;
                    log.ReferenceData = "Email=" + email + ", Entry URL=" + redirect.EntryURL + ", RedirectURL=" + redirect.RedirectURL + ", CampaignID=" + campaign;
                    log.IPAddress = LogUtilities.GetIPAddress();
                    log.Insert();

                    // redirect to URL
                    (sender as HttpApplication).Response.Redirect(redirect.RedirectURL, true);
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {

            if (!String.IsNullOrEmpty(Request.QueryString["redirectID"]))
            {
                redirect_id = Convert.ToInt32(Request.QueryString["redirectID"]);

                qPtl_Redirect redirect = new qPtl_Redirect(redirect_id);

                lblTitle.Text = "Edit Server Redirect (ID: " + redirect.RedirectID + ")";
                string raw_watch_for = redirect.EntryURL;
                string watch_for_trimmed = raw_watch_for.Substring(1, raw_watch_for.Length - 2);
                txtWatchFor.Text = watch_for_trimmed;
                txtURL.Text = redirect.RedirectURL;
                rblAvailable.SelectedValue = redirect.Available;

                if (Convert.ToString(Request.QueryString["mode"]) == "add-successful")
                {
                    lblMessage.Text = "*** Record Successfully Added ***";
                }
            }

            else
            {
                lblTitle.Text = "New Server Redirect";
                btnDelete.Visible = false;
                rblAvailable.SelectedValue = "Yes";
                plhTools.Visible = false;
            }
        }
    }