コード例 #1
0
        private void AddOrUpdateContent(Repository repository, IncomingQueue queueItem)
        {
            var textContent        = (Dictionary <string, object>)queueItem.Object;
            var values             = textContent.ToNameValueCollection();
            var files              = values.GetFilesFromValues();
            var medias             = values.GetMediaFromValues();
            var newVirtualPathDict = new Dictionary <string, string>();

            for (int i = 0, len = medias.Count; i < len; i++)
            {
                var virtualPath = this._repositoryNameRegex.Replace(medias[i].FileName, string.Format("$1{0}$3", repository.Name));
                var folder      = this._repositoryNameRegex.Match(virtualPath).Groups["mediaFolder"].Value;

                if (!string.IsNullOrWhiteSpace(virtualPath))
                {
                    newVirtualPathDict.Add(medias[i].FileName, virtualPath);

                    var physicalPath = Kooboo.Web.Url.UrlUtility.MapPath(virtualPath);

                    var mediaFolder = new MediaFolder(repository, folder);
                    if (mediaFolder.AsActual() == null)
                    {
                        this._mediaFolderManager.Add(repository, mediaFolder);
                    }

                    var folderPath = Path.GetDirectoryName(physicalPath);

                    var fileName = Path.GetFileName(physicalPath);

                    this._mediaContentManager.Add(repository, mediaFolder,
                                                  fileName, medias[i].InputStream, false);
                }
            }

            foreach (var prop in values.AllKeys)
            {
                if (!prop.StartsWith("__"))
                {
                    if (values[prop] != null && values[prop] is string && this._mediaPathField.IsMediaPathField(values[prop].ToString()))
                    {
                        var fieldValue = values[prop].ToString();
                        foreach (var key in newVirtualPathDict.Keys)
                        {
                            fieldValue = fieldValue.Replace(key, newVirtualPathDict[key]);
                        }
                        values[prop] = fieldValue;
                    }
                }
            }

            var categories = values.GetCategories().Select(it => new TextContent(repository.Name, "", it.CategoryFolder)
            {
                UUID = it.CategoryUUID
            }).ToArray();

            var textFolder = new TextFolder(repository, values["FolderName"]);

            _textContentManager.Delete(repository, textFolder, values["UUID"]);
            _textContentManager.Add(textFolder.Repository, textFolder, values, files, categories, values["UserId"]);
        }
コード例 #2
0
        public string AddTextContent(Site site, TextFolder textFolder, NameValueCollection values, string userid, string vendor)
        {
            var files      = values.GetFilesFromValues();
            var categories = values.GetCategories().Select(it => new TextContent(textFolder.Repository.Name, "", it.CategoryFolder)
            {
                UUID = it.CategoryUUID
            }).ToArray();
            var textContent = _textContentManager.Add(textFolder.Repository, textFolder, values, files, categories, userid);

            return(textContent.IntegrateId);
        }
コード例 #3
0
        private void InsertOrUpdate(TextFolder textFolder, TextContent textContent)
        {
            var oldContent = textFolder.CreateQuery().WhereEquals("UUID", textContent.UUID).FirstOrDefault();

            textContent.Repository = textFolder.Repository.Name;
            textContent.FolderName = textFolder.FullName;
            textContent.SchemaName = textFolder.SchemaName;
            if (oldContent != null)
            {
                foreach (var key in textContent.Keys)
                {
                    oldContent[key] = textContent[key];
                }

                _textContentProvider.Update(oldContent, oldContent);
            }
            else
            {
                var nameValues = textContent.ToNameValueCollection();
                _textContentManager.Add(textFolder.Repository, textFolder, nameValues, null, null, System.Web.HttpContext.Current.User.Identity.Name);
            }
        }
コード例 #4
0
ファイル: TextContentController.cs プロジェクト: webrot/CMS
        public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form, string @return)
        {
            var data = new JsonResultData();

            try
            {
                if (ModelState.IsValid)
                {
                    TextFolder textFolder = new TextFolder(Repository, folderName).AsActual();
                    var        schema     = textFolder.GetSchema().AsActual();

                    SchemaPath schemaPath = new SchemaPath(schema);
                    IEnumerable <TextContent> addedCategories;
                    IEnumerable <TextContent> removedCategories;

                    ParseCategories(form, out addedCategories, out removedCategories);
                    ContentBase content;

                    content = TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name);

                    data.RedirectUrl = @return;
                }
            }
            catch (RuleViolationException ruleEx)
            {
                foreach (var item in ruleEx.Issues)
                {
                    data.AddFieldError(item.PropertyName, item.ErrorMessage);
                }
            }
            catch (Exception e)
            {
                data.AddException(e);
            }
            data.AddModelState(ModelState);
            return(Json(data));
        }
コード例 #5
0
ファイル: IIncomeDataManager.cs プロジェクト: bootmarket/CMS
        public string AddTextContent(Site site, TextFolder textFolder, NameValueCollection values, HttpFileCollectionBase files, IEnumerable <TextContent> categories, string userid, string vendor)
        {
            var textContent = _textContentManager.Add(textFolder.Repository, textFolder, values, files, categories, "");

            return(textContent.IntegrateId);
        }