public override void Execute(Guid targetInstanceId) { loga("Iniciando job"); SPWebApplication webApp = this.Parent as SPWebApplication; Configuration config = WebConfigurationManager.OpenWebConfiguration("/", webApp.Name); loga("Crregado config e webapp"); DataTable dt = SQLConnector.GetDataTable(config.AppSettings.Settings["QueryPessoas"].Value, config.AppSettings.Settings["ConnectionStrPessoas"].Value); loga("dt carregado " + dt.Rows.Count.ToString()); SPSite site = webApp.Sites[0]; SPWeb web = site.RootWeb; loga("iniciando erase"); SPList listPessoas = EraseListPessoas(web); loga("fim erase " + listPessoas.Items.Count); loga("inicio update"); listPessoas = UpdateListPessoas(dt, web); loga("inicio fill"); FillListPessoas(dt, listPessoas); web.Dispose(); site.Dispose(); dt.Dispose(); }
public void ProcessRequest(HttpContext context) { try { //write your handler implementation here. context.Response.ContentType = "text/plain"; var query = context.Request.Params["p"]; var inv = new[] { "update", "delete", "create ", "alter ", "drop", "database" }; foreach (var i in inv) { if (query.ToLower().Contains(i)) { context.Response.StatusCode = 500; context.Response.StatusDescription = "Invalid Query"; context.Response.Write("Invalid Query"); context.Response.End(); return; } } DataTable dtSaida = SQLConnector.GetDataTable(query, ConfigurationManager.AppSettings.Get("ConnectionStrPessoas")); context.Response.ContentType = "application/json"; context.Response.Write( JsonConvert.SerializeObject(dtSaida, Formatting.Indented) ); context.Response.End(); } catch { } }