Esempio n. 1
0
        protected void Back_Click(object o, EventArgs e)
        {
            WebBackEnd remoteObj = (WebBackEnd)Session["RemObj"];

            //if (IsPostBack && HttpContext.Current.Session.IsNewSession)
            if (remoteObj == null)
            {
                Output.Text  = enableSessionMsg;
                Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false;
                return;
            }

            if ((remoteObj == null) || !(remoteObj.allowGlobalAccess || isLocalReq()))
            {
                Output.Text        = localReqOnlyMsg;
                Back.Visible       = Forward.Visible = GlobalSearchCheckBox.Visible = false;
                sourceList.Enabled = SearchBox.Enabled = Search.Enabled = false;
                return;
            }

            string sessId = Session.SessionID;

            SearchBox.Text           = (string)Session["SearchString"];
            sourceList.SelectedValue = (string)Session["Source"];

            //if (remoteObj == null)  { Output.Text = NO_RESULTS; return; }

            string response = "";

            try {
                response = convertUrls(remoteObj.doBack(sessId));
            }
            catch (Exception ex)
            {
                response = "Exception in WebBackEnd:doBack method\n";
                Console.WriteLine("WebFrontEnd: Caught Exception in WebBackEnd:doBack()\n" + ex.Message);
            }

            Session["ResultsOnDisplay"] = Output.Text = HeaderMsg + response;

            GlobalSearchCheckBox.Checked = (bool)Session["GlobalCheckBox"];
            Back.Enabled    = (remoteObj != null) && (remoteObj.canBack(sessId));
            Forward.Enabled = (remoteObj != null) && (remoteObj.canForward(sessId));
        }
