예제 #1
0
        public static string getDoc(int index)
        {
            SDDocumentation doc     = DocumentList[index];
            string          docJSON = convertSerializedJSON(doc); //TODO: ONE LINE

            return(docJSON);
        }
예제 #2
0
        public static string convertSerializedJSON(SDDocumentation doc)
        {
            sdDocJSON docJSON = new sdDocJSON();

            docJSON.id            = doc.id;
            docJSON.index         = DocumentList.IndexOf(doc);
            docJSON.alias         = doc.alias;
            docJSON.documentTitle = doc.documentTitle;
            if (doc.DocumentLink_id != null)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pdfDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.DocumentLink_id);
                    docJSON.documentLink = pdfDoc.link;
                    docJSON.PDFaccess    = pdfDoc.Access_id;
                }
            }
            docJSON.passwordTitle = doc.passwordTitle;
            if (doc.PasswordHyperlink_id != null)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pwDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.PasswordHyperlink_id);
                    docJSON.passwordHyperlink = pwDoc.link;
                    docJSON.PWaccess          = pwDoc.Access_id;
                }
            }

            var json = new JavaScriptSerializer().Serialize(docJSON);

            return(json);
        }
예제 #3
0
        private SDDocumentation ParseDocumentation(IEnumerable <XElement> docElements, bool multilang = false)
        {
            var sdDocumentation = new SDDocumentation();

            foreach (var child in docElements)
            {
                switch (child.Name.LocalName.ToLower())
                {
                case "typeparam":
                    var typeparamKey = child.Attribute("name")?.Value ?? "typeparam";
                    if (!sdDocumentation.TypeParams.ContainsKey(typeparamKey))
                    {
                        sdDocumentation.TypeParams.Add(typeparamKey, ParseContentTokens(child, multilang));
                    }
                    break;

                case "param":
                    var paramKey = child.Attribute("name")?.Value ?? "param";
                    if (!sdDocumentation.Params.ContainsKey(paramKey))
                    {
                        sdDocumentation.Params.Add(paramKey, ParseContentTokens(child, multilang));
                    }
                    break;

                case "exception":
                    var exKey = child.Attribute("cref")?.Value ?? "exception";
                    if (!sdDocumentation.Exceptions.ContainsKey(exKey))
                    {
                        sdDocumentation.Exceptions.Add(exKey, ParseContentTokens(child, multilang));
                    }
                    break;

                case "summary":
                    sdDocumentation.Summary = ParseContentTokens(child, multilang);
                    break;

                case "remarks":
                    sdDocumentation.Remarks = ParseContentTokens(child, multilang);
                    break;

                case "example":
                    sdDocumentation.Example = ParseContentTokens(child, multilang);
                    break;

                case "returns":
                    AddResultsSection(sdDocumentation.Returns, child, multilang);
                    break;

                case "seealso":
                    var seeToken = new SDSeeToken(child.ToString());
                    _seeTokens.Add(seeToken);
                    sdDocumentation.SeeAlsos.Add(seeToken);
                    break;
                }
            }

            return(sdDocumentation);
        }
예제 #4
0
        private SDDocumentation ParseDocumentation(IEnumerable <XmlDocumentationElement> docElements)
        {
            var sdDocumentation = new SDDocumentation();

            foreach (var child in docElements)
            {
                switch (child.Name.ToLower())
                {
                case "typeparam":
                    var typeparamKey = child.GetAttribute("name") ?? "typeparam";
                    if (!sdDocumentation.TypeParams.ContainsKey(typeparamKey))
                    {
                        sdDocumentation.TypeParams.Add(typeparamKey, ParseContentTokens(child));
                    }
                    break;

                case "param":
                    var paramKey = child.GetAttribute("name") ?? "param";
                    if (!sdDocumentation.Params.ContainsKey(paramKey))
                    {
                        sdDocumentation.Params.Add(paramKey, ParseContentTokens(child));
                    }
                    break;

                case "exceptions":
                    var exKey = child.GetAttribute("name") ?? "exceptions";
                    if (!sdDocumentation.Exceptions.ContainsKey(exKey))
                    {
                        sdDocumentation.Exceptions.Add(exKey, ParseContentTokens(child));
                    }
                    break;

                case "summary":
                    sdDocumentation.Summary = ParseContentTokens(child);
                    break;

                case "remarks":
                    sdDocumentation.Remarks = ParseContentTokens(child);
                    break;

                case "example":
                    sdDocumentation.Example = ParseContentTokens(child);
                    break;

                case "returns":
                    sdDocumentation.Returns = ParseContentTokens(child);
                    break;

                case "seealso":
                    sdDocumentation.SeeAlsos.Add(GetSeeRef(child));
                    break;
                }
            }

            return(sdDocumentation);
        }
        public static string convertSerializedJSON(SDDocumentation doc)
        {
            LearningCenterDocJSON docJSON = new LearningCenterDocJSON();

            docJSON.alias = doc.alias;
            if (doc.DocumentLink_id != null)
            {
                int linkId = (int)doc.DocumentLink_id;
                docJSON.documentLink = HyperlinkList[linkId - 1].link;
            }

            var json = new JavaScriptSerializer().Serialize(docJSON);

            return(json);
        }
 private void InsertDocumentation(SDMember sdMember, SDDocumentation documentation, int navigationLevel)
 {
     if (documentation != null)
     {
         if (documentation.Summary != null)
         {
             _wordTemplater.AppendMarkdown(documentation.Summary.ToMarkdown(), "MemberBody");
         }
         InsertDocumentationPart(_wordStrings.Remarks, documentation.Remarks);
         InsertDocumentationPart(_wordStrings.Returns, documentation.Returns);
         InsertParamDocumentationPart(_wordStrings.Params, documentation.Params, sdMember);
         InsertParamDocumentationPart(_wordStrings.TypeParams, documentation.TypeParams, sdMember);
         InsertParamDocumentationPart(_wordStrings.Exceptions, documentation.Exceptions, sdMember);
         InsertDocumentationPart(_wordStrings.Example, documentation.Example);
     }
 }
