Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecordStorage class in v8 #1773

Closed
miackers opened this issue Jul 12, 2019 · 8 comments
Closed

RecordStorage class in v8 #1773

miackers opened this issue Jul 12, 2019 · 8 comments

Comments

@miackers
Copy link

@miackers miackers commented Jul 12, 2019

Hi, I am trying to get the sample to work for V8, but can't find an implementation for RecordStorage class.

This is the page with issues: https://github.com/umbraco/UmbracoDocs/edit/master/Add-ons/UmbracoForms/Developer/Extending/Adding-a-Workflowtype.md

@miackers

This comment has been minimized.

Copy link
Author

@miackers miackers commented Jul 12, 2019

I meant the Umbraco.Forms.Data.Storage namespace no longer have the RecordStorage class in it (or it can't be found by VS). This works on V7

Might be related to: #1765

@sofietoft

This comment has been minimized.

Copy link
Contributor

@sofietoft sofietoft commented Jul 15, 2019

Hi @miackers

Thanks for reporting!
I've added some labels to this, and will see what we can do about getting it updated for the latest versions.
/Sofie

@miackers

This comment has been minimized.

Copy link
Author

@miackers miackers commented Jul 15, 2019

Thanks for getting back to me @sofietoft.

After digging a little further, I suspect this is actually a bug in v8 of Umbraco forms. I can't be 100% sure though, since it might just be that I am looking in the wrong place, so it's worth leaving this open for now. FYI: I've raised a bug here: umbraco/Umbraco.Forms.Issues#186

@sofietoft

This comment has been minimized.

Copy link
Contributor

@sofietoft sofietoft commented Jul 15, 2019

I just had a chat with one of our Forms guys here. I don't think it's' bug actually 🤔
He provided me with an example of how this is done in Umbraco 8:

using System;
using System.Collections.Generic;
using umbraco.BusinessLogic;
using Umbraco.Forms.Core;
using Umbraco.Forms.Core.Enums;
using Umbraco.Forms.Data.Storage;
using Umbraco.Forms.Web.Services;

/// <summary>
/// Summary description for Class1
/// </summary>
public class TestWorkflow : WorkflowType
{
   private IRecordService _recordService;
   private IRecordStorage _recordStorage;
   public TestWorkflow(IRecordService recordService, IRecordStorage recordStorage)
   {
       this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0202");
       this.Name = "TestWorkflow";
       this.Description = "This workflow is just for testing";
       this.Icon = "icon-chat-active";
       this.Group = "Services";
       _recordService = recordService;
       _recordStorage = recordStorage;
   }
   public override WorkflowExecutionStatus Execute(Record record, RecordEventArgs e)
   {
       // first we log it
       Log.Add(LogTypes.Debug, -1, "the IP " + record.IP + " has submitted a record");

       // we can then iterate through the fields
       foreach (RecordField rf in record.RecordFields.Values)
       {
           // and we can then do something with the collection of values on each field
           List<object> vals = rf.Values;

           // or just get it as a string
           rf.ValuesAsString();
       }

       // If we altered a field, we can save it using the record storage
       _recordStorage.UpdateRecord(record, e.Form);

       // we then invoke the recordservice which handles all record states // and make the service delete the record.
       _recordService .Delete(record, e.Form);

       return WorkflowExecutionStatus.Completed;
   }

   public override List<Exception> ValidateSettings()
   {
       return new List<Exception>();
   }
}

I'm looking into getting the docs article updated as well 💪

@miackers

This comment has been minimized.

Copy link
Author

@miackers miackers commented Jul 15, 2019

Thanks!

This makes perfect sense - ie, forcing the user to use dependency injection is a great idea

@AmadeuAntunes

This comment has been minimized.

Copy link

@AmadeuAntunes AmadeuAntunes commented Jul 16, 2019

Doing that way I got:

Erro de servidor na aplicação '/'.
Boot failed: Umbraco cannot run. See Umbraco's log file for more details.

-> Umbraco.Core.Exceptions.BootFailedException: Boot failed.

-> System.InvalidOperationException: Unable to resolve type: Umbraco.Core.Composing.ComponentCollection, service name:
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)
em LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError)
em LightInject.ServiceContainer.GetInstance(Type serviceType)
em Umbraco.Core.Composing.LightInject.LightInjectContainer.GetInstance(Type type)
em Umbraco.Core.FactoryExtensions.GetInstance[T](IFactory factory)
em Umbraco.Core.Runtime.CoreRuntime.Boot(IRegister register, DisposableTimer timer)

