Beispiel #1
0
        internal SlotSummary CreateSlotSummary(ICollection <SlotModel> slots, DateTime updateDateTime)
        {
            var slotSummary = new SlotSummary();

            slotSummary.HfmVersion     = Application.FullVersion;
            slotSummary.NumberFormat   = NumberFormat.Get(Preferences.Get <int>(Preference.DecimalPlaces), XsltNumberFormat);
            slotSummary.UpdateDateTime = updateDateTime;
            slotSummary.SlotTotals     = SlotTotals.Create(slots);
            slotSummary.Slots          = SortSlots(slots).Select(_mapper.Map <SlotModel, SlotData>).ToList();
            return(slotSummary);
        }
        protected override string OnGetCellText(object value, SlotModel slotModel)
        {
            if (!slotModel.Status.IsOnline())
            {
                return(String.Empty);
            }

            var    decimalPlaces = slotModel.Prefs.Get <int>(Preference.DecimalPlaces);
            string format        = NumberFormat.Get(decimalPlaces);
            var    number        = (double)value;

            return(number.ToString(format));
        }
Beispiel #3
0
        internal SlotDetail CreateSlotDetail(SlotModel slot, DateTime updateDateTime)
        {
            var slotDetail = new SlotDetail();

            slotDetail.HfmVersion             = Application.FullVersion;
            slotDetail.NumberFormat           = NumberFormat.Get(Preferences.Get <int>(Preference.DecimalPlaces), XsltNumberFormat);
            slotDetail.UpdateDateTime         = updateDateTime;
            slotDetail.LogFileAvailable       = Preferences.Get <bool>(Preference.WebGenCopyFAHlog);
            slotDetail.LogFileName            = slot.Settings.ClientLogFileName;
            slotDetail.TotalRunCompletedUnits = slot.TotalRunCompletedUnits;
            slotDetail.TotalCompletedUnits    = slot.TotalCompletedUnits;
            slotDetail.TotalRunFailedUnits    = slot.TotalRunFailedUnits;
            slotDetail.TotalFailedUnits       = slot.TotalFailedUnits;
            slotDetail.SlotData = _mapper.Map <SlotModel, SlotData>(slot);
            return(slotDetail);
        }
Beispiel #4
0
        public override void Generate(IBenchmarksReportSource source)
        {
            var benchmarkText = new List <string>();

            var slotIdentifier = source.SlotIdentifier;
            var projects       = source.Projects;

            if (slotIdentifier is null || projects.Count == 0)
            {
                Result = benchmarkText;
                return;
            }

            string numberFormat     = NumberFormat.Get(Preferences.Get <int>(Preference.DecimalPlaces));
            var    bonusCalculation = Preferences.Get <BonusCalculation>(Preference.BonusCalculation);
            bool   calculateBonus   = bonusCalculation != BonusCalculation.None;

            foreach (var projectID in projects)
            {
                var protein = ProteinService.Get(projectID);
                if (protein is null)
                {
                    benchmarkText.Add(String.Format(CultureInfo.InvariantCulture, " Project ID: {0} Not Found", projectID));
                    benchmarkText.AddRange(Enumerable.Repeat(String.Empty, 2));
                    continue;
                }

                var benchmarks = BenchmarkService.GetBenchmarks(slotIdentifier.Value, protein.ProjectNumber)
                                 .OrderBy(x => x.SlotIdentifier.Name)
                                 .ThenBy(x => x.Threads);

                benchmarkText
                .AddRange(EnumerateProjectInformation(protein)
                          .Concat(Enumerable.Repeat(String.Empty, 2)));

                foreach (var b in benchmarks)
                {
                    benchmarkText
                    .AddRange(EnumerateBenchmarkInformation(protein, b, numberFormat, calculateBonus)
                              .Concat(EnumerateSlotInformation(FindRunningSlot(b), numberFormat, bonusCalculation))
                              .Concat(Enumerable.Repeat(String.Empty, 2)));
                }
            }

            Result = benchmarkText;
        }
Beispiel #5
0
        public void GridModelSlotTotalsChanged(SlotTotals totals)
        {
            string numberFormat = NumberFormat.Get(Preferences.Get <int>(Preference.DecimalPlaces));

            NotifyIconText = String.Format("{0} Working Slots{3}{1} Idle Slots{3}{2} PPD",
                                           totals.WorkingSlots, totals.NonWorkingSlots, totals.PPD.ToString(numberFormat), Environment.NewLine);

            string slots = "Slots";

            if (totals.TotalSlots == 1)
            {
                slots = "Slot";
            }

            int percentWorking = 0;

            if (totals.TotalSlots > 0)
            {
                percentWorking = ((totals.WorkingSlots * 200) + totals.TotalSlots) / (totals.TotalSlots * 2);
            }

            WorkingSlotsText    = $"{totals.WorkingSlots} of {totals.TotalSlots} {slots} ({percentWorking}%)";
            TotalProductionText = $"{totals.PPD.ToString(numberFormat)} PPD";
        }
        private void SetupDataGridView(IPreferences preferences)
        {
            // Add Column Selector
            new DataGridViewColumnSelector(dataGridView1);

            string[] names        = WorkUnitQueryParameter.GetColumnNames();
            string   numberFormat = NumberFormat.Get(preferences.Get <int>(Preference.DecimalPlaces));

            dataGridView1.AutoGenerateColumns = false;
            // ReSharper disable PossibleNullReferenceException
            dataGridView1.Columns.Add(WorkUnitRowColumn.ProjectID.ToString(), names[(int)WorkUnitRowColumn.ProjectID]);
            dataGridView1.Columns[WorkUnitRowColumn.ProjectID.ToString()].DataPropertyName = WorkUnitRowColumn.ProjectID.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.WorkUnitName.ToString(), names[(int)WorkUnitRowColumn.WorkUnitName]);
            dataGridView1.Columns[WorkUnitRowColumn.WorkUnitName.ToString()].DataPropertyName = WorkUnitRowColumn.WorkUnitName.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Name.ToString(), names[(int)WorkUnitRowColumn.Name]);
            dataGridView1.Columns[WorkUnitRowColumn.Name.ToString()].DataPropertyName = WorkUnitRowColumn.Name.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Path.ToString(), names[(int)WorkUnitRowColumn.Path]);
            dataGridView1.Columns[WorkUnitRowColumn.Path.ToString()].DataPropertyName = WorkUnitRowColumn.Path.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Username.ToString(), names[(int)WorkUnitRowColumn.Username]);
            dataGridView1.Columns[WorkUnitRowColumn.Username.ToString()].DataPropertyName = WorkUnitRowColumn.Username.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Team.ToString(), names[(int)WorkUnitRowColumn.Team]);
            dataGridView1.Columns[WorkUnitRowColumn.Team.ToString()].DataPropertyName = WorkUnitRowColumn.Team.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.SlotType.ToString(), names[(int)WorkUnitRowColumn.SlotType]);
            dataGridView1.Columns[WorkUnitRowColumn.SlotType.ToString()].DataPropertyName = WorkUnitRowColumn.SlotType.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Core.ToString(), names[(int)WorkUnitRowColumn.Core]);
            dataGridView1.Columns[WorkUnitRowColumn.Core.ToString()].DataPropertyName = WorkUnitRowColumn.Core.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.CoreVersion.ToString(), names[(int)WorkUnitRowColumn.CoreVersion]);
            dataGridView1.Columns[WorkUnitRowColumn.CoreVersion.ToString()].DataPropertyName = WorkUnitRowColumn.CoreVersion.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.FrameTime.ToString(), names[(int)WorkUnitRowColumn.FrameTime]);
            dataGridView1.Columns[WorkUnitRowColumn.FrameTime.ToString()].DataPropertyName = WorkUnitRowColumn.FrameTime.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.KFactor.ToString(), names[(int)WorkUnitRowColumn.KFactor]);
            dataGridView1.Columns[WorkUnitRowColumn.KFactor.ToString()].DataPropertyName = WorkUnitRowColumn.KFactor.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.PPD.ToString(), names[(int)WorkUnitRowColumn.PPD]);
            dataGridView1.Columns[WorkUnitRowColumn.PPD.ToString()].DataPropertyName = WorkUnitRowColumn.PPD.ToString();
            dataGridView1.Columns[WorkUnitRowColumn.PPD.ToString()].DefaultCellStyle = new DataGridViewCellStyle {
                Format = numberFormat
            };
            dataGridView1.Columns.Add(WorkUnitRowColumn.Assigned.ToString(), names[(int)WorkUnitRowColumn.Assigned]);
            dataGridView1.Columns[WorkUnitRowColumn.Assigned.ToString()].DataPropertyName = WorkUnitRowColumn.Assigned.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Finished.ToString(), names[(int)WorkUnitRowColumn.Finished]);
            dataGridView1.Columns[WorkUnitRowColumn.Finished.ToString()].DataPropertyName = WorkUnitRowColumn.Finished.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Credit.ToString(), names[(int)WorkUnitRowColumn.Credit]);
            dataGridView1.Columns[WorkUnitRowColumn.Credit.ToString()].DataPropertyName = WorkUnitRowColumn.Credit.ToString();
            dataGridView1.Columns[WorkUnitRowColumn.Credit.ToString()].DefaultCellStyle = new DataGridViewCellStyle {
                Format = numberFormat
            };
            dataGridView1.Columns.Add(WorkUnitRowColumn.Frames.ToString(), names[(int)WorkUnitRowColumn.Frames]);
            dataGridView1.Columns[WorkUnitRowColumn.Frames.ToString()].DataPropertyName = WorkUnitRowColumn.Frames.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.FramesCompleted.ToString(), names[(int)WorkUnitRowColumn.FramesCompleted]);
            dataGridView1.Columns[WorkUnitRowColumn.FramesCompleted.ToString()].DataPropertyName = WorkUnitRowColumn.FramesCompleted.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Result.ToString(), names[(int)WorkUnitRowColumn.Result]);
            dataGridView1.Columns[WorkUnitRowColumn.Result.ToString()].DataPropertyName = WorkUnitRowColumn.Result.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.Atoms.ToString(), names[(int)WorkUnitRowColumn.Atoms]);
            dataGridView1.Columns[WorkUnitRowColumn.Atoms.ToString()].DataPropertyName = WorkUnitRowColumn.Atoms.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.ProjectRun.ToString(), names[(int)WorkUnitRowColumn.ProjectRun]);
            dataGridView1.Columns[WorkUnitRowColumn.ProjectRun.ToString()].DataPropertyName = WorkUnitRowColumn.ProjectRun.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.ProjectClone.ToString(), names[(int)WorkUnitRowColumn.ProjectClone]);
            dataGridView1.Columns[WorkUnitRowColumn.ProjectClone.ToString()].DataPropertyName = WorkUnitRowColumn.ProjectClone.ToString();
            dataGridView1.Columns.Add(WorkUnitRowColumn.ProjectGen.ToString(), names[(int)WorkUnitRowColumn.ProjectGen]);
            dataGridView1.Columns[WorkUnitRowColumn.ProjectGen.ToString()].DataPropertyName = WorkUnitRowColumn.ProjectGen.ToString();
            // ReSharper restore PossibleNullReferenceException
        }
