Base solution for your next web application

Activities of "manojreddy"

I have a requirement in which User can enter multiline input, Could you please suggest any input which can be useful in this case which is supported by Asp.Net Core framework.

Requirement:

The user has to enter ingredients details. So it can be like 1 spoon sugar, 1-liter milk, 1.5-liter water and so on. So for this example, there are 3 input fields. It can be any number.

Right now I'm using TextArea (User enters each ingredient in the new line ), But it doesn't look good. So there any better way to this?

I am calling an API from Angular UI which uploads the image to the server to a physical path like ....../xyz/abc/pqr.png. Now I want to access this image from Angular UI like the following way.

<img src="url">

url will be something like <a class="postlink" href="http://1.2.3.4:80/xyz/abc/pqr">http://1.2.3.4:80/xyz/abc/pqr</a>

I'm getting the error while trying to access UI on <a class="postlink" href="http://localhost:4200">http://localhost:4200</a>.

INFO 2018-05-14 14:43:07,495 [22 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 OPTIONS <a class="postlink" href="http://localhost:22742/AbpUserConfiguration/GetAll">http://localhost:22742/AbpUserConfiguration/GetAll</a>
INFO 2018-05-14 14:43:07,542 [22 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-14 14:43:07,726 [22 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 209.9348ms 204 INFO 2018-05-14 14:43:07,953 [22 ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET <a class="postlink" href="http://localhost:22742/AbpUserConfiguration/GetAll">http://localhost:22742/AbpUserConfiguration/GetAll</a> application/json INFO 2018-05-14 14:43:07,961 [22 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-14 14:43:08,022 [22 ] pNetCore.Cors.Infrastructure.CorsService - Policy execution successful. INFO 2018-05-14 14:43:08,114 [22 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.GetAll (Abp.AspNetCore) with arguments ((null)) - ModelState is Valid ERROR 2018-05-14 14:43:08,169 [25 ] Mvc.ExceptionHandling.AbpExceptionFilter - No language defined! Abp.AbpException: No language defined! at Abp.Localization.MultiTenantLocalizationDictionaryProvider.GetDefaultDictionary() at Abp.Localization.Dictionaries.DictionaryBasedLocalizationSource.GetAllStrings(CultureInfo culture, Boolean includeDefaults) in D:\Github\aspnetboilerplate\src\Abp\Localization\Dictionaries\DictionaryBasedLocalizationSource.cs:line 146 at Abp.Web.Configuration.AbpUserConfigurationBuilder.GetUserLocalizationConfig() in D:\Github\aspnetboilerplate\src\Abp.Web.Common\Web\Configuration\AbpUserConfigurationBuilder.cs:line 135 at Abp.Web.Configuration.AbpUserConfigurationBuilder.<GetAll>d__38.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.Web.Common\Web\Configuration\AbpUserConfigurationBuilder.cs:line 70 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.<GetAll>d__2.MoveNext() in D:\Github\aspnetboilerplate\src\Abp.AspNetCore\AspNetCore\Mvc\Controllers\AbpUserConfigurationController.cs:line 18 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at lambda_method(Closure , Object ) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext() INFO 2018-05-14 14:43:08,185 [25 ] etCore.Mvc.Internal.ObjectResultExecutor - Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext. INFO 2018-05-14 14:43:08,188 [25 ] ore.Mvc.Internal.ControllerActionInvoker - Executed action Abp.AspNetCore.Mvc.Controllers.AbpUserConfigurationController.GetAll (Abp.AspNetCore) in 209.7928ms INFO 2018-05-14 14:43:08,203 [25 ] soft.AspNetCore.Hosting.Internal.WebHost - Request finished in 253.2542ms 500 application/json; charset=utf-8

I'm using 5.4.1 version with MqSql, I also observed that there is no entry in abplanguages table after running the service side application.

I have licensed version, but I'm getting the below error in Visual Studio Output window.

MyCompany.MyProject.Web.Host> AspNet Zero License Check Failed. Please contact to <a href="mailto:[email protected]">[email protected]</a> if you are using a licensed version!

I'm not able to install Power Tool version 1.5.0 in Visual Studio 15.6.6.

I'm getting the below error message.

Please find the logs below.

14-05-2018 12:14:16 - Microsoft VSIX Installer 14-05-2018 12:14:16 - ------------------------------------------- 14-05-2018 12:14:16 - vsixinstaller.exe version: 14-05-2018 12:14:16 - 15.6.152+ge95e4dd1ce 14-05-2018 12:14:16 - ------------------------------------------- 14-05-2018 12:14:16 - Command line parameters: 14-05-2018 12:14:16 - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe,C:\Users\MyName\Downloads\AspNetZeroRadToolVisualStudioExtension (1).vsix 14-05-2018 12:14:16 - ------------------------------------------- 14-05-2018 12:14:16 - Microsoft VSIX Installer 14-05-2018 12:14:16 - ------------------------------------------- 14-05-2018 12:14:16 - Initializing Install... 14-05-2018 12:14:17 - Extension Details... 14-05-2018 12:14:17 - Identifier : AspNetZeroPowerTools.9906ae75-6ad5-42ef-b6fe-18e263dde53c 14-05-2018 12:14:17 - Name : ASP.NET Zero Power Tools 14-05-2018 12:14:17 - Author : Volosoft 14-05-2018 12:14:17 - Version : 1.5.0 14-05-2018 12:14:17 - Description : ASP.NET Zero Rapid Application Development tooling. 14-05-2018 12:14:17 - Locale : en-US 14-05-2018 12:14:17 - MoreInfoURL : <a class="postlink" href="https://aspnetzero.com/">https://aspnetzero.com/</a> 14-05-2018 12:14:17 - InstalledByMSI : False 14-05-2018 12:14:17 - SupportedFrameworkVersionRange : [4.5,) 14-05-2018 12:14:17 - 14-05-2018 12:14:17 - SignatureState : Unsigned 14-05-2018 12:14:17 - Supported Products : 14-05-2018 12:14:17 - Microsoft.VisualStudio.Community 14-05-2018 12:14:17 - Version : [15.0] 14-05-2018 12:14:17 - 14-05-2018 12:14:17 - References : 14-05-2018 12:14:17 - ------------------------------------------------------- 14-05-2018 12:14:17 - Identifier : Microsoft.VisualStudio.MPF.15.0 14-05-2018 12:14:17 - Name : Visual Studio MPF 15.0 14-05-2018 12:14:17 - Version : [15.0] 14-05-2018 12:14:17 - MoreInfoURL : 14-05-2018 12:14:17 - Nested : No 14-05-2018 12:14:17 - 14-05-2018 12:14:17 - Prerequisites : 14-05-2018 12:14:17 - ------------------------------------------------------- 14-05-2018 12:14:17 - Identifier : Microsoft.VisualStudio.Component.CoreEditor 14-05-2018 12:14:17 - Name : Visual Studio core editor 14-05-2018 12:14:17 - Version : [15.0,16.0) 14-05-2018 12:14:17 - 14-05-2018 12:14:17 - Signature Details... 14-05-2018 12:14:17 - Extension is not signed. 14-05-2018 12:14:17 - 14-05-2018 12:14:17 - Searching for applicable products... 14-05-2018 12:14:17 - Found installed product - Global Location 14-05-2018 12:14:17 - Found installed product - Visual Studio Professional 2017 14-05-2018 12:14:18 - System.InvalidOperationException: VSHiveStub.exe failed: PkgdefManagement failed to create application: "0x80070005". at VSIXInstaller.LocationBasedSKU.get_RegRootHiveOverride() at VSIXInstaller.SupportedVSSKU.InitializeSettingsManager() at VSIXInstaller.SupportedVSSKU.get_Host() at VSIXInstaller.SupportedVSSKU.CreateExtensionEngine() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at VSIXInstaller.App.GetExtensionEngineForApplicableSKU(SupportedVSSKU supportedSKU, IInstallableExtension installableExtension, List1 applicableSKUs, Boolean isRepairSupported) at VSIXInstaller.App.TryAddSkuToValidSkuList(SupportedVSSKU supportedSKU, IInstallableExtension extension, List1 validSKUs, Boolean isRepairSupported) 14-05-2018 12:14:18 - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products. at VSIXInstaller.App.GetInstallableData(String vsixPath, Boolean isRepairSupported, IEnumerable1& skuData) at VSIXInstaller.App.Initialize(Boolean isRepairSupported) at VSIXInstaller.App.Initialize() at System.Threading.Tasks.Task`1.InnerInvoke() at System.Threading.Tasks.Task.Execute()

When I'm trying to install it again, then it gives error message This extention is already isntalled to all applicable products. But extension cannot be found inside the Tools menu (Tools -> Asp.Net Zero -> Create An Entity).

I want to implement reporting features in UI like graphs, pie charts, tables, print report. Could you please suggest tools which are compatible with ABP framework.

I'm trying to insert records in two tables, but getting the exception.

try
{
	var test = new Test();

	using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
	{
		int? tenantId = _unitOfWorkManager.Current.GetTenantId();
		using (_unitOfWorkManager.Current.SetTenantId(tenantId))
		{
			await _testRepository.InsertAsync(test);

			var xyz = new XYZ();
			await _xyzRepository.InsertAsync(xyz);
			await _unitOfWorkManager.Current.SaveChangesAsync();
			await uow.CompleteAsync();
		}
	}
}
catch (Exception ex)
{
	throw new UserFriendlyException(ex.Message);
}

Exception

Message : Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See <a class="postlink" href="http://go.microsoft.com/fwlink/?LinkId=527962">http://go.microsoft.com/fwlink/?LinkId=527962</a> for information on understanding and handling optimistic concurrency exceptions.

stack trace : at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyException(Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.<ConsumeResultSetWithPropagationAsync>d__4.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.<ConsumeAsync>d__2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.<ExecuteAsync>d__32.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.<ExecuteAsync>d__10.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.Storage.Internal.SqlServerExecutionStrategy.<ExecuteAsync>d__7`2.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.

INFO 2018-04-11 13:59:53,439 [3 ] ore.Mvc.Internal.ControllerActionInvoker - Executing action method MyCompany.MyProject.AdditionalMasterData.Tests.TestsAppService.CreateOrEdit (MyCompany.MyProject.Application) with arguments ([CreateOrEditTestDto ]) - ModelState is Valid WARN 2018-04-11 14:01:48,396 [4 ] Mvc.ExceptionHandling.AbpExceptionFilter - Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. Abp.UI.UserFriendlyException: Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions. at MyCompany.MyProject.AdditionalMasterData.Tests.TestsAppService.

Question

Trying to extend Edition, but its generating empty migration.

public class Class1 : Edition
    {
        public virtual long Price { get; set; }
    }

I need help to implement in the controller when user call an API like ChangeDatabase(string databaseConexionString), then all the request made for that user will use the new connection string instead.

[Produces("application/json")]
[Route("api/admin")]
public class AdminController : Controller
{
    private readonly DatabaseContext _context;
    private readonly IMapper _mapper;
    public AdminController(DatabaseContext context, IMapper mapper)
    {
        _context = context;
        _mapper = mapper;
    }
    [HttpGet("[action]")]
    public IActionResult ChangeDatabase(string databaseConexionString)
    {            
         //change conexion string...
         return Ok("changed!");
    }
}

My startup.cs file, the configure services is the default

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<DatabaseContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

I just want to change between databases and keep the same context class because the tables are the same, the only difference is the data.

I'm not sure the subject actually makes sense but I wasn't sure how to word it. Here's the set up: I have an Item, which has many ItemLogic, each of which has one Field. Each Item has, say, 25 ItemLogic entities. The logic determines whether that Item matches the given input from the form. For instance, Field X has a value greater than A and Field Y has a value equal to B and so on for each of the 25 fields.

In the current version of the app, all related entities are queried out and looped over, returning the first matching Item where all the ItemLogic were true. It's a bit more expensive, but simple code, and there were never that many Items to look at. Until now.

Now the app needs to filter 3000 Items to find a match. The previous query had at least two joins and takes about 45 seconds on our SQL instance. This is far too long.

A stored procedure seems a natural fit, but here's the catch: the data is dynamic for each set of Items, it comes in as a string value and often needs to be cast as a different type (DateTime or int most commonly) to perform the actual comparisons, and some logic is ignored rather than compared. That's a lot of extra overhead in a stored procedure, at least that's how it strikes me.

Alternately, I could chunk the data, but that doesn't save much for the poor bloke trying to match the last Item in the collection.

What are some approaches that could be taken to speed up the match?

Schema and some sample data:

CREATE TABLE [dbo].[Items](
    	[Id] [int] IDENTITY(1,1) NOT NULL,
    	[Name] [nvarchar](255) NOT NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    CREATE TABLE [dbo].[ItemLogic](
    	[Id] [int] IDENTITY(1,1) NOT NULL,
    	[ItemId] [int] NOT NULL,
    	[FieldId] [int] NOT NULL,
    	[Value] [nvarchar](max) NULL,
    	[Comparison] [int] NOT NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    CREATE TABLE [dbo].[Fields](
    	[Id] [int] IDENTITY(1,1) NOT NULL,
    	[Value] [nvarchar](max) NOT NULL,
    	[Type] [int] NOT NULL,
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    
    INSERT INTO [dbo].[Fields] (Value, Type) VALUES ('abc', 0), ('def', 0), ('123', 1)
    
    INSERT INTO [dbo].[Items] (Name) VALUES ('Item 1'), ('Item 2'), ('Item 3')
    
    INSERT INTO [dbo].[ItemLogic] (ItemId, FieldId, Value, Comparison) VALUES (1, 1, 'xyz', 1), (1, 2, 'qrs', 1), (1, 3, '200', 0), (2, 1, 'abc', 1), (2, 2, 'xyz', 1), (2, 3, '123', 2), (3, 1, 'abc', 1), (3, 2, 'def', 1), (3, 2, '100', 0)

For the Comparison field, it is an enum matching: 0 = Greater Than, 1 = Equal, 2 = Ignore. For the Type field, it is an enum matching: 0 = string, 1 = int.

The expected result of the above match should be that Item 3 is returned.

Showing 1 to 10 of 68 entries