public IPluginSetup GetPluginSetupElement()
        {
            if (_pluginSetup != null)
            {
                return(_pluginSetup);
            }

            if (_pluginSetupWasSearched)
            {
                return(null);
            }

            _pluginSetupWasSearched = true;

            if (this is IConfiguration)
            {
                return(null);
            }

            if (this is IPluginSetup pluginSetup)
            {
                _pluginSetup = pluginSetup;
            }
            else
            {
                _pluginSetup = Parent.GetPluginSetupElement();
            }

            return(_pluginSetup);
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="PluginData" /> class.
 /// </summary>
 public PluginData([NotNull] IPluginSetup pluginSetup, [NotNull] IPlugin plugin,
                   [NotNull] ISettings globalSettings,
                   [NotNull] ITypeBasedSimpleSerializerAggregator typeBasedSimpleSerializerAggregator)
 {
     Settings   = new PluginSettings(globalSettings, pluginSetup.SettingsElement, typeBasedSimpleSerializerAggregator);
     PluginName = pluginSetup.Plugin.Name;
     Plugin     = plugin;
 }
        protected override bool ExecutePostOpSync(IPluginSetup p)
        {
            if (!ObjectProviderService.Contains <IFrozenAccountManagement>())
            {
                throw new NullReferenceException(nameof(IFrozenAccountManagement));
            }

            var l = new LocalLogger(p.Logging, ClassName);

            var target = p.Helper.GetTargetEntity <CrmObject.Account>();

            if (!target.Contains(CrmObject.Account.Fields.think_frozen))
            {
                return(l.WriteAndReturn(false, $"Attribute not in target: {CrmObject.Account.Fields.think_frozen}."));
            }

            var preImage = p.Context.PreEntityImages[ImageName].ToEntity <CrmObject.Account>();

            if (!DidValueChange(preImage, target, CrmObject.Account.Fields.think_frozen))
            {
                return(l.WriteAndReturn(false, "Frozen flag did not change, Exiting plugin."));
            }

            try
            {
                ObjectProviderService.GetObject <IFrozenAccountManagement>()
                .ProcessChangedFrozenFlag(p.SystemService, l, target);
            }
            catch (Exception ex)
            {
                p.Logging.Write("Exception while updating Frozen flag on Account.");
                p.Logging.Write(ex);
                throw new InvalidPluginExecutionException(
                          "Plugin Error while updating Frozen Flag on Account records. Please try again. If this issue continues click download log file and contact support.");
            }

            return(l.WriteAndReturn(false, "Execution Completed."));
        }
Exemplo n.º 4
0
 protected virtual ICrmResourceStrings InitializeResourceStrings(IPluginSetup pluginSetup, ILogging logging)
 {
     logging.Write("ThinkCrmPlugin: No Resource Strings Configured");
     return null;
 }
Exemplo n.º 5
0
 protected virtual ILogging InitializeLogging(IPluginSetup pluginSetup, bool isInSandbox = true)
 {
     var log = new Logger(isInSandbox);
     log.AddListener(new LogToCrmTracingService(pluginSetup.Tracing));
     return log.WriteAndReturn(log, "ThinkCrmPlugin: Default Logging / Sandbox Mode={0}", isInSandbox.ToString());
 }
Exemplo n.º 6
0
 protected virtual void AddLoggers(ILogging logging, IPluginSetup pluginSetup)
 {
     return;
 }
Exemplo n.º 7
0
        public IPluginSetupResult Setup(IPluginSetup setup) {
            if (setup.ConnectionGuid != null) {
                this.ConnectionGuid = Guid.Parse(setup.ConnectionGuid);
            }

            if (setup.ConfigDirectoryPath != null) {
                this.ConfigDirectoryInfo = new DirectoryInfo(setup.ConfigDirectoryPath);
                this.ConfigDirectoryInfo.Create();
            }

            if (setup.LogDirectoryPath != null) {
                this.LogDirectoryInfo = new DirectoryInfo(setup.LogDirectoryPath);
                this.LogDirectoryInfo.Create();
            }

            return new PluginSetupResult() {
                Commands = this.HandledCommandNames(),
                Title = this.Title
            };
        }
Exemplo n.º 8
0
 public new bool ExecutePostOpSync(IPluginSetup pluginSetup)
 {
     return(base.ExecutePostOpSync(pluginSetup));
 }