public RuleViolationException([NotNull] NotificationCollection notifications, [NotNull] string format, params object[] args) : base(Concat(string.Format(format, args), notifications)) { _notifications = notifications; }
public NotificationCollection ResetPassword(int userAccountId) { var result = NotificationCollection.CreateEmpty(); var userAccount = repository.FindById <UserAccount>(userAccountId); if (userAccount.IsNotNull()) { var newPassword = passwordGenerator.NewPassword(); userAccount.Password = newPassword; userAccount.EncrypPassword(passwordEncryptor); result += repository.Save(userAccount); if (!result.HasErrors()) { var message = repository.FindBy <EmailTemplate>(e => e.TemplateName == Constants.EmailTemplates.PasswordReset).FirstOrDefault(); message.Body = message.Body.Replace(Constants.EmailTemplatePlaceHolders.Password, newPassword); message.Body = message.Body.Replace(Constants.EmailTemplatePlaceHolders.Name, userAccount.FirstName); message.Body = message.Body.Replace(Constants.EmailTemplatePlaceHolders.Username, userAccount.Username); result += repository.Save(EmailNotification.Create(message.Subject, message.Body, SharedConfig.FromSupportEmailAddress, userAccount.EmailAddress)); } if (!result.HasErrors()) { result += new Notification("Password reset successful.", NotificationSeverity.Information); } } return(result); }
private IPath ValidatePolygonConnectLine([CanBeNull] IPath connectLine, [NotNull] IPoint targetPointShortest, [CanBeNull] NotificationCollection notifications) { if (connectLine == null) { return(null); } if (CrossesBlockingGeometry(connectLine)) { _msg.DebugFormat("Connect line {0} crosses original union. Setting null", GeometryUtils.ToString(connectLine)); connectLine = null; NotificationUtils.Add(notifications, "Unable to reshape as union because the connection between the shared boundary and the reshape line crosses existing polygons"); } // NOTE: Contains is wrong when just outside the polygon, but within the tolerance if (GeometryUtils.Intersects(_originalUnion, targetPointShortest)) { connectLine = null; NotificationUtils.Add(notifications, "Reshape as union not required in reshape to the inside"); } return(connectLine); }
private static bool ValidatePartCount([NotNull] IGeometry newGeometry, [NotNull] string errorPrefix, [NotNull] NotificationCollection notifications) { if (newGeometry.GeometryType != esriGeometryType.esriGeometryPolyline) { return(true); } if (GeometryUtils.GetPartCount(newGeometry) == 0) { NotificationUtils.Add(notifications, $"{errorPrefix}: A network edge cannot be empty."); return(false); } if (GeometryUtils.GetPartCount(newGeometry) > 1) { NotificationUtils.Add(notifications, $"{errorPrefix}: A network edge must be single part."); return(false); } return(true); }
/// <summary> /// Initializes a new instance of the <see cref="Decal"/> class. /// </summary> public Decal(GraphicsDevice graphics) { if (graphics == null) { throw new ArgumentNullException("graphics"); } rasterizeState = new RasterizerState(); rasterizeState.CullMode = CullMode.CullCounterClockwiseFace; rasterizeState.FillMode = FillMode.Solid; rasterizeState.MultiSampleAntiAlias = false; rasterizeState.ScissorTestEnable = false; Alpha = 1; Size = Vector3.One; Color = Vector3.One; FadeDuration = TimeSpan.FromSeconds(1); GraphicsDevice = graphics; Visible = true; DepthBias = 0.001f; decalGeometries = new NotificationCollection <IGeometry>(); decalGeometries.Added += (value) => { dirtyMask |= GeometryDirtyMask; }; decalGeometries.Removed += (value) => { dirtyMask |= GeometryDirtyMask; }; #if !TEXT_TEMPLATE #if !WINDOWS_PHONE //material = new DecalMaterial(graphics); #else throw new NotSupportedException("Decals aren't supported on Windows Phone."); #endif #endif }
private IGeometry Reshape([NotNull] IList <CutSubcurve> reshapeCurves, bool useNonDefaultReshapeSide, [CanBeNull] NotificationCollection notifications) { Assert.ArgumentNotNull(reshapeCurves, nameof(reshapeCurves)); Assert.AreEqual(1, ReshapeGeometryCloneByFeature.Count, "Unexpected number of reshape features: {0}", ReshapeGeometryCloneByFeature.Count); IGeometry geometryToReshape = ReshapeGeometryCloneByFeature[_feature]; IGeometry reshapedGeometry = null; if (reshapeCurves.Count > 0) { ICollection <ReshapeInfo> reshapeInfos; reshapedGeometry = ReshapeWithSimplifiedCurves( geometryToReshape, reshapeCurves, useNonDefaultReshapeSide, notifications, out reshapeInfos); AddPotentialTargetInsertPoints(reshapeCurves); AddToRefreshArea(reshapeInfos); ReleaseReshapeInfos(reshapeInfos); } return(reshapedGeometry); }
public NotificationCollection FetchAll() { NotificationCollection coll = new NotificationCollection(); Query qry = new Query(Notification.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
/// <summary> /// Removes the shorts segments of the specified featureVertexInfo unless they are protected /// by the specified featureVertexInfo's CrackPoints. The minimum of the featureVertexInfo must /// be set. /// </summary> /// <param name="fromPolycurve"></param> /// <param name="featureVertexInfo"></param> /// <param name="use2DLengthOnly"></param> /// <param name="inPerimeter"></param> /// <returns></returns> private static void RemoveShortSegments( [NotNull] IPolycurve fromPolycurve, [NotNull] FeatureVertexInfo featureVertexInfo, bool use2DLengthOnly, [CanBeNull] IGeometry inPerimeter) { Assert.ArgumentNotNull(fromPolycurve, nameof(fromPolycurve)); Assert.ArgumentNotNull(featureVertexInfo, nameof(featureVertexInfo)); Assert.ArgumentCondition(featureVertexInfo.ShortSegments != null, "featureVertexInfo's ShortSegments is null"); Assert.ArgumentCondition(featureVertexInfo.MinimumSegmentLength != null, "featureVertexInfo's MinimumSegmentLength is null"); var notifications = new NotificationCollection(); Assert.NotNull(featureVertexInfo.MinimumSegmentLength, "Minimum segment length not set."); var minimumSegmentLength = (double)featureVertexInfo.MinimumSegmentLength; IList <esriSegmentInfo> shortSegments = featureVertexInfo.ShortSegments; SegmentReplacementUtils.RemoveShortSegments(fromPolycurve, shortSegments, minimumSegmentLength, use2DLengthOnly, featureVertexInfo.CrackPointCollection, inPerimeter, notifications); if (notifications.Count > 0) { _msg.WarnFormat("Feature {0}: {1}", GdbObjectUtils.ToString(featureVertexInfo.Feature), notifications.Concatenate(" ")); } }
private static bool TryGetDatasetMatchCriteria( [NotNull] IEnumerable <NamedValuesExpression> expressions, [NotNull] NotificationCollection notifications, [NotNull] out IEnumerable <IDatasetMatchCriterion> criteria) { var list = new List <IDatasetMatchCriterion>(); var anyFailure = false; foreach (NamedValuesExpression expression in expressions) { IDatasetMatchCriterion criterion = TryCreate(expression, notifications); if (criterion == null) { anyFailure = true; } else { list.Add(criterion); } } criteria = list; return(!anyFailure); }
private static IDatasetMatchCriterion TryCreate( [NotNull] NamedValuesExpression expression, [NotNull] NotificationCollection notifications) { Assert.ArgumentNotNull(expression, nameof(expression)); Assert.ArgumentNotNull(notifications, nameof(notifications)); var simpleExpression = expression as SimpleNamedValuesExpression; if (simpleExpression != null) { return(TryCreate(simpleExpression.NamedValues, notifications)); } var conjunction = expression as NamedValuesConjunctionExpression; if (conjunction != null) { return(TryCreate(conjunction, notifications)); } throw new ArgumentException( string.Format("Unsupported expression type: {0}", expression), nameof(expression)); }
private static IDatasetMatchCriterion TryCreate( [NotNull] NamedValuesConjunctionExpression conjunction, [NotNull] NotificationCollection notifications) { var result = new DatasetMatchCriterionConjunction(); var anyFailure = false; foreach (NamedValues namedValues in conjunction.NamedValuesCollection) { IDatasetMatchCriterion criterion = TryCreate(namedValues, notifications); if (criterion != null) { result.Add(criterion); } else { anyFailure = true; } } return(anyFailure ? null : result); }
private static IDatasetMatchCriterion TryCreate( [NotNull] NamedValues namedValues, [NotNull] NotificationCollection notifications) { switch (namedValues.Name.ToLower(CultureInfo.InvariantCulture)) { case _criterionNameNames: return(new DatasetNameMatchCriterion(namedValues.Values)); case _criterionNameFeatureDatasets: return(new DatasetFeatureDatasetMatchCriterion(namedValues.Values)); default: notifications.Add("Unknown criterion name: {0}; supported criterion names: {1}", namedValues.Name, StringUtils.Concatenate( new[] { _criterionNameNames, _criterionNameFeatureDatasets }, ",")); return(null); } }
public NotificationCollection DeleteStaff(int staffId) { var result = NotificationCollection.CreateEmpty(); var staff = repository.FindById <Staff>(staffId); if (staff.IsNotNull()) { staff.IsActive = false; staff.Restaurants = new List <Restaurant>(); var waiterShifts = repository.FindBy <Shift>(s => s.Staff.Id == staff.Id && s.IsCancelled == false && s.StartTime >= DateTime.Now); if (waiterShifts.Any()) { result.AddError("The staff member cannot be deleted because there are still shifts assigned to them."); } else { result += repository.Save(staff); } } if (!result.HasErrors()) { result.AddMessage(new Notification("Staff member deleted.", NotificationSeverity.Information)); } return(result); }
private void ProcessSelection([NotNull] MapView activeMapView, [CanBeNull] CancelableProgressor progressor = null) { Dictionary <MapMember, List <long> > selectionByLayer = activeMapView.Map.GetSelection(); NotificationCollection notifications = new NotificationCollection(); List <Feature> applicableSelection = GetApplicableSelectedFeatures(selectionByLayer, notifications).ToList(); int selectionCount = selectionByLayer.Sum(kvp => kvp.Value.Count); if (applicableSelection.Count > 0 && (AllowNotApplicableFeaturesInSelection || applicableSelection.Count == selectionCount)) { LogUsingCurrentSelection(); AfterSelection(applicableSelection, progressor); } else { if (selectionCount > 0) { _msg.InfoFormat(notifications.Concatenate(Environment.NewLine)); } LogPromptForSelection(); StartSelectionPhase(); } }
/// <summary> /// Locates relevant service that can perform persistence operations on the given IMoveAttribute and performs Save operation /// </summary> public static NotificationCollection Save(Entity entity, IShifterSystem system) { var notifications = NotificationCollection.CreateEmpty(); var matchedType = false; if (entity is Waiter) { notifications += system.WaiterService.SaveWaiter(entity as Waiter); matchedType = true; } if (entity is Shift) { notifications += system.ShiftService.SaveShift(entity as Shift); matchedType = true; } if (entity is ShiftTimeslot) { notifications += system.ShiftTimeSlotService.SaveTimeslot(entity as ShiftTimeslot); matchedType = true; } if (!matchedType) { notifications.AddError("ST002", "Type not supported"); } return(notifications); }
public PageNavigator() { pages = new NotificationCollection <Page>(); pages.Sender = this; pages.Added += Child_Added; pages.Removed += Child_Removed; }
private static NotificationCollection SaveNewWaiter(WaiterViewModel viewModel, IMembershipService membershipService, IShifterSystem shifterSystem) { var notifications = NotificationCollection.CreateEmpty(); try { using (var scope = new TransactionScope()) { var createStatus = membershipService.CreateUser(viewModel.Waiter.EmailAddress, viewModel.Password, viewModel.Waiter.EmailAddress); if (createStatus == MembershipCreateStatus.Success) { notifications += CreateWaiterProfile(viewModel, shifterSystem, membershipService); } else { notifications.AddError(createStatus.ToString()); } scope.Complete(); } } catch (TransactionAbortedException ex) { notifications.AddError(ex.Message); } catch (ApplicationException ex) { notifications.AddError(ex.Message); } return(notifications); }
protected override void StoreReshapedGeometryCore( IFeature feature, IGeometry newGeometry, NotificationCollection notifications) { if (!HasEndpointChanged(feature, newGeometry)) { base.StoreReshapedGeometryCore(feature, newGeometry, notifications); return; } _msg.DebugFormat("Saving open jaw reshape on network feature {0}...", GdbObjectUtils.ToString(feature)); if (MoveLineEndJunction && NetworkFeatureFinder != null && newGeometry.GeometryType == esriGeometryType.esriGeometryPolyline) { StoreOpenJawReshapeWithEndPointMove(feature, newGeometry, notifications); } else { StoreOpenJawReshape(feature, newGeometry); } }
public NotificationCollection Validate(object entity, IRepository repository) { var notifications = NotificationCollection.CreateEmpty(); if (entity.IsNotNull()) { var timeslot = entity as ShiftTimeslot; if (timeslot.StartTime.IsNull() || timeslot.EndTime.IsNull()) { notifications.AddError("Timeslot start time and end time are required."); } var sameTimeslots = repository.FindBy <ShiftTimeslot>( w => w.StartTime == timeslot.StartTime && w.EndTime == timeslot.EndTime); if (sameTimeslots.Any()) { notifications.AddError("Timeslot already exists."); } } return(notifications); }
public static bool TryBuffer( [NotNull] IGeometry geometry, double tolerance, [CanBeNull] int?logInfoPointCountThreshold, [CanBeNull] string bufferingMessage, [CanBeNull] NotificationCollection notifications, [CanBeNull] out IPolygon bufferedPolygon) { bufferedPolygon = null; if (logInfoPointCountThreshold >= 0 && ((IPointCollection)geometry).PointCount > logInfoPointCountThreshold) { _msg.Info(bufferingMessage); } if (notifications == null) { notifications = new NotificationCollection(); } if (!ValidateBufferDistance(geometry, tolerance, notifications)) { _msg.DebugFormat("{0}: {1}.", bufferingMessage, notifications.Concatenate(". ")); return(false); } bufferedPolygon = GetOutlineBuffer(geometry, tolerance); return(true); }
/// <summary> /// Updates the specified reshaped feature and the connected network features assuming that only /// one end point has been updated in the newGeometry of the reshaped feature and the other end /// point has remained identical. /// </summary> /// <param name="reshapedFeature"></param> /// <param name="newGeometry"></param> /// <param name="notifications"></param> public virtual void UpdateFeatureEndpoint( [NotNull] IFeature reshapedFeature, [NotNull] IGeometry newGeometry, [CanBeNull] NotificationCollection notifications) { UpdateFeature(reshapedFeature, newGeometry); }
public override bool HasLocalOverrides(NotificationCollection notifications) { var result = false; if (HasLocalOverride(CentralizableLimitOverlapCalculationToExtent, "Calculate overlaps only in current map extent", notifications)) { result = true; } if (HasLocalOverride(CentralizableTargetFeatureSelection, "Target features for overlap calculation", notifications)) { result = true; } if (HasLocalOverride(CentralizableExplodeMultipartResults, "Explode multipart results into separate features", notifications)) { result = true; } if (HasLocalOverride(CentralizableInsertVerticesInTarget, "Insert vertices in target fetures for topological correctness", notifications)) { result = true; } return(result); }
public T Invoke(IEnumerable <EditedShift> shiftEdits) { Guard.InstanceNotNull(OnSuccess, "OnSuccess"); Guard.InstanceNotNull(OnError, "OnError"); var notifications = NotificationCollection.CreateEmpty(); //if shifts are marked as isSave (checked) then save them (when rendering shifts set the date and time) //else if they have an id delete them var shiftsToSave = shiftEdits.Where(s => s.IsSave).Select(s => s.Shift).ToList(); var shiftsToDelete = shiftEdits.Where(s => s.IsDelete).Select(s => s.Shift).ToList(); if (shiftsToSave.Any()) { foreach (var shift in shiftsToSave) { //if end time is smaller than start then it spans 2 days and therefor and extra day is added to the date if (shift.EndTime < shift.StartTime) { shift.EndTime = shift.EndTime.AddDays(1); } } var result = serviceRegistry.ShiftService.SaveShifts(new ShiftsRequest(shiftsToSave)); notifications += result.NotificationCollection; } if (shiftsToDelete.Any()) { notifications += serviceRegistry.ShiftService.DeleteShifts(new ShiftsRequest(shiftsToDelete)).NotificationCollection; } return(notifications.HasErrors() ? OnError(notifications) : OnSuccess()); }
public void EnsureModelHasErrorsIfAny() { var system = A.Fake <IServiceRegistry>(); A.CallTo(() => system.ShiftService.LoadShift(null)).WithAnyArguments().Returns(new LoadShiftResponse() { Shift = new ShiftDto() }); A.CallTo(() => system.ShiftService.LoadShifts(null)).WithAnyArguments().Returns(new LoadShiftCollectionResponse() { Shifts = new List <ShiftDto>() }); A.CallTo(() => system.ShiftService.DeleteShift(null)).WithAnyArguments().Returns(new GenericServiceResponse { NotificationCollection = NotificationCollection.CreateEmpty().AddError("error") }); var action = new DeleteShiftAction <dynamic>(system) { OnComplete = (m) => new { Model = m }, }; var result = action.Invoke(0, 0, 0).Model as ShiftsResultViewModel; Assert.IsTrue(result.HasErrors); }
public Panel(IEnumerable <UIElement> elements) { children = new NotificationCollection <UIElement>(); children.AddRange(elements); children.Sender = this; children.Added += Child_Added; children.Removed += Child_Removed; }
static void FillStorageCollection(NotificationCollection c, string resourceName) { //using (Stream stream = GetResourceStream(resourceName)) //{ // c.ReadXml(stream); // stream.Close(); //} }
public override void Visit(AssemblyFileReferenceWSP target, NotificationCollection notifications) { foreach (var typeDefinition in target.AssemblyFileReference.TypesThatImplementInterface("Microsoft.SharePoint.Utilities.SPPropertyBag")) { string message = string.Format(this.MessageTemplate(), typeDefinition.BaseType.FullName, target.ReadableElementName); this.Notify(target, message, notifications); } }
public override void Visit(ReceiverDefinition target, NotificationCollection notifications) { if (target.Type.ToString().StartsWith("Field", System.StringComparison.OrdinalIgnoreCase)) { string message = string.Format(this.MessageTemplate(), target.ReadableElementName); this.Notify(target, message, notifications); } }
public NotificationCollection DeleteWallPost(int wallPostId) { var result = NotificationCollection.CreateEmpty(); result += repository.Delete <WallPost>(wallPostId); return(result); }
public override void Visit(AssemblyFileReferenceWSP target, NotificationCollection notifications) { foreach (Mono.Cecil.TypeDefinition timerJob in target.AssemblyFileReference.TypesThatDerivesFromType("Microsoft.SharePoint.Administration.SPJobDefinition")) { string message = string.Format(this.MessageTemplate(), timerJob.BaseType.FullName, target.ReadableElementName); this.Notify(target, message, notifications); } }
public override void Visit(TemplateFileReference target, NotificationCollection notifications) { if (target.Location.ToLower().StartsWith("layouts\\")) { string message = string.Format(this.MessageTemplate(), target.ReadableElementName); this.Notify(target, message, notifications); } }
public NotificationCollection FetchByID(object NotificationId) { NotificationCollection coll = new NotificationCollection().Where("NotificationId", NotificationId).Load(); return coll; }
public NotificationCollection FetchByQuery(Query qry) { NotificationCollection coll = new NotificationCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
static void FillStorageCollection(NotificationCollection c, string resourceName) { //using (Stream stream = GetResourceStream(resourceName)) //{ // c.ReadXml(stream); // stream.Close(); //} }