当前位置: 首页>>代码示例>>C#>>正文


C# Util.GetWebPage方法代码示例

本文整理汇总了C#中Util.GetWebPage方法的典型用法代码示例。如果您正苦于以下问题:C# Util.GetWebPage方法的具体用法?C# Util.GetWebPage怎么用?C# Util.GetWebPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Util的用法示例。


在下文中一共展示了Util.GetWebPage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitWebServiceNodes

    protected void InitWebServiceNodes(XmlDocument doc, string event_field, RadTreeNode url_node,
        RadTreeNode WebServiceResponseRoot, XmlNode phone_data_requests)
    {
        string url = url_node.Text;
        url_node.ExpandParentNodes();
        url_node.CollapseChildNodes();
        Hashtable WebServiceMethodInputs = new Hashtable();
        Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
        State["WebServiceMethodInputs"] = WebServiceMethodInputs;
        RadTreeNode out_url = new RadTreeNode(url);
        out_url.CssClass = "RadTreeView";
        out_url.ImageUrl = "~/images/dialog.gif";
        WebServiceResponseRoot.Nodes.Add(out_url);

        Util util = new Util();

        if (!url.EndsWith("?WSDL"))
            url += "?WSDL";
        string xml = util.GetWebPage(url);
        if (xml == null)
        {
            SaveRequestMessage.Text = "Accessing " + url + " resulted in an error";
            return;
        }
        XmlDocument WebDoc = new XmlDocument();
        WebDoc.LoadXml(xml);
        XmlNamespaceManager nsmgr = new XmlNamespaceManager(WebDoc.NameTable);
        nsmgr.AddNamespace("s", "http://www.w3.org/2001/XMLSchema");

        XmlNodeList web_methods = WebDoc.SelectNodes("//s:schema/s:element", nsmgr);
        if (web_methods.Count == 0)
        {
            nsmgr.AddNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
            web_methods = WebDoc.SelectNodes("//wsdl:operation", nsmgr);
            if (web_methods.Count == 0)
            {
                SaveRequestMessage.Text = "Could not find any methods with URL: " + url;
                return;
            }
        }
        Hashtable used_names = new Hashtable();
        foreach (XmlNode web_method in web_methods)
        {
            //throw out certain methods with <s:any />
            if (web_method.InnerXml.Contains("s:any"))
                continue;
            string web_method_name = web_method.Attributes["name"].Value;
            if (used_names.ContainsKey(web_method_name))
                continue;
            used_names[web_method_name] = true;
            ArrayList MethodInputs = new ArrayList();
            string service_url = out_url.Text;
            if (out_url.Text.ToLower().EndsWith("?wsdl"))
                service_url = service_url.Remove(url.Length - 5);
            WebServiceMethodInputs[service_url + "/" + web_method_name] = MethodInputs;
            RadTreeNode in_method_node = new RadTreeNode(web_method_name);
            in_method_node.CssClass = "RadTreeView";
            in_method_node.ImageUrl = "~/images/forward_nav.gif";
            url_node.Nodes.Add(in_method_node);

            //response web methods
            XmlNode mapped_node = phone_data_requests.SelectSingleNode("//event_field[.='" + event_field + "']");
            RadTreeNode out_method_node = null;
            if (mapped_node != null &&  State["WebServiceTestDoc"] != null &&  State["WebServiceResponseTreeViewNodeText"] != null &&
                  State["WebServiceResponseTreeViewNodeText"].ToString() == web_method_name)
            {
                //make sure we are in the right event
                XmlNode method_node = mapped_node.ParentNode.SelectSingleNode("method");
                if (method_node != null && method_node.InnerText == web_method_name)
                {
                    XmlDocument TestDoc = (XmlDocument) State["WebServiceTestDoc"];
                    out_method_node = new RadTreeNode(web_method_name);
                     State["WebServiceResponseTreeViewMethodText"] = web_method_name;
                    out_method_node.CssClass = "RadTreeView";
                    out_method_node.ImageUrl = "~/images/backward_nav.gif";
                    out_method_node.Category = "method";
                    out_method_node.Value = service_url + ";" + web_method_name + ";";
                    out_url.Nodes.Add(out_method_node);
                    out_method_node.Value.Remove(out_method_node.Value.Length - 1, 1);
                    WebServiceResponseTreeView.ExpandAllNodes();

                    XmlToTreeViewNode(TestDoc.FirstChild.NextSibling, out_method_node, web_method_name);

                    out_method_node.ExpandParentNodes();

                    Session.Remove("WebServiceTestDoc");
                }
            }
            else if (mapped_node != null)
            {
                XmlNode web_service_node = mapped_node.ParentNode.SelectSingleNode("web_service[.='" + service_url + "']");
                XmlNode method_node = mapped_node.ParentNode.SelectSingleNode("method[.='" + web_method_name + "']");
                if (web_service_node != null && method_node != null)
                {
                    in_method_node.BackColor = Color.LightCoral;

                    out_method_node = new RadTreeNode(web_method_name);
                    out_method_node.CssClass = "RadTreeView";
                    out_method_node.ImageUrl = "~/images/backward_nav.gif";
                    out_method_node.Category = "method";
//.........这里部分代码省略.........
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:101,代码来源:ManageData.aspx.cs

示例2: Report


//.........这里部分代码省略.........
                        if (new_application_id != null)
                        {
                            XmlDocument Design = GetDesign(new_application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                            if (Design != null)
                            {
                                Design.SelectSingleNode("//status").InnerText = "update_app";
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                            }
                            else
                            {
                                Design = new XmlDocument();
                                XmlNode root2 = Design.CreateElement("report_response");
                                Design.AppendChild(root2);
                                x_util.CreateNode(Design, root2, "status", "kill");
                                x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                            }
                            return Design;
                        }
                    }
                    db.CloseViziAppsDatabase(State);
                }
            }

            string app_time_stamp = request.QueryString.Get("app_time_stamp");
            if (app_time_stamp != null && app_time_stamp.Length > 0)
            {
                string date_time_modified = null;
                if (app_status == "staging")
                    date_time_modified = util.GetStagingAppTimeStamp(State, application_id);
                else
                {
                    date_time_modified = State["DateTimeModified"].ToString();
                }
                DateTime AppDateTime;
                bool isGoodAppDateTime= DateTime.TryParse(app_time_stamp, out AppDateTime);
                DateTime DateTimeModified;
                bool isGoodDateTimeModified = DateTime.TryParse(date_time_modified, out DateTimeModified);
                if (isGoodAppDateTime && isGoodDateTimeModified && AppDateTime != DateTimeModified)
                { // assuming that there is a newer version
                    XmlDocument Design = null;
                    if (app_status == "staging")
                    {
                        Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, date_time_modified);
                    }
                    else
                    {
                        Design = new XmlDocument();
                        Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
                    }
                    if (Design != null)
                    {
                        Design.SelectSingleNode("//status").InnerText = "update_app";
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app updated");
                    }
                    else
                    {
                        Design = new XmlDocument();
                        XmlNode root2 = Design.CreateElement("report_response");
                        Design.AppendChild(root2);
                        x_util.CreateNode(Design, root2, "status", "kill");
                        x_util.CreateNode(Design, root2, "status_message", "Application no longer exists.");
                        SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app does not exist");
                    }

                    return Design;
                }
                else
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, latitude, longitude, "app opened");

            string status = "OK";

            //check for unlimited use
            if (app_status == "production")
            {
                if (State["HasUnlimitedUsers"].ToString() == "true")
                    status += " unlimited";
            }

            status_node = x_util.CreateNode(Report, root, "status", status);
        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);
            if (status_node == null)
            {
                Report = new XmlDocument();
                XmlNode root2 = Report.CreateElement("report_response");
                Report.AppendChild(root2);
                status_node = x_util.CreateNode(Report, root2, "status");

            }
            status_node.InnerText = SE.Message + ": " + SE.StackTrace;
        }

        return Report;
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:101,代码来源:PhoneWebService.cs

