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


C# Util.SaveDatabaseSchema方法代码示例

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


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

示例1: ParseGoogleDocsSpreadsheet

    public string ParseGoogleDocsSpreadsheet(Hashtable State, string use_spreadsheet_name)
    {
        try
        {
            SpreadsheetsService service = new SpreadsheetsService(State["SelectedApp"].ToString());
            GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("wise", "MobiFlex");
            requestFactory.ConsumerKey = ConfigurationManager.AppSettings["GoogleAppsKey"];
            requestFactory.ConsumerSecret = ConfigurationManager.AppSettings["GoogleAppsSecret"];
            service.RequestFactory = requestFactory;

            //get all spreadsheets
            Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();
            query.OAuthRequestorId = State["CustomerEmail"].ToString();
            query.Uri = new Uri("https://spreadsheets.google.com/feeds/spreadsheets/private/full?xoauth_requestor_id=" + State["CustomerEmail"].ToString());

            SpreadsheetFeed feed = service.Query(query);

            bool found_spreadsheet = false;
            Hashtable tables = new Hashtable();
            foreach (SpreadsheetEntry entry in feed.Entries)
            {
                string spreadsheet_name = entry.Title.Text;
                if (spreadsheet_name.ToLower() == use_spreadsheet_name.ToLower())
                {
                    //Use this spreadsheet
                    found_spreadsheet = true;
                    AtomLink link = entry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);

                    //get all worksheets
                    WorksheetQuery wk_query = new WorksheetQuery(link.HRef.ToString());
                    WorksheetFeed wk_feed = service.Query(wk_query);

                    foreach (WorksheetEntry worksheet in wk_feed.Entries)
                    {
                        string table_name = worksheet.Title.Text;

                        AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);

                        ListQuery list_query = new ListQuery(listFeedLink.HRef.ToString());
                        ListFeed list_feed = service.Query(list_query);

                        //get field names
                        if (list_feed.Entries.Count == 0)
                        {
                            return "The worksheet " + table_name + " has no values.";
                        }
                        ListEntry fieldRow = (ListEntry)list_feed.Entries[0];
                        ArrayList field_list = new ArrayList();
                        foreach (ListEntry.Custom column in fieldRow.Elements)
                        {
                            Hashtable field = new Hashtable();
                            field["name"] = column.LocalName;
                            field_list.Add(field);
                        }
                        tables[table_name] = field_list;
                    }
                    break;
                }
            }
            if (!found_spreadsheet)
            {
                return use_spreadsheet_name + " could not be found";
            }

            Util util = new Util();
            string connection_string = "spreadsheet=" + use_spreadsheet_name +
                ";consumer_key=" + ConfigurationManager.AppSettings["GoogleAppsKey"] +
                ";consumer_secret=" + ConfigurationManager.AppSettings["GoogleAppsSecret"] +
                ";requestor_id=" + State["Username"].ToString();
            State["DBConnectionString"] = connection_string;
            util.SaveDatabaseSchema(State, "GoogleDocs", connection_string, tables);

            return "OK";
        }
        catch (Exception ex)
        {
            Util util = new Util();
            util.LogError(State, ex);
            if (ex.Message.Contains("Execution of request failed"))
                return "Credentials to your Google Docs Account or spreadsheet name are not valid.";
            else
                return "There was an internal error with access to your Google Docs account.";
        }
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:84,代码来源:GDocs.cs

示例2: ParseSqlFile

    protected void ParseSqlFile(string sql_file)
    {
        SqlParser myParser = new SqlParser();
        string database_name = null;
        Hashtable tables = new Hashtable();

        XmlDocument doc = myParser.Parse(sql_file);
        XmlNodeList create_list = doc.SelectNodes("//Text[@Value='CREATE'] | //Text[@Value='create']");
        foreach (XmlNode create_node in create_list)
        {
            XmlNode next = create_node.NextSibling;
            if (next.Attributes[0].InnerText.ToLower() == "database")
            {
                for (int i = 0; i < 5; i++)
                {
                    next = next.NextSibling;
                    if (next.Attributes[0].InnerText.ToLower() != "if" &&
                       next.Attributes[0].InnerText.ToLower() != "not" &&
                       next.Attributes[0].InnerText.ToLower() != "exists" &&
                       next.Attributes[0].InnerText.ToLower() != "`")
                    {
                        database_name = next.Attributes[0].InnerText;
                    }
                }
            }
            else if (next.Attributes[0].InnerText.ToLower() == "table")
            {
                next = next.NextSibling.NextSibling;
                string table = next.Attributes[0].InnerText;

                //get first braces
                XmlNode brace_node = null;
                for (int i = 0; i < 5; i++)
                {
                    next = next.NextSibling;
                    if (next.Attributes[0].InnerText.ToLower() == "braces" )
                    {
                       brace_node = next;
                        break;
                    }
                }
                //get fields
                bool quote_toggle = true;
                ArrayList field_list = new ArrayList();

                foreach (XmlNode node in brace_node.ChildNodes)
                {
                    if (node.Attributes[0].InnerText == "`" && quote_toggle)
                    {
                        quote_toggle = false;
                        next = node.NextSibling;
                        Hashtable field = new Hashtable();
                        string field_name = next.Attributes[0].InnerText;
                        field["name"] = field_name;
                        next = next.NextSibling.NextSibling;
                        string field_type = next.Attributes[0].InnerText;
                        field["type"] = field_type;
                        field_list.Add(field);
                        next = next.NextSibling;
                        if (next.Attributes[0].InnerText == "BRACES")
                        {
                            string field_length = next.ChildNodes[0].Attributes[0].InnerText;
                            field["length"] = field_length;
                        }
                    }
                    else if (node.Attributes[0].InnerText == "`" && !quote_toggle)
                    {
                        quote_toggle = true;
                    }
                }

                tables[table] = field_list;
            }
        }

        //save in app xml
        Util util = new Util();
        util.SaveDatabaseSchema((Hashtable)HttpRuntime.Cache[Session.SessionID], DatabaseType.SelectedValue, DBConnectionString.Text, tables);
    }
开发者ID:dcolonvizi,项目名称:ViziAppsPortal,代码行数:79,代码来源:GetDatabaseInfo.aspx.cs


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