Base solution for your next web application

Activities of "rev319303"

Well, I have spent the last year developing my application with AspNetZero and am finally to the point of building in subscriptions to my application. I noticed that you now have a subscription feature within your latest release. I looked around your website but haven't found any documentation on how to use the subscription feature or how to set it up with Paypal.

**This may be very easy to do but I just haven't looked into it, yet, and I wanted to at least read your documentation on it first before I started. I just can't seem to find.

Do you have any docs on how to setup and start using subscriptions?

Question

Where is the latest metronic files for download?

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 ...?

I downloaded BoilerPlates's ASP.Net Core 1.x project without module zero.

I am creating a web application for intranet use only. The company already has a custom membership provider that, in the past, they have implemented in the web.config as such:

<membership defaultProvider="NCMProvider">
    <providers>
        <clear />
        <add name="NCMProvider" type="Netcenter.NetcenterMembershipProvider" description="..." connectionStringName"..." enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" applicationName="..." />
    </providers>
</membership>

<roleManager enabled="true" defaultProvdier="NCRProvider">
    <providers>
        <clear />
        <add name="NCRProvider" type="NetCenter.NetCenterRoleProvider" connectionStringName="..." applicationName="..." />
    </providers>
</roleManager>

They also have a Netcenter.dll reference in their projects. They do security by calling this:

Using System.Web.Security
Roles.IsUserInRole("...")

It is required that all security go through their Netcenter. Netcenter simply has a list of applications with roles and user assigned to roles by Windows NT (Domain + "/" + ThreeCharacterString). Their Netcenter dll has everything to check access. I simply need to write something like this:

string userNt = HttpContext.User.Identity.Name;
if(Roles.IsUserInRole(userNt) { }

Can anyone provide help on how to implement this within a BoilerPlate project without Module Zero?

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.

Question

Two Questions:

Do you have a link that shows all the updates you made in your latest release? I feel I have looked at this before but I can't seem to find it now.

Does your latest version of Core / MVC /jQuery still include the .Net framework or is it only running off the core framework now?

Edit 1: I found the release notes but I don't see any notes for 4.0.0. <a class="postlink" href="https://www.aspnetzero.com/Documents/Change-Logs">https://www.aspnetzero.com/Documents/Change-Logs</a>

I figured out my answer.

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

Can someone help please? I have entity Program that has two foreign keys to my subject table (MainContactSubjectId, SecondaryContactSubjectId). Both main and secondary are nullable longs. For some reason, when I try to insert entity Program it errors (Internal Server Error) and will not let me insert unless Main and Secondary are present. Below is my entity Program and some of my dbContext. Can anyone see what I am doing wrong?

namespace DiversionCore.AppTables.Programs
{
    [Table("Program")]
    public class Program : Entity<long>
    {

        [Required]
        public int TenantId { get; set; }

        [Required]
        public long ProgramTypeId { get; set; }

        [Required]
        [MaxLength(4000)]
        public string ProgramName { get; set; }

        public long? MainContactSubjectId { get; set; }

	public long? SecondaryContactSubjectId { get; set; }

        public virtual AppTables.ProgramTypes.ProgramType ProgramType { get; set; }
        public virtual AppTables.Subjects.Subject MainSubject { get; set; }
        public virtual AppTables.Subjects.Subject SecondarySubject { get; set; }
    }
}
//MY dBCONTEXT
//I'm guessing the problem is here but I'm not sure what it is. Without this code, the foreign keys are not getting created correctly and circular reference issues. 
			modelBuilder.Entity<AppTables.Programs.Program>()
					.HasRequired(m => m.MainSubject)
					.WithMany(t => t.ProgramsMain)
					.HasForeignKey(m => m.MainContactSubjectId)
					.WillCascadeOnDelete(false);

			modelBuilder.Entity<AppTables.Programs.Program>()
					.HasRequired(m => m.SecondarySubject)
					.WithMany(t => t.ProgramsSecondary)
					.HasForeignKey(m => m.SecondaryContactSubjectId)
					.WillCascadeOnDelete(false);

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!

Does anyone have any good examples of how to export data to an Excel document or how to Export a PDF?

In the past, I have always used the NPOI library to Export to Excel and iText to export a PDF but I don't think either of these work with ASP.NET Core.

I was hoping someone has already tackled this problem and had a good example they could share or some good links.

Thanks

Showing 1 to 10 of 20 entries