Inheritance: Persistente
Esempio n. 1
0
        public ContentDTO SaveContent(ContentDTO contentDto)
        {
            using (ISession session = HibernateHelper.GetSession().OpenSession()) {
                using (ITransaction transaction = session.BeginTransaction()) {
                    try {
                        Content content = new Content();
                        Mapper.CreateMap<ContentDTO, Content>();
                        //Mappo la  Content in ContentDTO
                        content = Mapper.Map<ContentDTO, Content>(contentDto);

                        HibernateHelper.Persist(content, session);

                        //Rimappo l'oggetto da restituire
                        Mapper.CreateMap<Content, ContentDTO>();

                        //Mappo la ContentDTO in Content
                        contentDto = Mapper.Map<Content, ContentDTO>(content);

                        transaction.Commit();

                    } catch (Exception ex) {
                        transaction.Rollback();
                        throw ex;
                    } finally {
                        session.Flush();
                        session.Close();
                    }
                }
            }
            return contentDto;
        }
Esempio n. 2
0
        public bool SetContentItemid(int contentId, int itemId, string repository)
        {
            bool status = false;
            using (ISession session = HibernateHelper.GetSession().OpenSession()) {
                using (ITransaction transaction = session.BeginTransaction()) {
                    try {
                        Content cont = new Content();
                        cont = EditorServices.GetContentById(contentId, session);

                        cont.Iditem = itemId;
                        cont.Repository = repository;
                        cont.Date_creation = DateTime.Now.Day.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Hour.ToString() + "-" + DateTime.Now.Minute.ToString() + "-" + DateTime.Now.Second.ToString();
                        cont.Dirty = true;

                        HibernateHelper.Persist(cont, session);

                        transaction.Commit();

                        status = true;
                        return status;
                    } catch (Exception ex) {
                        transaction.Rollback();
                        return status;
                        throw ex;
                    } finally {
                        session.Flush();
                        session.Close();
                    }
                }
            }
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        public virtual bool Equals(Content obj)
        {
            if (obj == null) return false;

            if (Equals(Contentid, obj.Contentid) == false)
                return false;

            if (Equals(Parentcontentid, obj.Parentcontentid) == false)
                return false;

            if (Equals(Title, obj.Title) == false)
                return false;

            if (Equals(Skinid, obj.Skinid) == false)
                return false;

            if (Equals(Themeid, obj.Themeid) == false)
                return false;

            if (Equals(Iditem, obj.Iditem) == false)
                return false;

            if (Equals(Repository, obj.Repository) == false)
                return false;

            if (Equals(Date_creation, obj.Date_creation) == false)
                return false;

            if (Equals(Date_publish, obj.Date_publish) == false)
                return false;

            if (Equals(Publish_active, obj.Publish_active) == false)
                return false;

            return true;
        }
Esempio n. 5
0
        public bool SetStateContent(int contentId, int state)
        {
            bool status = false;
            using (ISession session = HibernateHelper.GetSession().OpenSession()) {
                using (ITransaction transaction = session.BeginTransaction()) {
                    try {
                        Content cont = new Content();
                        cont = EditorServices.GetContentById(contentId, session);

                        if (state == (int)ContentStateEnum.Allineato || state == (int)ContentStateEnum.NonAllineato) {
                            if (state == (int)ContentStateEnum.Allineato) {
                                cont.Publish_active = 0;
                            }
                            cont.Dirty = true;
                            cont.State = state;
                            HibernateHelper.Persist(cont, session);
                        }
                        transaction.Commit();

                        status = true;
                        return status;
                    } catch (Exception ex) {
                        transaction.Rollback();
                        return status;
                        throw ex;
                    } finally {
                        session.Flush();
                        session.Close();
                    }
                }
            }
        }