public static string Name(this Entity entity, JonasPluginBag bag, bool includeEntityType)
        {
            var result = string.Empty;
            var priatt = bag.PrimaryAttribute(entity.LogicalName);

            if (!string.IsNullOrEmpty(priatt) && entity.Contains(priatt))
            {
                result = entity[priatt].ToString();
            }
            if (string.IsNullOrEmpty(result))
            {
                result = entity.Id.ToString();
            }
            if (includeEntityType)
            {
                result = $"{entity.LogicalName} {result}";
            }
            return(result);
        }
        protected override void Execute(CodeActivityContext context)
        {
            codeActivityContext = context;

            using (var bag = new JonasPluginBag(context))
            {
                var watch = Stopwatch.StartNew();
                try
                {
                    Execute(bag);
                }
                catch (Exception e)
                {
                    bag.trace("*** Exception ***\n{0}", e);
                    throw;
                }
                finally
                {
                    watch.Stop();
                    bag.trace("Internal execution time: {0} ms", watch.ElapsedMilliseconds);
                }
            }
        }
Example #3
0
 public void Execute(IServiceProvider serviceProvider)
 {
     using (var bag = new JonasPluginBag(serviceProvider))
     {
         var watch = Stopwatch.StartNew();
         try
         {
             Execute(bag);
         }
         catch (Exception e)
         {
             bag.TraceBlockStart(e.GetType().ToString());
             bag.trace(e.ToString());
             bag.TraceBlockEnd();
             throw;
         }
         finally
         {
             watch.Stop();
             bag.trace("Internal execution time: {0} ms", watch.ElapsedMilliseconds);
         }
     }
 }
 public abstract void Execute(JonasPluginBag bag);
 public JonasServiceProxy(IOrganizationService Service, JonasPluginBag bag)
 {
     service  = Service;
     this.bag = bag;
 }