コード例 #1
0
 private static void PopulateRunLevelData(QueueUnitItem queueUnitItem, SlotModel slotModel)
 {
     if (slotModel.UserId == Constants.DefaultUserID)
     {
         slotModel.UserId = queueUnitItem.UserID;
     }
     if (slotModel.MachineId == Constants.DefaultMachineID)
     {
         slotModel.MachineId = queueUnitItem.MachineID;
     }
 }
コード例 #2
0
        private static QueueDictionary BuildQueueDictionary(IEnumerable <Unit> unitCollection, Info info, SlotOptions slotOptions, int slotId)
        {
            QueueDictionary cq = null;

            foreach (var unit in unitCollection.Where(unit => unit.Slot == slotId))
            {
                // don't create a queue until we find a unit that matches this slot id
                if (cq == null)
                {
                    cq = new QueueDictionary {
                        CurrentIndex = -1
                    };
                }

                var cqe = new QueueUnitItem();
                cqe.EntryStatusLiteral = unit.StateEnum.ToString();
                cqe.WaitingOn          = unit.WaitingOn;
                cqe.Attempts           = unit.Attempts;
                cqe.NextAttempt        = unit.NextAttemptTimeSpan.GetValueOrDefault();
                cqe.NumberOfSmpCores   = info.System.CpuCount;
                cqe.BeginTimeUtc       = unit.AssignedDateTime.GetValueOrDefault();
                cqe.BeginTimeLocal     = unit.AssignedDateTime.GetValueOrDefault().ToLocalTime();
                cqe.ProjectID          = unit.Project;
                cqe.ProjectRun         = unit.Run;
                cqe.ProjectClone       = unit.Clone;
                cqe.ProjectGen         = unit.Gen;
                cqe.MachineID          = slotId;
                cqe.ServerIP           = unit.WorkServer;
                cqe.CpuString          = GetCpuString(info, slotOptions);
                cqe.OsString           = ToOperatingSystemString(info.System);
                // Memory Value is in Gigabytes - turn into Megabytes and truncate
                cqe.Memory = (int)(info.System.MemoryValue.GetValueOrDefault() * 1024);
                cq.Add(unit.Id, cqe);

                if (unit.StateEnum == UnitState.Running)
                {
                    cq.CurrentIndex = unit.Id;
                }
            }

            if (cq != null)
            {
                // if no running index and at least something in the queue
                if (cq.CurrentIndex == -1 && cq.Count != 0)
                {
                    // take the minimum queue id
                    cq.CurrentIndex = cq.Keys.First();
                }
            }

            return(cq);
        }
コード例 #3
0
        private void cboQueueIndex_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_queue == null)
            {
                return;
            }

            if (cboQueueIndex.SelectedIndex > -1)
            {
                SetControlsVisible(true);

                QueueUnitItem item = _queue[(int)cboQueueIndex.SelectedValue];
                txtStatus.Text          = item.EntryStatusLiteral;
                WaitingOnTextBox.Text   = String.IsNullOrEmpty(item.WaitingOn) ? "(No Action)" : item.WaitingOn;
                AttemptsTextBox.Text    = item.Attempts.ToString();
                NextAttemptTextBox.Text = item.NextAttempt.ToString();
                var protein = _proteinService.Get(item.ProjectID);
                txtCredit.Text = protein != null?protein.Credit.ToString(CultureInfo.CurrentCulture) : "0";

                if (item.BeginTimeUtc.IsUnknown())
                {
                    txtBeginDate.Text = "(Unknown)";
                }
                else
                {
                    txtBeginDate.Text = String.Format("{0} {1}", item.BeginTimeLocal.ToShortDateString(), item.BeginTimeLocal.ToShortTimeString());
                }
                txtServer.Text    = item.ServerIP;
                txtCpuType.Text   = item.CpuString;
                txtOsType.Text    = item.OsString;
                txtMemory.Text    = item.Memory.ToString(CultureInfo.CurrentCulture);
                txtSmpCores.Text  = item.NumberOfSmpCores.ToString(CultureInfo.CurrentCulture);
                txtMachineID.Text = item.MachineID.ToString(CultureInfo.CurrentCulture);

                OnQueueIndexChanged(new QueueIndexChangedEventArgs((int)cboQueueIndex.SelectedValue));
            }
            else
            {
                // hide controls and display queue not available message
                SetControlsVisible(false);

                OnQueueIndexChanged(new QueueIndexChangedEventArgs(-1));
            }
        }
