} /* ValidClassNameFormat */ private void ValidateClassName() { errorProvider1.SetError(ClassName, null); if (String.IsNullOrEmpty(ClassName.Text)) { errorProvider1.SetError(ClassName, "Can not leave the name blank."); validationErrorsFound = true; return; } if (addingNewClass) { String errMsg = ValidClassNameFormat(ClassName.Text); if (errMsg != null) { errorProvider1.SetError(ClassName, errMsg); validationErrorsFound = true; } else { PicesClass existingClass = mainDbConn.MLClassLoad(ClassName.Text); if (existingClass != null) { errorProvider1.SetError(ClassName, "This name is already in use."); validationErrorsFound = true; } } } else if (ClassName.Text.ToUpper() != selectedClass.Name.ToUpper()) { // Looks like user has changed the class name; make sure it is not already in use." PicesClass existingClass = mainDbConn.MLClassLoad(ClassName.Text); if (existingClass != null) { errorProvider1.SetError(ClassName, "This name is already in use."); validationErrorsFound = true; } else { String errMsg = ValidClassNameFormat(ClassName.Text); if (errMsg != null) { errorProvider1.SetError(ClassName, errMsg); validationErrorsFound = true; } } } return; } /* ValidateClassName */
} /* ImportValidatedClassAssignments */ private PicesClass GetClassFromName(PicesDataBase threadConn, String _name ) { PicesClass pc = threadConn.MLClassLoad(_name); if (pc == null) { pc = new PicesClass(_name, ""); threadConn.MLClassInsert(pc); } return(pc); }
} /* ProcessOneFeatureVector */ private PicesClass UpdateClassId(PicesClass mlClass) { // We lock 'predictionUpdateQueue' because all other classification processes refer to it. // lock (predictionUpdateQueue) { // Maybe another Classification process already updated the database and hence updated the classId field. if (mlClass.ClassId >= 0) { //int zed = 888; } else { String className = mlClass.Name; String parentName = mlClass.ParentName; if (String.IsNullOrEmpty(parentName)) { parentName = "AllClasses"; mlClass.Parent = PicesClassList.GetUniqueClass(parentName, ""); } if (runLog == null) { runLog = new PicesRunLog(); } PicesDataBase dbConn = null; if (dbServer == null) { dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog); } else { dbConn = new PicesDataBase(dbServer, runLog); } mlClass.Description = "Added by 'Classification'"; dbConn.MLClassInsert(mlClass); if (mlClass.ClassId < 0) { PicesClass pc = dbConn.MLClassLoad(className); if (mlClass.ClassId < 0) { runLog.Writeln("ClassifierProcess.UpdateClassId ***ERROR*** mlClass.ClassId < 0 ClassName[" + className + "]"); } } // I do not know what the impact of opening and closing a lot of connections // to the MySQL data base will be, and since this method should only get called // when a new MLClass is introduced I want to sleep a little to make // sure that we do not over stress resources that I am not aware of. Thread.Sleep(100); //dbConn.Close (); dbConn = null; GC.Collect(); } } return(mlClass); }