A queue of operations from the client side to be API called to the backend with progress.
The id for this queue control.
The list of QueueFunctions to execute.
Am optional Javascript funtion to call when complete.
The Javascript Id for this queue function.
The display name for this queue function to show on the page.
The Javascript id for the queue.
A string containing JQuery selectors for objects to hide when the queue starts and show again when the queue finishes.
The URL for the backend C# controller to call each function against.
An array of functions information.
The backend server function name to call.
The function step id for this step. It must match that used in the asp functions tag.
Optional. Javascript function to call to process this step. This function can return an optional json object to pass through.
Optional. Javascript function to call to after processing this step. The function being called will be passed the original json object if passed through to this step. It also returns any "data" object returned from the function, and a third parameter with the full QueueResult object.
Optional. Show the ongoing total figure when syncing data. Allows this to be turned off when the total is not known before hand.
A javascript function to call when the whole queue is complete. Use null if parameters are required after this one.
The number of objects processed in each page.
The inital starting number for the queue.
The total in this batch. Is set to pageSize if not provided.
The total number of items.
Status of this queue call.
The total percentage completed for this queue function only ie: 10% through all records.
The current item number being processed. ie: 10 to 20 of 50
The last item being processed in this batch. ie: 10 to 20 of 50.
The last item being processed in this batch. ie: 10 to 20 of 50.
Are there any more records to process in this function? Does this function need to be called again?
Any error message to be returned back to the client display.
Any optional data to return.
Triggered when each step starts. Sends the index of the starting step. $('#MyQueue').on('stepstart', (i) => { });
Triggered when each step ends. Sends the index of the ending step. $('#MyQueue').on('stepend', (i) => { });
<queue id="QueueName"> <queue-step id="Step1" text="Step 1"></queue-step> <queue-step id="Step2" text="Step 2"></queue-step></queue>ShareItLibrary.Queue.Start('QueueName', '/MyArea/MyController/', [{serverFn: 'Sync1',stepId: 'Sync1',}, {serverFn: 'Sync2',stepId: 'Sync2',}]);ShareItLibrary.Queue.Start('QueueName', '/MyArea/MyController/', [{serverFn: 'Sync1',stepId: 'Sync1',}, {serverFn: 'Sync2',stepId: 'Sync2',}]), null, 400);[HttpPost][ValidateJsonAntiForgeryToken]public ActionResult SyncToSystem(int page){ QueueResult qr = null; ... Do some work ... var errors = new List<QueueError>(); if (ok) { int current = (page - 1) * 400 + pageTotal; int to = current + 400 > total ? total : current + 400; qr = new QueueResult(true, current, to, total, errors); } else { errors.Add(new() { Category = "Step 2 Errors", Error = "Something went wrong" }); qr = new QueueResult(false, current, to, total, errors); } return Json(qr);}<queue id="QueueName"> <queue-step id="Step1" text="Step 1"></queue-step> <queue-step id="Step2" text="Step 2"></queue-step></queue>MyApp.JsController.Batch = 10;MyApp.JsController.Total = 0;MyApp.JsController.MyFunction = () => { var temp = $('[name^="Ids["]:checked'); var length; var o = new Array(); if (temp.length > MyApp.JsController.Batch) length = MyApp.JsController.Batch; else length = length = temp.length; for (var i = 0; i < length; i++) o[i] = temp[i].value; var current = MyApp.JsController.Total - temp.length + 1; var to = MyApp.JsController.Total - temp.length + length; var json = { ids: o, current: current, to: to, total: MyApp.JsController.Total, myCustomProperty1: $('#Element').prop('checked'), myCustomProperty2: $('#filterElement').val() === 'ABC' }; return json;};MyApp.JsController.MyFunctionEnd = (json, data, fullData) => { if (json.Ids.length > 0) { for (var i = 0; i < json.Ids.length; i++) $('[value="' + json.Ids[i] + '"]').prop('checked', false).hide(); }};