| 1 | public class Import |
| 2 | Inherits System.Web.UI.Page |
| 3 | protected WithEvents Alliance1 as DPM.Alliance |
| 4 | protected WithEvents Alliance2 as DPM.Alliance |
| 5 | protected WithEvents dlBM as System.Web.UI.WebControls.DataList |
| 6 | |
| 7 | private Sub Page_Load(ByVal sender as System.object, ByVal e as System.EventArgs) Handles MyBase.Load |
| 8 | |
| 9 | ' get the bookmark file into a string |
| 10 | Dim s as new System.IO.StreamReader(Server.MapPath("bookmark.htm")) |
| 11 | Dim bmrk as string |
| 12 | bmrk = s.ReadToEnd |
| 13 | s.Close() |
| 14 | |
| 15 | 'set up reqular expression and get matches |
| 16 | Dim r as new System.Text.RegularExpressions.Regex("(HREF=""(?<href>[^""]+)""[\w\W]*?ADD_DATE=""(?<add_date>[^""]+)""[\w\W]*?LAST_VISIT=""(?<last_visit>[^""]+)""[\w\W]*?LAST_MODIFIED=""(?<last_modified>[^""]+)""[\w\W]*?>(?<title>[^<]+)<)|(<H3[\w\W]*?>(?<folder>[^<]+)<)|(</DL>(?<back>[^p]+)p>)") |
| 17 | Dim ms as System.Text.RegularExpressions.MatchCollection = r.Matches(bmrk) |
| 18 | 'create holder for invidiular matches |
| 19 | Dim m as System.Text.RegularExpressions.Match |
| 20 | |
| 21 | 'create date time variable set to 1/1/1970. the start date for bookmark dates and times |
| 22 | Dim dt as new System.DateTime(1970, 1, 1) |
| 23 | 'create timespan to hold times from bookmark file |
| 24 | Dim ts as new System.TimeSpan() |
| 25 | |
| 26 | 'create holding table |
| 27 | Dim dtbl as new System.Data.DataTable("BookMarks") |
| 28 | dtbl.Columns.Add("Folder") |
| 29 | dtbl.Columns.Add("title") |
| 30 | dtbl.Columns.Add("href") |
| 31 | dtbl.Columns.Add("add_date") |
| 32 | dtbl.Columns.Add("last_visit") |
| 33 | dtbl.Columns.Add("last_modified") |
| 34 | |
| 35 | Dim rw as System.Data.DataRow |
| 36 | Dim path as string = "/" |
| 37 | 'loop through matches filling out table |
| 38 | for Each m in ms |
| 39 | ' if the folder match is not empty add it to the path |
| 40 | if m.Groups("folder").Value <> "" Then |
| 41 | path += m.Groups("folder").Value + "/" |
| 42 | End if |
| 43 | ' if the back match if not empty remove the last directory on the path |
| 44 | if m.Groups("back").Value <> "" Then |
| 45 | path = path.Substring(0, path.LastIndexOf("/")) |
| 46 | path = path.Substring(0, path.LastIndexOf("/") + 1) |
| 47 | End if |
| 48 | 'if title is not empty fill out record |
| 49 | if m.Groups("title").Value <> "" Then |
| 50 | rw = dtbl.NewRow() |
| 51 | rw("Folder") = path |
| 52 | rw("title") = m.Groups("title").Value |
| 53 | rw("href") = m.Groups("href").Value |
| 54 | 'convert time in seconds from bookmark file into ticks ( 100 nano seconds) |
| 55 | ts = new System.TimeSpan(Convert.ToDouble(m.Groups("add_date").Value) * 10000000) |
| 56 | 'add elapsed time to base date |
| 57 | rw("add_date") = dt.Add(ts) |
| 58 | 'convert time in seconds from bookmark file into ticks ( 100 nano seconds) |
| 59 | ts = new System.TimeSpan(Convert.ToDouble(m.Groups("last_visit").Value) * 10000000) |
| 60 | 'add elapsed time to base date |
| 61 | rw("last_visit") = dt.Add(ts) |
| 62 | 'convert time in seconds from bookmark file into ticks ( 100 nano seconds) |
| 63 | ts = new System.TimeSpan(Convert.ToDouble(m.Groups("last_modified").Value) * 10000000) |
| 64 | 'add elapsed time to base date |
| 65 | rw("last_modified") = dt.Add(ts) |
| 66 | dtbl.Rows.Add(rw) |
| 67 | End if |
| 68 | Next |
| 69 | |
| 70 | 'display results |
| 71 | dlBM.DataSource = dtbl |
| 72 | dlBM.DataBind() |
| 73 | |
| 74 | End Sub |
| 75 | |
| 76 | private Sub InitializeComponent() |
| 77 | |
| 78 | End Sub |
| 79 | End class |