private void TryToAssignQDBatchFromString(Device dev, string possibleQDBatch)
        {
            var qdBatchFromDB = ctx.Materials.Where(x => x.Name == possibleQDBatch).FirstOrDefault();

            if (qdBatchFromDB != null)
            {
                dev.QDBatch = (QDBatch)qdBatchFromDB;
            }
            else//add a new material
            {
                QDBatch newQDBatch = new QDBatch();
                newQDBatch.Name             = possibleQDBatch;
                newQDBatch.PhysicalRole     = ctx.PhysicalRoles.Where(x => x.ShortName == "EML").FirstOrDefault();
                newQDBatch.DepositionMethod = ctx.DepositionMethods.Where(x => x.Name == "Spincoating").FirstOrDefault();
                ctx.Materials.Add(newQDBatch);
                try
                {
                    ctx.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Debug.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following error: ", eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Debug.WriteLine("- property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    Debug.WriteLine(e.ToString());
                }
                dev.QDBatch = newQDBatch;
            }
        }
 public static void GenerateQDBatchReport(QDBatch qdBatch, string filePath = null)
 {
     Process.Start("net.exe", @"use Z: \\169.254.190.155\NPI Shared Data\"); //probably unnecessary but was having an error and this doesn't break anything
     if (filePath == null)
     {
         filePath = @"Z:\Data (LJV, Lifetime)\QD Batches\";
     }
     if (!Directory.Exists(filePath))
     {
         Directory.CreateDirectory(filePath);
     }
     using (var qdbExcel = new ExcelPackage())
     {
         {
             Debug.WriteLine("Updating report for QDBatch: " + qdBatch.Name);
             var EQESheet = qdbExcel.Workbook.Worksheets.Add("EQE");
             WriteQDBEQEToWS(EQESheet, qdBatch);
             FormatQDBWorksheet(EQESheet);
             var ColorDataSheet = qdbExcel.Workbook.Worksheets.Add("Color");
             WriteQDBColorToWS(ColorDataSheet, qdBatch);
             FormatQDBWorksheet(ColorDataSheet);
             string saveString = string.Concat(filePath, qdBatch.Name, ".xlsx");
             qdbExcel.SaveAs(new FileInfo(saveString));
         }
     }
 }
        private static void WriteQDBEQEToWS(ExcelWorksheet ws, QDBatch qdb)
        {
            int           rowCounter = 1;
            List <Device> deviceList = new List <Device>(qdb.Devices);

            deviceList = deviceList.OrderBy(x => x.DeviceBatch.FabDate).ThenBy(y => y.BatchIndex).ToList();

            foreach (Device d in deviceList)
            {
                int columnCounter = 2;
                ws.Cells[rowCounter, 1].Value = d.Label;
                foreach (DeviceLJVScanSummary ss in d.DeviceLJVScanSummaries)
                {
                    List <LJVScan> scansWherePixelLitUp = ss.LJVScans.ToList();
                    for (int j = 0; j < scansWherePixelLitUp.Count; j++)
                    {
                        if (scansWherePixelLitUp[j].PixelLitUp.HasValue)              //if PixelLitUp is not null
                        {
                            if (!scansWherePixelLitUp[j].PixelLitUp.Value)            //if it didn't light up
                            {
                                scansWherePixelLitUp.Remove(scansWherePixelLitUp[j]); //remove it from the list
                            }
                        }
                    }
                    //Debug.WriteLine("Adding data to cell for device " + d.BatchIndex + " with testCondition " + ss.TestCondition);
                    if (scansWherePixelLitUp.Count > 0)
                    {
                        decimal minEQE = scansWherePixelLitUp.Where(x => x.MaxEQE == scansWherePixelLitUp.Min(y => y.MaxEQE)).First().MaxEQE;
                        decimal maxEQE = ss.MaxEQE;
                        decimal minLuminanceAtPeakEQE = scansWherePixelLitUp.Where(x => x.LuminanceAtMaxEQE == scansWherePixelLitUp.Min(y => y.LuminanceAtMaxEQE)).First().LuminanceAtMaxEQE ?? default(int);
                        decimal maxLuminanceAtPeakEQE = scansWherePixelLitUp.Where(x => x.LuminanceAtMaxEQE == scansWherePixelLitUp.Max(y => y.LuminanceAtMaxEQE)).First().LuminanceAtMaxEQE ?? default(int);
                        decimal minAt1kNitsEQE        = scansWherePixelLitUp.Where(x => x.At1kNitsEQE == scansWherePixelLitUp.Min(y => y.At1kNitsEQE)).First().At1kNitsEQE;
                        decimal maxAt1kNitsEQE        = ss.Max1kNitsEQE;
                        string  cellString            = string.Concat(
                            ss.TestCondition,
                            "\n",
                            minEQE,
                            "-",
                            maxEQE,
                            "% ",
                            minLuminanceAtPeakEQE,
                            "-",
                            maxLuminanceAtPeakEQE,
                            "nits (@1K: ",
                            minAt1kNitsEQE,
                            "-",
                            maxAt1kNitsEQE,
                            "%)"
                            );
                        ws.Cells[rowCounter, columnCounter].Value = cellString;
                        columnCounter++;
                    }
                }
                rowCounter++;
            }
        }
        private static void WriteQDBColorToWS(ExcelWorksheet ws, QDBatch qdb)
        {
            int rowCounter           = 1;
            List <Device> deviceList = new List <Device>(qdb.Devices);

            deviceList = deviceList.OrderBy(x => x.DeviceBatch.FabDate).ThenBy(y => y.BatchIndex).ToList();

            foreach (Device d in deviceList)
            {
                int columnCounter = 2;
                ws.Cells[rowCounter, 1].Value = d.Label;
                foreach (DeviceLJVScanSummary ss in d.DeviceLJVScanSummaries)
                {
                    List <LJVScan> scansWherePixelLitUp = ss.LJVScans.ToList();
                    for (int j = 0; j < scansWherePixelLitUp.Count; j++)
                    {
                        if (scansWherePixelLitUp[j].PixelLitUp.HasValue)              //if PixelLitUp is not null
                        {
                            if (!scansWherePixelLitUp[j].PixelLitUp.Value)            //if it didn't light up
                            {
                                scansWherePixelLitUp.Remove(scansWherePixelLitUp[j]); //remove it from the list
                            }
                        }
                    }
                    //Debug.WriteLine("Adding data to cell for device " + d.BatchIndex + " with testCondition " + ss.TestCondition);
                    if (scansWherePixelLitUp.Count > 0)
                    {
                        try
                        {
                            LJVScanSummaryVM vm = new LJVScanSummaryVM(ss);

                            string cellString = string.Concat(
                                ss.TestCondition,
                                "\n",
                                "Peak λ: ",
                                vm.PeakLambda.Mean,
                                " FWHM: ",
                                vm.FWHM.Mean,
                                " CIE x: ",
                                vm.CIEx.Mean,
                                " CIE y: ",
                                vm.CIEy.Mean
                                );
                            ws.Cells[rowCounter, columnCounter].Value = cellString;
                            columnCounter++;
                        }
                        catch (Exception e)
                        {
                            Debug.WriteLine(e.ToString());
                        }
                    }
                }
                rowCounter++;
            }
        }
Пример #5
0
 public QDBatchVM(QDBatch qdb)
 {
     TheQDBatch = qdb;
     PopulatePropertiesFromQDBatch();
 }
Пример #6
0
 public QDBatchVM()
 {
     TheQDBatch = new QDBatch();
 }