-> System.InvalidOperationException: Unable to resolve type: Umbraco.Web.Search.ExamineComponent, service name:
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)
em LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError)
em LightInject.ServiceContainer.GetInstance(Type serviceType)
em Umbraco.Core.Composing.LightInject.LightInjectContainer.GetInstance(Type type)
em Umbraco.Core.Composing.ComponentCollectionBuilder.CreateItem(IFactory factory, Type itemType)
em Umbraco.Core.Composing.CollectionBuilderBase3.<>c__DisplayClass10_0.<CreateItems>b__0(Type x) em System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext()
em System.Linq.Buffer1..ctor(IEnumerable1 source)
em System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) em Umbraco.Core.Composing.CollectionBuilderBase3.CreateItems(IFactory factory)
em Umbraco.Core.Composing.ComponentCollectionBuilder.CreateItems(IFactory factory)
em Umbraco.Core.Composing.CollectionBuilderBase3.CreateCollection(IFactory factory) em Umbraco.Core.Composing.LightInject.LightInjectContainer.<>c__DisplayClass20_01.b__0(IServiceFactory f)
em DynamicMethod(Object[] )
em LightInject.ServiceContainer.<>c__DisplayClass150_0.b__0()
em LightInject.ServiceContainer.<>c__DisplayClass198_0.b__1()
em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope) em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action1 emitMethod, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__1(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action`1 serviceEmitter)
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)

-> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Web.Search.ExamineComponent], [Parameter: indexRebuilder(Umbraco.Examine.IndexRebuilder)], [Requested dependency: ServiceType:Umbraco.Examine.IndexRebuilder, ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__0(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action`1 serviceEmitter)
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)

-> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Examine.IndexRebuilder], [Parameter: populators(System.Collections.Generic.IEnumerable1[Umbraco.Examine.IIndexPopulator])], [Requested dependency: ServiceType:System.Collections.Generic.IEnumerable1[Umbraco.Examine.IIndexPopulator], ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__2(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action1 serviceEmitter) em LightInject.ServiceContainer.<>c__DisplayClass198_0.<EmitLifetime>b__1() em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope)
em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action`1 emitMethod, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__1(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

-> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Forms.Core.Data.RecordIndex.FormsIndexPopulator], [Parameter: recordService(Umbraco.Forms.Core.Services.IRecordService)], [Requested dependency: ServiceType:Umbraco.Forms.Core.Services.IRecordService, ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__2(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action1 serviceEmitter) em LightInject.ServiceContainer.<>c__DisplayClass198_0.<EmitLifetime>b__1() em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope)
em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action1 emitMethod, IEmitter emitter) em LightInject.ServiceContainer.<>c__DisplayClass197_0.<ResolveEmitMethod>b__1(IEmitter methodSkeleton) em LightInject.ServiceContainer.EmitNewArray(IList1 emitMethods, Type elementType, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass187_0.b__6(IEmitter e)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

-> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Forms.Core.Services.RecordService], [Parameter: workflowService(Umbraco.Forms.Core.Services.IWorkflowService)], [Requested dependency: ServiceType:Umbraco.Forms.Core.Services.IWorkflowService, ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__2(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action1 serviceEmitter) em LightInject.ServiceContainer.<>c__DisplayClass198_0.<EmitLifetime>b__1() em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope)
em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action`1 emitMethod, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__1(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

-> System.InvalidOperationException: Unresolved dependency [Target Type: Umbraco.Forms.Core.Services.WorkflowService], [Parameter: workflowCollection(Umbraco.Forms.Core.Providers.WorkflowCollection)], [Requested dependency: ServiceType:Umbraco.Forms.Core.Providers.WorkflowCollection, ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__2(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action1 serviceEmitter) em LightInject.ServiceContainer.<>c__DisplayClass198_0.<EmitLifetime>b__1() em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope)
em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action`1 emitMethod, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__1(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

-> System.InvalidOperationException: Unable to resolve type: WorkFlowEnviarEmail, service name:
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)
em LightInject.ServiceContainer.CreateDefaultDelegate(Type serviceType, Boolean throwError)
em LightInject.ServiceContainer.GetInstance(Type serviceType)
em Umbraco.Core.Composing.LightInject.LightInjectContainer.GetInstance(Type type)
em Umbraco.Core.Composing.CollectionBuilderBase3.CreateItem(IFactory factory, Type itemType) em Umbraco.Core.Composing.CollectionBuilderBase3.<>c__DisplayClass10_0.b__0(Type x)
em System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() em System.Linq.Buffer1..ctor(IEnumerable1 source) em System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
em Umbraco.Core.Composing.CollectionBuilderBase3.CreateItems(IFactory factory) em Umbraco.Core.Composing.CollectionBuilderBase3.CreateCollection(IFactory factory)
em Umbraco.Core.Composing.LightInject.LightInjectContainer.<>c__DisplayClass20_01.<Register>b__0(IServiceFactory f) em DynamicMethod(Object[] ) em LightInject.ServiceContainer.<>c__DisplayClass150_0.<WrapAsFuncDelegate>b__0() em LightInject.ServiceContainer.<>c__DisplayClass198_0.<EmitLifetime>b__1() em LightInject.PerContainerLifetime.GetInstance(Func1 createInstance, Scope scope)
em LightInject.ServiceContainer.EmitLifetime(ServiceRegistration serviceRegistration, Action`1 emitMethod, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__1(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

-> System.InvalidOperationException: Unresolved dependency [Target Type: WorkFlowEnviarEmail], [Parameter: recordService(Umbraco.Forms.Core.Services.IRecordService)], [Requested dependency: ServiceType:Umbraco.Forms.Core.Services.IRecordService, ServiceName:]
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)
em LightInject.ServiceContainer.EmitConstructorDependencies(ConstructionInfo constructionInfo, IEmitter emitter, Action1 decoratorTargetEmitter) em LightInject.ServiceContainer.EmitNewInstanceUsingImplementingType(IEmitter emitter, ConstructionInfo constructionInfo, Action1 decoratorTargetEmitMethod)
em LightInject.ServiceContainer.EmitNewInstance(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.EmitNewInstanceWithDecorators(ServiceRegistration serviceRegistration, IEmitter emitter)
em LightInject.ServiceContainer.<>c__DisplayClass197_0.b__0(IEmitter methodSkeleton)
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.CreateDynamicMethodDelegate(Action`1 serviceEmitter)
em LightInject.ServiceContainer.CreateDelegate(Type serviceType, String serviceName, Boolean throwError)

-> System.InvalidOperationException: Recursive dependency detected: ServiceType:Umbraco.Forms.Core.Services.IRecordService, ServiceName:]
em LightInject.ServiceContainer.<>c__DisplayClass153_0.b__0(IEmitter ms)
em LightInject.ServiceContainer.EmitConstructorDependency(IEmitter emitter, Dependency dependency)

@miackers

This comment has been minimized.

Copy link
Author

@miackers miackers commented Jul 16, 2019

I also got the same when I used the code as-is - but I realised that I don't need the recordService, so I removed it from the constructor and it worked for me after - but to honest I thought it might have been a coincidence at the time (ie, that the app just had some other issue booting up).
Do you need the recordService? Can you try without it? I could do what I needed using recordStorage (ie, update a record value)

By the way - I am just a user of the Forms plugin, so I can't give you details on the internals unfortunately...

@sofietoft

This comment has been minimized.

Copy link
Contributor

@sofietoft sofietoft commented Sep 15, 2019

Hi!
As we haven't seen any new activity on this issue in while, I'll close it for now.

If you feel it's still relevant, you're welcome to reopen it! 😁
Thanks.

/Sofie

@sofietoft sofietoft closed this Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.