One more issue I figured out as compared to the below URL :
<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API#naming-convention">http://www.aspnetboilerplate.com/Pages/ ... convention</a>
This says if your method name starts with Get it will by default use Get http verb, but it doesn't work so. All methods except one or two all are Post
That would be awesome. I can definitely wait.
The problem is what do I do with the return value when I don't have the actual value in my return value.
Waiting eagerly for your document.
internal class DTOInterceptors : IInterceptor
{
public void Intercept(IInvocation invocation)
{
try
{
if (AsyncHelper.IsAsyncMethod(invocation.Method))
{
PerformASyncDTOOperation(invocation);
}
else
{
PerformSyncDTOOperation(invocation);
}
}
catch (Exception ex)
{
// OnException(invocation, ex);
}
}
private void PerformSyncDTOOperation(IInvocation invocation)
{
var stopwatch = Stopwatch.StartNew();
try
{
invocation.Proceed();
}
catch (Exception ex)
{
throw;
}
finally
{
stopwatch.Stop();
}
}
private void PerformASyncDTOOperation(IInvocation invocation)
{
var stopwatch = Stopwatch.StartNew();
invocation.Proceed();
if (invocation.Method.ReturnType == typeof(Task))
{
invocation.ReturnValue = InternalAsyncHelper.AwaitTaskWithFinally(
(Task)invocation.ReturnValue,
exception => SaveAuditInfo(stopwatch, exception)
);
}
else //Task<TResult>
{
invocation.ReturnValue = InternalAsyncHelper.CallAwaitTaskWithFinallyAndGetResult(
invocation.Method.ReturnType.GenericTypeArguments[0],
invocation.ReturnValue,
exception => SaveAuditInfo(stopwatch, exception)
);
}
}
private void SaveAuditInfo(Stopwatch stopwatch, Exception exception)
{
stopwatch.Stop();
}
}
I am not doing much anything in the SyncMethods as I don't have the need. But when I try the Asyn Method I get :
e.g. invocation.ReturnValue = Id = 13743, Status = WaitingForActivation, Method = "{null}", Result = "{Not yet computed}"
Hi Hikalkan -
I tried my hand with Intercepting the calls but I am unable to intercept the Async methods. Is there a way I can intercept the result of the Aync methods.
I see some explanation in the below link :
<a class="postlink" href="https://gist.github.com/hikalkan/1e5d0f0142484da994e0">https://gist.github.com/hikalkan/1e5d0f0142484da994e0</a>
But these aren't helpful.
Could you throw some light into it ? I am kind of stuck.
Thanks, Partha
I see you have created the IShouldNormalize interface for Input DTO , won't it be good if you implement similar stuff for normalizing or decorating the output DTO
Thank You Sir !!! :ugeek:
Thank you. I will go through it. I am definitely waiting for AbpZero where you integrate Swagger UI. It's going to be very useful.
Thank You Daws. I had gone through this from one of your post in this forum and this is what I would be most likely doing. Do you mind sharing your code which you wrote using the Abp framework. I don't want to implement something which is against the design principle of Abp.
So if you have implemented a custom repository I would appreciate if you could share the code as well.
Thanks much Partha
Thank You for pointing to the right direction.
Finally I did the implementation without adding any new claims. Below is what I did :
Created a Static class containing a static dictionary storing the tenant ID and the DB Connection .
static class ConnectionStrings { static Dictionary<int, string> _dict = new Dictionary<int, string> { {1, @"Server =.\xxxxxx; Database = xxxxxxxx; Trusted_Connection = True;"}, {2, @"Server =.\xxxx; Database = xxxxxxxyyy; Trusted_Connection = True;"},
};
/// <summary>
/// Access the Dictionary from external sources
/// </summary>
public static string GetConnectionString(int intTenantID)
{
// Try to get the result in the static Dictionary
string result;
if (_dict.TryGetValue(intTenantID, out result))
{
return result;
}
else
{
return @"Server =.\xxxxx; Database = cxxxxxxxxx; Trusted_Connection = True;";
}
}
}
Then Created a Method called GetDynamicConnectionString()
Was able to access the TenantID using :
var ConnStringClaim = claimsIdentity.Claims.FirstOrDefault(c => c.Type == "http://www.aspnetboilerplate.com/identity/claims/tenantId");