Ejemplo n.º 1
0
        /// <summary>
        /// 判断是否存在同名
        /// </summary>
        /// <param name="parentFolder">父Element</param>
        static public bool ExistsSameFileName(FolderXmlElement parentFolder, DataType dataType, string newName)
        {
            string newFilePath = Path.Combine(parentFolder.AbsoluteFilePath, newName);

            switch (dataType)
            {
            case DataType.Tmplt:
                return(File.Exists(newFilePath + Utility.Const.TmpltFileExt));

            case DataType.Page:
                return(File.Exists(newFilePath + Utility.Const.PageFileExt));

            case DataType.File:
                return(File.Exists(newFilePath));

            case DataType.Channel:
            case DataType.Folder:
                return(Directory.Exists(newFilePath));

            default:
                Debug.Fail("");
                break;
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 是否存在同名Title
        /// </summary>
        /// <param name="parentFolder"></param>
        /// <param name="dataType"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        static private bool ExistsSameTitle(FolderXmlElement parentFolder, DataType dataType, string title)
        {
            switch (dataType)
            {
            case DataType.Channel:
            case DataType.Folder:
                foreach (XmlNode node in parentFolder.ChildNodes)
                {
                    if (node is FolderXmlElement)
                    {
                        if (((SimpleExIndexXmlElement)node).Title == title)
                        {
                            return(true);
                        }
                    }
                }
                break;

            case DataType.Tmplt:
                foreach (XmlNode node in parentFolder.ChildNodes)
                {
                    if (node is TmpltSimpleExXmlElement)
                    {
                        if (((SimpleExIndexXmlElement)node).Title == title)
                        {
                            return(true);
                        }
                    }
                }
                break;

            case DataType.Page:
                foreach (XmlNode node in parentFolder.ChildNodes)
                {
                    if (node is PageSimpleExXmlElement)
                    {
                        if (((SimpleExIndexXmlElement)node).Title == title)
                        {
                            return(true);
                        }
                    }
                }
                break;

            case DataType.File:
                foreach (XmlNode node in parentFolder.ChildNodes)
                {
                    if (node is FileSimpleExXmlElement)
                    {
                        if (((SimpleExIndexXmlElement)node).Title == title)
                        {
                            return(true);
                        }
                    }
                }
                break;

            default:
                Debug.Fail("未知的DataType:" + dataType);
                break;
            }
            return(false);
        }
Ejemplo n.º 3
0
        static private string CreateIncreaseTitleCore(FolderXmlElement parentFolder, DataType dataType, TmpltType tmpltType, PageType pageType)
        {
            ///取默认Title
            string defaultTitle = "";

            switch (dataType)
            {
            case DataType.Channel:
                defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.newChannel");
                break;

            case DataType.Tmplt:
            {
                switch (tmpltType)
                {
                case TmpltType.General:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.newTmplt");
                    break;

                case TmpltType.Product:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.productTmplt");
                    break;

                case TmpltType.Project:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.projectTmplt");
                    break;

                case TmpltType.InviteBidding:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.inviteBiddingTmplt");
                    break;

                case TmpltType.Knowledge:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.knowledgeTmplt");
                    break;

                case TmpltType.Hr:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.HRTmplt");
                    break;

                case TmpltType.Home:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.homeTmplt");
                    break;

                default:
                    Debug.Fail("未处理的TmpltType:" + tmpltType);
                    break;
                }
                break;
            }

            case DataType.Page:
            {
                switch (pageType)
                {
                case PageType.None:
                    defaultTitle = "页面";
                    break;

                case PageType.General:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.newPage");
                    break;

                case PageType.Product:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.productPage");
                    break;

                case PageType.Project:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.projectPage");
                    break;

                case PageType.InviteBidding:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.inviteBiddingPage");
                    break;

                case PageType.Knowledge:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.knowledgePage");
                    break;

                case PageType.Hr:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.HRPage");
                    break;

                case PageType.Home:
                    defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.homePage");
                    break;

                default:
                    Debug.Fail("未处理的PageType:" + pageType);
                    break;
                }
                break;
            }

            case DataType.Folder:
                defaultTitle = ResourceService.GetResourceText("Tree.MyTreeMenu.addFolder");
                break;

            default:
                Debug.Fail("未知的DataType:" + dataType);
                break;
            }

            ///遍历以生成一个不重名的Title
            for (int i = 1; i < int.MaxValue; i++)
            {
                string newTitle = defaultTitle + i;
                if (!ExistsSameTitle(parentFolder, dataType, newTitle))
                {
                    return(newTitle);
                }
            }

            return(defaultTitle + Utility.Guid.NewGuid());
        }
Ejemplo n.º 4
0
 static public string CreateIncreaseTmpltTitle(FolderXmlElement parentFolder, TmpltType tmpltType)
 {
     return(CreateIncreaseTitleCore(parentFolder, DataType.Tmplt, tmpltType, PageType.None));
 }
Ejemplo n.º 5
0
 static public string CreateIncreasePageTitle(FolderXmlElement parentFolder, PageType pageType)
 {
     return(CreateIncreaseTitleCore(parentFolder, DataType.Page, TmpltType.None, pageType));
 }
Ejemplo n.º 6
0
 static public string CreateIncreaseChannelTitle(FolderXmlElement parentFolder)
 {
     return(CreateIncreaseTitleCore(parentFolder, DataType.Channel, TmpltType.None, PageType.None));
 }