XmlDatabase_GetGuidanceItemXml() private method

private XmlDatabase_GetGuidanceItemXml ( Guid guidanceItemId ) : string
guidanceItemId Guid
return string
Ejemplo n.º 1
0
        public void handleAction_Xsl(string data, string xsltToUse)
        {
            //if (this.TmWebServices.tmAuthentication.sessionID. UserRole.ReadArticles
            var xstlFile = context.Server.MapPath("\\xslt\\" + xsltToUse);

            if (xstlFile.fileExists())
            {
                var guid = tmWebServices.getGuidForMapping(data);
                if (guid != Guid.Empty)
                {
                    var xmlContent = tmWebServices.XmlDatabase_GetGuidanceItemXml(guid);
                    //.add_Xslt(xsltToUse);
                    if (xmlContent.valid())
                    {
                        //var xslTransform = new System.Xml.Xsl.XslTransform();
                        var xslTransform = new System.Xml.Xsl.XslCompiledTransform();

                        xslTransform.Load(xstlFile);

                        var xmlReader      = new System.Xml.XmlTextReader(new StringReader(xmlContent));
                        var xpathNavigator = new System.Xml.XPath.XPathDocument(xmlReader);
                        var stringWriter   = new StringWriter();

                        xslTransform.Transform(xpathNavigator, new System.Xml.Xsl.XsltArgumentList(), stringWriter);

                        context.Response.ContentType = "text/html";
                        context.Response.Write(stringWriter.str());

                        var article = tmWebServices.GetGuidanceItemById(guid);
                        switch (xsltToUse)
                        {
                        case "Notepad_Edit.xslt":
                            tmWebServices.RBAC_Demand_EditArticles();               // will trigger an Security exception if the user if not authorized
                            tmWebServices.logUserActivity("Edit Article (Notepad)", "{0} ({1})".format(article.Metadata.Title, guid));
                            break;

                        case "TeamMentor_Article.xslt":
                            tmWebServices.logUserActivity("View Article (xslt)", "{0} ({1})".format(article.Metadata.Title, guid));
                            break;

                        case "JsCreole_Article.xslt":
                            tmWebServices.logUserActivity("View Article (wiki)", "{0} ({1})".format(article.Metadata.Title, guid));
                            break;

                        default:
                            tmWebServices.logUserActivity("View Article ({0})", "{1} ({2})".format(xsltToUse, data, xsltToUse));
                            break;
                        }

                        endResponse();
                    }
                }
                else
                {
                    transfer_Request("articleViewer");              // will trigger exception
                }
            }
        }
Ejemplo n.º 2
0
        public void handleAction_Xsl(string data, string xsltToUse)
        {
            //if (this.TmWebServices.tmAuthentication.sessionID. UserRole.ReadArticles
            var xstlFile = context.Server.MapPath("\\xslt\\" + xsltToUse);

            if (xstlFile.fileExists())
            {
                var guid = tmWebServices.getGuidForMapping(data);
                if (guid != Guid.Empty)
                {
                    var xmlContent = tmWebServices.XmlDatabase_GetGuidanceItemXml(guid);
                    //.add_Xslt(xsltToUse);
                    if (xmlContent.valid())
                    {
                        //var xslTransform = new System.Xml.Xsl.XslTransform();
                        var xslTransform = new System.Xml.Xsl.XslCompiledTransform();

                        xslTransform.Load(xstlFile);

                        var xmlReader      = new System.Xml.XmlTextReader(new StringReader(xmlContent));
                        var xpathNavigator = new System.Xml.XPath.XPathDocument(xmlReader);
                        var stringWriter   = new StringWriter();

                        xslTransform.Transform(xpathNavigator, new System.Xml.Xsl.XsltArgumentList(), stringWriter);

                        context.Response.ContentType = "text/html";
                        context.Response.Write(stringWriter.str());
                        endResponse();
                    }
                }
                else
                {
                    transfer_Request("articleViewer");              // will trigger exception
                }
            }
        }