コード例 #4
0
        private void cboQueueIndex_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_queue == null)
            {
                return;
            }

            if (cboQueueIndex.SelectedIndex > -1)
            {
                SetControlsVisible(true);

                QueueUnitItem item = _queue[(int)cboQueueIndex.SelectedValue];
                txtStatus.Text          = item.EntryStatusLiteral;
                WaitingOnTextBox.Text   = String.IsNullOrEmpty(item.WaitingOn) ? "(No Action)" : item.WaitingOn;
                AttemptsTextBox.Text    = item.Attempts.ToString();
                NextAttemptTextBox.Text = item.NextAttempt.ToString();
                var protein = _proteinService.Get(item.ProjectID);
                txtCredit.Text = protein != null?protein.Credit.ToString(CultureInfo.CurrentCulture) : "0";

                if (item.BeginTimeUtc.IsUnknown())
                {
                    txtBeginDate.Text = "(Unknown)";
                }
                else
                {
                    if (_utcOffsetIsZero)
                    {
                        txtBeginDate.Text = String.Format("{0} {1}", item.BeginTimeUtc.ToShortDateString(), item.BeginTimeUtc.ToShortTimeString());
                    }
                    else
                    {
                        txtBeginDate.Text = String.Format("{0} {1}", item.BeginTimeLocal.ToShortDateString(), item.BeginTimeLocal.ToShortTimeString());
                    }
                }
                if (item.EndTimeUtc.Equals(new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc)))
                {
                    txtEndDate.Text = "(Not Completed)";
                }
                else
                {
                    if (_utcOffsetIsZero)
                    {
                        txtEndDate.Text = String.Format("{0} {1}", item.EndTimeUtc.ToShortDateString(), item.EndTimeUtc.ToShortTimeString());
                    }
                    else
                    {
                        txtEndDate.Text = String.Format("{0} {1}", item.EndTimeLocal.ToShortDateString(), item.EndTimeLocal.ToShortTimeString());
                    }
                }
                txtSpeedFactor.Text         = String.Format(CultureInfo.CurrentCulture, "{0} x min speed", item.SpeedFactor);
                txtPerformanceFraction.Text = String.Format(CultureInfo.CurrentCulture, "{0} (u={1})", _queue.PerformanceFraction, _queue.PerformanceFractionUnitWeight);
                txtMegaFlops.Text           = String.Format(CultureInfo.CurrentCulture, "{0:f}", item.MegaFlops);
                txtServer.Text = item.ServerIP;
                txtAverageDownloadRate.Text = String.Format(CultureInfo.CurrentCulture, "{0} KB/s (u={1})", _queue.DownloadRateAverage, _queue.DownloadRateUnitWeight);
                txtAverageUploadRate.Text   = String.Format(CultureInfo.CurrentCulture, "{0} KB/s (u={1})", _queue.UploadRateAverage, _queue.UploadRateUnitWeight);
                txtCpuType.Text             = item.CpuString;
                txtOsType.Text     = item.OsString;
                txtMemory.Text     = item.Memory.ToString(CultureInfo.CurrentCulture);
                txtBenchmark.Text  = item.Benchmark.ToString(CultureInfo.CurrentCulture);
                txtSmpCores.Text   = item.NumberOfSmpCores.ToString(CultureInfo.CurrentCulture);
                txtCoresToUse.Text = item.UseCores.ToString(CultureInfo.CurrentCulture);
                txtUserID.Text     = item.UserID;
                txtMachineID.Text  = item.MachineID.ToString(CultureInfo.CurrentCulture);

                #region Test TextBox Code (commented)
                //txtStatus.Text = "Status";
                //txtCredit.Text = "Credit";
                //txtBeginDate.Text = "BeginDate";
                //txtEndDate.Text = "EndDate";
                //txtSpeedFactor.Text = "SpeedFactor";
                //txtPerformanceFraction.Text = "PerfFraction";
                //txtMegaFlops.Text = "MegaFlops";
                //txtServer.Text = "Server";
                //txtAverageDownloadRate.Text = "AvgDownload";
                //txtAverageUploadRate.Text = "AvgUpload";
                //txtCpuType.Text = "CpuType";
                //txtOsType.Text = "OsType";
                //txtMemory.Text = "Memory";
                //txtGpuMemory.Text = "GpuMemory";
                //txtBenchmark.Text = "Benchmark";
                //txtSmpCores.Text = "SmpCores";
                //txtCoresToUse.Text = "CoresToUse";
                //txtUserID.Text = "UserID";
                //txtMachineID.Text = "MachineID";
                #endregion

                OnQueueIndexChanged(new QueueIndexChangedEventArgs((int)cboQueueIndex.SelectedValue));
            }
            else
            {
                // hide controls and display queue not available message
                SetControlsVisible(false);

                OnQueueIndexChanged(new QueueIndexChangedEventArgs(-1));
            }
        }