Esempio n. 1
0
        static (Result leftResult, Result rightResult) CalculateSpring(this ExcelWorkbook workbook, int doorValue, int numberOfSprings)
        {
            try
            {
                // Fetch used sheets
                var inputSheet       = workbook.Worksheets["Input"];
                var dataSheet        = workbook.Worksheets["Data"];
                var calculationSheet = workbook.Worksheets["Calculation"];

                // Fetch Inputs
                var doorWidth  = inputSheet.Cells["B12"];
                var doorHeight = inputSheet.Cells["C12"];
                var doorLift   = inputSheet.Cells["D12"];
                var doorPitch  = inputSheet.Cells["E12"];
                var doorWeight = inputSheet.Cells["F12"];
                var doorBs     = inputSheet.Cells["G12"];

                // preference inputs
                var doorType      = dataSheet.Cells["Z15"];
                var calculation   = dataSheet.Cells["V8"];
                var cycles        = dataSheet.Cells["N12"];
                var cableDrum     = dataSheet.Cells["AH22"];
                var springDInside = dataSheet.Cells["N22"];
                var springNumber  = calculationSheet.Cells["B41"];

                // Modify input values.
                doorType.Value     = doorValue;
                springNumber.Value = numberOfSprings;

                // Fetch results
                var results = GetResult(inputSheet);

                // Call same method with another preference (doorType, calculation, ..., springNumber) if no solutions are available.
                return(results.leftResult.Spring.Contains("No solution") ||
                       results.leftResult.Spring.Contains("not a stock item") ?
                       workbook.CalculateSpring(2, 2) :
                       results);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }