public JsonResult getPublicationInfo(ClimaticPublication data) { string userIpAddress = this.Request.UserHostAddress; try { ClimaticPublication pub = new ClimaticPublication(); if (HttpContext.Request.IsAjaxRequest()) { //get the source attribute pub = pub.getPublicationInfo(data.idResource); //NOT SOURCE YET, TODO //IF SCRAP IS 0 = not apply getScrapData if (pub.Scrap == 1) { String href = getScrapData(pub); if (href.Length <= 1) { //This below, should prevent the bad requested Publications to be displayed pub.State = 0; } else { if (pub.OriginalURL.Length == 0) { pub.source += href; } else if (href.Length >= 90) { pub.source = href; } else { //Original ID has the reference value pub.source = pub.OriginalURL += href; } } } return(Json(pub, JsonRequestBehavior.AllowGet)); } return(null); } catch (Exception ex) { //Log error DBcontext.setPiactProblem(ex.Message, ex.StackTrace, "NA", userIpAddress, "BETA"); return(null); } }
public JsonResult findFileByName(ClimaticPublication pub) { if (HttpContext.Request.IsAjaxRequest()) { try { if (pub.title.Length >= 10) { pub.title = pub.title.Substring(0, 10); } if (pub.title.Length >= 3) { List <ClimaticPublication> list = (List <ClimaticPublication>)Session["files"]; List <ClimaticPublication> res = new List <ClimaticPublication>(); // list = FileContext.readFilesFromLocalPath("/Biblioteca"); string ext = ""; foreach (ClimaticPublication fi in list) { ext = (fi.title); String icon = ext.ToUpper(); if (icon.Contains(pub.title.ToUpper())) { ext = fi.source; ext = Path.GetExtension(ext); fi.OriginalURL = loadIcon(ext); res.Add(fi); } } // return View(ShowContent); return(Json(res, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(null, JsonRequestBehavior.AllowGet)); throw; } return(null); } else { return(null); } }
//public ActionResult IndexResource() //{ // return View(); //} //public ActionResult Files() //{ // return View(); //} //prueba Scraping private String getScrapData(ClimaticPublication pub) { string userIpAddress = this.Request.UserHostAddress; //return ScrapContext.loadScrapByPubID(pubID); try { String href = ""; if (pub.nodeIndex > 0) { href = ScrapContext.scrapPubByPubIndex(pub.source, pub.nodeIndex, pub.tagType); } else { switch (pub.idPublication) { case 26: href = ScrapContext.scrap26anomSST(); break; case 29: href = ScrapContext.scrap29anomDepth(); break; //ENOS plumas case 66: href = ScrapContext.scrapInGroup(pub.idPublication, pub.source); break; case 67: href = ScrapContext.scrapInGroup(pub.idPublication, pub.source); break; default: break; } } return(href); } catch (Exception ex) { DBcontext.setPiactProblem(ex.Message, ex.StackTrace, userIpAddress, "IP", "BETA"); return("Server error"); } }
public JsonResult getPubBySection(Sections section) { string userIpAddress = this.Request.UserHostAddress; try { if (HttpContext.Request.IsAjaxRequest()) { List <ClimaticPublication> Publication_List = new List <ClimaticPublication>(); int id = 0; Int32.TryParse(section.Name, out id);//Security feature, handeling indexes //Case for get DAta in Entrevistas if (id == 32 || id == 19 || id == 20) { int pageNum = 0; Int32.TryParse(section.pageNum, out pageNum);//Security feature, handeling indexes Session["Publication_List"] = ClimaticPublication.getPublicationBySection(id, pageNum); Publication_List = (List <ClimaticPublication>)Session["Publication_List"]; } else { Session["Publication_List"] = ClimaticPublication.getPublicationBySection(id); Publication_List = (List <ClimaticPublication>)Session["Publication_List"]; } foreach (ClimaticPublication pub in Publication_List) { //IF SCRAP IS 0 = not apply getScrapData if (pub.Scrap == 1) { String href = getScrapData(pub); if (href.Length <= 1) { //This below, should prevent the bad requested Publications to be displayed pub.State = 0; } else { if (pub.OriginalURL.Length == 0 && href.Length < 600) { pub.source += href; } else if (href.Length >= 90) { pub.source = href; } else { //Original ID has the reference value pub.source = pub.OriginalURL += href; } } } } return(Json(Publication_List, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { if (ex.Message.Contains("network-related")) { //send user some alert about the network related problem } else { //Log error DBcontext.setPiactProblem(ex.Message, ex.StackTrace, "NA", userIpAddress, "BETA"); } } return(null); }
public JsonResult setPublicationInfo(ClimaticPublication publication) { if (HttpContext.Request.IsAjaxRequest()) { try { //Traking String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name; TrackLog(location, "Create Publication: " + "Source: " + publication.idPublication); if (publication.img != null) { if (publication.idDisplayMode == 1) { String path = publication.tagType; if (path == null) { return(null); } path = path.Split('/').Last(); if (path.ToString().Length > 4) { //If is FIle, store it in local server and return saved virtual path String to pass it to ppub Source FileContext.SaveByteArrayAsImage(path, publication.img, "/img"); publication.tagType = ""; publication.img = null; //get the source attribute Boolean res = ClimaticPublication.setPublicationInfo(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } } else if (publication.idDisplayMode == 3) { //Youtube update source publication.source = publication.img; publication.img = null; Boolean res = ClimaticPublication.setPublicationInfo_Source(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } else { //Clean flags Boolean res = ClimaticPublication.setPublicationInfo(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } } else { //get the source attribute Boolean res = ClimaticPublication.setPublicationInfo(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { //SAVE LOG //Log error string userIpAddress = this.Request.UserHostAddress; DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA"); return(null); } } return(null); }
public JsonResult setInterviewPublicationInfo(ClimaticPublication publication) { if (HttpContext.Request.IsAjaxRequest()) { //validate USER VAR try { //Traking String location = "Class: " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; location += "-Method: " + System.Reflection.MethodBase.GetCurrentMethod().Name; TrackLog(location, "Update publication id: " + publication.idPublication); //THE NEXT RULE JUST ALLOW INTERVIEWS AND BIBLIOTECA TO UPLOAD CONTENT if (publication.idPublication == 32) { String res = ""; //Upload file for Biblioteca try { if (publication.img != null) { if (publication.idDisplayMode == 2) { String path = publication.tagType; path = path.Split('/').Last(); if (path.ToString().Length > 4) { //If is FIle, store it in local server and return saved virtual path String to pass it to ppub Source FileContext.SaveByteArrayAsImage(path, publication.img, "/Biblioteca"); publication.tagType = ""; publication.img = null; publication.source = path; //SAVE ICON in Original URL column String ext = Path.GetExtension(path); publication.OriginalURL = loadIcon(ext); //get the source attribute res = ClimaticPublication.setInterviewPublicationInfo(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } } else { //UPDATE res = ClimaticPublication.setPublicationInfo(publication).ToString(); return(Json(res, JsonRequestBehavior.AllowGet)); } } else { //if cannot upload full do nothing return(null); } } catch (Exception ex) { //SAVE LOG //Log error string userIpAddress = this.Request.UserHostAddress; DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA"); return(null); } } else if (publication.idPublication == 19 || publication.idPublication == 20) { //get the source attribute String res = ClimaticPublication.setInterviewPublicationInfo(publication); return(Json(res, JsonRequestBehavior.AllowGet)); } return(null); } catch (Exception ex) { //Log error string userIpAddress = this.Request.UserHostAddress; DBcontext.setPiactProblem(ex.Message, ex.StackTrace, Session["email"].ToString(), userIpAddress, "BETA"); } } return(null); }