Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
How can I auto-expand a left menu item by default at login time?
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
How can I iplement O365 Azure AD authentication with Zero v6.9.0 angular/core? I unfortunately don't have the option to upgrade Zero version at this point, but can manually replace modules if possible. Please advise as to best method/approach and resources here.
Please answer the following questions before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
Using the standard generated methods for exporting a grid to Excel, my users are frequently finding when they open the Excel file, it only contains the heading. What might be the cause here and how can I make the full file download consistently?
For v6.9.0.0: The build date or release date that displays in the site footer - internal var releaseDate does not consistentlly update and is rarely correct. It seems to just randomly update. Most of the time I can go multiple days with multiple builds (dev AND --prod) and the releaseDate does not update. How can I get this to update consistently and correctly?
Cheers
New File Upload ASP.NET Core API method (clone of user upload) not working - 401 unauthorized error
This is v6.9 angular/asp.net core template.
**asp.net core side solution:
.Application project:
.Shared project:
.Web.Core project:
.Web.Host project:
**CashSheetsControllerBase.cs:
using System; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Abp.IO.Extensions; using Abp.UI; using Abp.Web.Models; using SchlarmanConsulting.OneTAFUnify.Authorization.Users.Dto; using SchlarmanConsulting.OneTAFUnify.Storage; using Abp.BackgroundJobs; using SchlarmanConsulting.OneTAFUnify.Authorization; using Abp.AspNetCore.Mvc.Authorization; using Abp.Authorization; using Abp.Runtime.Session; using GraphQL; using Microsoft.AspNetCore.Authorization; using SchlarmanConsulting.OneTAFUnify.CashSheets; using SchlarmanConsulting.OneTAFUnify.CashSheets.Dto; using SchlarmanConsulting.OneTAFUnify.CashSheets.Importing;
namespace SchlarmanConsulting.OneTAFUnify.Web.Controllers { public abstract class CashSheetsControllerBase : OneTAFUnifyControllerBase { protected readonly IBinaryObjectManager BinaryObjectManager; protected readonly IBackgroundJobManager BackgroundJobManager;
protected CashSheetsControllerBase(
IBinaryObjectManager binaryObjectManager,
IBackgroundJobManager backgroundJobManager)
{
BinaryObjectManager = binaryObjectManager;
BackgroundJobManager = backgroundJobManager;
}
//[AllowAnonymous] //currently only way this works, but then can't get abp user object needed for transactions :\
//[AbpAllowAnonymous] //this doesn't work either
[HttpPost]
[AbpAuthorize,
AbpMvcAuthorize,
AbpMvcAuthorize(AppPermissions.Pages_ProcessCashSheets),
AbpMvcAuthorize(AppPermissions.Pages_ProcessCashSheets_CashSheetBatches_Create),
AbpMvcAuthorize(AppPermissions.Pages_ProcessCashSheets_CashSheetBatches_Edit)]
public async Task<JsonResult> ImportFromExcel()
{
try
{
var file = Request.Form.Files.First();
//TODO: parse file name for batch number and org, etc.
if (file == null)
{
throw new UserFriendlyException(L("File_Empty_Error"));
}
if (file.Length > 1048576 * 100) //100 MB
{
throw new UserFriendlyException(L("File_SizeLimit_Error"));
}
byte[] fileBytes;
using (var stream = file.OpenReadStream())
{
fileBytes = stream.GetAllBytes();
}
var tenantId = AbpSession.TenantId;
var fileObject = new BinaryObject(tenantId, fileBytes);
//set CashSheetBatchID also to assign to args
var dict = Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString());
var cashSheetBatchID = Int32.Parse(dict["CashSheetBatchID"]);
await BinaryObjectManager.SaveAsync(fileObject);
await BackgroundJobManager.EnqueueAsync<ImportCashSheetTransactionsFromExcelJob, ImportCashSheetTransactionsFromExcelJobArgs>(new ImportCashSheetTransactionsFromExcelJobArgs
{
//These fields are required for core operation
//This is where arg values are set
TenantId = tenantId,
BinaryObjectId = fileObject.Id,
User = AbpSession.ToUserIdentifier(), //think this isn't working because entering anonymously
//User = objUser,
//need to also set passed in CashSheetBatchID
CashSheetBatchID = cashSheetBatchID
});
return Json(new AjaxResponse(new { }));
}
catch (UserFriendlyException ex)
{
return Json(new AjaxResponse(new ErrorInfo(ex.Message)));
}
}
}
}
**CashSheetsController.cs:
using Abp.AspNetCore.Mvc.Authorization; using SchlarmanConsulting.OneTAFUnify.Authorization; using SchlarmanConsulting.OneTAFUnify.Storage; using Abp.BackgroundJobs;
namespace SchlarmanConsulting.OneTAFUnify.Web.Controllers { //auth seems to be working fine here [AbpMvcAuthorize(AppPermissions.Pages_ProcessCashSheets_CashSheetBatches_Create), AbpMvcAuthorize(AppPermissions.Pages_ProcessCashSheets_CashSheetBatches_Edit)] public class CashSheetsController : CashSheetsControllerBase { public CashSheetsController(IBinaryObjectManager binaryObjectManager, IBackgroundJobManager backgroundJobManager) : base(binaryObjectManager, backgroundJobManager) { } } }
Angular solution:
Create-or-edit-cashSheetBatch-modal.component.html:
…
<a href="javascript:;" *ngIf="isGranted('Pages.ProcessCashSheets')" class="no-padding">
<span>
<p-fileUpload customUpload="true"
name="ExcelFileUpload"
#ExcelFileUpload
maxFileSize="10000000"
auto="auto"
accept=".csv,.xls,.xlsx"
(uploadHandler)="uploadExcel($event)"
(onError)="onUploadExcelError()"
chooseLabel="{{'ImportFromExcel' | localize}}">
</p-fileUpload>
</span>
</a>
…
Create-or-edit-cashSheetBatch-modal.component.ts:
//upload import { FileUpload } from 'primeng/fileupload'; import { HttpClient } from '@angular/common/http';
…
export class CreateOrEditCashSheetBatchModalComponent extends AppComponentBase implements OnInit{
//CONSTRUCTOR
constructor(
injector: Injector,
private _cashSheetTransactionsServiceProxy: CashSheetTransactionsServiceProxy, //added for local use to load bank filter dropdown
private _cashSheetBatchesServiceProxy: CashSheetBatchesServiceProxy,
public formBuilderStepper:FormBuilder, //stepper visual
private _httpClient: HttpClient, //for file upload
private formBuilderCashSheetAccountSummaries: FormBuilder, //for accountsummaries
public cashSheetAccountSummariesEditService: CashSheetAccountSummariesEditService //for account summaries
) {
super(injector);
this.uploadUrl = AppConsts.remoteServiceBaseUrl + '/CashSheets/ImportFromExcel'; //for file upload
}
…
//IMPORT TAB DECLARATIONS
//file upload
@ViewChild('ExcelFileUpload') excelFileUpload: FileUpload;
//file upload
uploadUrl: string;
…
//IMPORT TAB EVENT HANDLERS
uploadExcel(data: { files: File }): void {
const formData: FormData = new FormData();
const file = data.files[0];
var cashSheetBatchID: string = "";
formData.append('file', file, file.name);
//get cash sheet batch id - this should be created in show
if (this.cashSheetBatch.id == null) {
//do nothing, accept initialized value
} else {
//cast to string
cashSheetBatchID=this.cashSheetBatch.id.toString();
}
//Append Cash Sheet Batch ID to form object
formData.append("CashSheetBatchID", cashSheetBatchID);
//post the request - transfer the Excel file to the API for import/processing
//TODO: get list of errors back from API - this will populate the new "problems" table to replace
//the field in the equivalent LP table
//TODO: Also need to pass in QBBatchSummary start and end date values - remote function will populate
//based on detail data
this._httpClient
.post<any>(this.uploadUrl, formData)
.pipe(finalize(() => this.excelFileUpload.clear()))
.subscribe(response => {
if (response.success) {
this.notify.success(this.l('ImportCashSheetProcessStart'));
} else if (response.error != null) {
this.notify.error(this.l('ImportCashSheetUploadFailed'));
}
});
}
onUploadExcelError(): void {
this.notify.error(this.l('ImportCashSheetUploadFailed'));
}
**So, I have a catch 22:
If I leave the [AllowAnonymous] decorator off CashSheetsControllerBase.ImportFromExcel, then I get a permission error:
Failed to load resource: the server responded with a status of 401 (Unauthorized) [http://localhost:22742/CashSheets/ImportFromExcel] ERROR core.js:15724 HttpErrorResponse {headers: HttpHeaders, status: 401, statusText: "Unauthorized", url: "http://localhost:22742/CashSheets/ImportFromExcel", ok: false, …} core.js:15724
I've tried multiple combinations of [AbpMvcAuthorize] decorator values, and nothing seems to work.
If I set the decorator on CashSheetsControllerBase.ImportFromExcel to [AllowAnonymous], I can use the method without the above permissions error from angular, but the User object is not populated, and I can’t use it further on in processing as I need.
I’ve compared all the modules in the UserUpload process to my cloned modules, and it seems like I’m doing everything the same. I must be missing something. Any thoughts?
I've generated a test lookup entity "TestLookup" with just one property "LookupDescription" (string).
I then generated a test entity "TestEntity" with one property "Description" and one navigation property "TestLookupId" which references "TestLookup". "LookupDescription" is the display property. I've tried generating with setting the "nullable" checkbox check and also unchecked.
Regardless, when I generate "TestEntity" and test the UI, the edit modal always displays the lookup control with the "Pick" search button (magnifying glass) icon. I don't want this. I simply want a dropdown list containing the lookup values.
How do I accomplish this via PowerTools?
Cheers