Ejemplo n.º 1
0
        public static async Task <bool> NeedsNewXhtmlDoc(ContentURI uri,
                                                         GeneralHelpers.DOC_STATE_NUMBER displayDocType,
                                                         string xmlDocPath, string xhtmlDocPath)
        {
            bool bNeedsNewXhtmlDoc = false;

            //rule 1: authorized edits always get new html
            bNeedsNewXhtmlDoc = await AuthorizedEditNeedsHtmlFragment(uri,
                                                                      displayDocType, xmlDocPath);

            if (bNeedsNewXhtmlDoc)
            {
                bNeedsNewXhtmlDoc = true;
                return(bNeedsNewXhtmlDoc);
            }
            if (!await FileStorageIO.URIAbsoluteExists(uri, xhtmlDocPath))
            {
                //rule 2: if the html doesn't exist, make it
                bNeedsNewXhtmlDoc = true;
                return(bNeedsNewXhtmlDoc);
            }
            bNeedsNewXhtmlDoc = await FileStorageIO.File1IsNewerAsync(
                uri, xmlDocPath, xhtmlDocPath);

            return(bNeedsNewXhtmlDoc);
        }
Ejemplo n.º 2
0
        public static string GetViewsPanelStylesheetName(GeneralHelpers.DOC_STATE_NUMBER docState, ContentURI docToCalcURI,
                                                         string stylesheetName)
        {
            string sStylesheetNameForView = stylesheetName;

            if (docState == GeneralHelpers.DOC_STATE_NUMBER.thirddoc &&
                docToCalcURI.URIDataManager.SubActionView != string.Empty &&
                docToCalcURI.URIDataManager.SubActionView != Helpers.GeneralHelpers.NONE &&
                stylesheetName.IndexOf(GeneralHelpers.EXTENSION_XSLT) != 0)
            {
                //v1.1.1 uses multiple views
                GeneralHelpers.SUBACTION_VIEWS eSubActionView
                    = GeneralHelpers.GetSubActionView(docToCalcURI.URIDataManager.SubActionView);
                if (eSubActionView != GeneralHelpers.SUBACTION_VIEWS.none)
                {
                    //pattern is to change the stylesheet's last filename char using enum
                    //Operation1.xslt (mobile) to Operation3.xslt (full)
                    int    iStart            = stylesheetName.IndexOf(GeneralHelpers.EXTENSION_XSLT) - 1;
                    string sSubActionViewInt = stylesheetName.Substring(iStart, 1);
                    if (!string.IsNullOrEmpty(sSubActionViewInt))
                    {
                        int iNewSSEnum = (int)eSubActionView;
                        sStylesheetNameForView = stylesheetName.Replace(
                            string.Concat(sSubActionViewInt, GeneralHelpers.EXTENSION_XSLT),
                            string.Concat(iNewSSEnum.ToString(), GeneralHelpers.EXTENSION_XSLT));
                    }
                }
            }
            return(sStylesheetNameForView);
        }
Ejemplo n.º 3
0
        public static async Task <bool> AuthorizedEditNeedsHtmlFragment(ContentURI uri,
                                                                        GeneralHelpers.DOC_STATE_NUMBER displayDocType,
                                                                        string xmlDocPath)
        {
            bool bNeedsNewXhtmlFrag = false;

            //tempdocs can be edited by anyone
            if (uri.URIMember.ClubInUse.PrivateAuthorizationLevel
                == AccountHelper.AUTHORIZATION_LEVELS.fulledits ||
                uri.URIFileExtensionType == GeneralHelpers.FILENAME_EXTENSIONS.temp.ToString())
            {
                if (uri.URIDataManager.ServerSubActionType
                    == GeneralHelpers.SERVER_SUBACTION_TYPES.runaddin)
                {
                    //if temp doc exists they are in the middle of running calcs
                    //if save = calcs they have just finished running calcs
                    if (await FileStorageIO.URIAbsoluteExists(
                            uri, uri.URIDataManager.TempDocPath) &&
                        (!string.IsNullOrEmpty(uri.URIDataManager.TempDocSaveMethod) &&
                         uri.URIDataManager.TempDocSaveMethod != Helpers.GeneralHelpers.NONE))
                    {
                        if (displayDocType
                            == GeneralHelpers.DOC_STATE_NUMBER.seconddoc)
                        {
                            //v1.2.0: need to pass params to seconddoc telling which save message to display
                            bNeedsNewXhtmlFrag = true;
                        }
                        else
                        {
                            bNeedsNewXhtmlFrag = false;
                        }
                    }
                    else
                    {
                        if (displayDocType
                            == GeneralHelpers.DOC_STATE_NUMBER.seconddoc)
                        {
                            //always init calcors/analyzers with new doc
                            bNeedsNewXhtmlFrag = true;
                        }
                    }
                }
                else
                {
                    bNeedsNewXhtmlFrag = true;
                }
            }
            return(bNeedsNewXhtmlFrag);
        }
Ejemplo n.º 4
0
        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);
        }