/// <summary> /// find pages list /// </summary> private byte[] _WikiFindList(WikiFileType wft, string namesspace) { WikiFileParse wfp = null; WikiFolderInfo wfi = null; try { if ((wfp = (WikiFileParse)this._WikiFilesParse( wft, namesspace, null, null, false )) == null) { throw new WikiEngineInternalNameSpaceErrorException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wft.ToString() ) ); } switch (wfp.FolderType) { case WikiFileType.FileReadMd: case WikiFileType.FileWriteMd: case WikiFileType.FileReadBinary: case WikiFileType.FileWriteBinary: case WikiFileType.FileReadAttic: case WikiFileType.FileWriteAttic: { if ((wfi = (WikiFolderInfo)this._FindFiles(wfp)) == null) { throw new WikiEngineInternalSearchEmptyException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } break; } default: { throw new WikiEngineNotImplementPageException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } } return(Encoding.UTF8.GetBytes( this.ResourceListToMdString(wfi, null, wfp.FolderType) )); } catch (Exception e) { throw e; } }
/// <summary> /// get page/media/attic/meta /// </summary> private byte[] _WikiGetFile(WikiFileType wft, string namesspace) { try { WikiData wd = null; WikiFileParse wfp = null; if ((wfp = (WikiFileParse)this._WikiFilesParse( wft, namesspace, null, null, true )) == null) { throw new WikiEngineInternalNameSpaceErrorException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wft.ToString() ) ); } switch (wfp.FolderType) { default: case WikiFileType.FileReadMd: case WikiFileType.FileWriteMd: case WikiFileType.FileReadBinary: case WikiFileType.FileWriteBinary: { wd = this._GetFile(wfp); break; } case WikiFileType.FileReadAttic: case WikiFileType.FileWriteAttic: { wd = this._GetFileFromAttic(wfp); break; } case WikiFileType.FileReadMeta: { return(Encoding.UTF8.GetBytes( this.MetaListToMdString( this._GetFileMeta(wfp) ) )); } case WikiFileType.FileWriteMeta: { throw new WikiEngineNotImplementPageException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } } if ( (wd == null) || (wd.FileContent == null) || (wd.FileContent.Length == 0) ) { throw new WikiEngineInternalSearchEmptyException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } return(wd.FileContent); } catch (Exception e) { throw e; } }
/// <summary> /// put page/media /// </summary> private byte[] _WikiPutFile(WikiFileType wft, string namesspace, WikiFileMeta wfm = null) { try { WikiData wd = null; WikiFileParse wfp = null; if (wfm == null) { throw new WikiEnginePutException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wft.ToString() ) ); } if ((wfp = (WikiFileParse)this._WikiFilesParse( wft, namesspace, null, null, true )) == null) { throw new WikiEngineInternalNameSpaceErrorException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wft.ToString() ) ); } if ((wfp.IsNameSpaceValid) && (!wfp.IsNameSpaceOnly)) { switch (wfp.FolderType) { case WikiFileType.FileWriteMd: case WikiFileType.FileWriteBinary: { break; } case WikiFileType.FileWriteAttic: case WikiFileType.FileWriteMeta: { throw new WikiEngineNotImplementPageException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } default: case WikiFileType.FileReadMd: case WikiFileType.FileReadMeta: case WikiFileType.FileReadAttic: case WikiFileType.FileReadBinary: { throw new WikiEngineInternalFileTypeException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTreePut, MethodBase.GetCurrentMethod().Name, wfp.FolderType.ToString(), namesspace ) ); } } } else { throw new WikiEngineInternalNameSpaceErrorException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTreeNameSpace, MethodBase.GetCurrentMethod().Name, wfp.FolderType.ToString(), namesspace ) ); } if ( ((wd = this._PutFile(wfp, null, wfm)) == null) || (wd.FileContent == null) || (wd.FileContent.Length == 0) ) { throw new WikiEngineInternalSearchEmptyException( string.Format( Properties.ResourceWikiEngine.fmtErrorMapTree, MethodBase.GetCurrentMethod().Name, namesspace, wfp.FolderType.ToString() ) ); } return(wd.FileContent); } catch (Exception e) { throw e; } }
internal static string WikiFileTypeToString(WikiFileType type) { switch (type) { case WikiFileType.FileReadMd: case WikiFileType.FileWriteMd: { return(WikiFile.wikiLocalPage); } case WikiFileType.FileReadAttic: case WikiFileType.FileWriteAttic: { return(WikiFile.wikiLocalAttic); } case WikiFileType.FileReadBinary: case WikiFileType.FileWriteBinary: { return(WikiFile.wikiLocalMedia); } case WikiFileType.FileReadMeta: case WikiFileType.FileWriteMeta: { return(WikiFile.wikiLocalMeta); } case WikiFileType.None: case WikiFileType.FileUnknown: { throw new WikiEngineInternalFileTypeException("detect empty type: " + type.ToString()); } default: { throw new WikiEngineInternalFileTypeException("not detect type from WikiFileType"); } } }