Friday, July 17, 2020

SQL Server Reporting Services - Summing a Field Calculated in a Custom Code Assembly

I have a report that has a complex calculation being done in a custom code assembly that is attached to the report as a reference. The problem I ran into is trying to get a SUM on that calculation. I've written some custom code that you can input into the Code section on Report Properties.

Public Shared Value as Decimal=0.00
Public Shared ReturnValue as Decimal = 0.00
Public Shared Function GetValue(Item as Integer) as Integer
     value= value + Item
     return Item
End Function
Public Shared Function GetTotal()
     returnvalue = value
     value = 0
     return returnvalue
End Function


Then you just enclose the original expression inside:

=Code.GetValue(put expression here)

And then use this expression where you want the total:

=Code.GetTotal()

This code will also zero-out the 'Value' variable so that you can reuse it in a repeating group.

Friday, June 12, 2020

MacOS Google File Stream Error: drive file stream has encountered a problem and has stopped

I've spent too much of the last few days trying to figure out why I couldn't get Google File Stream running on a new account on a mac. I tried all of the recommended solutions with no luck so finally I decided to try to figure it out myself and I did get it working.

The problem I was seeing is that I was just getting an error every single time I tried to run the application. All I'd get was "drive file stream has encountered a problem and has stopped" and I couldn't change any preferences at all or do anything besides quit the app.

What fixed this issue for me (after trying everything else recommended online) was to uninstall Google File Stream, and then in finder show hidden files on the HD (cmd + shift + .) and go to Volumes and delete the Google Drive volume. Then I reinstalled Google File Stream, and once that was done it started working just fine the next time I fired the program up.

My guess is that the volume is created under the context of the user who installs the program, and if another account gets created it doesn't have permissions to access that volume. Purely a guess though. Anyway I hope that helps anyone who is running into this same issue.

Friday, January 31, 2020

.NET Core 3.1 Identity Database Script to Build Necessary DB Objects Without Using Migrate

Not everyone has the database access they need to use the whiz-bang database-migration tools when writing Razor apps with .NET Core 3.1. If this is you, and you either can't get the DBAs to give you that access, or you don't want to be running migrations on a database with other important data in it, then you can use this script directly in SQL Server to build the DB objects you'll need for the default .NET Core 3.1 Identity implementation.


      CREATE TABLE [AspNetRoles] (
          [Id] nvarchar(450) NOT NULL,
          [Name] nvarchar(256) NULL,
          [NormalizedName] nvarchar(256) NULL,
          [ConcurrencyStamp] nvarchar(max) NULL,
          CONSTRAINT [PK_AspNetRoles] PRIMARY KEY ([Id])
      );

      CREATE TABLE [AspNetUsers] (
          [Id] nvarchar(450) NOT NULL,
          [UserName] nvarchar(256) NULL,
          [NormalizedUserName] nvarchar(256) NULL,
          [Email] nvarchar(256) NULL,
          [NormalizedEmail] nvarchar(256) NULL,
          [EmailConfirmed] bit NOT NULL,
          [PasswordHash] nvarchar(max) NULL,
          [SecurityStamp] nvarchar(max) NULL,
          [ConcurrencyStamp] nvarchar(max) NULL,
          [PhoneNumber] nvarchar(max) NULL,
          [PhoneNumberConfirmed] bit NOT NULL,
          [TwoFactorEnabled] bit NOT NULL,
          [LockoutEnd] datetimeoffset NULL,
          [LockoutEnabled] bit NOT NULL,
          [AccessFailedCount] int NOT NULL,
          CONSTRAINT [PK_AspNetUsers] PRIMARY KEY ([Id])
      );

      CREATE TABLE [AspNetRoleClaims] (
          [Id] int NOT NULL IDENTITY,
          [RoleId] nvarchar(450) NOT NULL,
          [ClaimType] nvarchar(max) NULL,
          [ClaimValue] nvarchar(max) NULL,
          CONSTRAINT [PK_AspNetRoleClaims] PRIMARY KEY ([Id]),
          CONSTRAINT [FK_AspNetRoleClaims_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE
      );

      CREATE TABLE [AspNetUserClaims] (
          [Id] int NOT NULL IDENTITY,
          [UserId] nvarchar(450) NOT NULL,
          [ClaimType] nvarchar(max) NULL,
          [ClaimValue] nvarchar(max) NULL,
          CONSTRAINT [PK_AspNetUserClaims] PRIMARY KEY ([Id]),
          CONSTRAINT [FK_AspNetUserClaims_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
      );

      CREATE TABLE [AspNetUserLogins] (
          [LoginProvider] nvarchar(128) NOT NULL,
          [ProviderKey] nvarchar(128) NOT NULL,
          [ProviderDisplayName] nvarchar(max) NULL,
          [UserId] nvarchar(450) NOT NULL,
          CONSTRAINT [PK_AspNetUserLogins] PRIMARY KEY ([LoginProvider], [ProviderKey]),
          CONSTRAINT [FK_AspNetUserLogins_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
      );

      CREATE TABLE [AspNetUserRoles] (
          [UserId] nvarchar(450) NOT NULL,
          [RoleId] nvarchar(450) NOT NULL,
          CONSTRAINT [PK_AspNetUserRoles] PRIMARY KEY ([UserId], [RoleId]),
          CONSTRAINT [FK_AspNetUserRoles_AspNetRoles_RoleId] FOREIGN KEY ([RoleId]) REFERENCES [AspNetRoles] ([Id]) ON DELETE CASCADE,
          CONSTRAINT [FK_AspNetUserRoles_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
      );

      CREATE TABLE [AspNetUserTokens] (
          [UserId] nvarchar(450) NOT NULL,
          [LoginProvider] nvarchar(128) NOT NULL,
          [Name] nvarchar(128) NOT NULL,
          [Value] nvarchar(max) NULL,
          CONSTRAINT [PK_AspNetUserTokens] PRIMARY KEY ([UserId], [LoginProvider], [Name]),
          CONSTRAINT [FK_AspNetUserTokens_AspNetUsers_UserId] FOREIGN KEY ([UserId]) REFERENCES [AspNetUsers] ([Id]) ON DELETE CASCADE
      );

      CREATE INDEX [IX_AspNetRoleClaims_RoleId] ON [AspNetRoleClaims] ([RoleId]);

      CREATE UNIQUE INDEX [RoleNameIndex] ON [AspNetRoles] ([NormalizedName]) WHERE [NormalizedName] IS NOT NULL;

      CREATE INDEX [IX_AspNetUserClaims_UserId] ON [AspNetUserClaims] ([UserId]);

      CREATE INDEX [IX_AspNetUserLogins_UserId] ON [AspNetUserLogins] ([UserId]);

      CREATE INDEX [IX_AspNetUserRoles_RoleId] ON [AspNetUserRoles] ([RoleId]);

      CREATE INDEX [EmailIndex] ON [AspNetUsers] ([NormalizedEmail]);

      CREATE UNIQUE INDEX [UserNameIndex] ON [AspNetUsers] ([NormalizedUserName]) WHERE [NormalizedUserName] IS NOT NULL;