Base solution for your next web application

Activities of "rev319303"

Thank-You for your response.

Let me rephrase because now that I have researched for a while, I think I can better ask my question. The companies netcenter security simply stores a users 3 character windows nt account tied to a role tied to an application in a separate database. I simply need to know how to extend ABP's IAbpSession to include a user's windows nt or how to pass/get a hold of the user's NT through the many layers of the application? For example, if I make an ajax call to my app service then how do I get a hold of the user's NT?

I'm still a young developer and realize this answer is probably on StackOverflow but I haven't been able to find it. I'm just not sure whether to extend IAbpSession or Cookie or Asp.Net Session or ...?

Answer

So, if I choose the .NET Core option then will the project still reference .NET 4.6 or is it using only .NET Core?

I was under the impression that you guys were going to continue referencing .NET 4.6 because of lacking features in EF Core. ie Lazy Loading, etc.

I figured out my answer.

I switched .HasRequired to .HasOptional and everything now works.

Copying code example for others to see... <ins>EXPORT TO EXCEL</ins>

JAVASCRIPT:

$('#ExportUsersToExcelButton').click(function () {
            _userService
                .getUsersToExcel({})
                .done(function (result) {
                    app.downloadTempFile(result);
                });
        });

USER APP SERVICE:

public async Task<FileDto> GetUsersToExcel()
        {
            var users = await UserManager.Users.Include(u => u.Roles).ToListAsync();
            var userListDtos = users.MapTo<List<UserListDto>>();
            await FillRoleNames(userListDtos);

            return _userListExcelExporter.ExportToFile(userListDtos);
        }

USER LIST EXCEL EXPORTER:

public FileDto ExportToFile(List<UserListDto> userListDtos)
        {
            return CreateExcelPackage(
                "UserList.xlsx",
                excelPackage =>
                {
                    var sheet = excelPackage.Workbook.Worksheets.Add(L("Users"));
                    sheet.OutLineApplyStyle = true;

                    AddHeader(
                        sheet,
                        L("Name"),
                        L("Surname"),
                        L("UserName"),
                        L("PhoneNumber"),
                        L("EmailAddress"),
                        L("EmailConfirm"),
                        L("Roles"),
                        L("LastLoginTime"),
                        L("Active"),
                        L("CreationTime")
                        );

                    AddObjects(
                        sheet, 2, userListDtos,
                        _ => _.Name,
                        _ => _.Surname,
                        _ => _.UserName,
                        _ => _.PhoneNumber,
                        _ => _.EmailAddress,
                        _ => _.IsEmailConfirmed,
                        _ => _.Roles.Select(r => r.RoleName).JoinAsString(", "),
                        _ => _timeZoneConverter.Convert(_.LastLoginTime, _abpSession.TenantId, _abpSession.GetUserId()),
                        _ => _.IsActive,
                        _ => _timeZoneConverter.Convert(_.CreationTime, _abpSession.TenantId, _abpSession.GetUserId())
                        );

                    //Formatting cells

                    var lastLoginTimeColumn = sheet.Column(8);
                    lastLoginTimeColumn.Style.Numberformat.Format = "yyyy-mm-dd";

                    var creationTimeColumn = sheet.Column(10);
                    creationTimeColumn.Style.Numberformat.Format = "yyyy-mm-dd";

                    for (var i = 1; i <= 10; i++)
                    {
                        sheet.Column(i).AutoFit();
                    }
                });
        }

CREATE EXCEL PACKAGE:

public IAppFolders AppFolders { get; set; }

        protected FileDto CreateExcelPackage(string fileName, Action<ExcelPackage> creator)
        {
            var file = new FileDto(fileName, MimeTypeNames.ApplicationVndOpenxmlformatsOfficedocumentSpreadsheetmlSheet);

            using (var excelPackage = new ExcelPackage())
            {
                creator(excelPackage);
                Save(excelPackage, file);
            }

            return file;
        }

        protected void AddHeader(ExcelWorksheet sheet, params string[] headerTexts)
        {
            if (headerTexts.IsNullOrEmpty())
            {
                return;
            }

            for (var i = 0; i < headerTexts.Length; i++)
            {
                AddHeader(sheet, i + 1, headerTexts[i]);
            }
        }

        protected void AddHeader(ExcelWorksheet sheet, int columnIndex, string headerText)
        {
            sheet.Cells[1, columnIndex].Value = headerText;
            sheet.Cells[1, columnIndex].Style.Font.Bold = true;
        }

        protected void AddObjects<T>(ExcelWorksheet sheet, int startRowIndex, IList<T> items, params Func<T, object>[] propertySelectors)
        {
            if (items.IsNullOrEmpty() || propertySelectors.IsNullOrEmpty())
            {
                return;
            }

            for (var i = 0; i < items.Count; i++)
            {
                for (var j = 0; j < propertySelectors.Length; j++)
                {
                    sheet.Cells[i + startRowIndex, j + 1].Value = propertySelectors[j](items[i]);
                }
            }
        }

        protected void Save(ExcelPackage excelPackage, FileDto file)
        {
            var filePath = Path.Combine(AppFolders.TempFileDownloadFolder, file.FileToken);
            excelPackage.SaveAs(new FileInfo(filePath));
        }

If anyone else has a good PDF sample, it would be much appreciated. In the past, I would create a form fillable pdf and use iText to fill in the values for the pdf. I have also used iText to create the pdf from scratch. What I am trying to do is print off a "Course of Completion" pdf and fill in the users' details on the form fillable pdf. Any suggestions appreciated! Thanks!

I figured it out. It is case sensitive and wants camel case on the call. I changed my ajax call to this:

var _customerService = abp.services.app.customer;
_customerService.createNewStripeCustomerWithSubscription({
                    CaseType: "Unlimited",
                    stripeToken: token.id,
                    StripeEmail: token.email
                }).done(function () {
                    abp.notify.success("Successfully created subscription. Thank-You for your purchase!");
                });

Also, this was not needed in the PreInitialize()

Configuration.Modules.AbpAspNetCore().CreateControllersForAppServices(typeof(DiversionCore.DiversionCoreApplicationModule).Assembly, moduleName: "app", useConventionalHttpVerbs: true);

I figured it out.

I just added this:

public virtual string StripeToken { get; set; }

to this file: MyProjectName.Authorization.Users.User.cs

Thanks

Please forgive me but this is my first code-first project. I'm used to the .edmx file doing these types of things for me.

Your answer is exactly what I thought but I do not see the AbpUser.cs class anywhere. Do you mean extend it here "MyProjectName.Authorization.Users.User.cs"? Or, do yo mean create my own User.cs that inherits AbpUser like "public class User : AbpUser<User>" and extend it here?

Showing 1 to 7 of 7 entries