public TokenResult FindExact(TokenParameter parameter) { IndexSearcher indexSearcher = Searcher; string projectIdentifier = string.Format("{0}_{1}", parameter.Username, parameter.Project).ToLower(); var projectQuery = new TermQuery(new Term(ItemProjectIdentifier, projectIdentifier)); var identfierQuery = new TermQuery(new Term(ItemIdentifier, string.Format("{0}", parameter.FullyQualifiedName))); var booleanQuery = new BooleanQuery(); booleanQuery.Add(projectQuery, BooleanClause.Occur.MUST); booleanQuery.Add(identfierQuery, BooleanClause.Occur.MUST); Hits hits = indexSearcher.Search(booleanQuery); if (hits.Length() > 0) { var document = hits.Doc(0); // Take only the first one string filePath = document.Get(ItemPath); int location = Int32.Parse(document.Get(ItemLocation)); var projectCodeDirectory = this.applicationConfigurationProvider.GetProjectSourceCodePath(parameter.Username, parameter.Project); //string relativePath = filePath //projectCodeDirectory.MakeRelativePath(filePath); return(new Models.TokenResult { FileName = Path.GetFileName(filePath), Position = location, Path = filePath }); } return(null); }
// GET: TrakMe public JsonResult Token(TokenParameter param) { var ticks = DateTime.UtcNow.Ticks;; var token = SecurityManager.GenerateToken(param.email, param.password, ticks); return(Json(new { Success = true, Token = token }, JsonRequestBehavior.AllowGet)); }
internal void DoVisit(ISemanticModel semanticModel, CommonSyntaxNode token, TokenParameter parameter, TokenKind searchTokenKind, Action <int> symbolFoundDelegate) { this.semanticModel = semanticModel; this.symbolFoundDelegate = symbolFoundDelegate; this.parameter = parameter; this.searchTokenKind = searchTokenKind; Visit(token); }
private void TraverseThroughAllTheProjectFiles(TokenParameter parameter, IFindReferenceProgress findReferenceProgressListener, Func <string, string, ISemanticModel, CommonSyntaxNode, bool> visitorAction) { findReferenceProgressListener.OnFindReferenceStarted(); var projectCodeDirectory = new DirectoryInfo(this.applicationConfigurationProvider.GetProjectSourceCodePath(parameter.Username, parameter.Project)); var solutionPath = FindSolutionPath(parameter.Username, parameter.Project); if (solutionPath == null) { findReferenceProgressListener.OnFindReferenceCompleted(0); return; } findReferenceProgressListener.OnFindReferenceInProgress(); var workspace = Roslyn.Services.Workspace.LoadSolution(solutionPath); var currentFilePath = Path.Combine(projectCodeDirectory.FullName, parameter.Path.Replace(@"/", @"\")); var solution = workspace.CurrentSolution; foreach (var project in solution.Projects) { try { bool processingCompleted = false; if (!project.HasDocuments) { continue; } foreach (var document in project.Documents) { var documentSemanticModel = document.GetSemanticModel(); var findReferenceSyntaxtWalker = new FindReferenceSyntaxWalker(); CommonSyntaxNode syntaxRoot = null; if (documentSemanticModel.SyntaxTree.TryGetRoot(out syntaxRoot)) { var documentRelativePath = new Uri(projectCodeDirectory.FullName + Path.DirectorySeparatorChar).MakeRelativeUri(new Uri(document.FilePath)).ToString(); processingCompleted = visitorAction(document.Name, documentRelativePath, documentSemanticModel, syntaxRoot); if (processingCompleted) { break; } } } if (processingCompleted) { break; } } catch (Exception ex) { this.logger.Error(ex, "An error has occured while loading the project {0}", project.Name); } } }
public static void Authentication() { var config = new ConfigurationBuilder() .SetBasePath(AppContext.BaseDirectory) .AddJsonFile("appsettings.json") .Build(); _tokenParameter = config.GetSection("tokenParameter").Get <TokenParameter>(); }
public TokenResult GoToDefinition(TokenParameter parameter, IFindReferenceProgress findReferenceProgressListener) { try { return(this.sourceCodeQueryService.FindExact(parameter)); } catch (Exception ex) { this.logger.Error(ex, "Error occured while finding definition for {0}", parameter.FullyQualifiedName); } return(null); }
public Task <List <TokenResult> > FindReferences(TokenParameter tokenParameter) { return(Task.Factory.StartNew <List <TokenResult> >(() => { if (this.findProgressListener is IClientCallback) { ((IClientCallback)this.findProgressListener).ProjectConnectionId = ControllerContext.Request.Cookie("ProjectConnectionId"); } tokenParameter.Path = tokenParameter.Path.CorrectPathToWindowsStyle(); return this.editorService.FindRefernces(tokenParameter, findProgressListener); })); }
public async Task <ActionResult> Token([FromBody] TokenParameter param) { ActionResult response = Unauthorized(); if (param.ClientSecret.IsBase64()) { var jwtResponse = await _authService.GenerateJwtAsync(param.ClientId, param.ClientSecret.ToBase64DecodeWithKey(_config["Security:EncryptKey"]), param.Username); if (!string.IsNullOrEmpty(jwtResponse.Token)) { response = Ok(jwtResponse); } } return(response); }
public List <TokenResult> FindRefernces(TokenParameter parameter, IFindReferenceProgress findReferenceProgressListener) { var result = new List <TokenResult>(); var findReferenceSyntaxWalker = new FindReferenceSyntaxWalker(); TraverseThroughAllTheProjectFiles(parameter, findReferenceProgressListener, (documentName, documentRelativePath, semanticModel, syntaxRoot) => { findReferenceSyntaxWalker.DoVisit(syntaxRoot, parameter.Text, (foundlocation) => { result.Add(new TokenResult { FileName = documentName, Path = documentRelativePath, Position = foundlocation }); }); return(false); }); findReferenceProgressListener.OnFindReferenceCompleted(result.Count); return(result); }
public BidsSet Active(TokenParameter token) { return(apiClient.GetWatched(token.AccessToken)); }
public Startup(IConfiguration configuration) { Configuration = configuration; _tokenParameter = configuration.GetSection("TokenParameter").Get <TokenParameter>() ?? throw new ArgumentNullException(nameof(_tokenParameter)); }
public BidsSet Bought(TokenParameter token) { return(apiClient.GetBought(token.AccessToken)); }
public AuthenticationController(IConfiguration configuration) { _tokenParameter = configuration.GetSection("tokenParameter").Get <TokenParameter>(); }
public JWTService(IConfiguration configuration) { _tokenParameter = configuration.GetSection("TokenParameter").Get <TokenParameter>(); }