コード例 #1
0
        public void AddBrewToWorkSheet(IBrew brew, int columnIndex)
        {
            Monitor.Enter(period);

            period.AddBrewToWorkSheet(brew, columnIndex);

            Monitor.Exit(period);
        }
コード例 #2
0
        internal string GetBrewFilePath(IBrew brew)
        {
            string year       = brew.Year;
            string month      = brew.Month.ToLower();
            string day        = brew.Day;
            string brewNumber = brew.BrewNumber;

            return(fileServerPath + folderSeparator + year + folderSeparator + month + folderSeparator + day + folderSeparator);
        }
コード例 #3
0
 public override void AddBrew(IBrew brew)
 {
     if (!_brews.ContainsKey(brew.BrewNumber)) // && !BrewInWorkSheet(brew))
     {
         int newColumnIndex = _brews.Count + 3;
         //AddBrewToWorkSheet(brew, newColumnIndex);
         workSheetSaver.AddBrewToWorkSheet(brew, newColumnIndex);
         _brews.Add(brew.BrewNumber, brew);
     }
 }
コード例 #4
0
        // Worksheet methods
        internal void AddBrewToWorkSheet(IBrew brew, int columnIndex)
        {
            using (xlPackage = new ExcelPackage(fileInfo))
            {
                ExcelWorksheet brewingFormWorksheet = xlPackage.Workbook.Worksheets[brewingFormSheetName];

                SetBrewingFormData(brew, columnIndex);
                SetRawData(brew, columnIndex);
            }
        }
コード例 #5
0
        public override void UpdateBrew(IBrew brew)
        {
            if (_brews.ContainsKey(brew.BrewNumber)) // && !BrewInWorkSheet(brew))
            {
                int columnIndex = GetColumnNumber(brew);

                workSheetSaver.AddBrewToWorkSheet(brew, columnIndex);
                _brews[brew.BrewNumber] = brew;
            }
        }