示例3: Login


//.........这里部分代码省略.........
                            else
                            {
                                sql = "INSERT INTO users_device_ids SET device_id='" + device_id + "',user_id='" + row["user_id"].ToString() + "'";
                                db.ViziAppsExecuteNonQuery(State, sql);
                            }
                        }
                        //else app is allowed
                    }
                }
            }
            else //staging
            {
                sql = "SELECT * FROM customers WHERE username='" + user.ToLower() + "'";
                rows = db.ViziAppsExecuteSql(State, sql);
                if (rows.Length == 0)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: user not registered");
                    throw new Exception("The username " + user.ToLower() + " is not registered. Go to www.viziapps.com and create a free account.");
                }

                DataRow row = rows[0];
                if (row["password"].ToString() != password)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: bad credentials");
                    throw new Exception("Either the username or the password: " + password + " is incorrect.");
                }
                if (row["status"].ToString() == "inactive")
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: account is inactive");
                    throw new Exception("Your account is inactive. Contact ViziApps to re-activate your account.");
                }
                customer_id = row["customer_id"].ToString();
                State["CustomerID"] = customer_id;
            }

            //user is now logged in

            if (app_status == "staging")
            {
                sql = "SELECT application_id FROM applications WHERE " +
                   "in_staging=1 AND customer_id='" + customer_id + "'";

                application_id = db.ViziAppsExecuteScalar(State, sql);
                if (application_id == null)
                {
                    db.CloseViziAppsDatabase(State);
                    SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                    throw new System.InvalidOperationException("You need to select an app to test, on the design page of your ViziApps Studio account.");
                }
            }

            db.CloseViziAppsDatabase(State);

            //get design
            if (State["AppDesignURL"] == null)
            {
                Design = GetDesign(application_id, user_id, customer_id, Convert.ToInt32(display_width), Convert.ToInt32(display_height), app_status, null);
                //save design in a file if production
                if (app_status == "production")
                {
                    util.SaveProductionAppInfo(State, application_name, Design);
                }
            }
            else
            {
                Design = new XmlDocument();
                Design.LoadXml(util.GetWebPage(State["AppDesignURL"].ToString()));
            }
            if (Design == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: no app selected");
                status = x_util.CreateNode(Design, root2, "status", "You need to select an app to test, on the design page of your ViziApps Studio account.");
            }
            else
                SaveReport(State, application_id, app_status, customer_id, user_id, device_id, device_model, device_version, viziapps_version, null, null, "app login: design downloaded");

        }
        catch (System.Exception SE)
        {
            util.LogError(State, SE);

            if (status == null)
            {
                Design = new XmlDocument();
                XmlNode root2 = Design.CreateElement("login_response");
                Design.AppendChild(root2);
                status = x_util.CreateNode(Design, root2, "status");

            }
            status.InnerText = SE.Message;
            util.LogError(State, SE);
        }
        return Design;
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:101,代码来源:PhoneWebService.cs

