/// <summary> /// Add method for starting parse single document /// </summary> public static void SingleParsingWithDoc(string id) { PostgreDB.ReadFilesInDB(id); FileInfo file = new FileInfo("ems-resume/" + id + ".doc"); LogicForParsing.NewParse(file.FullName, file.Name); }
/// <summary> /// Method for parse all users from postre without files /// </summary> public static void StartParsingAllWithoutDoc() { var users = PostgreDB.GetUsers(); try { MongoClient client = new MongoClient(Properties.Settings.Default.connectionStringMongo); IMongoDatabase database = client.GetDatabase("ems"); var colUsers = database.GetCollection <BsonDocument>("users"); UpdateOptions updateOptions = new UpdateOptions { IsUpsert = true }; foreach (var user in users) { FilterDefinition <BsonDocument> builders = Builders <BsonDocument> .Filter.Eq("lotuspersonUn", user.personId); colUsers.UpdateOne(builders, user.GetUserBson(), updateOptions); new Models.Exceptions_and_Events.Info("sending data", "INFO", "document " + user.personId + " succesesfull send in db", 1); } } /*Exception e - from System Exception * new Exception({params}) - from Exeptions_and_Events*/ catch (Exception e) { new Models.Exceptions_and_Events.Exception("writing in db", "ERROR", e.Message); } }
/// <summary> /// Method for training base with data from the specified folder /// </summary> /// <param name="destination_name">specified folder</param> public static void StartTraining(bool type_of_parse) { string destination_name = "ems-resume"; PostgreDB.ReadFilesInDB(); LogicForTraining.TrainList = new List <TrainSkill>(); if (Directory.Exists(destination_name)) { List <Thread> threads = new List <Thread>(); //Create list with threads DirectoryInfo dir = new DirectoryInfo(destination_name); //Open directory FileInfo[] files = dir.GetFiles("*.doc"); //Get files from directory if (files.Length != 0) { foreach (FileInfo file in files) //For each file, create new thread { threads.Add(new Thread(() => LogicForTraining.NewTrain(file.FullName))); threads.Last().Start(); } AwaitThreads(ref threads); if (type_of_parse) { WriteDataInDBWithSaving(); } else { WriteDataInDB(); } } else { new Models.Exceptions_and_Events.Exception("finding documents", "ERROR", "folder doesn't contain documents"); } } else { new Models.Exceptions_and_Events.Exception("finding folder", "ERROR", "folder not found"); } }
public EmployeesRepository(PostgreDB context) { _context = context; }