/// <summary> /// Called to (re)Populate the grid /// </summary> private void Populate() { OperationList listOperations = new OperationList(); listOperations.Populate(Operation.OPERATION.any, Operation.STATUS.any); // Add to the data set this.operationsDataSet.Tables[0].Rows.Clear(); foreach (Operation operation in listOperations) { if (operation.StartDate >= dtpStartDateTime.DateTime) { if (operation.EndDate.Ticks == 0) { operationsDataSet.Tables[0].Rows.Add(new object[] { operation , operation.StartDate , operation.AssetName , operation.OperationAsString , operation.StatusAsString , null , operation.ErrorText }); } else { operationsDataSet.Tables[0].Rows.Add(new object[] { operation , operation.StartDate , operation.AssetName , operation.OperationAsString , operation.StatusAsString , operation.EndDate , operation.ErrorText }); } } } }
/// <summary> /// This function is called periodically by the expiry of the refresh timer to check for /// and process any outstanding operations /// </summary> protected void CheckOperations() { LogFile ourLog = LogFile.Instance; try { // Do we have any items left in our 'outstanding queue' - If not check to see if anymore // have been queued if (_listOutstandingOperations.Count == 0) { // OK no operations left in the queue but have new ones been queued in the database? OperationsDAO lwDataAccess = new OperationsDAO(); int lastOperation = lwDataAccess.OperationGetLastIndex(); if (lastOperation > _lastOperation) { // New Operations have been queued - recover them _listOutstandingOperations.Populate(Operation.OPERATION.any, Operation.STATUS.none); // Update the last operation index - the returned operations are ordered by their ID if (_listOutstandingOperations.Count > 0) { Operation operation = _listOutstandingOperations[_listOutstandingOperations.Count - 1]; _lastOperation = operation.OperationID; } } } // Check for threads which need to be killed off as they have timed out CheckTimedOutOperations(); // Now loop round checking any outstanding operations unless and until we are returned false bool status; do { status = ProcessOperations(); }while (status == true); } catch (Exception ex) { ourLog.Write("CheckOperations:: An exception has occurred, error text: " + ex.Message, true); return; } }