public string ConvertCtagsGithubRepositoryFinalizeRequest(Guid uploadID, string user, string repo, string branch, string accessToken, string hideMethods, string hideProperties)
        {
            try
            {
                ClassDiagramFilterServiceGithubUserdata ud = new ClassDiagramFilterServiceGithubUserdata();
                ud.User   = user;
                ud.Repo   = repo;
                ud.Branch = branch;

                if (isLocal)
                {
                    debugOutput = "";
                }

                GetGithubRepositoryZip(uploadID, user, repo, branch, accessToken);
                RunCtagsOnGithubRepository(uploadID);
                return(ConvertCtagsGithubFile(uploadID, ud, hideMethods, hideProperties));
            }
            catch (Exception e)
            {
                WebOperationContext.Current.OutgoingResponse.StatusCode  = System.Net.HttpStatusCode.InternalServerError;
                WebOperationContext.Current.OutgoingResponse.ContentType = "text/json";

                if (isLocal)
                {
                    debugOutput += "Error: " + e.Message + "\r\n";
                    debugOutput += "Stack trace: " + e.StackTrace;

                    try
                    {
                        using (System.IO.FileStream fs = new System.IO.FileStream(TempFileLocation + CurrPathSeparator + "tmp-github-request-" + uploadID.ToString() + CurrPathSeparator + "crashlog.txt", System.IO.FileMode.Create))
                        {
                            byte[] buff = Encoding.UTF8.GetBytes(debugOutput);
                            fs.Write(buff, 0, buff.Length);
                        }
                        System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(TempFileLocation + CurrPathSeparator + "tmp-github-request-" + uploadID.ToString() + CurrPathSeparator);
                    }
                    catch (Exception x)
                    {
                        return("Error when finalizing transfer: " + e.Message + "\n\nAdditionally, could not create output log.");
                    }
                }

                return("Error when finalizing transfer: " + e.Message);
            };
        }
        private string ConvertCtagsGithubFile(Guid uploadID, ClassDiagramFilterServiceGithubUserdata ud, string hideMethods, string hideProperties)
        {
            if (isLocal)
            {
                debugOutput += "Ctags successful, running filter...\r\n";
            }

            System.IO.DirectoryInfo         dir    = new System.IO.DirectoryInfo(TempFileLocation + CurrPathSeparator + "tmp-github-request-" + uploadID.ToString());
            ClassDiagram.ClassDiagramFilter filter = new ClassDiagram.ClassDiagramFilter();
            filter.SignatureInNote = true;

            if (!((hideMethods == null) || (hideMethods == "0")))
            {
                filter.MethodsInNote = true;
            }

            if (!((hideProperties == null) || (hideProperties == "0")))
            {
                filter.PropertiesInNote = true;
            }

            filter.LinkGenerator = GetLinkFromInfo;
            filter.Userdata      = ud;
            filter.LoadFromCtagsFile(dir.FullName + CurrPathSeparator + "out.txt");
            SDON.Model.Diagram diagram = filter.ConvertCtags();

            if (isLocal)
            {
                debugOutput += "Filter successful\r\n";
            }

            if (!isLocal)
            {
                dir.Delete(true);
            }

            return(SDON.SDONBuilder.ToJSON(diagram));
        }
        private string GetLinkFromInfo(string file, int line, Object userdata)
        {
            int endPrefix = file.IndexOf("repository" + CurrPathSeparator);

            if ((endPrefix == -1) || (userdata.GetType() != typeof(ClassDiagramFilterServiceGithubUserdata)))
            {
                return(null);
            }

            ClassDiagramFilterServiceGithubUserdata ud = (ClassDiagramFilterServiceGithubUserdata)userdata;

            string[] path = file.Substring(endPrefix + ("repository" + CurrPathSeparator).Length).Split(new string[1] {
                "\\"
            }, StringSplitOptions.RemoveEmptyEntries);
            string pathName = "";

            for (int i = 0; i < path.Length; i++)
            {
                pathName += "/" + path[i];
            }

            return("https://github.com/" + ud.User + "/" + ud.Repo + "/blob/" + ud.Branch + pathName + "#L" + line.ToString());
        }