I'm creating project which will parse .html to database (kind of sqlite or other, it's not important yet). Database will has many tables, relationship and to understanding the schema will be some difficult, well I'll show you more simple Schema.
For example:
Models:
Subject: SubjectId, NameTeacher: TeacherId, SubjectFk, Name, SurnameClassRoom: ClassRoomId, yearStudent: StudentId, ClassRoomFk, Name, Surname
Relations (it's not important!):
One subject is leading by multiple teacher, one teacher leads only one subject
One ClassRoom contains many students, one students belongs to only one classRoom
Is unique pair: TeacherId, ClassRoomId (In one classRoom can be only one object carried by a particular teacher, many teachers can not teach in a classRoom of the same subject, iam not sure...but it's not important).
Now I build a project hierarchy:
ParseData - solution name
ParseData.Repository - it contains App.Config which contains app settings to root folder where exist data.
ParseData.Domain - Classes for data model which will be parse, for example:
public class Student
{
public int StudentId {get;set;}
public string Name {get;set;}
public string Surname {get;set;}
public int ClassRoomFk {get;set;}
}
public class ClassRoom
{
public int ClasRoomId {get; set;}
public List<Student> Students {get;set;}
}
ParseData.Core - contains all algorithm and Classes which will read file from path and convert data to class model, for example:
public class StudentParse : IEntity<Student>
{
public Student Student {get; set;}
public StudentParse(string filePathWithDataForStudentsFromParticularClass, int ClassRoomFk) { (...) }
/* All methods, which will parse data to StudentModel */
}
public class ClassRoomParse : IEntity<ClassRoom>
{
public ClassRoom ClassRoom {get;set;}
public ClassRoomParse(string filePathWithClassRoomsData) { (...) }
/* All methods, which will parse data to ClassRoomModel */
}
public interface IParser
{
string filePathToMainFile {get;set;}
List<ClassRoom> Start();
}
ParseData.UI - Console application. Here i can write some code which will present me results from featching data. For example:
IParser parser = new Parser(Repository.MainFilePath);
List<ClassRoom> parser.Start();
/* LINQ or other actions..save to file or something else */
I'm searching a knowledge how could I organize my solution to best practices. I am open to criticism about my approach and inexperience.
Aucun commentaire:
Enregistrer un commentaire