Пример #1
0
        /// <summary>
        /// 加载指定的单位信息
        /// </summary>
        /// <param name="fId"></param>
        private void InitUnitInfo(int unitId)
        {
            UnitInfoModel unitInfo = RequestStar.GetUnitInfo(unitId);

            if (unitInfo != null)
            {
                //将信息加载到信息框
                txtUnitName.Text = unitInfo.UnitName;
                oldName          = unitInfo.UnitName;
                txtUnitNo.Text   = unitInfo.UnitNo;
                txtUnitPYNo.Text = unitInfo.UnitPYNo;
                txtUnitType.Text = RequestStar.GetUnitType(unitInfo.UTypeId).UTypeName;
                uType            = new UnitTypeInfoModel()
                {
                    UTypeId   = unitInfo.UTypeId,
                    UTypeName = txtUnitType.Text
                };
                oldTypeId = unitInfo.UTypeId;
                cboUnitProperties.Text = unitInfo.UnitProperties;
                int regionId = unitInfo.RegionId;
                SetRegion(regionId);//区域信息加载
                txtAddress.Text       = unitInfo.Address;
                txtRemark.Text        = unitInfo.Address;
                txtContactPerson.Text = unitInfo.ContactPerson;
                txtPhoneNumber.Text   = unitInfo.PhoneNumber;
                txtEmail.Text         = unitInfo.Email;
                txtFax.Text           = unitInfo.Fax;
                txtTelephone.Text     = unitInfo.Telephone;
                txtPostalCode.Text    = unitInfo.PostalCode;
            }
        }
Пример #2
0
 public MessageResult UpdateUnitInfo(UnitInfoModel unitInfo)
 {
     try
     {
         var result = unitBLL.UpdateUnitInfo(unitInfo);
         return(MessageResult.Success(result));
     }
     catch (Exception ex)
     {
         return(MessageResult.Fail(ex.Message));
     }
 }
Пример #3
0
      public void UpdateBenchmarkDataTest()
      {
         // setup
         var benchmarkCollection = new ProteinBenchmarkCollection();
         var database = MockRepository.GenerateMock<IUnitInfoDatabase>();
         var fahClient = new FahClient(MockRepository.GenerateStub<IMessageConnection>()) { BenchmarkCollection = benchmarkCollection, UnitInfoDatabase = database };

         var unitInfo1 = new UnitInfo();
         unitInfo1.OwningClientName = "Owner";
         unitInfo1.OwningClientPath = "Path";
         unitInfo1.OwningSlotId = 0;
         unitInfo1.ProjectID = 2669;
         unitInfo1.ProjectRun = 1;
         unitInfo1.ProjectClone = 2;
         unitInfo1.ProjectGen = 3;
         unitInfo1.FinishedTime = new DateTime(2010, 1, 1);
         unitInfo1.QueueIndex = 0;
         var currentUnitInfo = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1 };

         var unitInfo1Clone = unitInfo1.DeepClone();
         unitInfo1Clone.FramesObserved = 4;
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 });
         unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 });
         unitInfo1Clone.UnitResult = WorkUnitResult.FinishedUnit;
         var unitInfoLogic1 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone };

         var parsedUnits = new[] { unitInfoLogic1 };

         // arrange
         database.Stub(x => x.Connected).Return(true);
         database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(1);

         var benchmarkClient = new BenchmarkClient("Owner Slot 00", "Path");

         // assert before act
         Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient));
         Assert.AreEqual(false, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
         Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData));

         // act
         fahClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 0);

         // assert after act
         Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient));
         Assert.AreEqual(true, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
         Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime);

         database.VerifyAllExpectations();
      }
