Esempio n. 1
0
        public SessionsLog Save(SessionsLog session)
        {
            var sessionsLogDal = MapperFacade.SessionsLogMapper.GetDalObject(session);

            sessionsLogDal = DefaultRepository.SimpleSave(sessionsLogDal);
            return(MapperFacade.SessionsLogMapper.GetBizObject(sessionsLogDal));
        }
Esempio n. 2
0
        public IEnumerable <BackendActionLog> Save(IEnumerable <BackendActionLog> logs)
        {
            IEnumerable <BackendActionLogDAL> toSave = MapperFacade.BackendActionLogMapper.GetDalList(logs.ToList());
            var saved = DefaultRepository.SimpleSave(toSave);

            return(MapperFacade.BackendActionLogMapper.GetBizList(saved.ToList()));
        }
Esempio n. 3
0
        private static void CreateDefaultGroup(Site site)
        {
            var group = new ContentGroupDAL()
            {
                Name = ContentGroup.DefaultName, SiteId = site.Id
            };

            DefaultRepository.SimpleSave(group);
        }
Esempio n. 4
0
        /// <summary>
        /// Сохранить записи в таблице union_contents
        /// </summary>
        internal static void RecreateUserQuerySourcesInfo(Content uqVirtualContent)
        {
            var virtualContentId = uqVirtualContent.Id;

            RemoveUserQuerySourcesInfo(uqVirtualContent);
            DefaultRepository.SimpleSave(uqVirtualContent.UserQueryContentViewSchema.SelectUniqContentIDs().Select(id => new UserQueryContentsDAL
            {
                IsIdSource       = false,
                RealContentId    = id,
                VirtualContentId = virtualContentId
            }));
        }
Esempio n. 5
0
        /// <summary>
        /// Сохранить записи в таблице union_contents
        /// </summary>
        internal static void RecreateUnionSourcesInfo(Content virtualContent, IEnumerable <int> unionSourceContentIDs)
        {
            try
            {
                ChangeUnionContentTriggerState(false);
                var virtualContentId = virtualContent.Id;
                var recToRemove      = QPContext.EFContext.UnionContentsSet.Where(u => u.VirtualContentId == virtualContentId).ToArray();

                DefaultRepository.SimpleDelete(recToRemove);
                DefaultRepository.SimpleSave(unionSourceContentIDs.Select(id => new UnionContentsDAL {
                    VirtualContentId = virtualContentId, UnionContentId = id
                }));
            }
            finally
            {
                ChangeUnionContentTriggerState(true);
            }
        }
Esempio n. 6
0
        internal static void UpdateContentWorkflowBind(ContentWorkflowBind binding)
        {
            var oldDal        = GetContentWorkflowDal(binding.Content.Id);
            var persisted     = oldDal != null;
            var needToPersist = binding.WorkflowId != WorkflowBind.UnassignedId;
            var changed       = persisted && needToPersist && (oldDal.WorkflowId != binding.WorkflowId || oldDal.IsAsync != binding.IsAsync);
            var newDal        = !needToPersist ? null : MapperFacade.ContentWorkflowBindMapper.GetDalObject(binding);

            if (persisted && changed || persisted && !needToPersist)
            {
                DefaultRepository.SimpleDelete(oldDal.EntityKey);
            }

            if (persisted && changed || !persisted && needToPersist)
            {
                DefaultRepository.SimpleSave(newDal);
            }
        }
Esempio n. 7
0
        internal static ContentConstraint Save(ContentConstraint constraint)
        {
            if (constraint == null)
            {
                throw new ArgumentNullException(nameof(constraint));
            }

            if (!constraint.IsNew)
            {
                throw new ArgumentException("Метод вызван для существующего в БД ContentConstraint");
            }


            // Сохраняем ограничение только если есть правила
            if (constraint.Rules != null && constraint.Rules.Any())
            {
                var ccDal = MapperFacade.ContentConstraintMapper.GetDalObject(constraint);

                using (var scope = new QPConnectionScope())
                {
                    ccDal = DefaultRepository.SimpleSave(ccDal);
                    foreach (var rule in ccDal.Rules)
                    {
                        rule.Constraint   = ccDal;
                        rule.ConstraintId = ccDal.Id;
                        DefaultRepository.SimpleSave(rule);
                    }

                    if (constraint.IsComplex)
                    {
                        Common.CreateComplexIndex(QPContext.EFContext, scope.DbConnection, ccDal);
                    }
                }

                var newContraint = MapperFacade.ContentConstraintMapper.GetBizObject(ccDal);
                return(newContraint);
            }



            return(constraint);
        }
