Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/12/12 11:04:23 (12 years ago)
Author:
ascheibe
Message:

#1994 Calculating/Waiting Tasks are now calculated for the selected resource

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.Hive.Web/Hive-3.3/Status.aspx.cs

    r9028 r9033  
    5555            var resId = dao.GetResources(x => x.Name == resourceName).Single().Id;
    5656            resourceIds = dao.GetChildResources(resId).Select(x => x.Id).Union(new List<Guid> { resId });
     57            calculatingTasksByUser = dao.GetCalculatingTasksByUserForResources(resourceIds.ToList());
     58            waitingTasksByUser = dao.GetWaitingTasksByUserForResources(resourceIds.ToList());
    5759        }, false, false);       
    5860    } else {
     
    6062        {
    6163             resourceIds = dao.GetResources(x => true).Select(y => y.Id);
     64             calculatingTasksByUser = dao.GetCalculatingTasksByUser();
     65             waitingTasksByUser = dao.GetWaitingTasksByUser();           
    6266        }, false, false);
    6367    }   
     
    6569    transactionManager.UseTransaction(() =>
    6670    {                     
    67         onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));       
    68         currentlyJobsWaiting = dao.GetLightweightTasks(x => x.State == DA.TaskState.Waiting).Count();
    69         calculatingTasksByUser = dao.GetCalculatingTasksByUser();
    70         waitingTasksByUser = dao.GetWaitingTasksByUser();
     71        onlineSlaves = dao.GetSlaves(x => (x.SlaveState == DA.SlaveState.Calculating || x.SlaveState == DA.SlaveState.Idle) && resourceIds.Contains(x.ResourceId));
     72        currentlyJobsWaiting = dao.GetLightweightTasks(x => x.State == DA.TaskState.Waiting).Count();           
    7173    }, false, false);
    7274
     
    116118    }
    117119
    118     foreach (var kvp in waitingTasksByUser) {
     120    GenerateTasksByUserTable(waitingTasksByUser, waitingTasksByUserTable); 
     121    GenerateTasksByUserTable(calculatingTasksByUser, calculatingTasksByUserTable); 
     122  }
     123
     124  private void GenerateTasksByUserTable(Dictionary<Guid, int> tasksByUser, Table table) {
     125    foreach (var kvp in tasksByUser) {
    119126      TableRow curRow = new TableRow();
    120127      TableCell cellUser = new TableCell();
     
    125132      curRow.Cells.Add(cellUser);
    126133      curRow.Cells.Add(cellCnt);
    127       waitingTasksByUserTable.Rows.Add(curRow);
     134      table.Rows.Add(curRow);
    128135    }
    129 
    130     foreach (var kvp in calculatingTasksByUser) {
    131       TableRow curRow = new TableRow();
    132       TableCell cellUser = new TableCell();
    133       cellUser.Text = ServiceLocator.Instance.UserManager.GetUserById(kvp.Key).UserName;
    134       TableCell cellCnt = new TableCell();
    135       cellCnt.Text = kvp.Value.ToString();
    136 
    137       curRow.Cells.Add(cellUser);
    138       curRow.Cells.Add(cellCnt);
    139       calculatingTasksByUserTable.Rows.Add(curRow);
     136    if (tasksByUser.Count() > 0) {
     137      TableRow sumRow = new TableRow();       
     138      TableCell sumCell = new TableCell();
     139      sumCell.BorderWidth = Unit.Pixel(3);
     140      sumCell.Text = tasksByUser.Sum(x => x.Value).ToString();
     141      sumRow.Cells.Add(new TableCell());
     142      sumRow.Cells.Add(sumCell);
     143      table.Rows.Add(sumRow);
    140144    }
    141   }
     145  } 
    142146}
Note: See TracChangeset for help on using the changeset viewer.