private void ImportFromSite()
        {
            err.Clear();
            if (string.IsNullOrWhiteSpace(txtAccessPoint.Text))
            {
                err.SetError(txtAccessPoint, "主機位置不可空白");
                return;
            }

            Connection connection = new Connection();
            connection.EnableSecureTunnel= true;
            try
            {
                connection.Connect(txtAccessPoint.Text, txtContract.Text, txtUserName.Text, txtPassword.Text);
            }
            catch (Exception ex)
            {
                err.SetError(txtAccessPoint, "主機連線失敗 : \n" + ex.Message);
                return;
            }

            XmlHelper h = new XmlHelper();
            h.AddElement(".","ApplicationName","shared");
            Envelope env = new Envelope(h);
            
            env = connection.SendRequest("Server.ExportApplication", env);
            h = new XmlHelper(env.Body);
            Console.WriteLine(h.XmlString);
            this.Import(h.GetElement("."));
        }
        private XmlElement GenerateServiceDefinition()
        {
            if (Source == null)
                Source = XmlHelper.ParseAsDOM("<Definition Type=\"JavaScript\"/>");

            if (Source.SelectSingleNode("Code") == null)
            {
                XmlHelper xh = new XmlHelper(Source);
                xh.AddElement("Code");
            }

            Source.SelectSingleNode("Code").InnerXml =((JSEditor)Editor).JavaScriptCode;

            return Source;
        }
        public XmlElement GetAuthElement()
        {
            XmlHelper h = new XmlHelper("<Authentication />");
            h.SetAttribute(".", "Extends", Type.ToString());


            if (dgRestrict.Rows.Count > 0 || dgExt.Rows.Count > 0)
                h.AddElement(".", "UserInfoProcessors");

            if (dgRestrict.Rows.Count > 0)
            {
                XmlElement xml = h.AddElement("UserInfoProcessors", "Processor");
                xml.SetAttribute("Type", "restrict");

                XmlHelper xh = new XmlHelper(xml);
                foreach (DataGridViewRow row in this.dgRestrict.Rows)
                {
                    XmlElement res = row.Tag as XmlElement;
                    xh.AddElement(".", res);
                }
            }

            foreach (DataGridViewRow row in this.dgExt.Rows)
            {
                XmlElement xml = h.AddElement("UserInfoProcessors", "Processor");
                xml.SetAttribute("Type", "ExtendProperty");

                XmlHelper xh = new XmlHelper(xml);

                XmlElement res = row.Tag as XmlElement;
                xh.AddElement(".", res);
            }

            return h.GetElement(".");
        }