///<summary> Verify files. </summary> ///<remarks> Amartinez, 22/05/2017. </remarks> ///<param name="plLstfiles"> The pl lstfiles. </param> ///<param name="pstrPath"> Full pathname of the pstr file. </param> public static void VerifyFilesKM(List <string> plLstfiles, string pstrPath) { ImportedReportService lObjImortedReportService = new ImportedReportService(); Console.WriteLine("Verificando archivos..."); // int iIntTotalRegistros = 0; int lIntTotalArchivos = 0; foreach (string lStrFile in plLstfiles) { bool lBolExistFile = lObjImortedReportService.Exist(lStrFile); if (!lBolExistFile) { List <KilometersTraveled> lLstKilometers = ReadKilometers(pstrPath + "\\" + lStrFile); if (lLstKilometers.Count > 0) { if (SaveData(lLstKilometers, lStrFile)) { if (ImportFiles.InsertImportedReport(lStrFile)) { //iIntTotalRegistros += lLstKilometers.Count; lIntTotalArchivos++; } } } } } LogUtility.Write("Total archivos \"Distancia recorrida\" guardados: " + lIntTotalArchivos); Console.WriteLine("Total archivos \"Distancia recorrida\" guardados: " + lIntTotalArchivos); }
public static void VerifyFilesTime(List <string> plLstfiles, string pstrPath) { ImportedReportService lObjImportedReportService = new ImportedReportService(); Console.WriteLine("Verificando archivos..."); // var lLstFiles = ReadCSV.ReadFiles(pstrPath); int lIntTotalArchivos = 0; foreach (string lStrFile in plLstfiles) { bool lBolExistFile = lObjImportedReportService.Exist(lStrFile); if (!lBolExistFile) { List <TimeEngine> lListTimeEngine = ReadTimeEngine(pstrPath + "\\" + lStrFile); if (lListTimeEngine.Count > 0) { if (SaveData(lListTimeEngine, lStrFile)) { if (ImportFiles.InsertImportedReport(lStrFile)) { lIntTotalArchivos++; } } } } } LogUtility.Write("Total archivos de \"Tiempo de motor\" guardados: " + lIntTotalArchivos); Console.WriteLine("Total archivos \"Tiempo de motor\" guardados: " + lIntTotalArchivos); }
private void timer_Elapsed(object sender, ElapsedEventArgs e) { tmrService.Enabled = false; try { if (!mBolProcessInProgress) { mBolProcessInProgress = true; LogUtility.Write("Proceso de importar Reporte de distancia iniciado"); string lStrPathKM = ConfigurationManager.AppSettings["PathKM"]; //@"C:\Users\amartinez\Desktop\csv\KM"; if (!string.IsNullOrEmpty(lStrPathKM)) { List <string> lLstFilesKM = ImportFiles.FindFiles(lStrPathKM); ReadCsvKm.VerifyFilesKM(lLstFilesKM, lStrPathKM); } LogUtility.Write("Proceso reporte de distancia terminado"); LogUtility.Write("Proceso de Importar reporte de horas de motor iniciado"); string lStrPathTime = ConfigurationManager.AppSettings["PathTIME"]; //@"C:\Users\amartinez\Desktop\csv\TIME"; if (!string.IsNullOrEmpty(lStrPathTime)) { List <string> lLstFilesTime = ImportFiles.FindFiles(lStrPathTime); ReadCsvTime.VerifyFilesTime(lLstFilesTime, lStrPathTime); } LogUtility.Write("Proceso horas de motor terminado"); mBolProcessInProgress = false; } } catch (Exception ex) { string msg = ex.Message; Exception ie = ex.InnerException; while (ie != null) { msg += "||" + ie.Message; ie = ie.InnerException; } LogUtility.Write(msg); } finally { } tmrService.Enabled = true; }
public static bool SaveData(List <TimeEngine> pListTimeEngine, string pstrPath) { Console.Write("Guardando archivo: "); TimeEngineService lObjTimeEngineService = new TimeEngineService(); foreach (TimeEngine lObjTimeEngine in pListTimeEngine) { int lIntErrorCode = lObjTimeEngineService.Add(lObjTimeEngine); if (lIntErrorCode != 0) { Console.WriteLine(DIApplication.Company.GetLastErrorDescription()); LogUtility.Write(DIApplication.Company.GetLastErrorDescription() + " En archivo: " + Path.GetFileName(pstrPath)); return(false); } } Console.WriteLine(" OK "); ImportFiles.InsertImportedReport(pstrPath); Console.WriteLine("Archivo: " + Path.GetFileName(pstrPath) + " Guardado correctamente"); LogUtility.Write("Archivo: " + Path.GetFileName(pstrPath) + " Guardado correctamente"); return(true); }
static void Main(string[] args) { Credentials lObjCredentials = new Credentials(); //lObjCredentials.LicenseServer = ConfigurationManager.AppSettings["LicenseServer"].ToString(); lObjCredentials.UserName = ConfigurationManager.AppSettings["UsernameSAP"].ToString(); lObjCredentials.Password = ConfigurationManager.AppSettings["PasswordSAP"].ToString(); switch (ConfigurationManager.AppSettings["DBServer"].ToString()) { case "MSSQL2012": lObjCredentials.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; break; case "MSSQL2014": lObjCredentials.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2014; break; case "MSSQL2016": lObjCredentials.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2016; break; default: break; } //lObjCredentials.DbServerType = SAPbobsCOM.BoDataServerTypes.dst_MSSQL2012; lObjCredentials.SQLServer = ConfigurationManager.AppSettings["SQLServer"].ToString(); lObjCredentials.SQLUserName = ConfigurationManager.AppSettings["UsernameSQL"].ToString(); lObjCredentials.SQLPassword = ConfigurationManager.AppSettings["PasswordSQL"].ToString(); lObjCredentials.DataBaseName = ConfigurationManager.AppSettings["DBName"].ToString(); //lObjCredentials.Language = SAPbobsCOM.BoSuppLangs.ln_English; DIConnection lObjDIConnection = new DIConnection(); lObjDIConnection.ConnectToDI(lObjCredentials); if (lObjDIConnection.Company != null && lObjDIConnection.Company.Connected) { DIApplication.DIConnect(lObjDIConnection.Company); } //IList<string> list = new List<string>() { "raul", "martin", "anaya", "rojo" }; //Console.WriteLine(string.Join(",", list.ToArray())); //Console.ReadLine(); GPSFactoryServices lObjGPSFactoryServices = new GPSFactoryServices(); lObjGPSFactoryServices.GetSetupService().InitializeTables(); UGRS.Core.SDK.DI.Configuration.ConfigurationServicesFactory lObjConfigurationFactoryServices = new UGRS.Core.SDK.DI.Configuration.ConfigurationServicesFactory(); //ServiceBase[] ServicesToRun = new ServiceBase[] //{ // new SAP_ServiceGPS() //}; //ServiceBase.Run(ServicesToRun); string lStrPathKM = ConfigurationManager.AppSettings["PathKM"].ToString(); string lStrPathTime = ConfigurationManager.AppSettings["PathTime"].ToString(); if (!string.IsNullOrEmpty(lStrPathKM)) { //@"C:\Users\amartinez\Desktop\csv\KM"; List <string> lLstFilesKM = ImportFiles.FindFiles(lStrPathKM); ReadCsvKm.VerifyFilesKM(lLstFilesKM, lStrPathKM); } else { LogUtility.Write("Error al momento de consultar el directorio Kilometros recorridos"); } if (!string.IsNullOrEmpty(lStrPathTime)) { //@"C:\Users\amartinez\Desktop\csv\TIME"; List <string> lLstFilesTime = ImportFiles.FindFiles(lStrPathTime); // ReadCsvTime.VerifyFilesTime(lLstFilesTime, lStrPathTime); } else { LogUtility.Write("Error al momento de consultar el directorio de Horas de motor"); } //ReadCSV.ReadKilometers(@"C:\testkm.csv"); //ReadCSV.ReadTimeEngine(@"C:\test.csv"); }