コード例 #1
0
ファイル: AppSettings.cs プロジェクト: kpboyle1/devtreks.3.1
        public static string GetXhtmlDocPath(ContentURI uri,
                                             GeneralHelpers.DOC_STATE_NUMBER displayDocType,
                                             string xmlDocPath, AppHelpers.Resources.FILEEXTENSION_TYPES fileExtType,
                                             string viewEditType)
        {
            string sXhtmlDocPath = string.Empty;

            if (string.IsNullOrEmpty(xmlDocPath))
            {
                uri.ErrorMessage = DevTreks.Exceptions.DevTreksErrors.MakeStandardErrorMsg(
                    string.Empty, "IOHELPER_CANTBUILD");
                return(sXhtmlDocPath);
            }
            //same paths, different file extensions
            sXhtmlDocPath = xmlDocPath;
            GeneralHelpers.ChangeFileExtension(
                fileExtType, ref sXhtmlDocPath);
            //add viewEditType as a filename extension (owners and authorized clubs usually
            //get full html view while others get print view)
            //and use pagination with the html
            //and make sure the pagination doesn't interfere with uripatterns
            string sFileName = Path.GetFileNameWithoutExtension(xmlDocPath);
            string sHtmlFileName
                = string.Concat(sFileName,
                                GeneralHelpers.FILENAME_DELIMITER, viewEditType);

            if (displayDocType == GeneralHelpers.DOC_STATE_NUMBER.thirddoc)
            {
                //stories are the same in all views
                if (!sFileName.Contains(string.Concat(GeneralHelpers.FILENAME_DELIMITER,
                                                      GeneralHelpers.FILENAME_EXTENSIONS.selected)))
                {
                    //v1.1.1 uses multiple html views
                    GeneralHelpers.SUBACTION_VIEWS eSubActionView
                        = GeneralHelpers.GetSubActionView(uri.URIDataManager.SubActionView);
                    //do not include graph subaction view -no stateful html doc used
                    if (eSubActionView == GeneralHelpers.SUBACTION_VIEWS.mobile ||
                        eSubActionView == GeneralHelpers.SUBACTION_VIEWS.full ||
                        eSubActionView == GeneralHelpers.SUBACTION_VIEWS.summary)
                    {
                        //each html view is distinguished by the int representation of enum
                        int iSubActionView = (int)eSubActionView;
                        sHtmlFileName = string.Concat(sFileName,
                                                      GeneralHelpers.FILENAME_DELIMITER, viewEditType,
                                                      iSubActionView.ToString());
                    }
                }
            }
            sXhtmlDocPath
                = sXhtmlDocPath.Replace(sFileName, sHtmlFileName);
            //technically not an issue in 2.0.0 servers but not clear about
            //where this is being deployed so retain for now
            if (sXhtmlDocPath.Length > 260)
            {
                //watch for file length limitation
                int    iShortNameLength = sXhtmlDocPath.Length - 257;
                string sNewName         = sFileName.Substring(iShortNameLength,
                                                              sFileName.Length - iShortNameLength);
                sXhtmlDocPath = sXhtmlDocPath.Replace(sFileName, sNewName);
            }
            return(sXhtmlDocPath);
        }