Exemplo n.º 1
0
        public override ContentItem GetById(ValidUrl url_, ContentViewType viewType_)
        {
            ContentItem item = new ContentItem();
            item.Url = url_;
            JObject jsonBody = LoadPageContents(url_, viewType_,true);
            item.Body = jsonBody;
            item.Head = GetHeadContentByViewName(url_, jsonBody, viewType_);

            string temp2 = null;
            foreach (JToken token in jsonBody.Children())
            {
                if (token is JProperty)
                {
                    temp2 = (token as JProperty).Value.ToString();
                    if (temp2.Contains("@"))
                    {
                        string hashCode = temp2.GetHashCode().ToString();
                        if (DependencyManager.CachingService.Get<ITemplate>(hashCode) == null)
                        {
                            var task = Task.Factory.StartNew(() => CreateTemplateAndSetInCache(hashCode, (token as JProperty).Value.ToString()));
                            DependencyManager.CachingService.Set<Task>("Task." + hashCode, task);
                        }
                    }
                }
            }
            return item;
        }
Exemplo n.º 2
0
 public abstract void Save(ContentItem content_, ECMSView view_);
Exemplo n.º 3
0
 public abstract void Save(ContentItem content_, ContentViewType viewType_);
Exemplo n.º 4
0
 public ActionResult DefaultDataEdit(Guid id, ContentItem item_)
 {
     item_.LastModifiedBy = this.CMSUser.UserName;
     item_.LastModifiedOn = DateTime.Now;
     //item_.Body = item_.Body[0].ToString().Replace("\"", "\"\"");
     DefaultDataAdd(id, item_);
     return Index();
 }
Exemplo n.º 5
0
 //[HttpGet]
 //public ActionResult DefaultDataAdd(Guid id)
 //{
 //    ViewBag.ECMSView = _viewRepository.Get(new ECMSView { Id = id });
 //    return View(GetControllerView("DefaultDataAdd"));
 //}
 //[HttpPost]
 //[ValidateInput(false)]
 public ActionResult DefaultDataAdd(Guid id, ContentItem item_)
 {
     ECMSView view = _viewRepository.GetById(id);
     DependencyManager.ContentRepository.Save(item_, view);
     return View(GetControllerView("DefaultDataAdd"));
 }
Exemplo n.º 6
0
 public ActionResult UrlDataEdit(Guid id, ContentItem item_, ContentViewType vm)
 {
     ValidUrl url = DependencyManager.URLRepository.GetById(this.GetSiteIdFromContext(), id, false);
     item_.Url = url;
     DependencyManager.ContentRepository.Save(item_, vm);
     return RedirectToAction("Index", "Urls");
 }
Exemplo n.º 7
0
        public override ContentItem GetContentForEditing(ECMSView view_)
        {
            string headContentFilePath = ConstructPath(view_, false);
            string bodyContentFilePath = ConstructPath(view_, true);

            ContentItem contentItem = null;
            if (File.Exists(headContentFilePath))
            {
                contentItem = new ContentItem();
                using (StreamReader streamReader = new StreamReader(headContentFilePath))
                {
                    using (var csv = new CsvReader(streamReader))
                    {
                        while (csv.Read())
                        {
                            contentItem.Head = csv.GetRecord<ContentItemHead>();
                        }
                    }
                }
            }
            if (File.Exists(bodyContentFilePath))
            {
                contentItem.Body = (dynamic)File.ReadAllText(bodyContentFilePath);
            }
            return contentItem;
        }
Exemplo n.º 8
0
 public override void Delete(ContentItem content_, ContentViewType viewType_)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 9
0
        public override void Save(ContentItem content_, ECMSView view_)
        {
            string bodyContentFilePath = ConstructPath(view_, true);
            string headContentFilePath = ConstructPath(view_, false);

            File.WriteAllText(bodyContentFilePath, Convert.ToString(content_.Body[0]));

            using (StringWriter stringWriter = new StringWriter())
            {
                using (CsvWriter csvWriter = new CsvWriter(stringWriter))
                {
                    csvWriter.WriteHeader<ContentItemHead>();
                    csvWriter.WriteRecord<ContentItemHead>(content_.Head);
                    File.WriteAllText(headContentFilePath, stringWriter.ToString());
                }
            }
        }
Exemplo n.º 10
0
 public override void Save(ContentItem content_, ECMSView view_)
 {
     content_.ContentView = view_;
     Save(content_, view_.ViewType);
 }
Exemplo n.º 11
0
        public override void Save(ContentItem content_, ContentViewType viewType_)
        {
            //ContentItem previousItem = _db.GetCollection<ContentItem>(COLLNAME).AsQueryable<ContentItem>().Where(x => x.ContentId ==  content_.ContentId && x.ViewType == viewType_).FirstOrDefault<ContentItem>();
            ContentItem previousItem = _db.GetCollection<ContentItem>(COLLNAME).Find(Query.And(Query.EQ("ContentId", content_.ContentId), Query.EQ("ViewType", Convert.ToInt32(viewType_)))).FirstOrDefault<ContentItem>();

            if (previousItem != null)
            {
                previousItem.ContentId = Guid.Empty;
                _db.GetCollection<ContentItem>(ARC_COLLNAME).Save<ContentItem>(previousItem);
            }
            _db.GetCollection<ContentItem>(COLLNAME).Save<ContentItem>(content_);
        }