public SnowflakeIdState(long id, ISnowflakeId idGen) { Id = id; _idGen = idGen; MachineIdLength = _idGen.MaxMachineMask.ToString().Length; SequenceLength = _idGen.SequenceMask.ToString().Length; Sequence = Id & _idGen.SequenceMask; MachineId = (Id >> _idGen.SequenceBits) & _idGen.MaxMachineMask; if (MachineId != _idGen.MachineId) { throw new ArgumentException($"MachineId:[{MachineId}] not Equal IdGen.MachineId:[{_idGen.MachineId}]", nameof(MachineId)); } UtcTime = _idGen.EpochTime.AddMilliseconds((Id >> _idGen.TimestampShift) & _idGen.TimestampMask); var machineIdFormat = $"D{MachineIdLength}"; var sequenceFormat = $"D{SequenceLength}"; IdString = $"{UtcTime.ToString(TIME_FORMAT)}{MachineId.ToString(machineIdFormat)}{Sequence.ToString(sequenceFormat)}"; }
public string Hydrate() { return("{0}@{1}".ToFormat(UtcTime.ToString("r"), TimeZone.Id)); }
public string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo AccessingUser, Scope CurrentScope, ref bool PropertyNotFound) { string OutputFormat = string.Empty; if (strFormat == string.Empty) { OutputFormat = "g"; } PropertyNotFound = true; //Content locked for NoSettings if (CurrentScope == Scope.NoSettings) { return(PropertyAccess.ContentLocked); } string result = string.Empty; bool PublicProperty = true; switch (strPropertyName.ToLower()) { case "month": case "months": { PublicProperty = true; PropertyNotFound = false; result = Months.ToString(formatProvider); break; } case "day": case "days": { PublicProperty = true; PropertyNotFound = false; result = Days.ToString(formatProvider); break; } case "dayofweek": case "daysofweek": { PublicProperty = true; PropertyNotFound = false; result = DaysofWeek.ToString(formatProvider); break; } case "category": { PublicProperty = true; PropertyNotFound = false; result = Category; break; } case "groupname": { PublicProperty = true; PropertyNotFound = false; result = GroupName; break; } case "startdate": { PublicProperty = true; PropertyNotFound = false; result = StartDate.ToString(OutputFormat, formatProvider); break; } case "enddate": { PublicProperty = true; PropertyNotFound = false; result = EndDate.ToString(OutputFormat, formatProvider); break; } case "starttime": { PublicProperty = true; PropertyNotFound = false; result = string.Format(formatProvider, strFormat, TimeSpan.FromMinutes(Convert.ToDouble(StartTime))); break; } case "endtime": { PublicProperty = true; PropertyNotFound = false; result = string.Format(formatProvider, strFormat, TimeSpan.FromMinutes(Convert.ToDouble(EndTime))); break; } case "title": { PublicProperty = true; PropertyNotFound = false; result = Title; break; } case "createdbyuserid": { PublicProperty = true; PropertyNotFound = false; result = CreatedByUserID.ToString(formatProvider); break; } case "createdbyuser": { PublicProperty = true; PropertyNotFound = false; var mc = new ModuleController(); int PortalId = mc.GetModule(ModuleID, -1).PortalID; DotNetNuke.Entities.Users.UserInfo usr = LastModifiedByUser(PortalId); if (usr != null) { result = usr.DisplayName; } break; } case "createddate": case "createdondate": { PublicProperty = true; PropertyNotFound = false; result = CreatedOnDate.ToString(OutputFormat, formatProvider); break; } case "lastmodifiedbyuserid": { PublicProperty = true; PropertyNotFound = false; result = LastModifiedByUserID.ToString(formatProvider); break; } case "lastmodifiedbyuser": { PublicProperty = true; PropertyNotFound = false; var mc = new ModuleController(); int PortalId = mc.GetModule(ModuleID, -1).PortalID; DotNetNuke.Entities.Users.UserInfo usr = LastModifiedByUser(PortalId); if (usr != null) { result = usr.DisplayName; } break; } case "lastmodifiedondate": { PublicProperty = true; PropertyNotFound = false; result = LastModifiedOnDate.ToString(OutputFormat, formatProvider); break; } case "portaltime": { PublicProperty = true; PropertyNotFound = false; result = PortalTime.ToString(OutputFormat, formatProvider); break; } case "usertime": { PublicProperty = true; PropertyNotFound = false; result = UserTime.ToString(OutputFormat, formatProvider); break; } case "utctime": { PublicProperty = true; PropertyNotFound = false; result = UtcTime.ToString(OutputFormat, formatProvider); break; } } if (!PublicProperty && CurrentScope != Scope.Debug) { PropertyNotFound = true; result = PropertyAccess.ContentLocked; } return(result); }
/// <summary> /// Shows the UTC time. /// </summary> public override string ToString() { return(UtcTime.ToString()); }