protected void OnPagerPrerender(object sender, EventArgs e) { var randomVignette = Utility.GetRandomImages(Server.MapPath("~/img/outlet/")); var taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); DataTable dtNews = taNews.GetListaNews("0"); var arrayBlogPosts = new ArrayList(); var k = 0; var j = 0; for (var i = 0; i < dtNews.Rows.Count; i++) { if (j > 0 && j % 12 == 0) { k++; } if (IsFirstBox(j, k) || IsSecondBox(j, k) || IsThirdBox(j, k)) { AddCartoons(arrayBlogPosts, j, randomVignette[0]); AddBlogPost(arrayBlogPosts, j, dtNews.Rows[i]); j++; } else { AddBlogPost(arrayBlogPosts, j, dtNews.Rows[i]); } j++; } lvBlogPosts.DataSource = arrayBlogPosts; lvBlogPosts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { ltrSocial.Text = Utility.ReadTemplateFromFile("pathSocial"); var promoId = Request.GetFriendlyUrlSegments()[0]; var taPromo = new DataSetVepAdminTableAdapters.NewsTableAdapter(); DataTable dtPromo = taPromo.GetDataByID(int.Parse(promoId)); var imagePath = Url + dtPromo.Rows[0]["UrlFotoHome"]; var fbMetaTagsTemplate = ReadTemplateFromFile("template_tagFb.htm"); CreateFacebookMetaTags(fbMetaTagsTemplate, imagePath, String.Format("{0}PromoDettaglio/{1}/{2}", Url, dtPromo.Rows[0]["News_ID"], dtPromo.Rows[0]["Titolo"])); }
protected void Page_Load(object sender, EventArgs e) { ltrSocial.Text = Utility.ReadTemplateFromFile("pathSocial"); string id = Request.QueryString["Id"]; DataSetVepAdminTableAdapters.NewsTableAdapter taN = new DataSetVepAdminTableAdapters.NewsTableAdapter(); DataTable dtArticolo = taN.GetDataByID(int.Parse(id)); string url = Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/");//Page.Request.Url.ToString(); string imagePath = url + "img/logo_w.png"; //BlogPost.aspx?Id string templateHtml = readTemplateFromFile("template_tagFb.htm"); string replaceImage_p = templateHtml.Replace("##image##", imagePath); string replaceUrl_p = replaceImage_p.Replace("##url##", url + "SuggDettaglio.aspx?Id=" + dtArticolo.Rows[0]["News_ID"].ToString()); string replaceTitle_p = replaceUrl_p.Replace("##titolo##", dtArticolo.Rows[0]["Titolo"].ToString()); string replaceDesc_p = replaceTitle_p.Replace("##caption##", Helper.GetShortStringAndCleanTags(Utility.CleanHtmlTagsFromString(dtArticolo.Rows[0]["Testo"].ToString()), 200)); Session["metatagFB"] = replaceDesc_p; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) //check if the webpage is loaded for the first time. { ViewState["PreviousPage"] = Request.UrlReferrer; //Saves the Previous page url in ViewState } int AlbumID = int.Parse((string)Request.QueryString["AlbumID"]); DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); DataSetVepAdminTableAdapters.AlbumsTableAdapter taAlb = new DataSetVepAdminTableAdapters.AlbumsTableAdapter(); DataTable dtAlb = taAlb.GetInfoAlbumbyID(AlbumID); if (!string.IsNullOrEmpty(dtAlb.Rows[0]["NewsEventoID"].ToString())) { DataTable dtNews = taNews.GetDataByID(int.Parse(dtAlb.Rows[0]["NewsEventoID"].ToString())); // lblArticolo.Text = dtNews.Rows[0]["Titolo"].ToString(); } lblNomeAlb.Text = PhotoManager.GetNomeAlbum(AlbumID); }
protected void _OnItemCommand(object sender, ListViewCommandEventArgs e) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; string newsID = ListViewNews.DataKeys[dataItem.DisplayIndex].Value.ToString(); if (e.CommandName == "cancella") { DataSetMateraArredamentiTableAdapters.NewsTableAdapter taNews = new DataSetMateraArredamentiTableAdapters.NewsTableAdapter(); taNews.DeleteNewsEventi(int.Parse(newsID)); } else if (e.CommandName == "modifica") { Response.Redirect("AddModNews.aspx?tipo=" + ddlTipo.SelectedValue + "&NewsID=" + newsID); } else if (e.CommandName == "fotoGallery") { DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); int idNews = int.Parse(newsID); DataSetVepAdminTableAdapters.AlbumsTableAdapter taAlbums = new DataSetVepAdminTableAdapters.AlbumsTableAdapter(); int albumID = 0; DataTable dtAlbum = taAlbums.GetIdAlbum(idNews); DataTable dtNews = taNews.GetDataByID(idNews); string idScuola = (string)Session["ddlScuola"]; if (dtAlbum.Rows.Count == 0) { albumID = Convert.ToInt32(taAlbums.InsertAlbumRetID(dtNews.Rows[0]["Descrizione"].ToString(), true, idNews)); //nuova news inserita faccio una redirect e nella sessione ho già l'id_news! Response.Redirect("~/Admin/Photos.aspx?AlbumID=" + albumID.ToString()); } else { Response.Redirect("~/Admin/Photos.aspx?AlbumID=" + dtAlbum.Rows[0]["AlbumID"].ToString()); } } ListViewNews.DataBind(); }
protected void _OnCreated(object sender, ListViewItemEventArgs e) { if (e.Item.ItemType.ToString() != "EmptyItem") { DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); ListViewDataItem dataItem = (ListViewDataItem)e.Item; string newsID = ListViewNews.DataKeys[dataItem.DisplayIndex].Value.ToString(); DataTable dtNews = taNews.GetDataByID(int.Parse(newsID)); Label lblAllegato = (Label)(e.Item.FindControl("lblAllAss")); Label lbllinkGall = (Label)(e.Item.FindControl("lbllinkGall")); Label lblVideo = (Label)(e.Item.FindControl("lblVideoAss")); Label lblriga = (Label)(e.Item.FindControl("lblriga")); lblriga.Text = (dataItem.DataItemIndex + 1).ToString(); Image imgPhoto = (Image)(e.Item.FindControl("imgPhoto")); Image imgVideo = (Image)(e.Item.FindControl("imgVideo")); Image imgAllegato = (Image)(e.Item.FindControl("imgAllegato")); if (dtNews.Rows[0]["Allegati"].ToString() != "") { imgAllegato.Visible = true; //lblAllegato.Text = "Si"; //imgAllegato.ImageUrl = "~/Admin/images/ball_blue_16.png"; } } }
protected void Page_Load(object sender, EventArgs e) { DivError.Visible = false; string idNews = Request.QueryString["NewsID"]; idTipo = Request.QueryString["tipo"]; if (idNews != null) { Session["NewsIDInserita"] = int.Parse(idNews); // si tratta di una modifica if ((txtTitoloNews.Text == "") && (txtData.Text == "") && (FCKeditor1.Value == "")) { //sto caricando una news da modificare DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); DataTable dtNews = taNews.GetDataByID(int.Parse(idNews)); News_ID.Text = idNews; txtTitoloNews.Text = dtNews.Rows[0]["Titolo"].ToString(); txtData.Text = dtNews.Rows[0]["Data"].ToString(); //txtAutore.Text = dtNews.Rows[0]["Autore"].ToString(); // txtFonte.Text = dtNews.Rows[0]["Fonte"].ToString(); txtDescrizione.Text = dtNews.Rows[0]["Descrizione"].ToString(); imgFotoArticolo.ImageUrl = "~/" + dtNews.Rows[0]["UrlFotoHome"].ToString(); if ((imgFotoArticolo.ImageUrl != "") && (imgFotoArticolo.ImageUrl != "~/") && (imgFotoArticolo.ImageUrl != "~/img/Foto/standard.jpg")) { lnkCancFoto.Visible = true; imgFotoArticolo.Visible = true; FileUploadFoto.Visible = false; ButtonUploadFoto.Visible = false; } else { imgFotoArticolo.Visible = false; FileUploadFoto.Visible = true; ButtonUploadFoto.Visible = true; } //Fotogallery if (PhotoManager.isNewsLinked(int.Parse(idNews))) { imgCancFotoG.Visible = true; txtFotoGallery.Text = "FotoAlbum associato"; btnFotoAlbum.Text = "MODIFICA FotoAlbum"; btnFotoAlbum.CssClass = "button blue"; } else { imgCancFotoG.Visible = false; txtFotoGallery.Text = "Nessun FotoAlbum associato"; btnFotoAlbum.Text = "ASSOCIA FotoAlbum"; btnFotoAlbum.CssClass = "button green"; } txtNomeFile.Text = dtNews.Rows[0]["Allegati"].ToString().Replace("public/allegati/", ""); if ((txtNomeFile.Text != "Nessun file allegato") && (txtNomeFile.Text != "")) { lnkCancAllegato.Visible = true; FileUploadAllegati.Visible = false; ButtonUploadAllegati.Visible = false; } else { txtNomeFile.Text = "Nessun file allegato"; lnkCancAllegato.Visible = false; FileUploadAllegati.Visible = true; ButtonUploadAllegati.Visible = true; } FCKeditor1.Value = dtNews.Rows[0]["Testo"].ToString(); //uso il campo autore per ved. se visualizzare la news in homepage chkboxPrjHome.Checked = false;// (bool.Parse(dtNews.Rows[0]["Autore"].ToString())); // devo prendermi anche i path degli allegati e delle foto e salvare queste info nel var di sessione Session["UrlFotoHome"] = dtNews.Rows[0]["UrlFotoHome"].ToString(); Session["UrlAllegato"] = dtNews.Rows[0]["Allegati"].ToString(); Session["DataInserimento"] = dtNews.Rows[0]["Data"].ToString(); } ButtonAgg.Visible = true; ButtonInsert.Visible = false; trFotoGallery.Visible = true; } else { if (txtTitoloNews.Text == "") //si tratta del pageload di una nuova news { string allegati = (string)Session["UrlAllegato"]; string PathStdFotoHome = Utility.SearchConfigValue("pathFotoNews") + Utility.SearchConfigValue("standardFotoName"); ButtonAgg.Visible = false; ButtonInsert.Visible = true; Session["UrlFotoHome"] = PathStdFotoHome.Remove(0, 2); imgFotoArticolo.ImageUrl = PathStdFotoHome; previewFoto.HRef = PathStdFotoHome; lnkCancFoto.Visible = false; imgFotoArticolo.Visible = false; FileUploadFoto.Visible = true; ButtonUploadFoto.Visible = true; lnkCancAllegato.Visible = false; } } }
//Pulsante di AGGIORNAMENTO della News protected void ButtonAgg_Click(object sender, EventArgs e) { int idNews = (int)Session["NewsIDInserita"]; DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); string allegati = (string)Session["UrlAllegato"]; string urlFotoHome = (string)Session["UrlFotoHome"]; // string data = (string)Session["DataInserimento"]; string data = txtData.Text; string idScuola = (string)Session["ddlScuola"]; string inHome = ""; if (chkboxPrjHome.Checked) { inHome = "si"; } else { inHome = "no"; } //scrivo la regola per l'url rewriting /* * Blog: 0 * Evento 1 * Promozione 5 * casa. 2 * manu. 3 * cucina. 4 */ //switch (idTipo) //{ // case "0": // Utility.writeXmlRewriterRules("BlogPost", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "1": // Utility.writeXmlRewriterRules("EventoDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "2": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "3": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "4": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "5": // Utility.writeXmlRewriterRules("PromoDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; //} try { News_ID.Text = idNews.ToString(); taNews.UpdateNewsEventi("_fonte", txtTitoloNews.Text, FCKeditor1.Value, System.Convert.ToDateTime(System.Convert.ToDateTime(data).ToShortDateString()) , chkboxPrjHome.Checked.ToString(), txtDescrizione.Text, idTipo, urlFotoHome, allegati, idNews ); DivSuccess.Visible = true; DivError.Visible = false; Response.Redirect("~/Admin/ManageNews.aspx?tipo=" + idTipo); } catch (Exception ex) { LabelError.Text = ex.Message; DivSuccess.Visible = false; DivError.Visible = true; } }
//Pulsante di INSERIMENTO della News /* scrivo anche la regola nel file RewriterConfing.xml*/ protected void ButtonInsert_Click(object sender, EventArgs e) { string idScuola = (string)Session["ddlScuola"]; string urlFotoHome = (string)Session["UrlFotoHome"]; string allegati = (string)Session["UrlAllegato"]; try { if (urlFotoHome == "") { urlFotoHome = Utility.SearchConfigValue("pathFotoNews") + Utility.SearchConfigValue("standardFotoName"); } DataSetVepAdminTableAdapters.NewsTableAdapter taNews = new DataSetVepAdminTableAdapters.NewsTableAdapter(); string inHome = ""; if (chkboxPrjHome.Checked) { inHome = "si"; } else { inHome = "no"; } int idNews = Convert.ToInt32(taNews.InsertNewsRetID("_fonte", txtTitoloNews.Text, FCKeditor1.Value, System.Convert.ToDateTime(txtData.Text), chkboxPrjHome.Checked.ToString(), //AUTORE ->inHome txtDescrizione.Text, idTipo, urlFotoHome, allegati)); Session["NewsIDInserita"] = idNews; Session["CaptionAlbumNews"] = txtTitoloNews.Text; News_ID.Text = idNews.ToString(); //scrivo la regola per l'url rewriting /* * Blog: 0 * Evento 1 * Promozione 5 * casa. 2 * manu. 3 * cucina. 4 */ //switch (idTipo) //{ // case "0": // Utility.writeXmlRewriterRules("BlogPost", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "1": // Utility.writeXmlRewriterRules("EventoDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "2": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "3": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "4": // Utility.writeXmlRewriterRules("SuggDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; // case "5": // Utility.writeXmlRewriterRules("PromoDettaglio", "Id", idNews.ToString(), txtTitoloNews.Text, ""); // break; //} Response.Redirect("~/Admin/ManageNews.aspx?tipo=" + idTipo); } catch (Exception ex) { DivSuccess.Visible = false; DivError.Visible = true; LabelError.Text = ex.Message; } }