コード例 #6
0
        public override Period CreatePeriod(IBrew brew)
        {
            if (brew.Year != "" && brew.Month != "")
            {
                string year  = brew.Year;
                string month = brew.Month;

                return(CreatePeriod(year, month));
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        private int GetColumnNumber(IBrew brew)
        {
            using (xlPackage = new ExcelPackage(fileInfo))
            {
                xlRawDataWorksheet = xlPackage.Workbook.Worksheets[rawDataSheetName];

                for (int column = 3; column <= xlRawDataWorksheet.Dimension.Columns; column++)
                {
                    if (xlRawDataWorksheet.Cells[4, column].Value != null && brew.BrewNumber == xlRawDataWorksheet.Cells[4, column].Value.ToString())
                    {
                        return(column);
                    }
                }
                return(0);
            }
        }
コード例 #8
0
        public override IBrew GetBrewWithProcessParameters(IBrew brew)
        {
            using (xlExcelPackage = new ExcelPackage(template, true))
            {
                string brewNumber = brew.BrewNumber;
                string startDate  = brew.StartDate;

                StringDateWorker stringDateWorker = StringDateWorker.GetInstance();
                string           year             = stringDateWorker.GetYear(startDate);
                string           month            = stringDateWorker.GetMonth(startDate);

                Period period = CreatePeriod(year, month);

                return(period.GetBrewWithProcessParameters(brew));
            }
        }
コード例 #9
0
        internal bool BrewFileExists(IBrew brew)
        {
            DirectoryInfo dir = new DirectoryInfo(fileServerPath);

            string year       = brew.Year;
            string month      = brew.Month.ToLower();
            string brewNumber = brew.BrewNumber;
            string day        = brew.Day;

            bool yearFolderExists  = FolderWorker.IsSubDirectory(fileServerPath, year);
            bool monthFolderExists = FolderWorker.IsSubDirectory(fileServerPath + folderSeparator + year, month);
            bool fileExists        = FolderWorker.FileInFolder(fileServerPath + folderSeparator + year + folderSeparator + month + folderSeparator + day, brewNumber + ".txt");

            if (yearFolderExists && monthFolderExists && fileExists)
            {
                return(true);
            }
            return(false);
        }
コード例 #10
0
        public BrewProducer()
        {

            // Instantiate an object of each class that implement the IBrew interface.
            List<object> allBrewsInDomain = AppDomain.CurrentDomain.GetAssemblies().SelectMany(x => x.GetTypes())
                .Where(x => typeof(IBrew).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
                .Select(Activator.CreateInstance).ToList();

            // Instantiate an object of each class that implement the IBrewProductionStrategy interface.
            List<object> allBrewStrategiesInDomain = AppDomain.CurrentDomain.GetAssemblies()
                .SelectMany(x => x.GetTypes())
                .Where(x => typeof(IBrewProductionStrategy).IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
                .Select(Activator.CreateInstance).ToList();

            // Create a new Dictionary to hold our production strategies.
            ProductionStrategies = new Dictionary<string, IBrewProductionStrategy>(allBrewsInDomain.Count);

            // Assign all strategies to their respective brew.
            foreach (var brew in allBrewsInDomain)
            {
                IBrew tmp = (IBrew)brew;

                var brewStrategy = (IBrewProductionStrategy)allBrewStrategiesInDomain.First(x =>
                    x.GetType().ToString().Contains(tmp.GetType().ToString().Split('.')[1])
                    );

                ProductionStrategies.Add(brew.GetType().ToString(), brewStrategy);
            }

            
            // Debug OUTPUT.
            foreach (KeyValuePair<string, IBrewProductionStrategy> brewProductionStrategy in ProductionStrategies)
            {
                Console.WriteLine($"Key: {brewProductionStrategy.Key}, Value: {brewProductionStrategy.Value}");
            }


        }
コード例 #11
0
        // Thread safe SaveBrew
        public override string SaveBrew(IBrew brew)
        {
            Period period;

            // if brewnumber, brand and start date are valid, then go ahead and save brew
            if (brew.BrewNumber.Length > 0 && brew.BrandName.Length > 0 && brew.StartDate.Length > 0)
            {
                period = GetPeriod(brew);
                // If period exists update or add brew to period
                if (period != null)
                {
                    // If existing period contains the key then update brew in period
                    if (period.Brews.ContainsKey(brew.BrewNumber))
                    {
                        period.UpdateBrew(brew);
                    }
                    // If existing period contains the key then create brew in period
                    else
                    {
                        period.AddBrew(brew);
                    }
                    return("Success");
                }
                // If period does not exists, create period, add it to period list & add brew to it
                else
                {
                    period = CreatePeriod(brew);
                    AddPeriod(period);
                    period.AddBrew(brew);
                    return("Success");
                }
            }
            // if brewnumber, brand and start date are not valid, retrun failure
            else
            {
                return("Failure");
            }
        }
コード例 #12
0
 public void SaveBrew(IBrew brew)
 {
     _datasource.SaveBrew(brew);
 }
コード例 #13
0
        private void SetRawData(IBrew brew, int newColumnIndex)
        {
            using (xlPackage = new ExcelPackage(fileInfo))
            {
                ExcelWorksheet rawDataWorksheet = xlPackage.Workbook.Worksheets[rawDataSheetName];
                // Set Headers
                rawDataWorksheet.Cells[1, newColumnIndex].Value = "";
                rawDataWorksheet.Cells[2, newColumnIndex].Value = brew.StartDate;
                rawDataWorksheet.Cells[3, newColumnIndex].Value = brew.BrandName;
                rawDataWorksheet.Cells[4, newColumnIndex].Value = brew.BrewNumber;
                rawDataWorksheet.Cells[5, newColumnIndex].Value = brew.StartTime;

                // Set process parameter values
                // Mash Copper process parameters
                rawDataWorksheet.Cells[6, newColumnIndex].Value  = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInStartTime.ToString());
                rawDataWorksheet.Cells[7, newColumnIndex].Value  = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInEndTime.ToString());
                rawDataWorksheet.Cells[8, newColumnIndex].Value  = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.ProteinRestEndTime.ToString());
                rawDataWorksheet.Cells[9, newColumnIndex].Value  = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp1EndTime.ToString());
                rawDataWorksheet.Cells[10, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.Rest1EndTime.ToString());
                rawDataWorksheet.Cells[11, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp2EndTime.ToString());
                rawDataWorksheet.Cells[12, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.Rest2EndTime.ToString());
                rawDataWorksheet.Cells[13, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.TransferToMtEndTime.ToString());
                rawDataWorksheet.Cells[14, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.ProteinRestTemperature.ToString());
                rawDataWorksheet.Cells[15, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp1Temperature.ToString());
                rawDataWorksheet.Cells[16, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp2Temperature.ToString());

                // Mash Tun process parameters
                rawDataWorksheet.Cells[17, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashingInStartTime.ToString());
                rawDataWorksheet.Cells[18, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashingInEndTime.ToString());
                rawDataWorksheet.Cells[19, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.ProteinRestEndTime.ToString());
                rawDataWorksheet.Cells[20, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.SacharificationRestEndTime.ToString());
                rawDataWorksheet.Cells[21, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.HeatingUpEndTime.ToString());
                rawDataWorksheet.Cells[22, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashTunReadyAt.ToString());
                rawDataWorksheet.Cells[23, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.ProteinRestTemperature.ToString());
                rawDataWorksheet.Cells[24, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.SacharificationRestTemperature.ToString());
                rawDataWorksheet.Cells[25, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.HeatingUpTemperature.ToString());

                // Mash Filter process parameters
                rawDataWorksheet.Cells[26, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.PrefillingStartTime.ToString());
                rawDataWorksheet.Cells[27, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.PrefillingEndTime.ToString());
                rawDataWorksheet.Cells[28, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.WeakWortTransferEndTime.ToString());
                rawDataWorksheet.Cells[29, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.MainMashFiltrationEndTime.ToString());
                rawDataWorksheet.Cells[30, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpargingEndTime.ToString());
                rawDataWorksheet.Cells[31, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpargingToWWTEndTime.ToString());
                rawDataWorksheet.Cells[32, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.ExtraSpargingEndTime.ToString());
                rawDataWorksheet.Cells[33, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.DrippingEndTime.ToString());
                rawDataWorksheet.Cells[34, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpentGrainDischargeEndTime.ToString());
                rawDataWorksheet.Cells[35, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.ReadyAtTime.ToString());

                // Holding Vessel process parameters
                rawDataWorksheet.Cells[36, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.FillingStartTime.ToString());
                rawDataWorksheet.Cells[37, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.TransferToWcEndTime.ToString());
                rawDataWorksheet.Cells[38, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.EmptyAtTime.ToString());

                // Wort Copper process parameters
                rawDataWorksheet.Cells[39, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.HeatingStartTime.ToString());
                rawDataWorksheet.Cells[40, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.HeatingEndTime.ToString());
                rawDataWorksheet.Cells[41, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.BoilingEndTime.ToString());
                rawDataWorksheet.Cells[42, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.ExtraBoilingEndTime.ToString());
                rawDataWorksheet.Cells[43, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.CastingStartTime.ToString());
                rawDataWorksheet.Cells[44, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.CastingEndTime.ToString());
                rawDataWorksheet.Cells[45, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeBeforeBoiling.ToString());
                rawDataWorksheet.Cells[46, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeAfterBoiling.ToString());

                // Whirpool process parameters
                rawDataWorksheet.Cells[47, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CastingStartTime.ToString());
                rawDataWorksheet.Cells[48, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CastingEndTime.ToString());
                rawDataWorksheet.Cells[49, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.RestingEndTime.ToString());
                rawDataWorksheet.Cells[50, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CoolingEndTime.ToString());
                rawDataWorksheet.Cells[51, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.ReadyAtTime.ToString());

                SaveWorkSheet(xlPackage);
            }
        }
