コード例 #1
0
 public ActionResult ArcDetails(Guid id)
 {
     ECMSView view = new ECMSView();
     view.Id = id;
     view.SiteId = ECMSSettings.Current.SiteId;
     ViewData["sites"] = GetSiteList();
     ViewData["ViewTypes"] = GetViewTypeList();
     view = _viewRepository.GetArchieved(ECMSSettings.Current.SiteId, id);
     return View(GetControllerView("details"), view);
 }
コード例 #2
0
 public abstract void Save(ContentItem content_, ECMSView view_);
コード例 #3
0
 public abstract ContentItem GetContentForEditing(ECMSView view_);
コード例 #4
0
 private void SaveView(ECMSView view_)
 {
     view_.SiteId = ECMSSettings.Current.SiteId;
     view_.LastModifiedBy = this.CMSUser.UserName;
     view_.LastModifiedOn = DateTime.Now;
     _viewRepository.Save(view_);
 }
コード例 #5
0
 public ActionResult Save(ECMSView view_)
 {
     try
     {
         view_.ViewType = ContentViewType.PREVIEW;
         SaveView(view_);
         return RedirectToAction("Index");
     }
     catch (Exception ex)
     {
         LogEventInfo info = new LogEventInfo(LogLevel.Error, ECMSSettings.DEFAULT_LOGGER, ex.ToString());
         DependencyManager.Logger.Log(info);
         return View(GetControllerView("index"));
     }
 }
コード例 #6
0
 //
 // GET: /ECMSView/Edit/5
 public ActionResult Edit(Guid id)
 {
     ECMSView view = new ECMSView();
     view.Id = id;
     view.SiteId = ECMSSettings.Current.SiteId;
     ViewData["sites"] = GetSiteList();
     ViewData["ViewTypes"] = GetViewTypeList();
     view = _viewRepository.GetById(id);
     return View(GetControllerView("edit"), view);
 }
コード例 #7
0
 public ActionResult EditAndPublish(Guid id, ECMSView view_)
 {
     //try
     //{
     view_.LastModifiedOn = DateTime.Now;
     view_.LastModifiedBy = this.CMSUser.UserName;
     view_.ViewType = ContentViewType.PUBLISH;
     _viewRepository.Update(view_);
     return RedirectToAction("Index");
     //}
     //catch
     //{
     // return View(GetControllerView("index"));
     //}
 }
コード例 #8
0
 public void Save(ECMSView view_)
 {
     File.WriteAllText(GetViewPath(view_), view_.Html);
     _db.GetCollection<ECMSView>(COLLNAME).Save<ECMSView>(view_);
 }
コード例 #9
0
        //public ECMSView Get(ECMSView view_)
        //{
        //}
        public void Update(ECMSView view_)
        {
            // archieve publish view changes only.
            if (view_.ViewType == ContentViewType.PUBLISH)
            {
                // first archieve the content.
                ECMSView previousPublishedView = _db.GetCollection<ECMSView>(COLLNAME).AsQueryable().Where(x => x.Id == view_.Id).ToList<ECMSView>().Where(x => x.ViewType == ContentViewType.PUBLISH).FirstOrDefault<ECMSView>();
                if (previousPublishedView != null)
                {
                    previousPublishedView.Id = Guid.Empty;
                    previousPublishedView.LastModifiedBy = view_.LastModifiedBy;
                    previousPublishedView.LastModifiedOn = view_.LastModifiedOn;
                    _db.GetCollection<ECMSView>(ARC_COLLNAME).Save<ECMSView>(previousPublishedView);
                }

                // save the original content as well.
                Save(view_);

                //then update the same on preview mode.
                ECMSView previewView = _db.GetCollection<ECMSView>(COLLNAME).Find(Query.And(Query.EQ("ViewType", ContentViewType.PREVIEW), Query.EQ("ViewName", view_.ViewName))).FirstOrDefault<ECMSView>();
                if (previewView != null)
                {
                    previewView.LastModifiedBy = view_.LastModifiedBy;
                    previewView.LastModifiedOn = view_.LastModifiedOn;
                    previewView.Html = view_.Html;
                    Save(previewView);
                }
                else
                {
                    // preview mode content not found then simple create a preview mode.
                    view_.Id = Guid.Empty;
                    view_.ViewType = ContentViewType.PREVIEW;
                    Save(view_);
                }
            }
            else
            {
                // if preview then simple save as it is.
                Save(view_);
            }
        }
コード例 #10
0
        private static string GetViewPath(ECMSView view_)
        {
            string dirPath = ECMS.Core.ECMSSettings.GetCurrentBySiteId(view_.SiteId).AppBasePath + "Views\\" + view_.SiteId + "\\" + Convert.ToInt32(view_.ViewType);
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            return dirPath + "\\" + view_.ViewName + ".cshtml"; ;
        }
コード例 #11
0
 public void Delete(ECMSView view_)
 {
     //File.Delete(GetViewPath(view_));
     throw new NotImplementedException();
 }
コード例 #12
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;
        }
コード例 #13
0
 private string ConstructPath(ECMSView view_, bool forBodyContent_)
 {
     string filePath = AppDomain.CurrentDomain.BaseDirectory + "\\app_data\\" + view_.SiteId + "\\" + Convert.ToInt32(view_.ViewType).ToString() + (forBodyContent_ ? "\\bodycontent\\" : "\\headcontent\\") + view_.ViewName + "-default-content" + ECMS_FILE_EXTENSION;
     //if (!File.Exists(filePath))
     //{
     //    filePath = AppDomain.CurrentDomain.BaseDirectory + "\\app_data\\" + view_.SiteId + "\\" + Convert.ToInt32(view_.ViewType).ToString() + (forBodyContent_ ? "\\bodycontent\\" : "\\headcontent\\") + view_.ViewName + "-default-content" + ECMS_FILE_EXTENSION;
     //}
     return filePath;
 }
コード例 #14
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());
                }
            }
        }
コード例 #15
0
ファイル: MongoDBRepository.cs プロジェクト: ramkumar013/ECMS
 public override void Save(ContentItem content_, ECMSView view_)
 {
     content_.ContentView = view_;
     Save(content_, view_.ViewType);
 }
コード例 #16
0
ファイル: MongoDBRepository.cs プロジェクト: ramkumar013/ECMS
 public override ContentItem GetContentForEditing(ECMSView view_)
 {
     //return _db.GetCollection<ContentItem>(COLLNAME).AsQueryable<ContentItem>().Where(x => x.Url != null && x.Url.SiteId == view_.SiteId && x.Url.View == view_.ViewName && Convert.ToInt32(x.ViewType) == Convert.ToInt32(view_.ViewType)).FirstOrDefault<ContentItem>();
     ContentItem item = _db.GetCollection<ContentItem>(COLLNAME).Find(Query.And(Query.EQ("ContentView.SiteId", view_.SiteId), Query.EQ("ContentView.ViewName", view_.ViewName), Query.EQ("ContentView.ViewType", Convert.ToInt32(view_.ViewType)))).FirstOrDefault<ContentItem>();
     if (item != null)
     {
         item.Body = item.Body[0];
     }
     return item;
 }