Exemplo n.º 1
0
        /// <summary>
        /// Checks WorkflowActionFormAttribute model for legacy lava and outputs SQL to correct it.
        /// Fields evaluated: PreHtml PostHtml
        /// </summary>
        public void CheckWorkflowActionFormAttribute()
        {
            RockContext rockContext = new RockContext();
            WorkflowActionFormAttributeService workflowActionFormAttributeService = new WorkflowActionFormAttributeService(rockContext);

            foreach (WorkflowActionFormAttribute workflowActionFormAttribute in workflowActionFormAttributeService.Queryable().ToList())
            {
                // don't change if modified
                if (workflowActionFormAttribute.ModifiedDateTime != null)
                {
                    continue;
                }

                bool isUpdated = false;

                workflowActionFormAttribute.PreHtml = ReplaceUnformatted(workflowActionFormAttribute.PreHtml, ref isUpdated);
                workflowActionFormAttribute.PreHtml = ReplaceUrl(workflowActionFormAttribute.PreHtml, ref isUpdated);
                workflowActionFormAttribute.PreHtml = ReplaceGlobal(workflowActionFormAttribute.PreHtml, ref isUpdated);
                workflowActionFormAttribute.PreHtml = ReplaceDotNotation(workflowActionFormAttribute.PreHtml, ref isUpdated);

                workflowActionFormAttribute.PostHtml = ReplaceUnformatted(workflowActionFormAttribute.PostHtml, ref isUpdated);
                workflowActionFormAttribute.PostHtml = ReplaceUrl(workflowActionFormAttribute.PostHtml, ref isUpdated);
                workflowActionFormAttribute.PostHtml = ReplaceGlobal(workflowActionFormAttribute.PostHtml, ref isUpdated);
                workflowActionFormAttribute.PostHtml = ReplaceDotNotation(workflowActionFormAttribute.PostHtml, ref isUpdated);

                if (isUpdated)
                {
                    string sql = $"UPDATE [WorkflowActionFormAttribute] SET [PreHtml] = '{workflowActionFormAttribute.PreHtml.Replace( "'", "''" )}', [PostHtml] = '{workflowActionFormAttribute.PostHtml.Replace( "'", "''" )}' WHERE [Guid] = '{workflowActionFormAttribute.Guid}';";
                    _sqlUpdateScripts.Add(sql);
                }
            }
        }
        private static int LoadByGuid2(Guid guid, RockContext rockContext)
        {
            var workflowActionFormAttributeService = new WorkflowActionFormAttributeService(rockContext);

            return(workflowActionFormAttributeService
                   .Queryable().AsNoTracking()
                   .Where(c => c.Guid.Equals(guid))
                   .Select(c => c.Id)
                   .FirstOrDefault());
        }
        private static WorkflowActionFormAttributeCache LoadById2(int id, RockContext rockContext)
        {
            var workflowActionFormAttributeService = new WorkflowActionFormAttributeService(rockContext);
            var workflowActionFormAttributeModel   = workflowActionFormAttributeService
                                                     .Queryable()
                                                     .Where(t => t.Id == id)
                                                     .FirstOrDefault();

            if (workflowActionFormAttributeModel != null)
            {
                return(new WorkflowActionFormAttributeCache(workflowActionFormAttributeModel));
            }

            return(null);
        }