Monthly Archives: Januar 2021
Hilfsklassen für komplette Perioden
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
public enum FixPeriod { None = 0, LastMonth = 1, CurrentMonth = 2, PreLastMonth = 3, CurrentQuarter = 4, LastQuarter = 5, PreLastQuarter = 6, CurrentHalfYear = 7, LastHalfYear = 8, PreLastHalfYear = 9, CurrentYear = 10, LastYear = 11, PreLastYear = 12 } |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public class FixPeriodFrame { public DateTime StartDate { get; set; } public DateTime EndDate { get; set; } public FixPeriodFrame() { } public FixPeriodFrame(DateTime startDate, DateTime endDate) { this.StartDate = startDate; this.EndDate = endDate; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
public static class FixPeriodExtensions { public static DateTime GetFirstDayOfYear(DateTime date) => new DateTime(date.Year, 1, 1); public static DateTime GetFirstDayOfHalfYearSecondPart(DateTime date) => new DateTime(date.Year, 7, 1); public static DateTime GetLastDayOfHalfYearFirstPart(DateTime date) => GetFirstDayOfHalfYearSecondPart(date).AddMilliseconds(-100); public static DateTime GetLastDayOfYear(DateTime date) => GetFirstDayOfYear(date).AddYears(1).AddMilliseconds(-100); public static FixPeriodFrame GetMonth(DateTime date) => new FixPeriodFrame(new DateTime(date.Year, date.Month, 1), new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month), 23, 59, 59)); public static DateTime GetQuarterStartDate(int quarter, int year) => quarter switch { 1 => new DateTime(year, 1, 1), 2 => new DateTime(year, 4, 1), 3 => new DateTime(year, 7, 1), 4 => new DateTime(year, 10, 1), }; public static DateTime GetQuarterEndDate(int quarter, int year) => GetQuarterStartDate(quarter, year).AddMonths(3).AddMilliseconds(-100); public static FixPeriodFrame GetQuarter(DateTime date) { int quarter = (date.Month + 2) / 3; return new FixPeriodFrame(GetQuarterStartDate(quarter, date.Year), GetQuarterEndDate(quarter, date.Year)); } public static FixPeriodFrame GetHalfYear(DateTime date) => (date.Month <= 6) ? new FixPeriodFrame(GetFirstDayOfYear(date), GetLastDayOfHalfYearFirstPart(date)) : new FixPeriodFrame(GetFirstDayOfHalfYearSecondPart(date), GetLastDayOfYear(date)); public static FixPeriodFrame GetYear(DateTime date) => new FixPeriodFrame(GetFirstDayOfYear(date), GetLastDayOfYear(date)); public static FixPeriodFrame ToFixPeriodFrame(this FixPeriod fixPeriod) => fixPeriod switch { FixPeriod.CurrentMonth => GetMonth(DateTime.Now), FixPeriod.LastMonth => GetMonth(DateTime.Now.AddMonths(-1)), FixPeriod.PreLastMonth => GetMonth(DateTime.Now.AddMonths(-2)), FixPeriod.CurrentQuarter => GetQuarter(DateTime.Now), FixPeriod.LastQuarter => GetQuarter(DateTime.Now.AddMonths(-3)), FixPeriod.PreLastQuarter => GetQuarter(DateTime.Now.AddMonths(-6)), FixPeriod.CurrentHalfYear => GetHalfYear(DateTime.Now), FixPeriod.LastHalfYear => GetHalfYear(DateTime.Now.AddMonths(-6)), FixPeriod.PreLastHalfYear => GetHalfYear(DateTime.Now.AddMonths(-12)), FixPeriod.CurrentYear => GetYear(DateTime.Now), FixPeriod.LastYear => GetYear(DateTime.Now.AddYears(-1)), FixPeriod.PreLastYear => GetYear(DateTime.Now.AddYears(-2)), _ => null }; } |
0

SQL Column löschen inkl. aller Constraints
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
DECLARE @TableSchema NVARCHAR(255) = ''; DECLARE @TableName NVARCHAR(255) = ''; DECLARE @ColumnName NVARCHAR(255) = ''; DECLARE @sql NVARCHAR(MAX) WHILE 1=1 BEGIN SELECT TOP 1 @sql = N'ALTER TABLE ' + @TableSchema + '.' + @TableName + ' DROP CONSTRAINT ['+dc.NAME+N']' FROM sys.default_constraints dc LEFT JOIN sys.columns c ON c.default_object_id = dc.object_id WHERE dc.parent_object_id = OBJECT_ID(@TableSchema + '.' + @TableName) AND c.name = @ColumnName IF @@ROWCOUNT = 0 BREAK EXEC (@sql) END IF EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=@TableSchema AND TABLE_NAME = @TableName AND COLUMN_NAME = @ColumnName ) BEGIN EXEC ('ALTER TABLE ' + @TableSchema + '.' + @TableName + ' DROP COLUMN ' + @ColumnName) END GO |
Windows Dienst installieren / löschen
sc.exe create MyServiceName binpath= “C:\inetpub\wwwroot\….exe” sc.exe delete MyServiceName
Bibliotheken für Authorisierung
Das Thema Authorisierungen ist sehr komplex und es gibt dazu viele Ansätze. Hier ist eine Liste von Bibliotheken: Casbin Vergleich Casbin mit OPA: OPA vs Casbin (github.com) https://www.openpolicyagent.org/ oso Documentation — oso Documentation (osohq.com) (Nur Python und Java) ory/ladon: A SDK for access control policies: authorization for the microservice and IoT age. Inspired by AWS […]
Login