public override void LoadingAssembly(Assembly assembly) { rr = new RowReadRelation(); AssemblyName an = assembly.GetName(); rr.Values.Add("CodeBase", an.CodeBase); rr.Values.Add("AssemblyFullName", an.FullName); rr.Values.Add("AssemblyName", an.Name); rr.Values.Add("Name", an.Name); var types = new List <IRowReceiveRelation>(); rr.Relations.Add("Types", types); }
RowReadRelation DirectoryRow(DirectoryInfo di) { var item = new RowReadRelation(); //DirectoryInfo di = new DirectoryInfo(FolderName); item.Values.Add("Name", di.Name); item.Values.Add("FullName", di.FullName); item.Values.Add("RowType", "folder"); item.Values.Add("CreationTimeUtc", di.CreationTimeUtc); item.Values.Add("LastAccessTimeUtc", di.LastAccessTimeUtc); item.Values.Add("LastWriteTimeUtc", di.LastWriteTimeUtc); return(item); }
public async Task Run() { var dict = new Dictionary <T, List <RowReadRelation> >(); foreach (var item in valuesRead) { if (!item.Values.ContainsKey(Key)) { string message = $"item values does not contain {Key}"; //@class.Log(LogLevel.Information, 0, $"transformer group relational: {message}", null, null); message += ""; continue; } var val = (T)item.Values[Key]; if (val == null) { string message = $"val is null for {Key}"; //@class.Log(LogLevel.Information, 0, $"transformer group relational: {message}", null, null); message += ""; continue; } if (!dict.ContainsKey(val)) { dict.Add(val, new List <RowReadRelation>()); } var list = dict[val]; var rr = new RowReadRelation(); rr.AddValuesFrom(item); list.Add(rr); } var ret = new List <RowReadRelation>(); foreach (var item in dict) { var rr = new RowReadRelation(); rr.Values.Add(Key, item); var list = new List <IRowReceiveRelation>(); rr.Relations.Add("childs", list); foreach (var val in item.Value) { list.Add(val); } ret.Add(rr); } valuesTransformed = ret.ToArray(); await Task.CompletedTask; }
List <IRowReceiveRelation> Files(DirectoryInfo di) { var ret = new List <IRowReceiveRelation>(); foreach (var file in di.EnumerateFiles(SearchPattern)) { var item = new RowReadRelation(); item.Values.Add("Name", file.Name); item.Values.Add("FullName", file.FullName); item.Values.Add("RowType", "file"); item.Values.Add("CreationTimeUtc", file.CreationTimeUtc); item.Values.Add("LastAccessTimeUtc", file.LastAccessTimeUtc); item.Values.Add("LastWriteTimeUtc", file.LastWriteTimeUtc); ret.Add(item); } return(ret); }
public override void ProcessTypeInfo(TypeInfo item, Assembly assembly) { var types = rr.Relations["Types"]; var typeRR = new RowReadRelation(); typeRR.Values.Add("Name", item.Name); typeRR.Values.Add("FullName", item.FullName); typeRR.Values.Add("IsGeneric", item.IsGenericType); typeRR.Values.Add("IsAbstract", item.IsAbstract); typeRR.Values.Add("IsInterface", item.IsInterface); typeRR.Values.Add("AssemblyFullName", assembly.FullName); typeRR.Values.Add("AssemblyName", assembly.GetName().Name); types.Add(typeRR); var interfaces = new List <IRowReceiveRelation>(); typeRR.Relations.Add("Interfaces", interfaces); foreach (var @interface in item.ImplementedInterfaces) { var intRR = new RowReadRelation(); intRR.Values.Add("Name", @interface.Name); intRR.Values.Add("FullName", @interface.FullName); interfaces.Add(intRR); } typeRR.Values.Add("InterfacesNr", interfaces.Count); var props = new List <IRowReceiveRelation>(); typeRR.Relations.Add("Properties", props); foreach (var prop in item.GetProperties(BindingFlags.Public | BindingFlags.Instance)) { var propRR = new RowReadRelation(); propRR.Values.Add("Name", prop.Name); props.Add(propRR); } typeRR.Values.Add("PropertiesNr", props.Count); }
public async Task LoadData() { //@class.Log(LogLevel.Information,0,$"loading from {solutionFileName}",null,null); int x = (int)Microsoft.CodeAnalysis.CSharp.Formatting.BinaryOperatorSpacingOptions.Ignore; var _ = typeof(Microsoft.CodeAnalysis.CSharp.Formatting.CSharpFormattingOptions); var rr = new Dictionary <Guid, RowReadRelation>(); var dictAssemblyNames = new Dictionary <string, List <RowReadRelation> >(); var msWorkspace = MSBuildWorkspace.Create(); //var sol = msWorkspace.OpenSolutionAsync(@"D:\TFS\stankins\stankins.sln").Result; var sol = await msWorkspace.OpenSolutionAsync(SolutionFileName); var rrhSol = new RowReadRelation(); rrhSol.Values.Add("Name", Path.GetFileNameWithoutExtension(sol.FilePath)); rrhSol.Values.Add("FilePath", sol.FilePath); rrhSol.Values.Add("Type", sol.GetType().Name); var listProjects = new List <IRowReceiveRelation>(); rrhSol.Relations.Add("projects", listProjects); rr.Add(sol.Id.Id, rrhSol); var projectGraph = sol.GetProjectDependencyGraph(); var q = projectGraph.GetTopologicallySortedProjects().ToArray(); //@class.Log(LogLevel.Information,0,$"loading from {SolutionFileName} projects: {q.Length}",null,null); foreach (var projectId in q) { var project = sol.GetProject(projectId); var rrProject = new RowReadRelation(); listProjects.Add(rrProject); rrProject.Values.Add("ID", projectId.Id); rrProject.Values.Add("Name", project.Name); rrProject.Values.Add("FilePath", project.FilePath); rrProject.Values.Add("Type", project.GetType().Name); //rrProject.Add("Solution", rrhSol); rr.Add(projectId.Id, rrProject); var refProjects = projectGraph.GetProjectsThatThisProjectDirectlyDependsOn(projectId); var listRefProjects = new List <IRowReceiveRelation>(); rrProject.Relations.Add("referencedIn", listRefProjects); foreach (var item in refProjects) { var refItem = rr[item.Id]; listRefProjects.Add(refItem); } var c = project.GetCompilationAsync().Result; var listAssemblyReferenced = new List <IRowReceiveRelation>(); rrProject.Relations.Add("assemblyReferenced", listAssemblyReferenced); var refAssembly = c.ReferencedAssemblyNames.ToArray(); foreach (var item in refAssembly) { if (!dictAssemblyNames.ContainsKey(item.Name)) { dictAssemblyNames.Add(item.Name, new List <RowReadRelation>()); } var list = dictAssemblyNames[item.Name]; var rrAssFound = list.FirstOrDefault(it => it.Values["Version"].ToString() == item.Version.ToString()); if (rrAssFound == null) { rrAssFound = new RowReadRelation(); rrAssFound.Values.Add("Name", item.Name); rrAssFound.Values.Add("DisplayNameToken", item.GetDisplayName(true)); rrAssFound.Values.Add("DisplayName", item.GetDisplayName(false)); rrAssFound.Values.Add("Version", item.Version.ToString()); list.Add(rrAssFound); } listAssemblyReferenced.Add(rrAssFound); } //var x = project.MetadataReferences.ToArray(); //var y = x.Length; valuesRead = new IRowReceive[] { rrhSol }; } }
public async Task LoadData() { var rr = new Dictionary <string, RowReadRelation>(); var rrhServer = new RowReadRelation(); foreach (var item in await GetServerDetailsAsync()) { rrhServer.Values.Add(item.Key, item.Value); } rrhServer.Values.Add("PathID", "root"); var dbsList = new List <IRowReceiveRelation>(); rrhServer.Relations.Add("databases", dbsList); var dbs = await GetDatabasesAsync(); bool allDatabases = string.IsNullOrWhiteSpace(DatabaseName); foreach (var db in dbs) { if (!allDatabases) { bool ThisDatabase = string.Compare(db.Value, DatabaseName, StringComparison.OrdinalIgnoreCase) == 0; if (!ThisDatabase) { continue; } } var rrDatabase = new RowReadRelation(); rrDatabase.Values.Add("ID", db.Key); rrDatabase.Values.Add("Name", db.Value); rrDatabase.Values.Add("PathID", db.Key); rr.Add(db.Key, rrDatabase); dbsList.Add(rrDatabase); var dbsTables = new List <IRowReceiveRelation>(); rrDatabase.Relations.Add("tables", dbsTables); var tables = await GetTablesAsync(db); foreach (var table in tables) { var rrTable = new RowReadRelation(); dbsTables.Add(rrTable); rrTable.Values.Add("ID", table.Key); rrTable.Values.Add("PathID", rrDatabase.Values["PathID"] + "_" + table.Key); rrTable.Values.Add("Name", table.Value); rr.Add(rrTable.Values["PathID"].ToString(), rrTable); var dbsColumns = new List <IRowReceiveRelation>(); rrTable.Relations.Add("columns", dbsColumns); var cols = await GetColumnsAsync(table, db); foreach (var col in cols) { var rrCol = new RowReadRelation(); rrCol.Values.Add("ID", col.Key); rrCol.Values.Add("PathID", rrTable.Values["PathID"] + "_" + col.Key); rrCol.Values.Add("Name", col.Value); rr.Add(rrCol.Values["PathID"].ToString(), rrCol); dbsColumns.Add(rrCol); } //TODO: add relationships } var dbsViews = new List <IRowReceiveRelation>(); rrDatabase.Relations.Add("views", dbsViews); var views = await GetViewsAsync(db); foreach (var view in views) { var rrView = new RowReadRelation(); dbsViews.Add(rrView); rrView.Values.Add("ID", view.Key); rrView.Values.Add("PathID", rrDatabase.Values["PathID"] + "_" + view.Key); rrView.Values.Add("Name", view.Value); rr.Add(rrView.Values["PathID"].ToString(), rrView); var dbsColumns = new List <IRowReceiveRelation>(); rrView.Relations.Add("columns", dbsColumns); var cols = await GetColumnsAsync(view, db); foreach (var col in cols) { var rrCol = new RowReadRelation(); rrCol.Values.Add("ID", col.Key); rrCol.Values.Add("PathID", rrView.Values["PathID"] + "_" + col.Key); rrCol.Values.Add("Name", col.Value); rr.Add(rrCol.Values["PathID"].ToString(), rrCol); dbsColumns.Add(rrCol); } } //TODO: add stored procs //TODO: add logins this.valuesRead = new IRowReceive[] { rrhServer }; } }