Esempio n. 1
0
        public ActionResult SeekAndDestroyConfirmed(int id, bool?deleteEventLogs, bool?deleteFolders)
        {
            StoreFront target = GStoreDb.StoreFronts.FindById(id);

            if (target == null)
            {
                //client not found, already deleted? overpost?
                AddUserMessage("Store Front Delete Error!", "Store Front not found Store Front Id: " + id + "<br/>Store Front may have been deleted by another user.", UserMessageType.Danger);
                return(RedirectToAction("Index"));
            }
            StoreFrontConfiguration config = target.CurrentConfigOrAny();

            string name        = config == null ? "id [" + target.StoreFrontId + "]" : config.Name;
            string folder      = config == null ? null : config.Folder;
            string folderToMap = config == null ? null : config.StoreFrontVirtualDirectoryToMap(Request.ApplicationPath);

            try
            {
                string report = SeekAndDestroyChildRecordsNoSave(target, deleteEventLogs ?? true, deleteFolders ?? true);
                AddUserMessage("Seek and Destroy report.", report.ToHtmlLines(), UserMessageType.Info);
                bool deleted = GStoreDb.StoreFronts.DeleteById(id);
                GStoreDb.SaveChangesEx(false, false, false, false);
                if (deleted)
                {
                    AddUserMessage("Store Front Deleted", "Store Front '" + name.ToHtml() + "' [" + id + "] was deleted successfully.", UserMessageType.Success);
                }
            }
            catch (Exception ex)
            {
                AddUserMessage("Store Front Seek and Destroy Error!", "Error with Seek and Destroy for Store Front '" + name.ToHtml() + "' [" + id + "].<br/>This Store Front may have child records.<br/>Exception:" + ex.ToString(), UserMessageType.Danger);
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 2
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);
                }
            }
        }