/// <summary>
    /// Performs the Move of Copy action.
    /// </summary>
    public void PerformAction()
    {
        if (!IsLoad)
        {
            if (CheckPermissions())
            {
                pnlInfo.Visible  = true;
                pnlEmpty.Visible = false;

                if (CopyMoveAction.ToLowerCSafe() == "copy")
                {
                    ctlAsyncLog.TitleText = GetString("media.copy.startcopy");
                }
                else
                {
                    ctlAsyncLog.TitleText = GetString("media.move.startmove");
                }
                RunAsync(PerformAction);
            }
        }
        else
        {
            pnlInfo.Visible  = false;
            pnlEmpty.Visible = true;
            lblEmpty.Text    = GetString("media.copymove.noselect");
        }
    }
Example #2
0
    /// <summary>
    /// Performes the Move of Copy action.
    /// </summary>
    public void PerformAction()
    {
        if (!IsLoad)
        {
            if (CheckPermissions())
            {
                pnlInfo.Visible  = true;
                pnlEmpty.Visible = false;

                if (CopyMoveAction.ToLowerCSafe() == "copy")
                {
                    titleElemAsync.TitleText  = GetString("media.copy.startcopy");
                    titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_MediaLibrary/foldercopy.png");
                }
                else
                {
                    titleElemAsync.TitleText  = GetString("media.move.startmove");
                    titleElemAsync.TitleImage = GetImageUrl("CMSModules/CMS_MediaLibrary/foldermove.png");
                }
                RunAsync(PerformAction);
            }
        }
        else
        {
            pnlInfo.Visible  = false;
            pnlEmpty.Visible = true;
            lblEmpty.Text    = GetString("media.copymove.noselect");
        }
    }
    private void ctlAsyncLog_OnCancel(object sender, EventArgs e)
    {
        CurrentInfo = (CopyMoveAction.ToLowerCSafe() == "copy") ? GetString("media.copy.canceled") : GetString("media.move.canceled");
        AddLog(CurrentInfo);

        pnlLog.Visible  = false;
        pnlInfo.Visible = true;

        AddScript("var __pendingCallbacks = new Array();DestroyLog();");

        ShowConfirmation(CurrentInfo);
        HandlePossibleErrors();
    }
    /// <summary>
    /// Performs action itself.
    /// </summary>
    /// <param name="origDBFilePath">Path of the file specified in DB</param>
    /// <param name="newDBFilePath">New path of the file being inserted into DB</param>
    private void CopyMove(string origDBFilePath, string newDBFilePath)
    {
        switch (CopyMoveAction.ToLowerCSafe())
        {
        case "move":
            MediaFileInfoProvider.MoveMediaFile(SiteContext.CurrentSiteName, MediaLibraryID, origDBFilePath, newDBFilePath);
            break;

        case "copy":
            MediaFileInfoProvider.CopyMediaFile(SiteContext.CurrentSiteName, MediaLibraryID, origDBFilePath, newDBFilePath, false, CurrentUser.UserID);
            break;
        }
    }
 /// <summary>
 /// Check permissions for selected library.
 /// </summary>
 private bool CheckPermissions()
 {
     // If mFiles is empty handle directory copy/move
     if (String.IsNullOrEmpty(Files) && !mAllFiles)
     {
         if (CopyMoveAction.ToLowerCSafe().Trim() == "copy")
         {
             // Check 'Folder create' permission
             if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "foldercreate"))
             {
                 ShowError(MediaLibraryHelper.GetAccessDeniedMessage("foldercreate"));
                 return(false);
             }
         }
         else
         {
             // Check 'Folder modify' permission
             if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "foldermodify"))
             {
                 ShowError(MediaLibraryHelper.GetAccessDeniedMessage("foldermodify"));
                 return(false);
             }
         }
     }
     else
     {
         if (CopyMoveAction.ToLowerCSafe().Trim() == "copy")
         {
             // Check 'File create' permission
             if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "filecreate"))
             {
                 ShowError(MediaLibraryHelper.GetAccessDeniedMessage("filecreate"));
                 return(false);
             }
         }
         else
         {
             // Check 'File modify' permission
             if (!MediaLibraryInfoProvider.IsUserAuthorizedPerLibrary(LibraryInfo, "filemodify"))
             {
                 ShowError(MediaLibraryHelper.GetAccessDeniedMessage("filemodify"));
                 return(false);
             }
         }
     }
     return(true);
 }
    /// <summary>
    /// Moves document.
    /// </summary>
    private void PerformAction(object parameter)
    {
        AddLog(GetString(CopyMoveAction.ToLowerCSafe() == "copy" ? "media.copy.startcopy" : "media.move.startmove"));

        if (LibraryInfo != null)
        {
            // Library path (used in recursive copy process)
            string libPath = MediaLibraryInfoProvider.GetMediaLibraryFolderPath(SiteContext.CurrentSiteName, LibraryInfo.LibraryFolder);

            // Ensure libPath is in original path type
            libPath = Path.GetFullPath(libPath);

            // Original path on disk from query
            string origPath = Path.GetFullPath(DirectoryHelper.CombinePath(libPath, FolderPath));

            // Original path in DB
            string origDBPath = Path.EnsureForwardSlashes(FolderPath);

            // New path in DB
            string newDBPath;

            AddLog(NewPath);

            // Check if requested folder is in library root folder
            if (!origPath.StartsWithCSafe(libPath, true))
            {
                CurrentError = GetString("media.folder.nolibrary");
                AddLog(CurrentError);
                return;
            }

            string origFolderName = Path.GetFileName(origPath);

            if ((String.IsNullOrEmpty(Files) && !mAllFiles) && string.IsNullOrEmpty(origFolderName))
            {
                NewPath = NewPath + "\\" + LibraryInfo.LibraryFolder;
                NewPath = NewPath.Trim('\\');
            }

            // New path on disk
            string newPath = NewPath;

            // Process current folder copy/move action
            if (String.IsNullOrEmpty(Files) && !AllFiles)
            {
                newPath = Path.EnsureEndSlash(newPath) + origFolderName;
                newPath = newPath.Trim('\\');

                // Check if moving into same folder
                if ((CopyMoveAction.ToLowerCSafe() == "move") && (newPath == FolderPath))
                {
                    CurrentError = GetString("media.move.foldermove");
                    AddLog(CurrentError);
                    return;
                }

                // Error if moving folder into itself
                string newRootPath           = Path.GetDirectoryName(newPath).Trim();
                string newSubRootFolder      = Path.GetFileName(newPath).ToLowerCSafe().Trim();
                string originalSubRootFolder = Path.GetFileName(FolderPath).ToLowerCSafe().Trim();
                if (String.IsNullOrEmpty(Files) && (CopyMoveAction.ToLowerCSafe() == "move") && newPath.StartsWithCSafe(Path.EnsureEndSlash(FolderPath)) &&
                    (originalSubRootFolder == newSubRootFolder) && (newRootPath == FolderPath))
                {
                    CurrentError = GetString("media.move.movetoitself");
                    AddLog(CurrentError);
                    return;
                }

                try
                {
                    // Get unique path for copy or move
                    string path = Path.GetFullPath(DirectoryHelper.CombinePath(libPath, newPath));
                    path    = MediaLibraryHelper.EnsureUniqueDirectory(path);
                    newPath = path.Remove(0, (libPath.Length + 1));

                    // Get new DB path
                    newDBPath = Path.EnsureForwardSlashes(newPath.Replace(Path.EnsureEndSlash(libPath), ""));
                }
                catch (Exception ex)
                {
                    CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                    Service.Resolve <IEventLogService>().LogException("MediaFolder", CopyMoveAction, ex);
                    AddLog(CurrentError);
                    return;
                }
            }
            else
            {
                origDBPath = Path.EnsureForwardSlashes(FolderPath);
                newDBPath  = Path.EnsureForwardSlashes(newPath.Replace(libPath, "")).Trim('/');
            }

            // Error if moving folder into its subfolder
            if ((String.IsNullOrEmpty(Files) && !AllFiles) && (CopyMoveAction.ToLowerCSafe() == "move") && newPath.StartsWithCSafe(Path.EnsureEndSlash(FolderPath)))
            {
                CurrentError = GetString("media.move.parenttochild");
                AddLog(CurrentError);
                return;
            }

            // Error if moving files into same directory
            if ((!String.IsNullOrEmpty(Files) || AllFiles) && (CopyMoveAction.ToLowerCSafe() == "move") && (newPath.TrimEnd('\\') == FolderPath.TrimEnd('\\')))
            {
                CurrentError = GetString("media.move.fileserror");
                AddLog(CurrentError);
                return;
            }

            NewPath      = newPath;
            AsyncNewPath = newPath;

            // If mFiles is empty handle directory copy/move
            if (String.IsNullOrEmpty(Files) && !mAllFiles)
            {
                try
                {
                    switch (CopyMoveAction.ToLowerCSafe())
                    {
                    case "move":
                        MediaLibraryInfoProvider.MoveMediaLibraryFolder(SiteContext.CurrentSiteName, MediaLibraryID, origDBPath, newDBPath);
                        break;

                    case "copy":
                        MediaLibraryInfoProvider.CopyMediaLibraryFolder(SiteContext.CurrentSiteName, MediaLibraryID, origDBPath, newDBPath, CurrentUser.UserID);
                        break;
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    CurrentError = GetString("general.erroroccurred") + " " + GetString("media.security.accessdenied");
                    Service.Resolve <IEventLogService>().LogException("MediaFolder", CopyMoveAction, ex);
                    AddLog(CurrentError);
                }
                catch (ThreadAbortException ex)
                {
                    if (CMSThread.Stopped(ex))
                    {
                        // When canceled
                        CurrentInfo = GetString("general.actioncanceled");
                        AddLog(CurrentInfo);
                    }
                    else
                    {
                        // Log error
                        CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                        Service.Resolve <IEventLogService>().LogException("MediaFolder", CopyMoveAction, ex);
                        AddLog(CurrentError);
                    }
                }
                catch (Exception ex)
                {
                    CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                    Service.Resolve <IEventLogService>().LogException("MediaFolder", CopyMoveAction, ex);
                    AddLog(CurrentError);
                }
            }
            else
            {
                string origDBFilePath;
                string newDBFilePath;

                if (!mAllFiles)
                {
                    try
                    {
                        string[] files = Files.Split('|');
                        foreach (string filename in files)
                        {
                            origDBFilePath = (string.IsNullOrEmpty(origDBPath)) ? filename : origDBPath + "/" + filename;
                            newDBFilePath  = (string.IsNullOrEmpty(newDBPath)) ? filename : newDBPath + "/" + filename;
                            AddLog(filename);
                            CopyMove(origDBFilePath, newDBFilePath);
                        }
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        CurrentError = GetString("general.erroroccurred") + " " + GetString("media.security.accessdenied");
                        Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                        AddLog(CurrentError);
                    }
                    catch (ThreadAbortException ex)
                    {
                        if (CMSThread.Stopped(ex))
                        {
                            // When canceled
                            CurrentInfo = GetString("general.actioncanceled");
                            AddLog(CurrentInfo);
                        }
                        else
                        {
                            // Log error
                            CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                            Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                            AddLog(CurrentError);
                        }
                    }
                    catch (Exception ex)
                    {
                        CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                        Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                        AddLog(CurrentError);
                    }
                }
                else
                {
                    var fileNames = GetFileNames().ToList();
                    if (!fileNames.Any())
                    {
                        return;
                    }

                    foreach (string fileName in fileNames)
                    {
                        AddLog(fileName);

                        origDBFilePath = (string.IsNullOrEmpty(origDBPath)) ? fileName : origDBPath + "/" + fileName;
                        newDBFilePath  = (string.IsNullOrEmpty(newDBPath)) ? fileName : newDBPath + "/" + fileName;

                        try
                        {
                            CopyMove(origDBFilePath, newDBFilePath);
                        }
                        catch (UnauthorizedAccessException ex)
                        {
                            CurrentError = GetString("general.erroroccurred") + " " + GetString("media.security.accessdenied");
                            Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                            AddLog(CurrentError);
                            return;
                        }
                        catch (ThreadAbortException ex)
                        {
                            if (CMSThread.Stopped(ex))
                            {
                                // When canceled
                                CurrentInfo = GetString("general.actioncanceled");
                                AddLog(CurrentInfo);
                            }
                            else
                            {
                                // Log error
                                CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                                Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                                AddLog(CurrentError);
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                            Service.Resolve <IEventLogService>().LogException("MediaFile", CopyMoveAction, ex);
                            AddLog(CurrentError);
                            return;
                        }
                    }
                }
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!QueryHelper.ValidateHash("hash"))
        {
            return;
        }

        // Check if hashtable containing dialog parameters is not empty
        if ((Parameters == null) || (Parameters.Count == 0))
        {
            return;
        }

        // Initialize events
        ctlAsyncLog.OnFinished += ctlAsyncLog_OnFinished;
        ctlAsyncLog.OnError    += ctlAsyncLog_OnError;
        ctlAsyncLog.OnCancel   += ctlAsyncLog_OnCancel;

        // Get the source node
        MediaLibraryID = ValidationHelper.GetInteger(Parameters["libraryid"], 0);
        CopyMoveAction = ValidationHelper.GetString(Parameters["action"], string.Empty);
        FolderPath     = Path.EnsureSlashes(ValidationHelper.GetString(Parameters["path"], ""));
        Files          = ValidationHelper.GetString(Parameters["files"], "").Trim('|');
        RootFolder     = MediaLibraryHelper.GetMediaRootFolderPath(SiteContext.CurrentSiteName);
        AllFiles       = ValidationHelper.GetBoolean(Parameters["allFiles"], false);
        NewPath        = Path.EnsureSlashes(ValidationHelper.GetString(Parameters["newpath"], ""));

        // Target folder
        string tarFolder = NewPath;

        if (string.IsNullOrEmpty(tarFolder) && (LibraryInfo != null))
        {
            tarFolder = LibraryInfo.LibraryFolder + " (root)";
        }
        lblFolder.Text = tarFolder;

        if (!IsLoad)
        {
            if (AllFiles || String.IsNullOrEmpty(Files))
            {
                if (AllFiles)
                {
                    lblFilesToCopy.ResourceString = "media.folder.filestoall" + CopyMoveAction.ToLowerCSafe();
                }
                else
                {
                    lblFilesToCopy.ResourceString = "media.folder.folderto" + CopyMoveAction.ToLowerCSafe();
                }

                // Source folder
                string srcFolder = FolderPath;
                if (string.IsNullOrEmpty(srcFolder) && (LibraryInfo != null))
                {
                    srcFolder = LibraryInfo.LibraryFolder + "&nbsp;(root)";
                }
                lblFileList.Text = HTMLHelper.HTMLEncode(srcFolder);
            }
            else
            {
                lblFilesToCopy.ResourceString = "media.folder.filesto" + CopyMoveAction.ToLowerCSafe();
                string[] fileList = Files.Split('|');
                foreach (string file in fileList)
                {
                    lblFileList.Text += HTMLHelper.HTMLEncode(DirectoryHelper.CombinePath(FolderPath.TrimEnd('\\'), file)) + "<br />";
                }
            }

            if (!RequestHelper.IsCallback() && !RequestHelper.IsPostBack())
            {
                bool performAction = ValidationHelper.GetBoolean(Parameters["performaction"], false);
                if (performAction)
                {
                    // Perform Move or Copy
                    PerformAction();
                }
            }

            pnlInfo.Visible  = true;
            pnlEmpty.Visible = false;
        }
        else
        {
            pnlInfo.Visible  = false;
            pnlEmpty.Visible = true;
            lblEmpty.Text    = GetString("media.copymove.select");

            // Disable New folder button
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "DisableNewFolderOnLoad", ScriptHelper.GetScript("if ((window.parent != null) && window.parent.DisableNewFolderBtn) { window.parent.DisableNewFolderBtn(); }"));
        }
    }
Example #8
0
    /// <summary>
    /// Moves document.
    /// </summary>
    private void PerformAction(object parameter)
    {
        if (CopyMoveAction.ToLowerCSafe() == "copy")
        {
            AddLog(GetString("media.copy.startcopy"));
        }
        else
        {
            AddLog(GetString("media.move.startmove"));
        }

        if (LibraryInfo != null)
        {
            // Library path (used in recursive copy process)
            string libPath = MediaLibraryInfoProvider.GetMediaLibraryFolderPath(CMSContext.CurrentSiteName, LibraryInfo.LibraryFolder);

            // Ensure libPath is in original path type
            libPath = Path.GetFullPath(libPath);

            // Original path on disk from query
            string origPath = Path.GetFullPath(DirectoryHelper.CombinePath(libPath, FolderPath));

            // New path on disk
            string newPath = null;

            // Original path in DB
            string origDBPath = MediaLibraryHelper.EnsurePath(FolderPath);

            // New path in DB
            string newDBPath = null;

            AddLog(NewPath);

            // Check if requested folder is in library root folder
            if (!origPath.StartsWithCSafe(libPath, true))
            {
                CurrentError = GetString("media.folder.nolibrary");
                AddLog(CurrentError);
                return;
            }

            string origFolderName = Path.GetFileName(origPath);

            if ((String.IsNullOrEmpty(Files) && !mAllFiles) && string.IsNullOrEmpty(origFolderName))
            {
                NewPath = NewPath + "\\" + LibraryInfo.LibraryFolder;
                NewPath = NewPath.Trim('\\');
            }
            newPath = NewPath;

            // Process current folder copy/move action
            if (String.IsNullOrEmpty(Files) && !AllFiles)
            {
                newPath = newPath.TrimEnd('\\') + '\\' + origFolderName;
                newPath = newPath.Trim('\\');

                // Check if moving into same folder
                if ((CopyMoveAction.ToLowerCSafe() == "move") && (newPath == FolderPath))
                {
                    CurrentError = GetString("media.move.foldermove");
                    AddLog(CurrentError);
                    return;
                }

                // Error if moving folder into itself
                string newRootPath           = Path.GetDirectoryName(newPath).Trim();
                string newSubRootFolder      = Path.GetFileName(newPath).ToLowerCSafe().Trim();
                string originalSubRootFolder = Path.GetFileName(FolderPath).ToLowerCSafe().Trim();
                if (String.IsNullOrEmpty(Files) && (CopyMoveAction.ToLowerCSafe() == "move") && newPath.StartsWithCSafe(DirectoryHelper.EnsurePathBackSlash(FolderPath)) &&
                    (originalSubRootFolder == newSubRootFolder) && (newRootPath == FolderPath))
                {
                    CurrentError = GetString("media.move.movetoitself");
                    AddLog(CurrentError);
                    return;
                }

                // Get unique path for copy or move
                string path = Path.GetFullPath(DirectoryHelper.CombinePath(libPath, newPath));
                path    = MediaLibraryHelper.EnsureUniqueDirectory(path);
                newPath = path.Remove(0, (libPath.Length + 1));

                // Get new DB path
                newDBPath = MediaLibraryHelper.EnsurePath(newPath.Replace(DirectoryHelper.EnsurePathBackSlash(libPath), ""));
            }
            else
            {
                origDBPath = MediaLibraryHelper.EnsurePath(FolderPath);
                newDBPath  = MediaLibraryHelper.EnsurePath(newPath.Replace(libPath, "")).Trim('/');
            }

            // Error if moving folder into its subfolder
            if ((String.IsNullOrEmpty(Files) && !AllFiles) && (CopyMoveAction.ToLowerCSafe() == "move") && newPath.StartsWithCSafe(DirectoryHelper.EnsurePathBackSlash(FolderPath)))
            {
                CurrentError = GetString("media.move.parenttochild");
                AddLog(CurrentError);
                return;
            }

            // Error if moving files into same directory
            if ((!String.IsNullOrEmpty(Files) || AllFiles) && (CopyMoveAction.ToLowerCSafe() == "move") && (newPath.TrimEnd('\\') == FolderPath.TrimEnd('\\')))
            {
                CurrentError = GetString("media.move.fileserror");
                AddLog(CurrentError);
                return;
            }

            NewPath       = newPath;
            refreshScript = @"
var topWin = GetTop();
if (topWin) {
    if ((topWin.opener) && (typeof(topWin.opener.RefreshLibrary) != 'undefined')) {
        topWin.opener.RefreshLibrary(" + ScriptHelper.GetString(NewPath.Replace('\\', '|')) + @");
    } 
    else if ((topWin.wopener) && (typeof(topWin.wopener.RefreshLibrary) != 'undefined')) { 
        topWin.wopener.RefreshLibrary(" + ScriptHelper.GetString(NewPath.Replace('\\', '|')) + @"); 
    } 
    CloseDialog();
}";

            // If mFiles is empty handle directory copy/move
            if (String.IsNullOrEmpty(Files) && !mAllFiles)
            {
                try
                {
                    switch (CopyMoveAction.ToLowerCSafe())
                    {
                    case "move":
                        MediaLibraryInfoProvider.MoveMediaLibraryFolder(CMSContext.CurrentSiteName, MediaLibraryID, origDBPath, newDBPath, false);
                        break;

                    case "copy":
                        MediaLibraryInfoProvider.CopyMediaLibraryFolder(CMSContext.CurrentSiteName, MediaLibraryID, origDBPath, newDBPath, false, CurrentUser.UserID);
                        break;
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    CurrentError = GetString("general.erroroccurred") + " " + GetString("media.security.accessdenied");
                    EventLogProvider ev = new EventLogProvider();
                    ev.LogEvent("MediaFolder", CopyMoveAction, ex);
                    AddLog(CurrentError);
                    return;
                }
                catch (ThreadAbortException ex)
                {
                    string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
                    if (state == CMSThread.ABORT_REASON_STOP)
                    {
                        // When canceled
                        CurrentInfo = GetString("general.actioncanceled");
                        AddLog(CurrentInfo);
                    }
                    else
                    {
                        // Log error
                        CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("MediaFolder", CopyMoveAction, ex);
                        AddLog(CurrentError);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                    EventLogProvider ev = new EventLogProvider();
                    ev.LogEvent("MediaFolder", CopyMoveAction, ex);
                    AddLog(CurrentError);
                    return;
                }
            }
            else
            {
                string origDBFilePath = null;
                string newDBFilePath  = null;

                if (!mAllFiles)
                {
                    try
                    {
                        string[] files = Files.Split('|');
                        foreach (string filename in files)
                        {
                            origDBFilePath = (string.IsNullOrEmpty(origDBPath)) ? filename : origDBPath + "/" + filename;
                            newDBFilePath  = (string.IsNullOrEmpty(newDBPath)) ? filename : newDBPath + "/" + filename;
                            AddLog(filename);
                            CopyMove(origDBFilePath, newDBFilePath);
                        }
                    }
                    catch (UnauthorizedAccessException ex)
                    {
                        CurrentError = GetString("general.erroroccurred") + " " + ResHelper.GetString("media.security.accessdenied");
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("MediaFile", CopyMoveAction, ex);
                        AddLog(CurrentError);
                        return;
                    }
                    catch (ThreadAbortException ex)
                    {
                        string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
                        if (state == CMSThread.ABORT_REASON_STOP)
                        {
                            // When canceled
                            CurrentInfo = GetString("general.actioncanceled");
                            AddLog(CurrentInfo);
                        }
                        else
                        {
                            // Log error
                            CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                            EventLogProvider ev = new EventLogProvider();
                            ev.LogEvent("MediaFile", CopyMoveAction, ex);
                            AddLog(CurrentError);
                            return;
                        }
                    }
                    catch (Exception ex)
                    {
                        CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                        EventLogProvider ev = new EventLogProvider();
                        ev.LogEvent("MediaFile", CopyMoveAction, ex);
                        AddLog(CurrentError);
                        return;
                    }
                }
                else
                {
                    HttpContext context = (parameter as HttpContext);
                    if (context != null)
                    {
                        HttpContext.Current = context;

                        DataSet files = GetFileSystemDataSource();
                        if (!DataHelper.IsEmpty(files))
                        {
                            foreach (DataRow file in files.Tables[0].Rows)
                            {
                                string fileName = ValidationHelper.GetString(file["FileName"], "");

                                AddLog(fileName);

                                origDBFilePath = (string.IsNullOrEmpty(origDBPath)) ? fileName : origDBPath + "/" + fileName;
                                newDBFilePath  = (string.IsNullOrEmpty(newDBPath)) ? fileName : newDBPath + "/" + fileName;

                                // Clear current httpcontext for CopyMove action in threat
                                HttpContext.Current = null;

                                try
                                {
                                    CopyMove(origDBFilePath, newDBFilePath);
                                }
                                catch (UnauthorizedAccessException ex)
                                {
                                    CurrentError = GetString("general.erroroccurred") + " " + ResHelper.GetString("media.security.accessdenied");
                                    EventLogProvider ev = new EventLogProvider();
                                    ev.LogEvent("MediaFile", CopyMoveAction, ex);
                                    AddLog(CurrentError);
                                    return;
                                }
                                catch (ThreadAbortException ex)
                                {
                                    string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
                                    if (state == CMSThread.ABORT_REASON_STOP)
                                    {
                                        // When canceled
                                        CurrentInfo = GetString("general.actioncanceled");
                                        AddLog(CurrentInfo);
                                    }
                                    else
                                    {
                                        // Log error
                                        CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                                        EventLogProvider ev = new EventLogProvider();
                                        ev.LogEvent("MediaFile", CopyMoveAction, ex);
                                        AddLog(CurrentError);
                                        return;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    CurrentError = GetString("general.erroroccurred") + " " + ex.Message;
                                    EventLogProvider ev = new EventLogProvider();
                                    ev.LogEvent("MediaFile", CopyMoveAction, ex);
                                    AddLog(CurrentError);
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
    }