Beispiel #7
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag];
            Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application;

            try
            {
                string cellName_Begin   = CellName_Begin.Get(context);
                string cellName_End     = CellName_End.Get(context);
                int    cellRow_Begin    = CellRow_Begin.Get(context);
                int    cellColumn_Begin = CellColumn_Begin.Get(context);
                int    cellRow_End      = CellRow_End.Get(context);
                int    cellColumn_End   = CellColumn_End.Get(context);
                double rowHeight        = RowHeight.Get(context);
                double colWidth         = ColWidth.Get(context);
                Int32  fontSize         = FontSize.Get(context);
                string sheetName        = SheetName.Get(context);

                Excel::_Worksheet sheet = null;
                if (sheetName == null)
                {
                    sheet = excelApp.ActiveSheet;
                }
                else
                {
                    sheet = excelApp.ActiveWorkbook.Sheets[sheetName];
                }

                Excel::Range range1, range2;
                range1 = cellName_Begin == null ? sheet.Cells[cellRow_Begin, cellColumn_Begin] : sheet.Range[cellName_Begin];
                range2 = cellName_End == null ? sheet.Cells[cellRow_End, cellColumn_End] : sheet.Range[cellName_End];
                Excel::Range range = sheet.Range[range1, range2];

                /*数字格式设置*/
                if (NumberFormat.Expression != null)
                {
                    range.NumberFormat = NumberFormat.Get(context);
                }

                /*对齐设置*/
                if ((int)_AlignStyle != 0)
                {
                    range.HorizontalAlignment = (AlignEnum)_AlignStyle;
                }

                /*字体*/
                range.Font.Bold      = isBold;
                range.Font.Italic    = isItalic;
                range.Font.Underline = isUnderLine;
                if (Font != 0)
                {
                    range.Font.Name = ConvertFont(Font.ToString());
                }
                range.Font.Size = fontSize;

                if ((int)_FontColor != 0)
                {
                    range.Font.ColorIndex = (int)_FontColor;
                }

                /*填充色*/
                if ((int)_CellColor != 0)
                {
                    range.Interior.ColorIndex = (int)_CellColor;
                }

                /*行列宽度*/
                range.RowHeight   = rowHeight;
                range.ColumnWidth = colWidth;

                /*边框*/
                if ((int)_BorderStyle != 0)
                {
                    switch ((int)_BorderType)
                    {
                    case 0:
                    {
                        range.Borders.LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 1:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 2:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 3:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    case 4:
                    {
                        range.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = (int)_BorderStyle;
                        break;
                    }

                    default:
                        break;
                    }
                }
                System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(range);
                sheet = null;
                range = null;
                GC.Collect();
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL区域设置执行过程出错", e.Message);
                new CommonVariable().realaseProcessExit(excelApp);
            }
            m_Delegate = new runDelegate(Run);
            return(m_Delegate.BeginInvoke(callback, state));
        }