private void processFile(string phoneId, string path, DBManager dbm) { string fileName = Path.GetFileName(path); if (!dbm.isFileProcess(phoneId, fileName, false)) { dbm.saveFile(phoneId, fileName, false, false, new FileInfo(path).Length); try { dbm.beginTransaction(phoneId + fileName); string date = Path.GetFileNameWithoutExtension(path).Substring(0, 8); StreamReader sr = new StreamReader(path); while (!sr.EndOfStream) this.processLine(sr.ReadLine(), fileName, date, dbm); sr.Close(); dbm.saveFile(phoneId, fileName, true, false, new FileInfo(path).Length); dbm.endTransaction(phoneId + fileName,true); } catch (Exception ex) { dbm.endTransaction(phoneId + fileName, false); } } }
public void execute(string phoneId,string zipPath,string pass) { DBManager dbm = new DBManager(); try { string res = dbm.saveFile(phoneId, Path.GetFileName(zipPath), false, true, new FileInfo(zipPath).Length); if (res == "OK.") { ZipManager zm = new ZipManager(); zm.descomprimirDir(zipPath, pass, Path.GetDirectoryName(zipPath), new ZipLog()); string[] files = Directory.GetFiles(Path.GetDirectoryName(zipPath), "*.txt", SearchOption.TopDirectoryOnly); for (int i = 0; (i < files.Length) && (res == "OK."); i++) { this.processFile(phoneId, files[i], dbm); File.Delete(files[i]); } if (res == "OK.") dbm.saveFile(phoneId, Path.GetFileName(zipPath), true, true, new FileInfo(zipPath).Length); } } catch (Exception ex) { dbm.saveFile(phoneId, Path.GetFileName(zipPath), false, true, new FileInfo(zipPath).Length); } }