protected override bool DoValidate()
        {
            if (TaskContext.Mode != PluginMode.Synchronous)
            {
                AddLogMessageLine($"Plugin mode is not {PluginMode.Synchronous}");
                return(false);
            }

            if (TaskContext.Stage != PluginStage.Preoperation)
            {
                AddLogMessageLine($"Plugin stage is not {PluginStage.Preoperation}");
                return(false);
            }

            if (TaskContext.Message != "Update" && TaskContext.Message != "Create")
            {
                AddLogMessageLine($"Plugin message is not Create or Update");
                return(false);
            }

            if (TaskContext.PrimaryEntityName != ContextEntity.LogicalName)
            {
                AddLogMessageLine($"Entity is not {ContextEntity.LogicalName}");
                return(false);
            }

            if (TaskContext.PrimaryEntityName != ContextEntity.LogicalName)
            {
                AddLogMessageLine($"Entity is not {ContextEntity.LogicalName}");
                return(false);
            }

            if (!ContextEntity.Contains(nameof(ContextEntity.Description).ToLower()))
            {
                AddLogMessageLine($"Context Entity does not contain attribute {nameof(ContextEntity.Description).ToLower()}");
                return(false);
            }

            if (ContextEntity.Description != "exception")
            {
                AddLogMessageLine($"Description are not equal to exception");
                return(false);
            }

            return(true);
        }
        protected override bool DoValidate()
        {
            if (TaskContext.Mode != PluginMode.Synchronous)
            {
                AddLogMessageLine($"Plugin mode is not {PluginMode.Synchronous}");
                return(false);
            }

            if (TaskContext.Stage != PluginStage.Postoperation)
            {
                AddLogMessageLine($"Plugin stage is not {PluginStage.Postoperation}");
                return(false);
            }

            if (TaskContext.Message != "Update" && TaskContext.Message != "Create")
            {
                AddLogMessageLine($"Plugin message is not Create or Update");
                return(false);
            }

            if (TaskContext.PrimaryEntityName != ContextEntity.LogicalName)
            {
                AddLogMessageLine($"Entity is not {ContextEntity.LogicalName}");
                return(false);
            }

            var mobAttname = nameof(ContextEntity.MobilePhone).ToLower();

            if (!ContextEntity.Contains(mobAttname))
            {
                AddLogMessageLine($"ContextEntity does not contains {mobAttname}");
                return(false);
            }

            if (string.IsNullOrEmpty(ContextEntity.MobilePhone))
            {
                AddLogMessageLine($"Mobile phone is empty");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        protected override void DoExecute()
        {
            var forbiddenWords = PluginServiceLocator.GetService <CustomerForbiddenNameService>().GetForbiddenNames();

            if (ContextEntity.Contains(nameof(ContextEntity.FirstName).ToLower()) &&
                forbiddenWords.FindIndex(x => x.Equals(ContextEntity.FirstName, StringComparison.InvariantCultureIgnoreCase)) != -1)
            {
                var msg = "First name is forbidden word, please write correct your first name";
                AddLogMessageLine(msg);
                //this exception  will not be logged
                throw new CrmNotLoggingException(msg);
            }

            if (ContextEntity.Contains(nameof(ContextEntity.LastName).ToLower()) &&
                forbiddenWords.FindIndex(x => x.Equals(ContextEntity.LastName, StringComparison.InvariantCultureIgnoreCase)) != -1)
            {
                var msg = "Last name is forbidden word, please write correct your last name";
                AddLogMessageLine(msg);

                //this exception  will be logged
                throw new InvalidPluginExecutionException(msg);
            }
        }