public void UpdateData(AdditionalDataInfo data)
        {
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = data.Json.ToJObject("UpdateContent"),
                CreatedByUserId      = data.CreatedByUserId,
                CreatedOnDate        = data.CreatedOnDate,
                LastModifiedByUserId = data.LastModifiedByUserId,
                LastModifiedOnDate   = data.LastModifiedOnDate
            };
            var versions = data.Versions;

            if (versions.Count == 0 || versions[0].Json.ToString() != data.Json)
            {
                versions.Insert(0, ver);
                if (versions.Count > OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalSettings.Current.PortalId).GetMaxVersions())
                {
                    versions.RemoveAt(versions.Count - 1);
                }
                data.Versions = versions;
            }
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <AdditionalDataInfo>();
                rep.Update(data);
            }
        }
        public void UpdateContent(OpenContentInfo content)
        {
            ClearDataCache(content);
            var json = content.JsonAsJToken;

            SynchronizeXml(content);
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = json,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = content.Versions;

            if (versions.Count == 0 || versions[0].Json.ToString() != content.Json)
            {
                versions.Insert(0, ver);
                if (versions.Count > (PortalId > -1 ? 5 : App.Services.CreateGlobalSettingsRepository(PortalId).GetMaxVersions()))
                {
                    versions.RemoveAt(versions.Count - 1);
                }
                content.Versions = versions;
            }
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Update(content);
            }
        }
        public void AddContent(OpenContentInfo content)
        {
            SynchronizeXml(content);
            ClearDataCache(content);
            var json = content.JsonAsJToken;

            if (string.IsNullOrEmpty(content.Key))
            {
                content.Key = json["_id"]?.ToString() ?? ObjectId.NewObjectId().ToString();
            }
            if (string.IsNullOrEmpty(content.Collection))
            {
                content.Collection = App.Config.DefaultCollection;
            }
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = json,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = new List <OpenContentVersion>();

            versions.Add(ver);
            content.Versions = versions;
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Insert(content);
            }
        }
Exemple #4
0
        public void AddContent(OpenContentInfo content, bool index, FieldConfig indexConfig)
        {
            ClearCache(content);

            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = content.JsonAsJToken,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = new List <OpenContentVersion>();

            versions.Add(ver);
            content.Versions = versions;
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Insert(content);
                ModuleController.SynchronizeModule(content.ModuleId);
            }
            if (index)
            {
                LuceneController.Instance.Add(content, indexConfig);
                LuceneController.Instance.Store.Commit();
            }
        }
Exemple #5
0
        public void UpdateContent(OpenContentInfo content)
        {
            ClearDataCache(content);
            var json = content.JsonAsJToken;
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = json,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = content.Versions;

            if (versions.Count == 0 || versions[0].Json.ToString() != content.Json)
            {
                versions.Insert(0, ver);
                if (versions.Count > OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController(PortalSettings.Current.PortalId).GetMaxVersions())
                {
                    versions.RemoveAt(versions.Count - 1);
                }
                content.Versions = versions;
            }
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Update(content);
                ModuleController.SynchronizeModule(content.ModuleId);
            }
        }
        public void AddContent(OpenContentInfo content, bool index, FieldConfig indexConfig)
        {
            ClearCache(content);
            var json = content.JsonAsJToken;

            if (string.IsNullOrEmpty(content.Key))
            {
                if (json["_id"] != null)
                {
                    content.Key = json["_id"].ToString();
                }
                else
                {
                    content.Key = ObjectId.NewObjectId().ToString();
                    //json["_id"] = content.Id;
                    //content.Json = json.ToString();
                }
            }
            if (string.IsNullOrEmpty(content.Collection))
            {
                content.Collection = AppConfig.DEFAULT_COLLECTION;
            }
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = json,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = new List <OpenContentVersion>();

            versions.Add(ver);
            content.Versions = versions;
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Insert(content);
                ModuleController.SynchronizeModule(content.ModuleId);
            }
            if (index)
            {
                LuceneController.Instance.Add(content, indexConfig);
                LuceneController.Instance.Store.Commit();
            }
        }
        public void AddData(AdditionalDataInfo data)
        {
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = data.Json.ToJObject("Adding AdditionalData"),
                CreatedByUserId      = data.CreatedByUserId,
                CreatedOnDate        = data.CreatedOnDate,
                LastModifiedByUserId = data.LastModifiedByUserId,
                LastModifiedOnDate   = data.LastModifiedOnDate
            };
            var versions = new List <OpenContentVersion>();

            versions.Add(ver);
            data.Versions = versions;
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <AdditionalDataInfo>();
                rep.Insert(data);
            }
        }
        public void UpdateContent(OpenContentInfo content, bool index, FieldConfig indexConfig)
        {
            ClearCache(content);
            var json = content.JsonAsJToken;
            //json["_id"] = content.Id;
            //content.Json = json.ToString();
            OpenContentVersion ver = new OpenContentVersion()
            {
                Json                 = json,
                CreatedByUserId      = content.CreatedByUserId,
                CreatedOnDate        = content.CreatedOnDate,
                LastModifiedByUserId = content.LastModifiedByUserId,
                LastModifiedOnDate   = content.LastModifiedOnDate
            };
            var versions = content.Versions;

            if (versions.Count == 0 || versions[0].Json.ToString() != content.Json)
            {
                versions.Insert(0, ver);
                if (versions.Count > OpenContentControllerFactory.Instance.OpenContentGlobalSettingsController.GetMaxVersions())
                {
                    versions.RemoveAt(versions.Count - 1);
                }
                content.Versions = versions;
            }
            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <OpenContentInfo>();
                rep.Update(content);
                ModuleController.SynchronizeModule(content.ModuleId);
            }
            if (index)
            {
                content.HydrateDefaultFields(indexConfig);
                LuceneController.Instance.Update(content, indexConfig);
                LuceneController.Instance.Store.Commit();
            }
        }