Base solution for your next web application

Activities of "daniel"

It's for migrating data into the old system, the file is around 3,000+ lines long! It will also eventually be removed, it just keeps it out of the way for when we need it :)

I think what I may need to do then, is remove this as a module and call the function from MyAppDataModule

In the EntityFramework project, I've just added this 'Migrate' class in there. I haven't used AbpBootsrapper before, I wasn't sure if it's a new thing I need to use to include this module.

Hi hikalkan,

I have seen the git issue (not the blog post), but I'm still slightly confused as to how I now need to get modules loaded.

Do I just call AbpBootstrapper.Create<Migrate>(); in another Startup Module?

Or do I need to make something depend on my 'Migrate' module?

I've just upgraded from 0.6.x to 0.11, and hit a snag with my Module not being loaded.

I image it's related to this issue: <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/issues/729">https://github.com/aspnetboilerplate/as ... issues/729</a>, but I just can't seem to see how to fix it. The Documentation looks the same as to what is was before: <a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Module-System">http://www.aspnetboilerplate.com/Pages/ ... ule-System</a>

Here's a snippet of the Module code:

using Abp.EntityFramework;
using Abp.Modules;

namespace MyApp.DataMigration {

	[DependsOn(typeof(MyAppCoreModule), typeof(MyAppDataModule), typeof(AbpEntityFrameworkModule))]
	public class Migrate : AbpModule
	{
		public override void Initialize()
		{
			IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
		}

		public override void PostInitialize()
		{
			var DB = IocManager.Resolve<MyAppDbContext>();

			ImportData(DB);
		}
	}
}

Any help is appreciated!

Hi All,

I've published the app on Azure - it appears to be up and running okay, however, I'm having a problem with the UserTokenProvider.

Everything is working fine on my local machine, but on Azure I'm running into the following error

The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.

After some reasearch, I've added the following to my web.config but this hasn't fixed it.

<system.identityModel>
	<identityConfiguration>
		<securityTokenHandlers>
			<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler,  
					 System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
			<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, 
					 System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
		</securityTokenHandlers>
	</identityConfiguration>
</system.identityModel>

I presume I'm missing something related to MachineKeySessionSecurity in my Global.asax.cs? Any suggestions would be very welcomed!

Hi, I've renamed my AppServices/Repositories to be generic, but this is the basics of the code which I'm running.

The problem is bizarre, as, as you can see, I can Create to another app services perfectly fine - There are no problems stepping into the function. It's as if the ComplexAppService isn't being correctly resolved.

I do have it working using IocManager.Instance.Resolve, so it's not a major bug for me currently, just more curiosity.

public class MyAppService : ApplicationService, IMyAppService
{
	private readonly IRepository<Thing> _thingRepository;
	private readonly IAnotherAppService _anotherAppService
	private readonly IComplexAppService _complexAppService

	public MyAppService(IRepository<Thing> thingRepository, IAnotherAppService anotherAppService, IComplexAppService complexAppService)
	{
		_thingRepository = thingRepository;
		_anotherAppService = anotherAppService;
		_complexAppService = complexAppService;
	}

	public Create(CreateInput input)
	{
		var ThingItem = _thingRepository.Get(1);
		ThingItem.Prop = true; // This updates correctly

		var AnotherId = _anotherAppService.Create(new CreateAnotherInput { Value = "Some text" }); // This will complete

		_complexAppService.Create(new CreateComplexInput { AnotherId = AnotherId }); // This fails

		var CAS = IocManager.Instance.Resolve<ComplexAppService>();
		CAS.Create(new CreateComplexInput { AnotherId = AnotherId }); // This works correctly
	}
}

I've managed to inject other AppServices to the same one too, they're all working perfectly. So, for example, in my "MyAppService", I've injected "TaskAppService", and I can call GetTasks() from there. This completes successfully.

I'm not receiving any error at all, the code will not call the function at all. It just skips over it and exits the function.