示例4: googleSpreadsheetQuery

    protected void googleSpreadsheetQuery(string SpreadsheetURL)
    {
        Util util = new Util();
        string json = util.GetWebPage(SpreadsheetURL).Substring(2); //remove beginning "?(" and ending ")"
        XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(json.Remove(json.Length - 1));
        XmlNode status = doc.SelectSingleNode("//status");
        if (status.InnerText != "success")
        {
            Message.Text = status.InnerText;
            return;
        }
        XmlNodeList rows = doc.SelectNodes("//row");
        if (rows.Count == 0)
        {
            SpreadsheetResponseTreeView.Nodes.Clear();
            RadTreeNode ResponseRootEmpty = new RadTreeNode("Response was successful but there were no response entries from this Spreadsheet Query");
            ResponseRootEmpty.CssClass = "RadTreeView";
            ResponseRootEmpty.Category = "response";
            SpreadsheetResponseTreeView.Nodes.Add(ResponseRootEmpty);
            return;
        }
        XmlNode first_row = rows[0];
        XmlNodeList fieldNames = first_row.SelectNodes("field");
        Hashtable DeviceFields = new Hashtable();
        foreach (XmlNode field in fieldNames)
        {
            DeviceFields[field.InnerText] = new ArrayList();
         }

        SpreadsheetResponseTreeView.Nodes.Clear();
        RadTreeNode ResponseRoot = new RadTreeNode("Response from Spreadsheet Query:");
        ResponseRoot.CssClass = "RadTreeView";
        ResponseRoot.Category = "response";

        //get database to device field map
        Hashtable DatabaseToDeviceMap = new Hashtable();
        if (rows != null && rows.Count > 0)
        {
            Hashtable State = (Hashtable)HttpRuntime.Cache[Session.SessionID];
            Hashtable CommandEntry = (Hashtable)State["TestCommandEntry"];
            ArrayList DBFields = (ArrayList)CommandEntry["database_fields"];
            foreach (Hashtable FieldEntry in DBFields)
            {
                DatabaseToDeviceMap[FieldEntry["database_field"].ToString()] = FieldEntry["device_field"].ToString();
            }

            //get all values for each database field
            foreach (XmlNode row in rows)
            {
                XmlNodeList fields = row.SelectNodes("field");
                XmlNodeList values = row.SelectNodes("value");
                int index = 0;
                foreach (XmlNode field in fields)
                {
                    ArrayList list = (ArrayList)DeviceFields[field.InnerText];
                    list.Add(values[index].InnerText);
                    index++;
                }
            }
        }
        foreach (String key in DeviceFields.Keys)
        {
            if (DatabaseToDeviceMap[key] == null)
                continue;
            StringBuilder string_array = new StringBuilder();
            ArrayList values = (ArrayList) DeviceFields[key];
            bool is_first = true;
            foreach(String value in values)
            {
                if(is_first)
                    is_first = false;
                else
                     string_array.Append("; ");

                if(values.Count > 1)
                     string_array.Append("\"" + value + "\"" );
                else
                    string_array.Append( value);
            }
            UserControl ResponseControl = null;
            string field_value = string_array.ToString();

            if (field_value.Length > 49)
                ResponseControl = LoadControl("../Controls/TestResponseLong.ascx", DatabaseToDeviceMap[key].ToString() + "=" + string_array.ToString());
            else
                ResponseControl = LoadControl("../Controls/TestResponse.ascx", DatabaseToDeviceMap[key].ToString() + "=" + string_array.ToString());

            RadTreeNode row_node = new RadTreeNode("row");
            ResponseRoot.CssClass = "RadTreeView";
            ResponseRoot.Category = "response";
            row_node.Controls.Add(ResponseControl);
            ResponseRoot.Nodes.Add(row_node);
        }
        SpreadsheetResponseTreeView.Nodes.Add(ResponseRoot);
        SpreadsheetResponseTreeView.ExpandAllNodes();
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:96,代码来源:TestQuery.aspx.cs


注:本文中的Util.GetWebPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。