Пример #4
0
        public bool Insert(UnitInfoModel unitInfoModel)
        {
            // if the work unit is not valid simply return
            if (!ValidateUnitInfo(unitInfoModel.UnitInfoData))
            {
                return(false);
            }

            // The Insert operation does not setup a WuHistory table if
            // it does not exist.  This was already handled when the
            // the DatabaseFilePath was set.
            Debug.Assert(TableExists(SqlTable.WuHistory));

            // ensure this unit is not written twice
            if (UnitInfoExists(unitInfoModel.UnitInfoData))
            {
                return(false);
            }

            var entry = AutoMapper.Mapper.Map <HistoryEntry>(unitInfoModel.UnitInfoData);

            // cannot map these two properties from a UnitInfo instance
            // they only live at the UnitInfoLogic level
            entry.FramesCompleted = unitInfoModel.FramesComplete;
            entry.FrameTimeValue  = unitInfoModel.GetRawTime(PpdCalculationType.AllFrames);
            // copy protein values for insert
            entry.WorkUnitName  = unitInfoModel.CurrentProtein.WorkUnitName;
            entry.KFactor       = unitInfoModel.CurrentProtein.KFactor;
            entry.Core          = unitInfoModel.CurrentProtein.Core;
            entry.Frames        = unitInfoModel.CurrentProtein.Frames;
            entry.Atoms         = unitInfoModel.CurrentProtein.NumberOfAtoms;
            entry.BaseCredit    = unitInfoModel.CurrentProtein.Credit;
            entry.PreferredDays = unitInfoModel.CurrentProtein.PreferredDays;
            entry.MaximumDays   = unitInfoModel.CurrentProtein.MaximumDays;
            using (var connection = new SQLiteConnection(ConnectionString))
            {
                connection.Open();
                using (var database = new PetaPoco.Database(connection))
                {
                    database.Insert(entry);
                }
            }

            return(true);
        }
Пример #5
0
        public void MultiThread_Test()
        {
            _database.DatabaseFilePath = TestScratchFile;
            var benchmarkService = MockRepository.GenerateStub <IProteinBenchmarkService>();

            Parallel.For(0, 100, i =>
            {
                Debug.WriteLine("Writing unit {0:00} on thread id: {1:00}", i, Thread.CurrentThread.ManagedThreadId);

                var unitInfoLogic            = new UnitInfoModel(benchmarkService);
                unitInfoLogic.CurrentProtein = BuildProtein1();
                unitInfoLogic.UnitInfoData   = BuildUnitInfo1(i);

                _database.Insert(unitInfoLogic);
            });

            Assert.AreEqual(100, _database.Fetch(QueryParameters.SelectAll).Count);
        }
Пример #6
0
        private void InsertTestInternal(UnitInfo unitInfo, Protein protein, Action <IList <HistoryEntry> > verifyAction)
        {
            _database.DatabaseFilePath = TestScratchFile;

            var unitInfoLogic = new UnitInfoModel(MockRepository.GenerateStub <IProteinBenchmarkService>());

            unitInfoLogic.CurrentProtein = protein;
            unitInfoLogic.UnitInfoData   = unitInfo;

            _database.Insert(unitInfoLogic);

            var rows = _database.Fetch(new QueryParameters());

            verifyAction(rows);

            // test code to ensure this unit is NOT written again
            _database.Insert(unitInfoLogic);
            // verify
            rows = _database.Fetch(new QueryParameters());
            Assert.AreEqual(1, rows.Count);
        }
