public SetStateContent ( int contentId, int state ) : bool | ||
contentId | int | |
state | int | |
return | bool |
private static void Pubblica(Content content, CMSCustomer customer) { string fileserver = ConfigurationSettings.AppSettings["ServerPath"]; string idcont = content.Contentid.ToString(); string iditemamm = content.Iditem.ToString(); string type = content.Repository; //Allineo lo stato del content ContentServices svc = new ContentServices(); svc.SetStateContent(content.Contentid, (int)ContentStateEnum.Allineato); if (type == "std") { //Contenuti Standard //cms.CoreLib.Net1.validation validation = new cms.CoreLib.Net1.validation(); string Title = customer.GetItemTitle(Convert.ToInt32(iditemamm), type); string pathIdItem = customer.GetItemPath(iditemamm, type); // string pathIdItem = @"contenutiAdm\" + iditemamm; // string response = string.Empty; EditorServices.PublicContent(Convert.ToInt32(idcont), pathIdItem, Title); // response = "~/" + response.Replace("\\", "/"); //Ricavo l'id Utente int iditemuser = Convert.ToInt32(customer.GetItemIdUser(Convert.ToInt32(iditemamm))); //cms.CoreLib.Net1.Item NewItem = new cms.CoreLib.Net1.Item(); //OracleDataReader objReader = NewItem.GetItemContent(Convert.ToInt32(iditemamm)); //objReader.Read(); //if (objReader["corrispond_item_id"] != DBNull.Value) { // iditemuser = Convert.ToInt32(objReader["corrispond_item_id"]); // cms.CoreLib.Net1.Item NewItemUS = new cms.CoreLib.Net1.Item(); // OracleDataReader objReaderUS = NewItemUS.GetItemContent(iditemuser); // objReaderUS.Read(); // if (objReaderUS["item_contents_id"] != DBNull.Value) { // int CorrispondIDContentUS = Convert.ToInt32(objReaderUS["item_contents_id"]); // NewItem.UpdContentStyle(CorrispondIDContentUS, 'F', "default.html"); // } // objReaderUS.Close(); //} //objReader.Close(); string pathIdItemUser = @"contenuti\" + iditemuser; CopyDirectory(Path.Combine(fileserver, pathIdItem), Path.Combine(fileserver, pathIdItemUser), true); //LUCENE customer.IndexItem(iditemuser); //EAI customer.UpdStdDoc(iditemuser); //response = "~/" + @"contenuti/" + iditemuser + @"/default.html"; //Response.Redirect(response); } else if (type == "com") { //Contenuti Commerciali //cms.Entities.Document doc = new cms.Entities.Document(Convert.ToInt32(iditemamm)); //doc.Load(); string Title = customer.GetItemTitle(Convert.ToInt32(iditemamm), type); //string pathIdItem = doc.View(""); //string pathIdItemUser = ""; //pathIdItemUser = pathIdItem = pathIdItem.Substring(0, pathIdItem.IndexOf("/Editor/")).Replace("/", @"\"); //pathIdItemUser = pathIdItem + @"\"; //pathIdItem = pathIdItem + @"\Admin"; string pathIdItem = customer.GetItemPath(iditemamm, type); string pathIdItemUser = pathIdItem;// = pathIdItem.Substring(0, pathIdItem.IndexOf("/Editor/")).Replace("/", @"\"); pathIdItemUser = pathIdItem + @"\"; pathIdItem = pathIdItem + @"\Admin"; string response = string.Empty; EditorServices.PublicContent(Convert.ToInt32(idcont), pathIdItem, Title); CopyDirectory(Path.Combine(fileserver, pathIdItem), Path.Combine(fileserver, pathIdItemUser), true); //EAI customer.UpdCommDoc(Convert.ToInt32(iditemamm)); //pathIdItemUser = pathIdItemUser.Replace(@"\", "/"); //response = "~/" + pathIdItemUser + @"/default.html"; //Response.Redirect(response); } }
public PageDTO MovePage(PageDTO pagedto) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { ITransaction transaction = session.BeginTransaction(); try { if (pagedto.Parentpageid > 0) { //Prendo i Figli del nuovo padre della pagina DTO List<Page> Figli = new List<Page>(); Figli = EditorServices.GetPageByParent(session, pagedto.Contentid, pagedto.Parentpageid); bool update = false; //Aggiorno la posizione dei figli successivi al DTO //Controllo se esiste un figlio in posizione 1 //var uone = (from u in Figli // where u.Position == 1 // select u).FirstOrDefault<Page>(); int oldpos = 0; var con = (from f in Figli where f.Pageid == pagedto.Pageid select f).FirstOrDefault<Page>(); if (con != null) { oldpos = con.Position; } foreach (Page pg in Figli) { if (pg.Pageid == pagedto.Pageid) { oldpos = pg.Position; pg.Position = pagedto.Position; pg.Parentpageid = pagedto.Parentpageid; pg.Dirty = true; HibernateHelper.Persist(pg, session); update = true; } else if (pg.Position > pagedto.Position) { pg.Position = pg.Position + 1; pg.Dirty = true; HibernateHelper.Persist(pg, session); } else if (pg.Position <= pagedto.Position // && pg.Position != 1 && con != null) { if (pg.Position == pagedto.Position && oldpos > pagedto.Position) { pg.Position = pg.Position + 1; } else { pg.Position = pg.Position - 1; } pg.Dirty = true; HibernateHelper.Persist(pg, session); } } if (!update) { Page page = new Page(); Mapper.CreateMap<PageDTO, Page>(); Mapper.CreateMap<PageElementDTO, PageElement>(); Mapper.CreateMap<ElementDTO, Element>(); //Mappo la PageDTO in Page page = Mapper.Map<PageDTO, Page>(pagedto); HibernateHelper.Persist(page, session); } transaction.Commit(); transaction = session.BeginTransaction(); Figli = EditorServices.GetPageByParent(session, pagedto.Contentid, pagedto.Parentpageid); var child = from cd in Figli orderby cd.Position ascending select cd; int position = 1; foreach (Page ch in child) { ch.Position = position; ch.Dirty = true; position++; HibernateHelper.Persist(ch, session); } transaction.Commit(); } } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); transaction.Dispose(); } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(pagedto.Contentid, (int)ContentStateEnum.NonAllineato); return pagedto; }
public PageDTO SavePage(PageDTO pagedto) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { Page page = new Page(); Mapper.CreateMap<PageDTO, Page>(); Mapper.CreateMap<PageElementDTO, PageElement>(); Mapper.CreateMap<ElementDTO, Element>(); //Mappo la PageDTO in Page page = Mapper.Map<PageDTO, Page>(pagedto); Regex punt = new Regex(@"[\t\r\n\e\a._%+-/]"); page.Title = punt.Replace(page.Title.Replace(" ", "").Trim().Replace(" ", "_"), "_"); if (page.Publictitle != null && page.Contentid > 0 && page.Position > 0) { page.Publictitle = EditorServices.ReplaceCharacters(page.Publictitle); if (page.IsNew) { // Salvo la Nuova pagina HibernateHelper.Persist(page, session); if (page.PageelementsList.Count == 0) { //Creo Le Page Elements in base alla struttura //Ricavo la lista degli elementi della struttura per generare i PageElement List<Element> structList = new List<Element>(); structList = HibernateHelper.SelectCommand<Element>(session, " STRUCTUREID =" + page.Structureid); ISet<PageElement> PaElements = new HashedSet<PageElement>(); foreach (Element el in structList) { PageElement PaElement = new PageElement(); PaElement.Element = el; PaElement.Elementid = el.Elementid; PaElement.Page = page; PaElement.Pageid = page.Pageid; PaElement.Valore = EditorServices.ReplaceCharacters(el.Description); PaElement.IsNew = true; if (el.Elementtypeid == (int)ElementTypeEnum.RawHtml) { //solo RawHtml RawHtml raw = new RawHtml(); raw.Value = EditorServices.ReplaceCharacters(el.Description); raw.IsNew = true; HibernateHelper.Persist(raw, session); PaElement.Rawhtmlid = raw.Rawhtmlid; } HibernateHelper.Persist(PaElement, session); PaElements.Add(PaElement); } page.PageElements = PaElements; PaElements = page.PageElements; } // Setto il padre al pageid se è zero if (page.Parentpageid == 0) { page.Parentpageid = page.Pageid; } else { page.Parentpageid = page.Parentpageid; } // Setto skinID a null se è zero if (page.Skinid == 0) { page.Skinid = null; } page.Dirty = true; HibernateHelper.Persist(page, session); } else if (page.Dirty) { //Update della Pagina Esistente HibernateHelper.Persist(page, session); //Foreach delle pageelements foreach (PageElement el in page.PageelementsList) { el.Pageid = page.Pageid; if (el.Deleted) { page.PageElements.Remove(el); HibernateHelper.Persist(el, session); } else { el.Valore = EditorServices.ReplaceCharacters(el.Valore); HibernateHelper.Persist(el, session); } } } } //Rimappo l'oggetto da restituire Mapper.CreateMap<Page, PageDTO>(); Mapper.CreateMap<PageElement, PageElementDTO>(); Mapper.CreateMap<Element, ElementDTO>(); //Mappo la PageDTO in Page pagedto = Mapper.Map<Page, PageDTO>(page); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); } } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(pagedto.Contentid, (int)ContentStateEnum.NonAllineato); return pagedto; }
public PageDTO ClonePage(PageDTO pagedto, int idItemAmm, string FolderToSave) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { Page page = new Page(); Mapper.CreateMap<PageDTO, Page>(); Mapper.CreateMap<PageElementDTO, PageElement>(); //Mappo la PageDTO in Page page = Mapper.Map<PageDTO, Page>(pagedto); //Tengo in memoria il pageid da clonare int pageId = page.Pageid; //Salvo la nuova Pagina HibernateHelper.Persist(page, session); //Ricavo i PageElements del padre List<PageElement> CloneElements = HibernateHelper.SelectCommand<PageElement>(session, new string[] { "Pageid" }, new object[] { pageId }, new Operators[] { Operators.Eq }); //Ciclo sui CloneElements ISet<PageElement> ChildElements = new HashedSet<PageElement>(); foreach (PageElement el in CloneElements) { PageElement child = new PageElement(); child.IsNew = true; child.Page = page; child.Pageid = page.Pageid; child.Valore = EditorServices.ReplaceCharacters(el.Valore); child.Filename = el.Filename; child.Element = el.Element; child.Elementid = el.Elementid; if (el.Element.ElementType.Elementtypeid == (int)ElementTypeEnum.RawHtml) { //Get RawHtml Clone RawHtml cloneraw = new RawHtml(); cloneraw = HibernateHelper.SelectIstance<RawHtml>(session, new string[] { "Rawhtmlid" }, new object[] { el.Rawhtmlid }, new Operators[] { Operators.Eq }); RawHtml childraw = new RawHtml(); childraw.IsNew = true; childraw.Value = EditorServices.ReplaceCharacters(cloneraw.Value); SaveRawHtml(childraw, FolderToSave); child.Rawhtmlid = childraw.Rawhtmlid; } HibernateHelper.Persist(child, session); ChildElements.Add(child); } page.PageElements = ChildElements; ChildElements = page.PageElements; // Setto il padre al pageid se è zero if (page.Parentpageid == 0) { page.Parentpageid = page.Pageid; } else { page.Parentpageid = page.Parentpageid; } // Setto skinID a null se è zero if (page.Skinid == 0) { page.Skinid = null; } page.Dirty = true; HibernateHelper.Persist(page, session); //Rimappo l'oggetto da restituire Mapper.CreateMap<Page, PageDTO>(); Mapper.CreateMap<PageElement, PageElementDTO>(); Mapper.CreateMap<Element, ElementDTO>(); //Mappo la PageDTO in Page pagedto = Mapper.Map<Page, PageDTO>(page); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); } } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(pagedto.Contentid, (int)ContentStateEnum.NonAllineato); return pagedto; }
public Boolean DeletePage(PageDTO pagedto) { Boolean status = false; using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { Page page = new Page(); Mapper.CreateMap<PageDTO, Page>(); Mapper.CreateMap<PageElementDTO, PageElement>(); //Mappo la PageDTO in Page page = Mapper.Map<PageDTO, Page>(pagedto); //Prendo i Figli del padre della pagina DTO List<Page> Figli = new List<Page>(); Figli = EditorServices.GetPageByParent(session, page.Contentid, page.Parentpageid); //Sposto il Pagedto Salvato accodandolo all'ultima posizione del cestino Page Cestino = new Page(); Cestino = EditorServices.GetBasket(session, page.Contentid); int actualpos = 0; if (Cestino != null) { List<Page> Cestinati = new List<Page>(); Cestinati = EditorServices.GetPageByParent(session, page.Contentid, Cestino.Pageid); if (Cestinati.Count > 0) { actualpos = (from c in Cestinati select c.Position).Max(); } } //Decremento la posizione dei figli successivi al DTO foreach (Page pg in Figli) { if (pg.Position > pagedto.Position) { pg.Position = pg.Position - 1; pg.Dirty = true; HibernateHelper.Persist(pg, session); } else if (pg.Pageid == page.Pageid) { page = pg; pg.Parentpageid = Cestino.Pageid; pg.Position = actualpos + 1; pg.Dirty = true; pg.Deleted = false; HibernateHelper.Persist(pg, session); } } transaction.Commit(); status = true; } catch (Exception ex) { transaction.Rollback(); status = false; throw ex; } finally { session.Flush(); session.Close(); } } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(pagedto.Contentid, (int)ContentStateEnum.NonAllineato); return status; }
public List<WidgetElementDTO> SynchronizeWidgetElement(int contentId, int iditemamm, string type) { bool result = false; result = _SynchronizeWidgetElement(contentId, iditemamm, type); List<WidgetElementDTO> ListToReturn = new List<WidgetElementDTO>(); if (result) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { //Ricava il/i Widget del content IList<Widget> widges = new List<Widget>(); widges = EditorServices.GetWidgetByContent(session, contentId) as List<Widget>; foreach (Widget wid in widges) { if (wid.Structureid == 4) { //è Utility e link if (wid.WidgetElementsList != null && wid.WidgetElementsList.Count > 0) { Mapper.CreateMap<WidgetElement, WidgetElementDTO>(); Mapper.CreateMap<Element, ElementDTO>(); ListToReturn.AddRange(Mapper.Map<List<WidgetElement>, List<WidgetElementDTO>>(wid.WidgetElementsList)); } } } //Riordino per widgetid e position var OrderedList = (from c in ListToReturn orderby c.Widgetid ascending, c.Position ascending select c).ToList<WidgetElementDTO>(); return OrderedList; } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); } } } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(contentId, (int)ContentStateEnum.NonAllineato); return ListToReturn; }
public WidgetElementDTO SaveWidgetElement(WidgetElementDTO wid) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { WidgetElement widget = new WidgetElement(); Mapper.CreateMap<WidgetElementDTO, WidgetElement>(); Mapper.CreateMap<ElementDTO, Element>(); WidgetElementDTO widgetDTO = new WidgetElementDTO(); if (wid.IsNew || wid.Deleted) { widget = Mapper.Map<WidgetElementDTO, WidgetElement>(wid); } else { widgetDTO = GetWidgetElement(wid.Widgetelementid); widget = Mapper.Map<WidgetElementDTO, WidgetElement>(widgetDTO); } if (widget.Type == 0) { widget.Type = 1; } if (widget.Name != null && widget.Widgetid > 0 && widget.Position > 0) { if (wid.Dirty) { if (widget.Name != wid.Name) { //Sto rinominando il link widget.Name = EditorServices.ReplaceCharacters(wid.Name); } else { if (widget.Valore != wid.Valore) { widget.Valore = wid.Valore; } } } widget.Dirty = wid.Dirty; widget.Deleted = wid.Deleted; widget.IsNew = wid.IsNew; HibernateHelper.Persist(widget, session); } Mapper.CreateMap<WidgetElement, WidgetElementDTO>(); Mapper.CreateMap<Element, ElementDTO>(); //Mappo la PageDTO in Page wid = Mapper.Map<WidgetElement, WidgetElementDTO>(widget); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); } } //Setto lo stato del content a non allineato WidgetDTO widg = new WidgetDTO(); widg = GetWidget(wid.Widgetid); ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(widg.Contentid, (int)ContentStateEnum.NonAllineato); return wid; } }
public WidgetDTO SaveWidget(WidgetDTO Widgetdto) { using (ISession session = HibernateHelper.GetSession().OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { try { Widget widget = new Widget(); Mapper.CreateMap<WidgetDTO, Widget>(); Mapper.CreateMap<WidgetElementDTO, WidgetElement>(); Mapper.CreateMap<ElementDTO, Element>(); widget = Mapper.Map<WidgetDTO, Widget>(Widgetdto); Regex punt = new Regex(@"[\t\r\n\e\a._%+-/]"); widget.Title = punt.Replace(widget.Title.Replace(" ", "").Trim().Replace(" ", "_"), "_"); if (widget.Publictitle != null && widget.Contentid > 0 && widget.Position > 0) { widget.Publictitle = EditorServices.ReplaceCharacters(widget.Publictitle); HibernateHelper.Persist(widget, session); //Foreach delle WidgetElements foreach (WidgetElement el in widget.WidgetElementsList) { el.Widgetid = widget.Widgetid; if (el.Type == 0) { el.Type = 1; } if (el.Deleted) { HibernateHelper.Persist(el, session); widget.WidgetElementsList.Remove(el); } else { HibernateHelper.Persist(el, session); } } } //Rimappo l'oggetto da restituire Mapper.CreateMap<Widget, WidgetDTO>(); Mapper.CreateMap<WidgetElement, WidgetElementDTO>(); Mapper.CreateMap<Element, ElementDTO>(); //Mappo la PageDTO in Page Widgetdto = Mapper.Map<Widget, WidgetDTO>(widget); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } finally { session.Flush(); session.Close(); } } } //Setto lo stato del content a non allineato ContentServices contSvc = new ContentServices(); contSvc.SetStateContent(Widgetdto.Contentid, (int)ContentStateEnum.NonAllineato); return Widgetdto; }