Ejemplo n.º 1
0
 /// <summary>
 /// 开始更新网址数据
 /// </summary>
 public void LoadWebsiteXML()
 {
     try
     {
         string path = Application.StartupPath + @"\XML\WebsiteList.xml";
         if (!File.Exists(path)) return;
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(path);
         XmlNodeList tabNodes = xmlDoc.SelectNodes("WebsiteList/TabType");
         if (tabNodes != null && tabNodes.Count > 0)
         {
             //清空网址表
             dmData.ClearWebsiteData();
             string type = string.Empty;
             Website website = null;
             foreach (XmlNode node in tabNodes)
             {
                 type = node.Attributes[1].Value;
                 foreach (XmlNode cNode in node.ChildNodes)
                 {
                     website = new Website();
                     website.Name = cNode.Attributes[0].Value;
                     website.Type = type;
                     website.Index = cNode.Attributes[1].Value;
                     website.Url = cNode.Attributes[2].Value;
                     website.IconPath = cNode.Attributes[3].Value;
                     //插入数据库
                     dmData.InsertWebsiteData(website);
                 }
             }
         }
     }
     catch(Exception ex)
     {
         log.WriteLog(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        public int InsertWebsiteData(Website website)
        {
            int result = 0;
            try
            {
                string sql = "INSERT INTO t_website(WebOrder,Type,Name,URL)values(@WebOrder,@Type,@Name,@URL)";

                SQLiteParameter[] parameters = new SQLiteParameter[]{
                                         new SQLiteParameter("@WebOrder",website.Index),
                                         new SQLiteParameter("@Type",website.Type),
                                         new SQLiteParameter("@Name",website.Name),
                                         new SQLiteParameter("@URL",website.Url)
                                         };
                SqlAction action = new SqlAction();
                result = action.IntQuery(sql, parameters);
            }
            catch (Exception ex)
            {
                log.WriteLog(ex.ToString());
            }
            return result;
        }