Пример #7
0
        public void UpdateBenchmarkDataTest()
        {
            // setup
            var benchmarkCollection = new ProteinBenchmarkService();
            var database            = MockRepository.GenerateMock <IUnitInfoDatabase>();
            var legacyClient        = new LegacyClient {
                BenchmarkService = benchmarkCollection, UnitInfoDatabase = database
            };

            var unitInfo1 = new UnitInfo();

            unitInfo1.OwningClientName = "Owner";
            unitInfo1.OwningClientPath = "Path";
            unitInfo1.ProjectID        = 2669;
            unitInfo1.ProjectRun       = 1;
            unitInfo1.ProjectClone     = 2;
            unitInfo1.ProjectGen       = 3;
            unitInfo1.FinishedTime     = new DateTime(2010, 1, 1);
            var currentUnitInfo = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo1
            };

            var unitInfo1Clone = unitInfo1.DeepClone();

            unitInfo1Clone.FramesObserved = 4;
            unitInfo1Clone.SetUnitFrame(new UnitFrame {
                TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0
            });
            unitInfo1Clone.SetUnitFrame(new UnitFrame {
                TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1
            });
            unitInfo1Clone.SetUnitFrame(new UnitFrame {
                TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2
            });
            unitInfo1Clone.SetUnitFrame(new UnitFrame {
                TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3
            });
            var unitInfoLogic1 = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone
            };

            var unitInfo2 = new UnitInfo();

            unitInfo2.OwningClientName = "Owner";
            unitInfo2.OwningClientPath = "Path";
            unitInfo2.ProjectID        = 2669;
            unitInfo2.ProjectRun       = 2;
            unitInfo2.ProjectClone     = 3;
            unitInfo2.ProjectGen       = 4;
            unitInfo2.FinishedTime     = new DateTime(2010, 1, 1);
            var unitInfoLogic2 = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo2
            };

            var unitInfo3 = new UnitInfo();

            unitInfo3.OwningClientName = "Owner";
            unitInfo3.OwningClientPath = "Path";
            unitInfo3.ProjectID        = 2669;
            unitInfo3.ProjectRun       = 3;
            unitInfo3.ProjectClone     = 4;
            unitInfo3.ProjectGen       = 5;
            unitInfo3.FinishedTime     = new DateTime(2010, 1, 1);
            var unitInfoLogic3 = new UnitInfoModel {
                CurrentProtein = new Protein(), UnitInfoData = unitInfo3
            };

            var parsedUnits = new[] { unitInfoLogic1, unitInfoLogic2, unitInfoLogic3 };

            // arrange
            database.Stub(x => x.Connected).Return(true);
            database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(3);

            var benchmarkClient = new ProteinBenchmarkSlotIdentifier("Owner", "Path");

            // assert before act
            Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient));
            Assert.AreEqual(false, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
            Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData));

            // act
            legacyClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 2);

            // assert after act
            Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient));
            Assert.AreEqual(true, new List <int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
            Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime);

            database.VerifyAllExpectations();
        }
Пример #8
0
        /// <summary>
        /// 初始化工作
        /// </summary>
        private void InitInfo()
        {
            if (saleId == 0)
            {
                //清空处理
                ClearInfo();
                SetBtnsEnabled(0);
            }
            else  //修改状态
            {
                //加载指定的销售单信息
                SaleOutStoreInfoModel saleInfo = RequestStar.GetSaleInfo(saleId);
                if (saleInfo != null)
                {
                    txtCustomers.Text = RequestStar.GetUnitInfo(saleInfo.UnitId).UnitName;
                    selCust           = new UnitInfoModel()
                    {
                        UnitId   = saleInfo.UnitId,
                        UnitName = txtCustomers.Text
                    };
                    txtOutStore.Text = RequestStar.GetStoreInfo(saleInfo.StoreId).StoreName;
                    store            = new StoreInfoModel()
                    {
                        StoreId   = saleInfo.StoreId,
                        StoreName = txtOutStore.Text
                    };
                    txtDealPerson.Text  = saleInfo.DealPerson;
                    txtCollectType.Text = saleInfo.PayDesp;
                    txtThisAmount.Text  = saleInfo.ThisAmount.ToString("0.00");
                    txtRemark.Text      = saleInfo.Remark;
                    txtTotalAmount.Text = saleInfo.TotalAmount.ToString("0.00");
                    txtYHAmount.Text    = saleInfo.YHAmount.ToString("0.00");
                    txtCreator.Text     = saleInfo.Creator;
                    txtCreateTime.Text  = saleInfo.CreateTime.ToShortDateString();
                    lblSaleNo.Text      = saleInfo.SaleOutNo;
                    switch (saleInfo.IsChecked)
                    {
                    case 0:
                        lblCheckState.Text = "待审核";
                        break;

                    case 1:
                        lblCheckState.Text = "已审核";
                        break;

                    case 2:
                        lblCheckState.Text = "已作废";    //未审核作废
                        break;

                    case 3:
                        lblCheckState.Text = "已红冲";    //已审核作废称红冲
                        break;
                    }
                    SetBtnsEnabled(saleInfo.IsChecked); //设置页面工具项或页面按钮的可用
                    if (saleInfo.IsPayed == 1)          //已经付款但并不定付完
                    {
                        hasPay = 1;
                    }
                    if (saleInfo.IsPayFull == 1) //付完
                    {
                        hasFullPay = 1;
                    }

                    //加载商品列表
                    List <ViewSaleGoodsInfoModel> saleGoodsList = RequestStar.GetSaleGoodsList(saleId);

                    dgvGoods.AutoGenerateColumns = false;
                    dgvGoods.DataSource          = saleGoodsList;
                    SetTotalInfo(saleGoodsList);//总计  数量  金额
                }
            }
            isOpened = RequestStar.GetOpenState(1);//获取开账状态
            if (!isOpened)
            {
                tsbtnAdd.Enabled      = false;
                tsbtnSave.Enabled     = false;
                tsbtnCheck.Enabled    = false;
                tsddbtnAct.Enabled    = false;
                btnAddGoods.Enabled   = false;
                btnDelete.Enabled     = false;
                storeList.Visible     = false;
                customersList.Visible = false;
                picPayType.Visible    = false;
                lblUnOpenDesp.Visible = true;
            }
            else
            {
                lblUnOpenDesp.Visible = false;
            }
        }