예제 #7
0
        /// <summary>
        /// Adds new SD Doc to db as well updates its original id
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        ///
        public static void addSDDocumentation(SDDocumentation doc)
        {
            using (var curDB = new HelpDesk_DB())
            {
                curDB.SDDocumentations.Add(doc);
                curDB.SaveChanges();
            }
            using (var curDB = new HelpDesk_DB())
            {
                //Update original id
                var originalDoc = curDB.SDDocumentations.Find(doc.id);
                if (originalDoc != null)
                {
                    originalDoc.Original_id = doc.id;
                    curDB.SaveChanges();
                }

                //Rebuilds document list for find reference
                DocumentList = curDB.SDDocumentations.Where(p => p.Status_id == 2).OrderBy(p => p.alias).ToList();
            }
        }
예제 #8
0
        public static void submit(sdDocJSON doc)
        {
            DocumentLink pdfLink = new DocumentLink();

            pdfLink.link      = doc.documentLink;
            pdfLink.Access_id = doc.PDFaccess;

            DocumentLink pwLink = new DocumentLink();

            pwLink.link      = doc.passwordHyperlink;
            pwLink.Access_id = doc.PWaccess;

            SDDocumentation sdDoc = new SDDocumentation();

            sdDoc.alias     = doc.alias;
            sdDoc.Status_id = 2;

            //TODO: Change if this Learning Center option is added to the info gathering page
            sdDoc.LearningCenterCategory_id = 1;

            sdDoc.documentTitle = doc.documentTitle;
            //Check for null document links
            //TODO: You can fix this so that null are handled in addDocumentLink Method
            if (doc.documentLink != "")
            {
                sdDoc.DocumentLink_id = addDocumentLink(pdfLink);
            }

            sdDoc.passwordTitle = doc.passwordTitle;

            //check for null pw links
            if (doc.passwordHyperlink != "")
            {
                sdDoc.PasswordHyperlink_id = addDocumentLink(pwLink);
            }

            addSDDocumentation(sdDoc);

            log();
        }
예제 #9
0
        public static void updateDoc(sdDocJSON doc)
        {
            SDDocumentation newSDDoc = new SDDocumentation();

            newSDDoc.Status_id = 2;

            using (var curDB = new HelpDesk_DB())
            {
                SDDocumentation oldDoc      = DocumentList[doc.index];
                var             originalDoc = curDB.SDDocumentations.Find(oldDoc.id);
                originalDoc.Status_id = 4;  //Historic

                //Transfer persisting information to new document
                newSDDoc.LearningCenterCategory_id = oldDoc.LearningCenterCategory_id;
                newSDDoc.Original_id = oldDoc.Original_id;
                if (oldDoc.learningCenterOrder != null)
                {
                    newSDDoc.learningCenterOrder = oldDoc.learningCenterOrder;
                }

                curDB.SaveChanges();
                //Rebuilds document list for find reference
                DocumentList = curDB.SDDocumentations.Where(p => p.Status_id == 2).OrderBy(p => p.alias).ToList();
            }

            DocumentLink pdfLink = new DocumentLink();

            pdfLink.link      = doc.documentLink;
            pdfLink.Access_id = doc.PDFaccess;

            //Check for null document links
            if (doc.documentLink != "")
            {
                newSDDoc.DocumentLink_id = addDocumentLink(pdfLink);
            }

            DocumentLink pwLink = new DocumentLink();

            pwLink.link      = doc.passwordHyperlink;
            pwLink.Access_id = doc.PWaccess;
            //check for null pw links
            if (doc.passwordHyperlink != "")
            {
                newSDDoc.PasswordHyperlink_id = addDocumentLink(pwLink);
            }

            newSDDoc.alias = doc.alias;

            newSDDoc.documentTitle = doc.documentTitle;


            newSDDoc.passwordTitle = doc.passwordTitle;


            using (var curDB = new HelpDesk_DB())
            {
                curDB.SDDocumentations.Add(newSDDoc);
                curDB.SaveChanges();

                //Rebuilds document list for find reference
                DocumentList = curDB.SDDocumentations.Where(p => p.Status_id == 2).OrderBy(p => p.alias).ToList();
            }

            log();
        }