Esempio n. 2
0
        protected void Page_Load(Object o, EventArgs e)
        {
            //note: this web-form relies on availability of Session information either through
            //     cookies or modified Url. It won't work if persistent session id is not available.

            string sessId = Session.SessionID;

            Output.Visible = Back.Visible = Forward.Visible = true;

            if (Session["ResultsOnDisplay"] != null &&
                ((string)Session["ResultsOnDisplay"]).StartsWith(HeaderMsg + NO_RESULTS))
            {
                Back.Visible = Forward.Visible = false;
            }

            string actionString         = null;
            bool   queryStringProcessed = false;

            string reqUrl = Request.Url.ToString();
            int    index  = reqUrl.IndexOf(".aspx?");

            if (index > 0)
            {
                actionString = reqUrl.Substring(index + ".aspx?".Length);
            }

            if (!IsPostBack)
            {
                //HTTP GET request
                if (actionString == null)
                {
                    //HTTP Get without any query string
                    if (Session["ResultsOnDisplay"] == null)
                    {
                        //First access
                        Output.Visible = false;
                        Back.Visible   = Forward.Visible = false;

                        int index1 = reqUrl.IndexOf(".aspx");
                        if ((index1 > 0) && (index1 + ".aspx".Length < reqUrl.Length))
                        {
                            Session["InitialReqUrl"] = reqUrl.Substring(0, index1 + ".aspx".Length);
                        }
                        else
                        {
                            Session["InitialReqUrl"] = reqUrl;
                        }

                        Session["SearchString"]  = "";
                        Session["Source"]        = "Anywhere";
                        sourceList.SelectedValue = "Anywhere";

                        if (Session["GlobalCheckBox"] == null)
                        {
                            //GlobalSearchCheckBox.Visible = ((string)Session["Source"]).Equals("Anywhere");
                            //By default, NetBeagleSearch checkbox is checked for local access & unchecked for ext. access
                            GlobalSearchCheckBox.Checked = isLocalReq()? true:false;
                            Session["GlobalCheckBox"]    = GlobalSearchCheckBox.Checked;
                        }
                    }
                    else
                    {
                        //Redirected from Tile-Action invocation, restore Results
                        SearchBox.Text           = (string)Session["SearchString"];
                        sourceList.SelectedValue = (string)Session["Source"];

                        Output.Text = (string)Session["ResultsOnDisplay"];
                        WebBackEnd remoteObj = (WebBackEnd)Session["RemObj"];
                        if (remoteObj != null)
                        {
                            Back.Enabled    = remoteObj.canBack(sessId);
                            Forward.Enabled = remoteObj.canForward(sessId);
                            GlobalSearchCheckBox.Visible = (remoteObj.NetworkBeagleActive) && (sourceList.SelectedValue.Equals("Anywhere"));

                            if (!isLocalReq() && (((string)TitleLabel.Text).IndexOf("host") < 0))
                            {
                                TitleLabel.Text += "  from host: " + remoteObj.HostName;
                            }
                        }
                        GlobalSearchCheckBox.Checked = (bool)Session["GlobalCheckBox"];
                    }
                }
                else               //HTTP-Get request with query string:
                                   //Initial web query initiated via HTTP Get (firefox search bar):

                {
                    string searchString     = null;
                    NameValueCollection nvc = Request.QueryString;

                    if ((nvc != null) && (nvc.Count != 0) &&
                        ((searchString = nvc["text"]) != null))
                    {
                        SearchBox.Text          = searchString;
                        Session["SearchString"] = searchString;

                        string source = null;
                        if ((source = nvc["source"]) != null)
                        {
                            switch (source.ToLower())
                            {
                            case "files":           sourceList.SelectedValue = "Files";
                                break;

                            case "addressbook": sourceList.SelectedValue = "Contact";
                                break;

                            case "mail":               sourceList.SelectedValue = "MailMessage";
                                break;

                            case "web":               sourceList.SelectedValue = "WebHistory";
                                break;

                            case "chats":           sourceList.SelectedValue = "IMLog";
                                break;

                            case "anywhere":
                            default:                        sourceList.SelectedValue = "Anywhere";
                                break;
                            }
                        }
                        else
                        {
                            sourceList.SelectedValue = "Anywhere";
                        }

                        Session["Source"]            = sourceList.SelectedValue;
                        GlobalSearchCheckBox.Visible = ((string)Session["Source"]).Equals("Anywhere");
                        //By default, NetBeagleSearch checkbox is checked for local access & unchecked for ext. access
                        GlobalSearchCheckBox.Checked = isLocalReq()? true:false;
                        Session["GlobalCheckBox"]    = GlobalSearchCheckBox.Checked;

                        if (Session["ResultsOnDisplay"] == null)
                        {
                            int index2 = reqUrl.IndexOf(".aspx");
                            if ((index2 > 0) && (index2 + ".aspx".Length < reqUrl.Length))
                            {
                                Session["InitialReqUrl"] = reqUrl.Substring(0, index2 + ".aspx".Length);
                            }
                            else
                            {
                                Session["InitialReqUrl"] = reqUrl;
                            }
                        }

                        queryStringProcessed = true;

                        Search_Click(o, e);

                        //Redirect client to initial Beagle webaccess URL:
                        Response.Redirect((string)Session["InitialReqUrl"]);
                    }
                }  //end else for if (actionString == null)
            }      //end if (!IsPostBack)

            //Process Tile!Action HTTP-Get request, if user has clicked on one:
            if (actionString != null && !queryStringProcessed)
            {
                WebBackEnd remoteObj = (WebBackEnd)Session["RemObj"];

                if (remoteObj != null)
                {
                    if (isLocalReq())
                    {
                        remoteObj.dispatchAction(sessId, actionString);
                    }
                }
                else
                {
                    Output.Text  = enableSessionMsg;
                    Back.Visible = Forward.Visible = GlobalSearchCheckBox.Visible = false;
                    return;
                }

                //Redirect client to initial Beagle webaccess URL:
                Response.Redirect((string)Session["InitialReqUrl"]);
            }
        }