Пример #9
0
        /// <summary>
        /// 选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnChoose_Click(object sender, EventArgs e)
        {
            UnitInfoModel selInfo = null;

            if (dgvUnitList.SelectedRows.Count == 0)
            {
                selInfo = dgvUnitList.Rows[0].DataBoundItem as UnitInfoModel;
            }
            else
            {
                selInfo = dgvUnitList.SelectedRows[0].DataBoundItem as UnitInfoModel;
            }
            //将选择的单位信息赋值给要选择页面的selUnit公有变量
            switch (typeName)
            {
            case "Supplier-PerInStore":    //采购单页面
                FrmPerchaseInStore frmPerInStore = cModel.FGet as FrmPerchaseInStore;
                frmPerInStore.selUnit = selInfo;
                break;

            case "Customer-SaleOutStore":    //销售单页面
                FrmSaleOutStore frmSaleOutStore = cModel.FGet as FrmSaleOutStore;
                frmSaleOutStore.selCust = selInfo;
                break;

            case "Unit-SheetQuery":    //单据查询页面
                FrmSheetQuery frmSheetQuery = cModel.FGet as FrmSheetQuery;
                frmSheetQuery.unit = selInfo;
                break;

            case "Supplier-PerQueryBySupplier":    //采购统计按供应商页面
                FrmPerchaseQueryBySupplier frmPerQueryBySupplier = cModel.FGet as FrmPerchaseQueryBySupplier;
                frmPerQueryBySupplier.unit = selInfo;
                break;

            case "Supplier-PerQueryByStore":    //采购统计按仓库页面
                FrmPerchaseQueryByStore frmPerQueryByStore = cModel.FGet as FrmPerchaseQueryByStore;
                frmPerQueryByStore.unit = selInfo;
                break;

            case "Supplier-PerQueryByGoods":    //采购统计按商品页面
                FrmPerchaseQueryByGoods frmPerQueryByGoods = cModel.FGet as FrmPerchaseQueryByGoods;
                frmPerQueryByGoods.unit = selInfo;
                break;

            case "Customer-SaleQueryByCustomer":    //销售统计按客户页面
                FrmSaleQueryByCustomer fSaleQueryCustomer = cModel.FGet as FrmSaleQueryByCustomer;
                fSaleQueryCustomer.unit = selInfo;
                break;

            case "Customer-SaleQueryByStore":    //销售统计按仓库页面
                FrmSaleQueryByStore fSaleQueryStore = cModel.FGet as FrmSaleQueryByStore;
                fSaleQueryStore.unit = selInfo;
                break;

            case "Customer-SaleQueryByGoods":    //销售统计按仓库页面
                FrmSaleQueryByGoods fSaleQueryGoods = cModel.FGet as FrmSaleQueryByGoods;
                fSaleQueryGoods.unit = selInfo;
                break;
            }
            this.SetUnit?.Invoke();//显示到文本框
            this.Close();
        }
