public static async Task WriteOrUpdateProcedure(string procedureURL) { DataBaseOpeartions.UpdateProcedure(procedureURL); string result = await Scrapper.Scrapper.Scrap("Conamer", procedureURL); DataBaseOpeartions.AddProcedure(procedureURL, result); }
public static async Task UpdateAllProcedures() { List <string> proceduresUrl = DataBaseOpeartions.GetAllProceduresURLs(); foreach (string procedureUrl in proceduresUrl) { await WriteOrUpdateProcedure(procedureUrl); } }
public static async Task <string> GetProcedure(string procedureURL) { if (!IsCurrent(procedureURL)) { await WriteOrUpdateProcedure(procedureURL); } DataRow row = DataBaseOpeartions.GetProcedure(procedureURL); return(row[3].ToString()); }
public static bool IsCurrent(string procedureURL) { DataRow row = DataBaseOpeartions.GetProcedure(procedureURL); DateTime lastUpdateDate = Convert.ToDateTime(row[2].ToString()); DateTime currentDate = DateTime.Now; TimeSpan differenceDate = currentDate - lastUpdateDate; int differenceDays = differenceDate.Days; if (differenceDays >= ValidityProcedureDays) { return(false); } return(true); }
public static object Transform(string url) { string conamerRawJson = DataBaseOpeartions.GetProcedure(url)[3].ToString(); dynamic conamer = JsonConvert.DeserializeObject(conamerRawJson); GetGeneralInfo(conamer); GetFundamentoJuridicoOrigenTramite(conamer); List <Requerimientos> requerimientosList = GetRequisitosList(conamer); output.Requerimientos = requerimientosList; output.FundamentosJuridicosOrigen = GetFundamentoJuridicoOrigenTramite(conamer); string outputJson = JsonConvert.SerializeObject(output, Formatting.Indented); return(JsonConvert.DeserializeObject(outputJson)); }