Base solution for your next web application

Activities of "daniel"

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,

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
			});
		}
	}

Is it possible to write to the database once an Entity has been created? Since the connection has been closed _repository.insert(...) will not save any changes, and initiating a new DB connection throws me a "The current TransactionScope is already complete" error.

Am I missing something obvious?

Code below:

private readonly IRepository<ActivityLog> _activityLogRepository;

		public ActivityLogWriter(IRepository<ActivityLog> activityLogRepository)
		{
			_activityLogRepository = activityLogRepository;
		}

		public void HandleEvent(EntityCreatedEventData<Comment> eventData)
		{
			_activityLogRepository.Insert(new ActivityLog
			{
				Message = "Something about the inserted entity"
			});
		}
Showing 1 to 5 of 5 entries