private void ValidateFilesThreadDoWork(object sender, DoWorkEventArgs e)
        {
            var listPathDbs = Directory.EnumerateFiles(pathSource, "*.mdf", SearchOption.AllDirectories).ToList();
            var totalFiles = listPathDbs.Count;
            var dbState = string.Empty;
            foreach (var file in listPathDbs)
            {
                var db = new MdfFile(file);
                dbState = string.Format("empresa{0} -> {1} ", db.Id.PadLeft(3, '0'), db.DbName.PadRight(35, '*'));
                backgroundWorkerValidate.ReportProgress(0, dbState + "adjuntando");
                db.attachDb();

                if (db.isAttached)
                {
                    backgroundWorkerValidate.ReportProgress(0, dbState + "contando objetos");
                    db.validateDb();
                    backgroundWorkerValidate.ReportProgress(0, dbState + "validando");

                    DataAccess.executeCommand(DataAccess.commandToSP(db.code));
                    db.detachDb();
                }

                var totalErrors = db.validation.listErrors;
                if (totalErrors.Count != 0)
                    DataAccess.executeCommand(DataAccess.commandToText(generateInserts(db)));

                backgroundWorkerValidate.ReportProgress(0, dbState + "terminada");

            }
        }
        private string generateInserts(MdfFile dbs)
        {
            var insertA = "insert into DETALLE_ERRORES (BASE, RUTA, EMPRESA_ID, PARTE, TIPO_ERROR) values";
            var insertB = "\n";

            insertB +=
                string.Concat(dbs.validation.listErrors.Select(x => string.Format("('{0}', '{1}', '{2}', '{3}', '{4}'),", dbs.code, dbs.PathDb, dbs.Id, dbs.Part, x)));

            return insertA + insertB.Remove(insertB.Length - 1);
        }
Ejemplo n.º 3
0
 public ValidateMdf(MdfFile db)
 {
     this.db = db;
     createConfiguration();
     executeValidation();
 }
Ejemplo n.º 4
0
 public ValidateMdf(MdfFile db)
 {
     this.db = db;
     createConfiguration();
     executeValidation();
 }