public static string ToDescriptionText(this LicenseMode licenseMode)
        {
            var descriptionAttribute = typeof(LicenseMode)
                                       .GetField(licenseMode.ToString())
                                       .GetCustomAttributes(typeof(DescriptionAttribute), false)
                                       .FirstOrDefault() as DescriptionAttribute;

            return(descriptionAttribute != null
                ? descriptionAttribute.Description
                : licenseMode.ToString());
        }
示例#2
0
        /// <summary>
        /// Main entry point for he business logic that the plug-in is to execute.
        /// </summary>
        /// <param name="localContext">The <see cref="LocalPluginContext"/> which contains the
        /// <see cref="IPluginExecutionContext"/>,
        /// <see cref="IOrganizationService"/>
        /// and <see cref="ITracingService"/>
        /// </param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances.
        /// The plug-in's Execute method should be written to be stateless as the constructor
        /// is not called for every invocation of the plug-in. Also, multiple system threads
        /// could execute the plug-in at the same time. All per invocation state information
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        protected override void ExecuteCrmPlugin(LocalPluginContext localContext)
        {
            if (localContext == null)
            {
                throw new ArgumentNullException("localContext");
            }

            // TODO: Implement your custom plug-in business logic.

            if (localContext.PluginExecutionContext.PrimaryEntityName.ToLower() == "xrm_autonumber")
            {
                //CRMHelper.OrganizationService = localContext.OrganizationService;
                //CRMHelper.TracingService = localContext.TracingService;
                //string licenseXml = CRMHelper.RetrieveWebResourceByName("xrm_license.xml");

                //InitializeLicense(localContext.TracingService);
                //localContext.TracingService.Trace("Called InitializeLicense");
                //licenseMode = GetLicenseFromXml(licenseXml, localContext.TracingService);

                GetLicenseMode();
                localContext.TracingService.Trace(licenseMode.ToString());

                //localContext.TracingService.Trace(localContext.PluginExecutionContext.MessageName);
                switch (localContext.PluginExecutionContext.MessageName)
                {
                case "Create":
                    ExecutePostAutoNumberCreate(localContext);
                    break;

                case "xrm_PublishAutoNumberEntity":
                    ExecutePostAutoNumberPublish(localContext);
                    break;

                case "xrm_UnpublishAutoNumberEntity":
                    break;

                case "xrm_FillEntityAutoNumber":
                    ExecutePostAutoNumberFill(localContext);
                    break;
                }
            }
            else
            {
                if (localContext.PluginExecutionContext.MessageName == "Create")
                {
                    ExecutePostEntityCreate(localContext);
                }
            }
        }