Пример #10
0
        /// <summary>
        /// 单位信息提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbtnSave_Click(object sender, EventArgs e)
        {
            Action act = () =>
            {
                //信息获取
                string unitName       = txtUnitName.Text.Trim();
                string unitNo         = txtUnitNo.Text.Trim();
                string unitPYNo       = txtUnitPYNo.Text.Trim();
                int    uTypeId        = uType.UTypeId;
                string unitProperties = cboUnitProperties.Text;
                int    regionId       = 0;
                if (cboCountries.SelectedValue != null || cboCountries.SelectedValue.ToString() != "0")
                {
                    regionId = cboCountries.SelectedValue.GetInt();
                }
                else if (cboCitys.SelectedValue != null || cboCitys.SelectedValue.ToString() != "0")
                {
                    regionId = cboCitys.SelectedValue.GetInt();
                }
                else if (cboProvinces.SelectedValue != null || cboProvinces.SelectedValue.ToString() != "0")
                {
                    regionId = cboProvinces.SelectedValue.GetInt();
                }
                string address = txtAddress.Text.Trim();
                //包括选择的区域+详细地址
                string fullAddress   = RequestStar.GetRegionAddress(regionId) + address;
                string remark        = txtRemark.Text.Trim();
                string contactPerson = txtContactPerson.Text.Trim();
                string email         = txtEmail.Text.Trim();
                string fax           = txtFax.Text.Trim();
                string pcode         = txtPostalCode.Text.Trim();
                string phoneNumber   = txtPhoneNumber.Text.Trim();
                string telephone     = txtTelephone.Text.Trim();
                //判断
                if (string.IsNullOrEmpty(unitName))
                {
                    MsgBoxHelper.MsgErrorShow("请输入单位名称");
                    txtUnitName.Focus();
                    return;
                }
                //判断是否已存在
                if (fModel.ActType == 1 || (!string.IsNullOrEmpty(oldName) && oldName != unitName) || (!string.IsNullOrEmpty(oldName) && oldName == unitName && (uTypeId != oldTypeId)))
                {
                    if (RequestStar.ExistUnit(unitName, uTypeId))
                    {
                        MsgBoxHelper.MsgErrorShow("该单位已存在!");
                        txtUnitName.Focus();
                        return;
                    }
                }
                if (uTypeId == 0)
                {
                    MsgBoxHelper.MsgErrorShow("请选择单位类别!");
                    txtUnitType.Focus();
                    return;
                }
                //信息的封装
                UnitInfoModel unitInfo = new UnitInfoModel()
                {
                    UnitId         = fModel.FId,
                    UnitName       = unitName,
                    UnitNo         = unitNo,
                    UnitPYNo       = unitPYNo,
                    UnitProperties = unitProperties,
                    UTypeId        = uTypeId,
                    RegionId       = regionId,
                    Address        = address,
                    FullAddress    = fullAddress,
                    Remark         = remark,
                    ContactPerson  = contactPerson,
                    Email          = email,
                    Fax            = fax,
                    Telephone      = telephone,
                    PhoneNumber    = phoneNumber,
                    PostalCode     = pcode,
                    Creator        = fModel.UName
                };
                //调用方法
                bool bl = false;
                bl = fModel.ActType == 1 ? RequestStar.AddUnitInfo(unitInfo) : RequestStar.UpdateUnitInfo(unitInfo);
                string actMsg   = fModel.ActType == 1 ? "添加" : "修改";
                string titleMsg = $"{actMsg}单位信息";
                string sucType  = bl ? "成功" : "失败";
                string msg      = $"单位信息{actMsg} {sucType}";
                if (bl)
                {
                    MsgBoxHelper.MsgBoxShow(titleMsg, msg);
                    this.ReLoadHandler?.Invoke();
                }
                else
                {
                    MsgBoxHelper.MsgErrorShow(msg);
                    return;
                }
            };

            act.TryCatch("单位信息提交出现异常");
        }
        private void PopulateBenchmarkInformation(Protein protein, ProteinBenchmark benchmark, UnitInfoModel unitInfoModel, SlotStatus status, string ppdFormatString, ICollection <string> lines)
        {
            if (protein == null)
            {
                return;
            }

            var calculateBonus        = _prefs.Get <BonusCalculationType>(Preference.BonusCalculation);
            var calculateBonusEnabled = calculateBonus.IsEnabled();

            lines.Add(String.Empty);
            lines.Add(String.Format(" Name: {0}", benchmark.OwningSlotName));
            lines.Add(String.Format(" Path: {0}", benchmark.OwningClientPath));
            lines.Add(String.Format(" Number of Frames Observed: {0}", benchmark.FrameTimes.Count));
            lines.Add(String.Empty);
            lines.Add(String.Format(" Min. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                    benchmark.MinimumFrameTime, GetPPD(benchmark.MinimumFrameTime, protein, calculateBonusEnabled)));
            lines.Add(String.Format(" Avg. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                    benchmark.AverageFrameTime, GetPPD(benchmark.AverageFrameTime, protein, calculateBonusEnabled)));

            if (unitInfoModel != null)
            {
                lines.Add(String.Format(" Cur. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                        unitInfoModel.GetFrameTime(PpdCalculationType.LastFrame), unitInfoModel.GetPPD(status, PpdCalculationType.LastFrame, calculateBonus)));
                lines.Add(String.Format(" R3F. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                        unitInfoModel.GetFrameTime(PpdCalculationType.LastThreeFrames), unitInfoModel.GetPPD(status, PpdCalculationType.LastThreeFrames, calculateBonus)));
                lines.Add(String.Format(" All  Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                        unitInfoModel.GetFrameTime(PpdCalculationType.AllFrames), unitInfoModel.GetPPD(status, PpdCalculationType.AllFrames, calculateBonus)));
                lines.Add(String.Format(" Eff. Time / Frame : {0} - {1:" + ppdFormatString + "} PPD",
                                        unitInfoModel.GetFrameTime(PpdCalculationType.EffectiveRate), unitInfoModel.GetPPD(status, PpdCalculationType.EffectiveRate, calculateBonus)));
            }

            lines.Add(String.Empty);
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtBenchmarks.Text = String.Empty;
            int     projectId = (int)listBox1.SelectedItem;
            Protein protein   = _proteinService.Get(projectId);

            if (protein == null)
            {
                Logger.WarnFormat("Could not find Project {0}.", projectId);
            }

            var projectInfoLines = new List <string>();

            PopulateProteinInformation(protein, projectInfoLines);

            List <ProteinBenchmark> list = _benchmarkService.GetBenchmarks(_currentSlotIdentifier, projectId).ToList();

            list.Sort((benchmark1, benchmark2) => benchmark1.OwningSlotName.CompareTo(benchmark2.OwningSlotName));

            var benchmarkInfoLines = new List <string>(projectInfoLines);

            foreach (ProteinBenchmark benchmark in list)
            {
                UnitInfoModel unitInfoModel = null;
                SlotStatus    status        = SlotStatus.Unknown;

                var slotModel = _clientConfiguration.Slots.FirstOrDefault(x =>
                                                                          x.Name == benchmark.OwningSlotName &&
                                                                          x.Settings.DataPath() == benchmark.OwningClientPath &&
                                                                          x.UnitInfoModel.UnitInfoData.ProjectID == benchmark.ProjectID);
                if (slotModel != null && slotModel.ProductionValuesOk)
                {
                    unitInfoModel = slotModel.UnitInfoModel;
                    status        = slotModel.Status;
                }
                PopulateBenchmarkInformation(protein, benchmark, unitInfoModel, status, _prefs.GetPpdFormatString(), benchmarkInfoLines);
            }

            UpdateBenchmarkText(benchmarkInfoLines);

            tabControl1.SuspendLayout();

            int clientsPerGraph = _prefs.Get <int>(Preference.BenchmarksClientsPerGraph);

            SetupGraphTabs(list.Count, clientsPerGraph);

            int tabIndex = 1;

            if (GraphLayoutType.Equals(GraphLayoutType.ClientsPerGraph))
            {
                int lastDisplayed = 0;
                for (int i = 1; i < list.Count; i++)
                {
                    if (i % clientsPerGraph == 0)
                    {
                        var benchmarks = new ProteinBenchmark[clientsPerGraph];
                        list.CopyTo(lastDisplayed, benchmarks, 0, clientsPerGraph);
                        DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                        tabIndex++;
                        lastDisplayed = i;
                    }
                }

                if (lastDisplayed < list.Count)
                {
                    var benchmarks = new ProteinBenchmark[list.Count - lastDisplayed];
                    list.CopyTo(lastDisplayed, benchmarks, 0, list.Count - lastDisplayed);
                    DrawGraphs(tabIndex, projectInfoLines, benchmarks, protein);
                }
            }
            else
            {
                DrawGraphs(tabIndex, projectInfoLines, list, protein);
            }

            tabControl1.ResumeLayout(true);
        }