private Box test1( DataModification dm, Action<string> setValue ) { var box = new EwfTextBox( "" ); box.SetupAutoComplete( TestService.GetInfo(), AutoCompleteOption.NoPostBack ); var dv = new DataValue<string>(); dm.AddTopValidationMethod( ( pbvd, validator ) => dv.Value = box.GetPostBackValue( pbvd ) ); dm.AddModificationMethod( () => setValue( dv.Value ) ); return new Box( "Autofill behavior. Typing more than 3 characters should bring up autofill options from a web service. " + "Selecting an item or changing the text will no cause a post-back. This value show appear when submitting the page's submit button.", box.ToSingleElementArray() ); }
internal ActionPostBack( bool forceFullPagePostBack, IEnumerable <UpdateRegionSet> updateRegions, string id, bool?forcePageDataUpdate, bool skipModificationIfNoChanges, Action firstModificationMethod, Func <PostBackAction> actionGetter, DataModification validationDm) : base(forceFullPagePostBack, id, forcePageDataUpdate) { this.updateRegions = updateRegions ?? new UpdateRegionSet[0]; this.skipModificationIfNoChanges = skipModificationIfNoChanges; dataModification = new BasicDataModification(); if (firstModificationMethod != null) { dataModification.AddModificationMethod(firstModificationMethod); } this.actionGetter = actionGetter; this.validationDm = validationDm; }
private Box test1(DataModification dm, Action <string> setValue) { var box = new EwfTextBox(""); box.SetupAutoComplete(TestService.GetInfo(), AutoCompleteOption.NoPostBack); var dv = new DataValue <string>(); dm.AddTopValidationMethod((pbvd, validator) => dv.Value = box.GetPostBackValue(pbvd)); dm.AddModificationMethod(() => setValue(dv.Value)); return (new Box( "Autofill behavior. Typing more than 3 characters should bring up autofill options from a web service. " + "Selecting an item or changing the text will no cause a post-back. This value show appear when submitting the page's submit button.", box.ToSingleElementArray())); }
internal ActionPostBack( bool forceFullPagePostBack, IEnumerable<UpdateRegionSet> updateRegions, string id, bool? forcePageDataUpdate, bool skipModificationIfNoChanges, Action<PostBackValueDictionary, Validator> firstTopValidationMethod, Action firstModificationMethod, Func<PostBackAction> actionGetter, DataModification validationDm) : base(forceFullPagePostBack, id, forcePageDataUpdate) { this.updateRegions = updateRegions ?? new UpdateRegionSet[ 0 ]; this.skipModificationIfNoChanges = skipModificationIfNoChanges; dataModification = new BasicDataModification(); if( firstTopValidationMethod != null ) dataModification.AddTopValidationMethod( firstTopValidationMethod ); if( firstModificationMethod != null ) dataModification.AddModificationMethod( firstModificationMethod ); this.actionGetter = actionGetter; this.validationDm = validationDm; }
private void Go_Click(object _, Windows.UI.Xaml.RoutedEventArgs _1) { ObservableCollection <Rennen> rennKonflikte = DataAccess.GetRennKonflikte(); //rule out an empty database if (rennKonflikte.Count < 3) { if (rennKonflikte.Count == 0) { PopUP("Daten wurden noch nicht importiert", "Mann kann ohne Daten leider keine Aussagen ohne Daten treffen.", "OK, ich werde Daten importiernen"); } else { PopUP("Unter 3 Meldungsabteilungen???", "Für so wenige Kategorien ist das Programm nicht desight", "Ok..."); } } else { //rule out TierOneKollisions Collection <Tier1Kollision> tier1Kollisions = DataModification.GetTierOneKollisions(); if (tier1Kollisions.Count > 0) { string stmp = "BootsID\tRennID\tName\t\tVerein"; foreach (Tier1Kollision tier1Kollision in tier1Kollisions) { stmp += "\n" + tier1Kollision.RennID.ToString() + "\t" + tier1Kollision.BootID.ToString() + "\t" + tier1Kollision.Name + "\t" + tier1Kollision.Verein; } PopUP("Level 1 Kollision (Personen doppelt in einem Boot oder in einem Rennen)", stmp, "OK, ich werde die Namen ändern"); } else { // generating the optimum array in mulitple Threads Array optimalesArray = generateEval(rennKonflikte.Count); //optimales Array ausgeben und in Datenbank schreiben } } }
/// <summary> /// Creates an intermediate post-back, which skips the page's data update and only executes itself plus the validations from another data modification. /// Supports async post-backs, but does not allow navigation to another page. /// </summary> /// <param name="updateRegions">The regions of the page that will change as a result of this post-back. If forceFullPagePostBack is true, the regions only /// need to include the form controls that will change; other changes are allowed anywhere on the page.</param> /// <param name="validationDm">The data modification that will have its validations executed if there were no errors in this post-back.</param> /// <param name="forceFullPagePostBack">Pass true to force a full-page post-back instead of attempting an async post-back. Note that an async post-back will /// automatically fall back to a full-page post-back if the page has changed in any way since it was last sent. This parameter currently has no effect since /// async post-backs are not yet implemented; see RSIS goal 478.</param> /// <param name="id">The ID of this post-back. Must be unique for every post-back in the page. Do not pass null or the empty string.</param> /// <param name="skipModificationIfNoChanges">Pass true to skip the validations and modification methods if no form values changed, or if no form controls /// are included in this post-back.</param> /// <param name="firstTopValidationMethod"></param> /// <param name="firstModificationMethod"></param> /// <param name="secondaryResponseGetter">A method that returns the secondary response EWF will send, in a new window/tab or as an attachment, if there were /// no modification errors.</param> public static ActionPostBack CreateIntermediate( IEnumerable <UpdateRegionSet> updateRegions, DataModification validationDm, bool forceFullPagePostBack = false, string id = "main", bool skipModificationIfNoChanges = false, Action <PostBackValueDictionary, Validator> firstTopValidationMethod = null, Action firstModificationMethod = null, Func <SecondaryResponse> secondaryResponseGetter = null) { if (!id.Any()) { throw new ApplicationException("The post-back must have an ID."); } if (validationDm == null) { throw new ApplicationException("A validation data-modification is required."); } return(new ActionPostBack( forceFullPagePostBack, updateRegions, id, null, skipModificationIfNoChanges, firstTopValidationMethod, firstModificationMethod, secondaryResponseGetter != null ? new Func <PostBackAction>(() => new PostBackAction(secondaryResponseGetter())) : null, validationDm)); }
public virtual void Delete() { // If it's not in the database in the first place, // deleting is a no-op. if (IsNew) { return; } // Store the ModificationCount var modCount = DataModification.Count; // Store a pre-deletion copy. This will be used in the modification events so that the Id can be captured by code that isn't in this table. var preDelete = this.FieldwiseClone(); var stopwatch = Stopwatch.StartNew(); var succeeded = false; // Make the database change. If an exception is thrown, FullFlush then rethrow it. try { // Delete from the database. NrdoTransactedScope.MaybeBeginTransaction(DataBase); using (var scope = new NrdoScope(DataBase)) { scope.ExecuteSql(DeleteStatement, setPkeyOnCmd); } isNew = true; succeeded = true; } catch { DataModification.RaiseFullFlush(); throw; } finally { stopwatch.Stop(); Nrdo.DebugLog(() => Nrdo.DebugArgs(stopwatch, "db-delete", typeof(T).FullName, "Delete", null)); if (!succeeded) { deletionCache.Value.HitInfo.updateStats(stats => stats.WithFailure(stopwatch.Elapsed), stats => stats.WithFailure(stopwatch.Elapsed)); } else { deletionCache.Value.HitInfo.updateStats(stats => stats.WithModification(stopwatch.Elapsed), stats => stats.WithSingleCacheNonHit(stopwatch.Elapsed, false)); } } // Lock again. If the modification count is not equal to what it was, FullFlush. Otherwise raise // the relevant event. lock (Nrdo.LockObj) { if (DataModification.Count != modCount) { DataModification.RaiseFullFlush(); } else { DataModification.RaiseDelete(preDelete); } } }
public virtual void UpdateThis() { // If we can skip it, skip it if (!IsNew && IsUnchanged) { Nrdo.DebugLog(() => Nrdo.DebugArgs("db-update-skipped", typeof(T).FullName, "Update", null)); return; } // Store the ModificationCount var modCount = DataModification.Count; // Make the database change. If an exception is thrown, FullFlush then rethrow it. var wasNew = IsNew; var stopwatch = Stopwatch.StartNew(); bool succeeded = false; try { // Insert or update in the database. string cmdText = IsNew ? InsertStatement : UpdateStatement; if (cmdText != null) { NrdoTransactedScope.MaybeBeginTransaction(DataBase); using (var scope = new NrdoScope(DataBase)) { scope.ExecuteSql(cmdText, cmd => { setDataOnCmd(cmd); setPkeyOnCmd(cmd); }); if (IsNew) { getPkeyFromSeq(scope); } isNew = false; succeeded = true; } } } catch { DataModification.RaiseFullFlush(); throw; } finally { stopwatch.Stop(); Nrdo.DebugLog(() => Nrdo.DebugArgs(stopwatch, wasNew ? "db-insert" : "db-update", typeof(T).FullName, "Update", null)); var cache = wasNew ? insertionCache.Value : updateCache.Value; if (!succeeded) { cache.HitInfo.updateStats(stats => stats.WithFailure(stopwatch.Elapsed), stats => stats.WithFailure(stopwatch.Elapsed)); } else { cache.HitInfo.updateStats(stats => stats.WithModification(stopwatch.Elapsed), stats => stats.WithSingleCacheNonHit(stopwatch.Elapsed, false)); } } // Lock again. If the modification count is not equal to what it was, FullFlush. Otherwise raise // the relevant event. lock (Nrdo.LockObj) { if (DataModification.Count != modCount) { DataModification.RaiseFullFlush(); } else if (wasNew) { DataModification.RaiseInsert((T)this); } else { DataModification.RaiseUpdate((T)this); } } }
/// <summary> /// Adds a new column on the left of the table containing a checkbox for each row. /// Use this method if you have an existing button (that might affect multiple tables) that you want to fire the action. /// Each row must specify the UniqueIdentifier for its row setup. This will be passed back to the given action method. /// Adding multiple actions results in just one column of checkboxes. /// The checkbox column consumes 5% of the table width. /// The action method automatically executes in an EhModifyData method, so your implementation does not need to do this. /// </summary> public void AddSelectedRowsAction(DataModification dataModification, RowMethod action) { selectedRowDataModificationsToMethods.Add(dataModification, action); }
/// <summary> /// Creates an intermediate post-back, which skips the page's data update and only executes itself plus the validations from another data modification. /// Supports async post-backs, but does not allow navigation to another page. /// </summary> /// <param name="updateRegions">The regions of the page that will change as a result of this post-back. If forceFullPagePostBack is true, the regions only /// need to include the form controls that will change; other changes are allowed anywhere on the page.</param> /// <param name="forceFullPagePostBack">Pass true to force a full-page post-back instead of attempting an async post-back. Note that an async post-back will /// automatically fall back to a full-page post-back if the page has changed in any way since it was last sent. This parameter currently has no effect since /// async post-backs are not yet implemented; see RSIS goal 478.</param> /// <param name="id">The ID of this post-back, which must be unique on the page. Do not pass null or the empty string.</param> /// <param name="skipModificationIfNoChanges">Pass true to skip the validations and modification methods if no form or component-state values changed, or if /// no form controls or component-state items are included in this post-back.</param> /// <param name="firstModificationMethod"></param> /// <param name="reloadBehaviorGetter">A method that returns the reload behavior, if there were no modification errors. If you do pass a method, the page /// will block interaction even for async post-backs. This prevents an abrupt focus change for the user when the page reloads.</param> /// <param name="validationDm">The data modification that will have its validations executed if there were no errors in this post-back. Pass null to use the /// first of the current data modifications.</param> public static ActionPostBack CreateIntermediate( IEnumerable <UpdateRegionSet> updateRegions, bool forceFullPagePostBack = false, string id = "main", bool skipModificationIfNoChanges = false, Action firstModificationMethod = null, Func <PageReloadBehavior> reloadBehaviorGetter = null, DataModification validationDm = null) { if (!id.Any()) { throw new ApplicationException("The post-back must have an ID."); } return(new ActionPostBack( forceFullPagePostBack, updateRegions, id, null, skipModificationIfNoChanges, firstModificationMethod, reloadBehaviorGetter != null ? new Func <PostBackAction>(() => new PostBackAction(reloadBehaviorGetter())) : null, validationDm ?? dataModificationGetter().First())); }
/// <summary> /// Creates an intermediate post-back, which skips the page's data update and only executes itself plus the validations from another data modification. /// Supports async post-backs, but does not allow navigation to another page. /// </summary> /// <param name="updateRegions">The regions of the page that will change as a result of this post-back. If forceFullPagePostBack is true, the regions only /// need to include the form controls that will change; other changes are allowed anywhere on the page.</param> /// <param name="validationDm">The data modification that will have its validations executed if there were no errors in this post-back.</param> /// <param name="forceFullPagePostBack">Pass true to force a full-page post-back instead of attempting an async post-back. Note that an async post-back will /// automatically fall back to a full-page post-back if the page has changed in any way since it was last sent. This parameter currently has no effect since /// async post-backs are not yet implemented; see RSIS goal 478.</param> /// <param name="id">The ID of this post-back. Must be unique for every post-back in the page. Do not pass null or the empty string.</param> /// <param name="skipModificationIfNoChanges">Pass true to skip the validations and modification methods if no form values changed, or if no form controls /// are included in this post-back.</param> /// <param name="firstTopValidationMethod"></param> /// <param name="firstModificationMethod"></param> /// <param name="secondaryResponseGetter">A method that returns the secondary response EWF will send, in a new window/tab or as an attachment, if there were /// no modification errors.</param> public static ActionPostBack CreateIntermediate( IEnumerable<UpdateRegionSet> updateRegions, DataModification validationDm, bool forceFullPagePostBack = false, string id = "main", bool skipModificationIfNoChanges = false, Action<PostBackValueDictionary, Validator> firstTopValidationMethod = null, Action firstModificationMethod = null, Func<SecondaryResponse> secondaryResponseGetter = null) { if( !id.Any() ) throw new ApplicationException( "The post-back must have an ID." ); if( validationDm == null ) throw new ApplicationException( "A validation data-modification is required." ); return new ActionPostBack( forceFullPagePostBack, updateRegions, id, null, skipModificationIfNoChanges, firstTopValidationMethod, firstModificationMethod, secondaryResponseGetter != null ? new Func<PostBackAction>( () => new PostBackAction( secondaryResponseGetter() ) ) : null, validationDm ); }