Ejemplo n.º 1
0
        public ITcpFrame PerformService(ILogger logger, IAppDocument iAppDocument)
        {
            AppDocument appDocument;

            appDocument = ( AppDocument )iAppDocument;
            MainForm mainForm = appDocument.MainForm;

            //	Start the browser.
            MainForm.StartBrowserFormDelegate startBrowserFormDelegate;
            startBrowserFormDelegate = new MainForm.StartBrowserFormDelegate(mainForm.StartBrowserForm);
            BrowserForm browserForm = ( BrowserForm )mainForm.Invoke(startBrowserFormDelegate);

            //	Decode the request and generate a response.
            ITcpFrame responseFrame = BuildResponse(browserForm);

            //	Stop the browser.
            MainForm.StopBrowserFormDelegate stopBrowserFormDelegate;
            stopBrowserFormDelegate = new MainForm.StopBrowserFormDelegate(mainForm.StopBrowserForm);
            object[] args = new object[1];
            args[0] = browserForm;
            bool isRemoved = ( bool )mainForm.Invoke(stopBrowserFormDelegate, args);

            //	Return the framed results.
            return(responseFrame);
        }
Ejemplo n.º 2
0
        public string NavigateToBlank(BrowserForm browserForm)
        {
            string url    = GeneralClassLibrary.Constants.BlankPageSite;
            string result = this.NavigteToUrl(browserForm, url);

            return(result);
        }
Ejemplo n.º 3
0
        public bool StopBrowserForm(BrowserForm browserForm)
        {
            bool isRemove;

            //	The lists are protected by a lock.
            isRemove = AppDocument.StopBrowserForm(browserForm);
            return(isRemove);
        }
Ejemplo n.º 4
0
        public string NavigteToUrl(BrowserForm browserForm, string url)
        {
            BrowserForm.BrowserWorkDelegate browserWorkDelegate;
            browserWorkDelegate = new BrowserForm.BrowserWorkDelegate(browserForm.BrowserWork);
            object[] args = new object[1];
            args[0] = url;
            string result = ( string )browserForm.Invoke(browserWorkDelegate, args);

            return(result);
        }
Ejemplo n.º 5
0
        public bool StopBrowserForm(BrowserForm browserForm)
        {
            bool isRemove;

            lock ( BrowserFormCollection )
            {
                isRemove = BrowserFormCollection.ActiveBrowserForms.Remove(browserForm);
                browserForm.Hide();

                if (BrowserFormCollection.PoolBrowserForms.Count > Properties.Settings.Default.SizeBrowserPool)
                {
                    //	When a form is closed, all resources created within the object are closed and the form is disposed.
                    browserForm.Close();
                }
                else
                {
                    BrowserFormCollection.PoolBrowserForms.Push(browserForm);
                }
            }
            return(isRemove);
        }
Ejemplo n.º 6
0
        public ITcpFrame BuildResponse(BrowserForm browserForm)
        {
            XmlPageRequestBody  xmlPageRequestBody;
            XmlPageRequestFrame xmlPageRequestFrame;

            xmlPageRequestFrame = XmlPageRequestFrame;
            xmlPageRequestBody  = xmlPageRequestFrame.XmlPageRequestBody;

            RequestResponseFrame responseFrame;

            NavigateAndSync(browserForm, xmlPageRequestBody);
            //string search = xmlPageRequestBody.ReceiveSearch;

            //	Wait until all navigation results are completed.
            BrowserDocument browserDocument = browserForm.BrowserDocument;

            browserDocument.NavigateManualResetEvent.WaitOne();

            //	Get the results of navigation
            string domText = browserDocument.DomText;
            string xmlText = browserDocument.XmlText;

            List <string> textList = new List <string>
            {
                domText,
                xmlText,
                browserDocument.DomContentOnly(),
                browserDocument.XmlContentOnly()
            };

            //	Frame the results.
            XmlPageReplyFrame xmlPageReplyFrame = new XmlPageReplyFrame(textList);

            responseFrame = new RequestResponseFrame(xmlPageReplyFrame.ToByteArray());

            //	Navigate to a blank page so the pool of browsers remains quiet.
            NavigateToBlank(browserForm);

            return(responseFrame);
        }
Ejemplo n.º 7
0
        public BrowserForm StartBrowserForm(MainForm mainForm)
        {
            BrowserForm browserForm;

            lock ( BrowserFormCollection )
            {
                if (BrowserFormCollection.PoolBrowserForms.Count > 0)
                {
                    browserForm = BrowserFormCollection.PoolBrowserForms.Pop();
                }
                else
                {
                    //	Create a modeless window.
                    browserForm = new BrowserForm(this)
                    {
                        Owner = mainForm
                    };
                }
                browserForm.Show();

                BrowserFormCollection.ActiveBrowserForms.Add(browserForm);
            }
            return(browserForm);
        }
Ejemplo n.º 8
0
        public string NavigateAndSync(BrowserForm browserForm, XmlPageRequestBody xmlPageRequestBody)
        {
            string result = this.NavigteToUrl(browserForm, xmlPageRequestBody.ReceiveUrl);

            return(result);
        }