or
| Public Class ContentEditorProvider |
| Inherits FileBrowserContentProvider |
| Private _LoadDirectory As String |
| Private _ImgDirectory As String |
| Private _DocumentsDirectory As String |
| Private _SecureDocumentsDirectory As String |
| Private _FullPermissions As PathPermissions = PathPermissions.Read Or PathPermissions.Delete Or PathPermissions.Upload |
| Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, ByVal selectedItemTag As String) |
| MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag) |
| End Sub |
| Public Overloads Overrides ReadOnly Property CanCreateDirectory() As Boolean |
| Get |
| Return True |
| End Get |
| End Property |
| Public Overrides Function CreateDirectory(ByVal path As String, ByVal name As String) As String |
| Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
| Directory.CreateDirectory(RealPath & "\" & name) |
| Return path & name |
| End Function |
| Public Overrides Function DeleteDirectory(ByVal path As String) As String |
| DeleteDirectory = IO.FileSystem.ResolveDirectory(path) |
| If Directory.Exists(DeleteDirectory) Then Directory.Delete(DeleteDirectory, True) |
| DeleteDirectory = String.Empty |
| Return DeleteDirectory |
| End Function |
| Public Overrides Function DeleteFile(ByVal path As String) As String |
| DeleteFile = IO.FileSystem.ResolveDirectory(path) |
| If File.Exists(DeleteFile) Then File.Delete(DeleteFile) |
| DeleteFile = String.Empty |
| Return DeleteFile |
| End Function |
| Public Overrides Function GetFile(ByVal url As String) As System.IO.Stream |
| Dim RealPath As String = IO.FileSystem.ResolveURL(url) |
| If System.IO.File.Exists(RealPath) = True Then |
| Dim File As Byte() = System.IO.File.ReadAllBytes(RealPath) |
| GetFile = New MemoryStream(File) |
| Else |
| GetFile = Nothing |
| End If |
| Return GetFile |
| End Function |
| Private Function GetName(ByVal path As String) As String |
| GetName = IIf(path = Nothing, String.Empty, path.Substring(path.LastIndexOf("\"c) + 1)) |
| Return GetName |
| End Function |
| Public Overrides Function GetFileName(ByVal url As String) As String |
| GetFileName = IIf(url = Nothing, String.Empty, url.Substring(url.LastIndexOf("/"c) + 1)) |
| Return GetFileName |
| End Function |
| Public Overrides Function GetPath(ByVal url As String) As String |
| GetPath = IO.FileSystem.ResolveURL(url) |
| Return GetPath |
| End Function |
| Public Function LoadFiles(ByVal Dir As System.IO.DirectoryInfo) As FileItem() |
| Dim xFiles As New List(Of FileItem) |
| For Each Fil As FileInfo In Dir.GetFiles() |
| Dim RealPath As String = Fil.FullName |
| Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
| Dim VirtualURL As String = IO.FileSystem.TranslateURL(RealPath) |
| xFiles.Add(New FileItem(Fil.Name, Fil.Extension, Fil.Length, VirtualPath, VirtualURL, VirtualPath, _FullPermissions)) |
| Next |
| Return xFiles.ToArray |
| End Function |
| Public Function LoadDirectories(ByVal Dir As System.IO.DirectoryInfo) As DirectoryItem() |
| Dim xDir As New List(Of DirectoryItem) |
| For Each SubDir As DirectoryInfo In Dir.GetDirectories() |
| Dim RealPath As String = SubDir.FullName |
| Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
| xDir.Add(New DirectoryItem(SubDir.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(SubDir), LoadDirectories(SubDir))) |
| Next |
| Return xDir.ToArray |
| End Function |
| Public Overrides Function ResolveDirectory(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
| Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
| Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
| Dim DirInfo As New DirectoryInfo(RealPath) |
| ResolveDirectory = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, IO.FileSystem.TranslateURL(VirtualPath), _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
| Return ResolveDirectory |
| End Function |
| Public Overrides Function ResolveRootDirectoryAsList(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem() |
| If path.StartsWith("/") = True Then path = IO.FileSystem.ResolveDirectory(path) |
| Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
| Dim DirInfo As New DirectoryInfo(RealPath) |
| ResolveRootDirectoryAsList = LoadDirectories(DirInfo) |
| Return ResolveRootDirectoryAsList |
| End Function |
| Public Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
| If path.StartsWith("/") = True Then path = IO.FileSystem.ResolveDirectory(path) |
| Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
| Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
| Dim DirInfo As New DirectoryInfo(RealPath) |
| 'HttpContext.Current.Response.Write(path & " - " & RealPath & " - " & VirtualPath) |
| 'HttpContext.Current.Response.End() |
| ResolveRootDirectoryAsTree = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
| Return ResolveRootDirectoryAsTree |
| End Function |
| Public Overrides Function StoreBitmap(ByVal bitmap As System.Drawing.Bitmap, ByVal url As String, ByVal format As System.Drawing.Imaging.ImageFormat) As String |
| Dim RealPath As String = IO.FileSystem.ResolveURL(url) |
| Dim newItemPath As String = IO.FileSystem.ResolveURL(url) |
| Dim name As String = GetName(newItemPath) |
| Dim _path As String = GetPath(newItemPath) |
| Dim tempFilePath As String = Path.GetTempFileName() |
| bitmap.Save(tempFilePath) |
| Dim content As Byte() |
| Using inputStream As FileStream = File.OpenRead(tempFilePath) |
| Dim size As Long = inputStream.Length |
| content = New Byte(size) {} |
| inputStream.Read(content, 0, CType(size, Integer)) |
| End Using |
| If File.Exists(tempFilePath) Then |
| File.Delete(tempFilePath) |
| End If |
| File.WriteAllBytes(RealPath, content) |
| Return url |
| End Function |
| Public Overloads Overrides Function StoreFile(ByVal file As Telerik.Web.UI.UploadedFile, ByVal path As String, ByVal name As String, ByVal ParamArray arguments() As String) As String |
| Dim FullName As String = IO.FileSystem.ResolveDirectory(path) & "\" & name |
| file.SaveAs(FullName) |
| Return path & name |
| End Function |
| End Class |
| Public Overrides Function CreateDirectory(ByVal path As String, ByVal name As String) As String |
| Dim RealPath As String = IO.FileSystem.ResolveDirectory(path) |
| Directory.CreateDirectory(RealPath & "\" & name) |
| Return path & "/" & name |
| End Function |
| Public Overrides Function ResolveRootDirectoryAsList(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem() |
| Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
| Dim DirInfo As New DirectoryInfo(RealPath) |
| ResolveRootDirectoryAsList = LoadDirectories(DirInfo) |
| Return ResolveRootDirectoryAsList |
| End Function |
| Public Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem |
| Dim RealPath As String = IO.FileSystem.ProcessDirectory(path) |
| Dim VirtualPath As String = IO.FileSystem.TranslateDirectory(RealPath) |
| Dim DirInfo As New DirectoryInfo(RealPath) |
| 'HttpContext.Current.Response.Write(path & " - " & RealPath & " - " & VirtualPath) |
| 'HttpContext.Current.Response.End() |
| ResolveRootDirectoryAsTree = New DirectoryItem(DirInfo.Name, VirtualPath, VirtualPath, VirtualPath, _FullPermissions, LoadFiles(DirInfo), LoadDirectories(DirInfo)) |
| Return ResolveRootDirectoryAsTree |
| End Function |
| Public Class FileSystem |
| Public Shared siteDomain As String = Configuration.Environment.SiteDomain |
| Public Shared siteRoot As String = Configuration.Environment.SiteRoot |
| Public Shared siteSecureDocuments As String = Configuration.Environment.SiteSecureDocuments |
| Public Shared dirRoot As String = Configuration.FileSystem.RootDirectory |
| Public Shared rgxDirRoot As String = Replace(dirRoot, "\", "\\") |
| Public Shared dirDomain As String = Configuration.FileSystem.PublicSiteDirectory |
| Public Shared rgxDirDomain As String = Replace(dirDomain, "\", "\\") |
| Public Shared dirSecureDocuments As String = Configuration.FileSystem.SecureDocumentsDirectory |
| Public Shared rgxDirSecureDocuments As String = Replace(dirSecureDocuments, "\", "\\") |
| Public Shared vfsSecureDocuments As String = Replace(siteSecureDocuments, "\", "/") |
| Public Shared Function QueryDirectory(ByVal path As String, Optional ByVal search As String = "*.*", Optional ByVal options As SearchOption = SearchOption.TopDirectoryOnly) As ListItemCollection |
| QueryDirectory = New ListItemCollection |
| Dim xDir As New DirectoryInfo(path) |
| path = Replace(path, "\", "\\") |
| For Each xFile As FileInfo In xDir.GetFiles(search, options) |
| QueryDirectory.Add(New ListItem(Replace(Regex.Replace(xFile.FullName, path, "", RegexOptions.IgnoreCase), "\", "/"))) |
| Next |
| Return QueryDirectory |
| End Function |
| Public Shared Function ProcessDirectory(ByVal path As String) As String |
| ProcessDirectory = path |
| Dim _TokenPattern As String = "\[\[(?<ConfigVar>(.)*?)\]\]" |
| Dim _RM As Match = Regex.Match(path, _TokenPattern) |
| Dim HasMatch As Boolean = False |
| HasMatch = _RM.Success |
| While HasMatch = True |
| Dim _Token As String = _RM.Groups("ConfigVar").Value |
| 'System.Web.HttpContext.Current.Response.Write(_Token & "<br />") |
| _Token = Configuration.AppSettings.GetSetting(_Token) |
| 'System.Web.HttpContext.Current.Response.Write(_Token) |
| 'System.Web.HttpContext.Current.Response.End() |
| ProcessDirectory = Replace(ProcessDirectory, _RM.Value, _Token) |
| _RM = _RM.NextMatch() |
| HasMatch = _RM.Success |
| End While |
| ProcessDirectory = Replace(ProcessDirectory, "/", "\") |
| Return ProcessDirectory |
| End Function |
| Public Shared Function ResolveDirectory(ByVal path As String) As String |
| ResolveDirectory = path |
| If InStrRev(ResolveDirectory, ".") > InStrRev(ResolveDirectory, "/") Then |
| ResolveDirectory = Left(ResolveDirectory, InStrRev(ResolveDirectory, "/")) |
| End If |
| If ResolveDirectory.StartsWith(dirRoot) = False Then |
| If ResolveDirectory.StartsWith(vfsSecureDocuments) = True Then |
| ResolveDirectory = Regex.Replace(ResolveDirectory, vfsSecureDocuments, dirRoot & dirSecureDocuments, RegexOptions.IgnoreCase) |
| ResolveDirectory = Replace(ResolveDirectory, "/", "\") |
| Else |
| ResolveDirectory = dirRoot & dirDomain & ResolveDirectory |
| ResolveDirectory = Replace(ResolveDirectory, "/", "\") |
| End If |
| End If |
| Return ResolveDirectory |
| End Function |
| Public Shared Function ResolveURL(ByVal Url As String) As String |
| If siteRoot.Length > 0 Then siteRoot = Left(siteRoot, siteRoot.Length - 1) |
| ResolveURL = Url |
| ResolveURL = Regex.Replace(ResolveURL, siteDomain & siteRoot, String.Empty, RegexOptions.IgnoreCase) |
| ResolveURL = ResolveDirectory(ResolveURL) |
| Return ResolveURL |
| End Function |
| Public Shared Function TranslateURL(ByVal path As String) As String |
| Dim strSiteRoot As String = siteRoot |
| If strSiteRoot.Length > 0 Then siteRoot = Left(strSiteRoot, siteRoot.Length - 1) |
| path = Regex.Replace(path, rgxDirRoot, "", RegexOptions.IgnoreCase) |
| path = Regex.Replace(path, rgxDirSecureDocuments, siteDomain & siteSecureDocuments, RegexOptions.IgnoreCase) |
| path = Regex.Replace(path, rgxDirDomain, siteDomain & strSiteRoot, RegexOptions.IgnoreCase) |
| path = Replace(path, "\", "/") |
| TranslateURL = path |
| Return TranslateURL |
| End Function |
| Public Shared Function TranslateDirectory(ByVal path As String) As String |
| path = Regex.Replace(path, rgxDirRoot, "", RegexOptions.IgnoreCase) |
| path = Regex.Replace(path, rgxDirDomain, "", RegexOptions.IgnoreCase) |
| path = Regex.Replace(path, rgxDirSecureDocuments, vfsSecureDocuments, RegexOptions.IgnoreCase) |
| path = Replace(path, "\", "/") |
| TranslateDirectory = path |
| Return TranslateDirectory |
| End Function |
| End Class |


| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadListViewTissue"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadListViewTissue" LoadingPanelID="RadAjaxLoadingPanel1" /> |
| <telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" LoadingPanelID="RadAjaxLoadingPanel1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" > |
| </telerik:RadAjaxLoadingPanel> |
| <telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="0" HideEvent="LeaveToolTip" |
| Width="400px" Height="170px" runat="server" |
| OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element" ShowDelay="500" |
| Animation="Fade" Sticky="True"> |
| </telerik:RadToolTipManager> |
| <telerik:RadFormDecorator ID="RadFormDecorator1" Runat="server" /> |
| <telerik:RadListView ID="RadListViewTissue" runat="server" |
| onitemdatabound="RadListViewTissue_ItemDataBound" DataKeyNames="contentID" |
| ItemPlaceholderID="TissueItemContainer" |
| onselectedindexchanged="RadListViewTissue_SelectedIndexChanged" |
| AllowPaging="true" onneeddatasource="RadListViewTissue_NeedDataSource" |
| onpageindexchanged="RadListViewTissue_PageIndexChanged" > |
| protected void Page_Load(object sender, EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| RadListViewTissue.DataSource = getTissueList(); |
| RadListViewTissue.DataBind(); |
| } |
| } |
| protected DataTable getTissueList() |
| { |
| // .. |
| DataTable dtTissue = (DataTable)Session[bufferedTissueList]; |
| // .. |
| return dtTissue; |
| } |
| protected void RadListViewTissue_PageIndexChanged(object sender, RadListViewPageChangedEventArgs e) |
| { |
| if (e.CommandName == "Sort" || e.CommandName == "Page") |
| { |
| RadToolTipManager1.TargetControls.Clear(); |
| } |
| RadListViewTissue.CurrentPageIndex = e.NewPageIndex; |
| RadListViewTissue.DataSource = getTissueList(); |
| RadListViewTissue.DataBind(); |
| } |
| protected void RadListViewTissue_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e) |
| { |
| RadListViewTissue.DataSource = getTissueList(); |
| } |
| protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args) |
| { |
| this.UpdateToolTip(args.Value, args.UpdatePanel); |
| } |
| private void UpdateToolTip(string elementID, UpdatePanel panel) |
| { |
| Control ctrl = Page.LoadControl("~/Modules/IWC_FabricDetail.ascx"); |
| panel.ContentTemplateContainer.Controls.Add(ctrl); |
| IWC_FabricDetail details = (IWC_FabricDetail)ctrl; |
| details.ContentID = elementID; |
| } |
| protected void RadListViewTissue_ItemDataBound(object sender, RadListViewItemEventArgs e) |
| { |
| if (e.Item.ItemType == RadListViewItemType.DataItem || e.Item.ItemType == RadListViewItemType.AlternatingItem) |
| { |
| Control target = e.Item.FindControl("thumbImage"); |
| if (!Object.Equals(target, null)) |
| { |
| if (!Object.Equals(this.RadToolTipManager1, null)) |
| { |
| // add to tooltip manager |
| string keyValue = (e.Item as RadListViewDataItem).GetDataKeyValue("contentID").ToString(); |
| this.RadToolTipManager1.TargetControls.Add(target.ClientID, keyValue, true); |
| } |
| } |
| } |
| } |
| Dim strValue1 As String |
| Dim strValue2 As String |
| Dim strResult As String |
| Dim diff As New Diff.DiffEngine |
| ' ...code here assigns long XML strings to strvalue1 and strvalue2; srvalue1's length = 93145; strvalue2's length = 113236... |
| strResult = diff.GetDiffs(strValue2, strValue1) |