예제 #1
0
        public static bool MoveStoreFrontFolders(this StoreFrontConfiguration config, string applicationPath, HttpServerUtilityBase server, string oldFolder, BaseController controller)
        {
            string oldFolderToMap = config.ClientVirtualDirectoryToMapToStoreFronts(applicationPath) + "/" + oldFolder;
            string newFolderToMap = config.StoreFrontVirtualDirectoryToMap(applicationPath);
            string oldFolderPath  = server.MapPath(oldFolderToMap);
            string newFolderPath  = server.MapPath(newFolderToMap);

            //default behavior is to move the old folder to the new name
            if (System.IO.Directory.Exists(oldFolderPath))
            {
                try
                {
                    System.IO.Directory.Move(oldFolderPath, newFolderPath);
                    if (controller != null)
                    {
                        controller.AddUserMessage("Store Front Folder Moved", "Store Front folder was moved from '" + oldFolderToMap.ToHtml() + "' to '" + newFolderToMap.ToHtml() + "'", UserMessageType.Success);
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    if (controller != null)
                    {
                        controller.AddUserMessage("Error Moving Client Folder!", "There was an error moving the client folder from '" + oldFolderToMap.ToHtml() + "' to '" + newFolderToMap.ToHtml() + "'. You will need to move the folder manually. Error: " + ex.Message, UserMessageType.Warning);
                    }
                    return(false);
                }
            }
            else
            {
                try
                {
                    bool result = config.CreateStoreFrontFolders(applicationPath, server);
                    if (result)
                    {
                        if (controller != null)
                        {
                            controller.AddUserMessage("Folders Created", "Store Front folders were created in : " + newFolderToMap.ToHtml(), UserMessageType.Info);
                        }
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    if (controller != null)
                    {
                        controller.AddUserMessage("Error Creating Store Front Folders!", "There was an error creating the Store Front folders in '" + newFolderToMap.ToHtml() + "'. You will need to create the folders manually. Error: " + ex.Message, UserMessageType.Warning);
                    }
                    return(false);
                }
            }
        }