Esempio n. 8
0
        internal static ContentConstraint Update(ContentConstraint constraint)
        {
            if (constraint == null)
            {
                throw new ArgumentNullException(nameof(constraint));
            }

            if (constraint.IsNew)
            {
                throw new ArgumentException("Метод вызван для несуществующего в БД ContentConstraint");
            }

            // если нет правил, то удалить ограничение
            if (constraint.Rules == null || constraint.Rules.Count == 0)
            {
                Delete(constraint);
                return(null);
            }

            var ccDal = QPContext.EFContext.ContentConstraintSet.Single(d => d.Id == constraint.Id);

            ccDal.Rules.Load();
            IEnumerable <ContentConstraintRuleDAL> ruleDalList = ccDal.Rules.ToArray();

            // удалить все правила которые уже есть
            DefaultRepository.SimpleDelete(ruleDalList);

            // создать новые записи для правил
            foreach (var rule in constraint.Rules)
            {
                rule.ConstraintId = constraint.Id;
            }

            var newDalList = MapperFacade.ContentConstraintRuleMapper.GetDalList(constraint.Rules.ToList());

            DefaultRepository.SimpleSave(newDalList.AsEnumerable());

            return(MapperFacade.ContentConstraintMapper.GetBizObject(ccDal));
        }
Esempio n. 9
0
 private static void CreateDefaultNotificationTemplate(Site site)
 {
     if (!site.ExternalDevelopment)
     {
         var template = new PageTemplateDAL()
         {
             SiteId          = site.Id,
             Name            = "Default Notification Template",
             NetTemplateName = "Default_Notification_Template",
             TemplatePicture = "",
             Created         = site.Created,
             Modified        = site.Modified,
             LastModifiedBy  = site.LastModifiedBy,
             Charset         = "utf-8",
             Locale          = 65001,
             Codepage        = 1049,
             IsSystem        = true,
             NetLanguageId   = NetLanguage.GetcSharp().Id
         };
         DefaultRepository.SimpleSave(template);
     }
 }
Esempio n. 10
0
        internal static ContentConstraint Save(ContentConstraint constraint)
        {
            if (constraint == null)
            {
                throw new ArgumentNullException(nameof(constraint));
            }

            if (!constraint.IsNew)
            {
                throw new ArgumentException("Метод вызван для существующего в БД ContentConstraint");
            }

            // Сохраняем ограничение только если есть правила
            if (constraint.Rules != null && constraint.Rules.Count > 0)
            {
                var ccDal = MapperFacade.ContentConstraintMapper.GetDalObject(constraint);
                ccDal = DefaultRepository.SimpleSave(ccDal);
                var newContraint = MapperFacade.ContentConstraintMapper.GetBizObject(ccDal);
                return(newContraint);
            }

            return(constraint);
        }
Esempio n. 11
0
        internal static void UpdateSchedule(Article article)
        {
            var item = article.Schedule;

            if (item != null)
            {
                item.Article   = article;
                item.ArticleId = article.Id;

                var originalId = item.Id;
                item.Id = 0;

                var dalItem       = MapperFacade.ArticleScheduleMapper.GetDalObject(item);
                var itemPersisted = originalId != 0;
                var hasChanges    = !itemPersisted;

                if (itemPersisted)
                {
                    var originalItem = GetDalById(originalId);
                    hasChanges = DetectChanges(originalItem, dalItem);
                    if (hasChanges)
                    {
                        DefaultRepository.Delete <ArticleScheduleDAL>(originalId);
                    }
                }

                var needToPersist = dalItem.FreqType != ScheduleFreqTypes.None && hasChanges;
                if (needToPersist)
                {
                    dalItem.UseService     = true;
                    dalItem.Created        = article.Modified;
                    dalItem.Modified       = article.Modified;
                    dalItem.LastModifiedBy = article.LastModifiedBy;
                    DefaultRepository.SimpleSave(dalItem);
                }
            }
        }
Esempio n. 12
0
        internal static void SaveAppSettings(IEnumerable <AppSettingsItem> values)
        {
            IEnumerable <AppSettingsDAL> result = values.Select(n => AppSettingsDAL.CreateAppSettingsDAL(n.Key, n.Value)).ToList();

            DefaultRepository.SimpleSave(result);
        }