コード例 #14
0
 public override Period GetPeriod(IBrew brew)
 {
     return(GetPeriod(brew.Year, brew.Month));
 }
コード例 #15
0
        private void SetBrewingFormData(IBrew brew, int newColumnIndex)
        {
            using (xlPackage = new ExcelPackage(fileInfo))
            {
                ExcelWorksheet brewingFormWorksheet = xlPackage.Workbook.Worksheets[brewingFormSheetName];

                // Set Headers
                brewingFormWorksheet.Cells[1, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[2, newColumnIndex].Value = brew.StartDate;
                brewingFormWorksheet.Cells[3, newColumnIndex].Value = brew.BrandName;
                brewingFormWorksheet.Cells[4, newColumnIndex].Value = brew.BrewNumber;
                brewingFormWorksheet.Cells[5, newColumnIndex].Value = brew.StartTime;

                // Set process parameter values
                // Mash Copper process parameters
                brewingFormWorksheet.Cells[6, newColumnIndex].Value  = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.MashingInDuration.ToString()]);
                brewingFormWorksheet.Cells[7, newColumnIndex].Value  = "";
                brewingFormWorksheet.Cells[8, newColumnIndex].Value  = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.ProteinRestTemperature.ToString());
                brewingFormWorksheet.Cells[9, newColumnIndex].Value  = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.ProteinRestDuration.ToString()]);
                brewingFormWorksheet.Cells[10, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.HeatingUp1Duration.ToString()]);
                brewingFormWorksheet.Cells[11, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp1Temperature.ToString());
                brewingFormWorksheet.Cells[12, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.Rest1Duration.ToString()]);
                brewingFormWorksheet.Cells[13, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.HeatingUp2Duration.ToString()]);
                brewingFormWorksheet.Cells[14, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp2Temperature.ToString());
                brewingFormWorksheet.Cells[15, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashCopperProcessDurations()[MashCopperProcessDurations.Rest2Duration.ToString()]);

                // Mash Tun process parameters
                brewingFormWorksheet.Cells[16, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashTunProcessDurations()[MashTunProcessDurations.MashingInDuration.ToString()]);
                brewingFormWorksheet.Cells[17, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[18, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.ProteinRestTemperature.ToString());
                brewingFormWorksheet.Cells[19, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashTunProcessDurations()[MashTunProcessDurations.ProteinRestDuration.ToString()]);
                brewingFormWorksheet.Cells[20, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashTunProcessDurations()[MashTunProcessDurations.SaccharificationDuration.ToString()]);
                brewingFormWorksheet.Cells[21, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[22, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.SacharificationRestTemperature.ToString());
                brewingFormWorksheet.Cells[23, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashTunProcessDurations()[MashTunProcessDurations.HeatingUpDuration.ToString()]);
                brewingFormWorksheet.Cells[24, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.HeatingUpTemperature.ToString());
                brewingFormWorksheet.Cells[25, newColumnIndex].Value = "";

                // Mash Filter process parameters
                brewingFormWorksheet.Cells[26, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashFilterProcessDurations()[MashFilterProcessDurations.MainWortFiltrationDuration.ToString()]);
                brewingFormWorksheet.Cells[27, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashFilterProcessDurations()[MashFilterProcessDurations.SpargingRestDuration.ToString()]);
                brewingFormWorksheet.Cells[28, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetMashFilterProcessDurations()[MashFilterProcessDurations.TotalFiltrationDuration.ToString()]);

                // Wort Copper process parameters
                brewingFormWorksheet.Cells[29, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetWortCopperProcessDurations()[WortCopperProcessDurations.HeatToBoilDuration.ToString()]);
                brewingFormWorksheet.Cells[30, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeBeforeBoiling.ToString());
                brewingFormWorksheet.Cells[31, newColumnIndex].Value = brew.GetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeAfterBoiling.ToString());
                brewingFormWorksheet.Cells[32, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[33, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetWortCopperProcessDurations()[WortCopperProcessDurations.BoilingDuration.ToString()]);

                // Whirpool process parameters
                brewingFormWorksheet.Cells[34, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetWhirlpoolProcessDurations()[WhirlpoolProcessDurations.CastingDuration.ToString()]);
                brewingFormWorksheet.Cells[35, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetWhirlpoolProcessDurations()[WhirlpoolProcessDurations.RestDuration.ToString()]);
                brewingFormWorksheet.Cells[36, newColumnIndex].Value = GetTimeValueOrBlank(brew.GetWhirlpoolProcessDurations()[WhirlpoolProcessDurations.CoolingDuration.ToString()]);
                brewingFormWorksheet.Cells[37, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[38, newColumnIndex].Value = "";
                brewingFormWorksheet.Cells[39, newColumnIndex].Value = "";

                SetNumberFormats(brewingFormWorksheet, newColumnIndex);

                SaveWorkSheet(xlPackage);
            }
        }
コード例 #16
0
        //public int GetBrewingFormSheetColumnNumber(IBrew brew)
        //{
        //    using (xlPackage = new ExcelPackage(fileInfo))
        //    {
        //        xlBrewingFormWorksheet = xlPackage.Workbook.Worksheets[brewingFormSheetName];

        //        for (int column = 3; column <= xlBrewingFormWorksheet.Dimension.Columns; column++)
        //        {
        //            if (xlBrewingFormWorksheet.Cells[4, column].Value != null && brew.BrewNumber == xlBrewingFormWorksheet.Cells[4, column].Value.ToString())
        //            {
        //                return column;
        //            }
        //        }
        //        return 0;
        //    }
        //}

        private Brew GetBrewParametersFromWorkSheet(IBrew brew)
        {
            int  columnIndex        = GetColumnNumber(brew);
            Brew brewWithParameters = new Brew();

            using (xlPackage = new ExcelPackage(fileInfo))
            {
                xlRawDataWorksheet = xlPackage.Workbook.Worksheets[rawDataSheetName];

                if (columnIndex > 0)
                {
                    ExcelWorksheet rawDataWorksheet = xlPackage.Workbook.Worksheets[rawDataSheetName];
                    // Get Headers
                    string startDate  = rawDataWorksheet.Cells[2, columnIndex].Value.ToString();
                    string brandName  = rawDataWorksheet.Cells[3, columnIndex].Value.ToString();
                    string brewNumber = rawDataWorksheet.Cells[4, columnIndex].Value.ToString();
                    string startTime  = rawDataWorksheet.Cells[5, columnIndex].Value.ToString();

                    brewWithParameters = new Brew(startDate, brandName, brewNumber);
                    //brew.StartTime = startTime;

                    // Get process parameter values
                    // Mash Copper process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInStartTime.ToString(), rawDataWorksheet.Cells[6, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.MashingInEndTime.ToString(), rawDataWorksheet.Cells[7, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.ProteinRestEndTime.ToString(), rawDataWorksheet.Cells[8, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp1EndTime.ToString(), rawDataWorksheet.Cells[9, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.Rest1EndTime.ToString(), rawDataWorksheet.Cells[10, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp2EndTime.ToString(), rawDataWorksheet.Cells[11, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.Rest2EndTime.ToString(), rawDataWorksheet.Cells[12, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.TransferToMtEndTime.ToString(), rawDataWorksheet.Cells[13, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.ProteinRestTemperature.ToString(), rawDataWorksheet.Cells[14, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp1Temperature.ToString(), rawDataWorksheet.Cells[15, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashCopper, MashCopperProcessParameters.HeatingUp2Temperature.ToString(), rawDataWorksheet.Cells[16, columnIndex].Value.ToString());

                    // Mash Tun process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashingInStartTime.ToString(), rawDataWorksheet.Cells[17, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashingInEndTime.ToString(), rawDataWorksheet.Cells[18, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.ProteinRestEndTime.ToString(), rawDataWorksheet.Cells[19, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.SacharificationRestEndTime.ToString(), rawDataWorksheet.Cells[20, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.HeatingUpEndTime.ToString(), rawDataWorksheet.Cells[21, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.MashTunReadyAt.ToString(), rawDataWorksheet.Cells[22, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.ProteinRestTemperature.ToString(), rawDataWorksheet.Cells[23, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.SacharificationRestTemperature.ToString(), rawDataWorksheet.Cells[24, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashTun, MashTunProcessParameters.HeatingUpTemperature.ToString(), rawDataWorksheet.Cells[25, columnIndex].Value.ToString());

                    // Mash Filter process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.PrefillingStartTime.ToString(), rawDataWorksheet.Cells[26, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.PrefillingEndTime.ToString(), rawDataWorksheet.Cells[27, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.WeakWortTransferEndTime.ToString(), rawDataWorksheet.Cells[28, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.MainMashFiltrationEndTime.ToString(), rawDataWorksheet.Cells[29, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpargingEndTime.ToString(), rawDataWorksheet.Cells[30, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpargingToWWTEndTime.ToString(), rawDataWorksheet.Cells[31, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.ExtraSpargingEndTime.ToString(), rawDataWorksheet.Cells[32, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.DrippingEndTime.ToString(), rawDataWorksheet.Cells[33, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.SpentGrainDischargeEndTime.ToString(), rawDataWorksheet.Cells[34, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.MashFilter, MashFilterProcessParameters.ReadyAtTime.ToString(), rawDataWorksheet.Cells[35, columnIndex].Value.ToString());

                    // Holding Vessel process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.FillingStartTime.ToString(), rawDataWorksheet.Cells[36, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.TransferToWcEndTime.ToString(), rawDataWorksheet.Cells[37, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.HoldingVessel, HoldingVesselProcessParameters.EmptyAtTime.ToString(), rawDataWorksheet.Cells[38, columnIndex].Value.ToString());

                    // Wort Copper process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.HeatingStartTime.ToString(), rawDataWorksheet.Cells[39, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.HeatingStartTime.ToString(), rawDataWorksheet.Cells[40, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.BoilingEndTime.ToString(), rawDataWorksheet.Cells[41, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.ExtraBoilingEndTime.ToString(), rawDataWorksheet.Cells[42, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.CastingStartTime.ToString(), rawDataWorksheet.Cells[43, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.CastingEndTime.ToString(), rawDataWorksheet.Cells[44, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeBeforeBoiling.ToString(), rawDataWorksheet.Cells[45, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.WortCopper, WortCopperProcessParameters.VolumeAfterBoiling.ToString(), rawDataWorksheet.Cells[46, columnIndex].Value.ToString());

                    // Whirpool process parameters
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CastingStartTime.ToString(), rawDataWorksheet.Cells[47, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CastingEndTime.ToString(), rawDataWorksheet.Cells[48, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.RestingEndTime.ToString(), rawDataWorksheet.Cells[49, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.CoolingEndTime.ToString(), rawDataWorksheet.Cells[50, columnIndex].Value.ToString());
                    brewWithParameters.SetProcessParameterValue(ProcessEquipment.Whirlpool, WhirlpoolProcessParameters.ReadyAtTime.ToString(), rawDataWorksheet.Cells[51, columnIndex].Value.ToString());
                }

                return(brewWithParameters);
            }
        }
コード例 #17
0
 public abstract void AddBrew(IBrew brew);
コード例 #18
0
 public override void RemoveBrew(IBrew brew)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
 public abstract void UpdateBrew(IBrew brew);
コード例 #20
0
 public abstract void RemoveBrew(IBrew brew);
コード例 #21
0
 public Brew GetBrewWithProcessParameters(IBrew brew)
 {
     return((BrewingModel.Brew)_datasource.GetBrewWithProcessParameters(brew));
 }
コード例 #22
0
 public abstract IBrew GetBrewWithProcessParameters(IBrew brew);
コード例 #23
0
 public override IBrew GetBrewWithProcessParameters(IBrew brew)
 {
     return(GetBrewParametersFromWorkSheet(brew));
 }