If you reject the injection method, which route should we go down? Injecting the IIocManager and resolving from there, or resolving as I did in the working example above?

Hi,

For some reason if I inject one AppService into another, the code will fail to work. However, if I resolve the AppService the code works fine. What's the correct way to go about this?

Streamlined code example below:

public class MyAppService : ApplicationService, IMyAppService
{
	private readonly IAnotherAppService _anotherAppService

	public MyAppService(IAnotherAppService anotherAppService)
	{
		_anotherAppService = anotherAppService;
	}

	public Create(CreateInput input)
	{
		_anotherAppService.Create(new CreateInputDto {}); // This fails

		var AAS = IocManager.Instance.Resolve<AnotherAppService>();
		AAS.Create(new CreateInputDto {}); // This works correctly
	}
}

Following the documentation I've injected the EventBus into both my AppServices, but the events are only being triggered in one app service at a time. Never both. If I remove the EventBus from the first App Service, all the events in the second app service will be triggered.

Is this a bug or have I missed something?

Example code:

public class CommentAppService : ApplicationService, ICommentAppService
	{

		private readonly ICommentRepository _commentRepository;

		public IEventBus EventBus { get; set; }

		public CommentAppService(ICommentRepository commentRepository)
		{
			_commentRepository = commentRepository;

			EventBus = NullEventBus.Instance;
		}

		public Comment CreateCommentForTask(CreateCommentInput input) {
			var comment = new Comment
			{
				CommentText = input.CommentText,
				TaskId = input.TaskId,
				UserId = input.UserId
			};

			EventBus.Trigger(new TaskCommentCreatedEventData(input.TaskId.Value));

			return _commentRepository.Insert(comment);
		}
	}
public class TaskAppService : ApplicationService, ITaskAppService
	{
		private readonly IRepository<Task> _taskRepository;
		
		public IEventBus EventBus;

		public ProjectTaskActionAppService(IRepository<Task> taskRepository
		{
			_taskRepository = taskRepository;

			EventBus = NullEventBus.Instance;
		}

		public void UpdateProjectTaskActionStatus(UpdateTaskStatusInput input)
		{
			var task = _taskRepository.Get(input.TaskId);
			task.Completed = input.Completed

			if(input.Completed)
			{
				// TODO: This isn't being triggered!
				EventBus.Trigger(new TaskCompleteEventData(task.Id));
			}
		}
	}
public class ActivityLogWriter :
		IEventHandler<TaskCommentCreatedEventData>,
		IEventHandler<TaskCompleteEventData>,
		ITransientDependency
	{
		private readonly IRepository<ActivityLog> _activityLogRepository;
		private readonly IRepository<Task> _taskRepository;

		public ActivityLogWriter(
			IRepository<ActivityLog> activityLogRepository,
			IRepository<ProjectTask> taskRepository
			)
		{
			_activityLogRepository = activityLogRepository;
			_taskRepository = taskRepository;
		}

		/// <summary>
		/// Log the event when users comment on a task
		/// </summary>
		/// <param name="eventData"></param>
		public void HandleEvent(TaskCommentCreatedEventData eventData)
		{
			WriteActivity("{User} commented on the task {Task}", null, eventData.TaskId);
		}

		/// <summary>
		/// Store a log when a user completes a task
		/// </summary>
		/// <param name="eventData"></param>
		public void HandleEvent(TaskCompleteEventData eventData)
		{
			WriteActivity("{User} complete the the task {Task}", eventData.TaskId);
		}

		/// <summary>
		/// Writes a log to the system
		/// </summary>
		/// <param name="message">The message to write as a long</param>
		/// <param name="projectTaskId">The project task which the event related to.</param>
		public void WriteActivity(string message, taskId)
		{
			_activityLogRepository.Insert(new ActivityLog
			{
				Message = message,
				TaskId = taskId
			});
		}
	}

Thanks for the reply! Would explain why I was getting nowhere with it.

Showing 1 to 10 of 11 entries