コード例 #1
0
        void CreateScene(ContentBrowser.Item item)
        {
            try
            {
                var prefix = VirtualDirectory.Exists("Scenes") ? @"Scenes\" : "";

                string fileName = null;
                for (int n = 1; ; n++)
                {
                    string f = prefix + string.Format(@"New{0}.scene", n > 1 ? n.ToString() : "");
                    if (!VirtualFile.Exists(f))
                    {
                        fileName = f;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(fileName))
                {
                    var realFileName = VirtualPathUtility.GetRealPathByVirtual(fileName);

                    var    template   = (Component_Scene.NewObjectSettingsScene.TemplateClass)item.Tag;
                    string name       = template.Name + ".scene";
                    var    sourceFile = VirtualPathUtility.GetRealPathByVirtual(@"Base\Tools\NewResourceTemplates\" + name);

                    //copy scene file

                    var text = File.ReadAllText(sourceFile);

                    var directoryName = Path.GetDirectoryName(realFileName);
                    if (!Directory.Exists(directoryName))
                    {
                        Directory.CreateDirectory(directoryName);
                    }

                    File.WriteAllText(realFileName, text);

                    //copy additional folder if exist
                    var sourceFolderPath = sourceFile + "_Files";
                    if (Directory.Exists(sourceFolderPath))
                    {
                        var destFolderPath = realFileName + "_Files";
                        IOUtility.CopyDirectory(sourceFolderPath, destFolderPath);
                    }

                    EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(new string[] { realFileName });
                    EditorAPI.OpenFileAsDocument(realFileName, true, true);
                }
            }
            catch (Exception e)
            {
                EditorMessageBox.ShowWarning(e.Message);
                //Log.Warning( e.Message );
                return;
            }
        }
コード例 #2
0
        public Page Copy(Site site, string sourcePageFullName, string newPageFullName)
        {
            GetLocker().EnterWriteLock();

            try
            {
                var page    = PageHelper.Parse(site, sourcePageFullName);
                var newPage = PageHelper.Parse(site, newPageFullName);

                IOUtility.CopyDirectory(page.PhysicalPath, newPage.PhysicalPath);

                return(newPage);
            }
            finally
            {
                GetLocker().ExitWriteLock();
            }
        }
コード例 #3
0
ファイル: ViewProvider.cs プロジェクト: trapatsas/CMS
        public Models.View Copy(Site site, string sourceName, string destName)
        {
            GetLocker().EnterWriteLock();

            try
            {
                var sourceView = new Models.View(site, sourceName).LastVersion();
                var destView   = new Models.View(site, destName);

                IOUtility.CopyDirectory(sourceView.PhysicalPath, destView.PhysicalPath);

                return(destView);
            }
            finally
            {
                GetLocker().ExitWriteLock();
            }
        }
コード例 #4
0
ファイル: LayoutProvider.cs プロジェクト: Epitomy/CMS
        //#region LayoutSample

        //public class LayoutSamplePath
        //{
        //    static LayoutSamplePath()
        //    {
        //        PhysicalPath = Kooboo.Web.Mvc.AreaHelpers.CombineAreaFilePhysicalPath("Sites", "Samples", "Layout");
        //        VirtualPath = Kooboo.Web.Mvc.AreaHelpers.CombineAreaFileVirtualPath("Sites", "Samples", "Layout");
        //    }
        //    public static string PhysicalPath { get; private set; }
        //    public static string VirtualPath { get; private set; }
        //}
        //public IEnumerable<LayoutSample> AllSamples()
        //{
        //    var basePath = LayoutSamplePath.PhysicalPath;
        //    if (Directory.Exists(basePath))
        //    {
        //        foreach (var item in Directory.EnumerateDirectories(basePath))
        //        {
        //            if (((new DirectoryInfo(Path.Combine(LayoutSamplePath.PhysicalPath, item)).Attributes) & FileAttributes.Hidden) != FileAttributes.Hidden)
        //            {
        //                yield return GetLayoutSample(Path.GetFileNameWithoutExtension(item));
        //            }
        //        }
        //    }
        //}
        //public LayoutSample GetLayoutSample(string name)
        //{
        //    string templateFile = Path.Combine(LayoutSamplePath.PhysicalPath, name, "template.aspx");
        //    string thumbnailFile = Path.Combine(LayoutSamplePath.PhysicalPath, name, "thumbnail.png");
        //    LayoutSample sample = new LayoutSample() { Name = name };
        //    if (File.Exists(templateFile))
        //    {
        //        sample.Template = Kooboo.IO.IOUtility.ReadAsString(templateFile);
        //    }
        //    if (File.Exists(thumbnailFile))
        //    {
        //        sample.ThumbnailVirtualPath = UrlUtility.Combine(LayoutSamplePath.VirtualPath, name, "thumbnail.png");
        //    }
        //    return sample;
        //}

        //#endregion

        public Layout Copy(Site site, string sourceName, string destName)
        {
            GetLocker().EnterWriteLock();

            try
            {
                var sourceLayout = new Layout(site, sourceName).LastVersion();
                var destLayout   = new Layout(site, destName);

                IOUtility.CopyDirectory(sourceLayout.PhysicalPath, destLayout.PhysicalPath);

                return(destLayout);
            }
            finally
            {
                GetLocker().ExitWriteLock();
            }
        }
コード例 #5
0
        public virtual Repository Copy(Repository sourceRepository, string destRepositoryName)
        {
            var sourcePath     = new RepositoryPath(sourceRepository);
            var destRepository = new Repository(destRepositoryName);
            var destPath       = new RepositoryPath(destRepository);

            GetLocker().EnterWriteLock();
            try
            {
                BackupContentAsXML(sourceRepository);
                IOUtility.CopyDirectory(sourcePath.PhysicalPath, destPath.PhysicalPath);
                CopyData(sourceRepository, destRepository);
            }
            finally
            {
                GetLocker().ExitWriteLock();
            }
            return(destRepository);
        }
コード例 #6
0
        public static void Import(string[] fileNames, string destRealFolder)          //Initial )
        {
            try
            {
                if (!Directory.Exists(destRealFolder))
                {
                    Directory.CreateDirectory(destRealFolder);
                }
            }
            catch (Exception e)
            {
                EditorMessageBox.ShowWarning(e.Message);
                return;
            }

            ////check files inside project Data folder
            //{
            //	foreach( var fileName in fileNames )
            //	{
            //		var virtualPath = VirtualPathUtils.GetVirtualPathByReal( fileName );
            //		if( !string.IsNullOrEmpty( virtualPath ) )
            //		{
            //			Log.Warning( "Unable to import from project \'Data\' folder. The file already inside the project." );
            //			return;
            //		}
            //	}
            //}

            //processing

            //!!!!пока просто копирование
            //нужно зависимые скопировать
            //также может какую-то обработку делать

            ////select folder if exists files outside Assets folder
            //string destRealFolder = "";
            //{
            //	var existsOutside = fileNames.Any( fileName => string.IsNullOrEmpty( VirtualPathUtility.GetVirtualPathByReal( fileName ) ) );
            //	if( existsOutside )
            //	{
            //		if( string.IsNullOrEmpty( destRealFolderInitial ) )
            //		{
            //			again:;
            //			destRealFolder = VirtualPathUtility.GetRealPathByVirtual( "Import" );
            //			if( !Directory.Exists( destRealFolder ) )
            //				destRealFolder = VirtualPathUtility.GetRealPathByVirtual( "" );

            //			CommonOpenFileDialog dialog = new CommonOpenFileDialog();
            //			dialog.InitialDirectory = destRealFolder;
            //			dialog.IsFolderPicker = true;
            //			if( dialog.ShowDialog() == CommonFileDialogResult.Ok )
            //			{
            //				destRealFolder = dialog.FileName;

            //				if( !VirtualPathUtility.GetVirtualPathByReal( destRealFolder, out _ ) )
            //				{
            //					EditorMessageBox.ShowWarning( "Need select folder inside Assets folder." );
            //					//Log.Warning( "Need select folder inside Data folder." );
            //					goto again;
            //				}
            //			}
            //		}
            //		else
            //			destRealFolder = destRealFolderInitial;
            //	}
            //}

            List <string> fileNamesToSelect = new List <string>();

            foreach (var fileName in fileNames)
            {
                var virtualPath = VirtualPathUtility.GetVirtualPathByReal(fileName);
                if (!string.IsNullOrEmpty(virtualPath))
                {
                    //already inside Data folder
                    fileNamesToSelect.Add(fileName);
                }
                else
                {
                    //copy to Data folder

                    string destinationFileName;
                    try
                    {
                        destinationFileName = Path.Combine(destRealFolder, Path.GetFileName(fileName));

                        if (Directory.Exists(fileName))
                        {
                            IOUtility.CopyDirectory(fileName, destinationFileName);
                        }
                        else
                        {
                            File.Copy(fileName, destinationFileName);
                        }
                    }
                    catch (Exception e)
                    {
                        EditorMessageBox.ShowWarning(e.Message);
                        //Log.Warning( e.Message );
                        return;
                    }

                    fileNamesToSelect.Add(destinationFileName);
                }
            }

            //select new files
            EditorAPI.SelectFilesOrDirectoriesInMainResourcesWindow(fileNamesToSelect.ToArray());
            EditorAPI.SelectDockWindow(EditorAPI.FindWindow <ResourcesWindow>());
        }