예제 #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);
        }
예제 #2
0
        public static async Task <bool> File1IsNewerAsync(ContentURI uri,
                                                          string file1Path, string file2Path)
        {
            bool bXmlIsNewer  = false;
            bool bFile2Exists = await FileStorageIO.URIAbsoluteExists(uri, file2Path);

            if (!bFile2Exists)
            {
                return(true);
            }
            if (await FileStorageIO.URIAbsoluteExists(uri, file1Path) &&
                bFile2Exists)
            {
                DateTime xmlFileTime
                    = await GetLastWriteTimeUtcAsync(uri, file1Path);

                DateTime xhtmlFileTime
                    = await GetLastWriteTimeUtcAsync(uri, file2Path);

                if (xmlFileTime > xhtmlFileTime)
                {
                    //rule 3: if the xmldoc is older than than the html, make a new html
                    bXmlIsNewer = true;
                }
            }
            return(bXmlIsNewer);
        }
예제 #3
0
        public async Task <bool> GetXmlFromFile(ContentURI uri,
                                                string filePath, XPathNavigator xPathNav)
        {
            bool bHasCompleted = false;

            xPathNav = null;
            if (await FileStorageIO.URIAbsoluteExists(uri, filePath))
            {
                XmlDocument oSelectedDoc = new XmlDocument();
                XmlReader   reader
                    = await Helpers.FileStorageIO.GetXmlReaderAsync(uri, filePath);

                if (reader != null)
                {
                    using (reader)
                    {
                        oSelectedDoc.Load(reader);
                    }
                }
                if (oSelectedDoc != null)
                {
                    xPathNav = oSelectedDoc.CreateNavigator();
                }
            }
            bHasCompleted = true;
            return(bHasCompleted);
        }
예제 #4
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);
        }
예제 #5
0
 public void GetXmlFromFile(ContentURI uri,
                            string filePath, out XPathDocument xPathDoc)
 {
     xPathDoc = null;
     if (FileStorageIO.URIAbsoluteExists(uri, filePath))
     {
         XmlReader reader = FileStorageIO.GetXmlReader(uri, filePath);
         if (reader != null)
         {
             using (reader)
             {
                 xPathDoc = new XPathDocument(reader);
             }
         }
     }
 }
예제 #6
0
        public async Task <bool> GetXmlFromFile(ContentURI uri,
                                                string filePath, XPathDocument xPathDoc)
        {
            bool bHasCompleted = false;

            xPathDoc = null;
            if (await FileStorageIO.URIAbsoluteExists(uri, filePath))
            {
                XmlReader reader = await FileStorageIO.GetXmlReaderAsync(uri, filePath);

                if (reader != null)
                {
                    using (reader)
                    {
                        xPathDoc = new XPathDocument(reader);
                    }
                }
            }
            bHasCompleted = true;
            return(bHasCompleted);
        }
예제 #7
0
 public void GetXmlFromFile(ContentURI uri,
                            string filePath, out XPathNavigator xPathNav)
 {
     xPathNav = null;
     if (FileStorageIO.URIAbsoluteExists(uri, filePath))
     {
         XmlDocument oSelectedDoc = new XmlDocument();
         XmlReader   reader
             = Helpers.FileStorageIO.GetXmlReader(uri, filePath);
         if (reader != null)
         {
             using (reader)
             {
                 oSelectedDoc.Load(reader);
             }
         }
         if (oSelectedDoc != null)
         {
             xPathNav = oSelectedDoc.CreateNavigator();
         }
     }
 }