Пример #1
0
        public double ConvertVolume(double value, string fromUnit, string toUnit)
        {
            int fromUnitId, toUnitId;
            // Attempt to look up unit both by ID and by name
            if (!int.TryParse(fromUnit, out fromUnitId) && !UnitsByName.TryGetValue(fromUnit.ToLower(), out fromUnitId)) {
                throw new ArgumentException("No corresponding unit definition found for unit: '" + fromUnit + "'");
            }
            if (!int.TryParse(toUnit, out toUnitId) && !UnitsByName.TryGetValue(toUnit.ToLower(), out toUnitId)) {
                throw new ArgumentException("No corresponding unit definition found for unit: '" + toUnit + "'");
            }

            if (fromUnitId == toUnitId) {
                return value;
            }

            int gallonUnitId;
            if (!UnitsByName.TryGetValue("gallons", out gallonUnitId)) {
                throw new ConfigurationException("Unable to find unit ID for standard unit 'gallons'!");
            }

            if (fromUnitId != gallonUnitId) {
                // First convert to gallons, our standard unit, then convert to whatever else is desired.
                value *= new ConfigDalc().GetConversionFactor(fromUnitId, gallonUnitId);
            }

            return value * new ConfigDalc().GetConversionFactor(gallonUnitId, toUnitId);
        }
        public ActionResult NoneCAFOIndex()
        {
            ViewBag.IsCafoDeployed = ConfigurationManager.AppSettings["is_cafo_deployed"].ToBoolean();
            ViewBag.IsEcfDeployed = ConfigurationManager.AppSettings["is_ecf_deployed"].ToBoolean();
            ViewBag.CurrentUserEmailAddress = ActingUser.Email;
            if (new ReportingDalc().CanUserOverrideReportingDates(ActualUser.ActingAsUserId ?? ActualUser.Id))
            {
                IsReportingAllowed = true;
            }

            if (Request["code"] != "1111")
            {
                return RedirectToAction("Index");
            }

            var cdalc = new ConfigDalc();
            return View(new ReportingViewModel()
            {
                meterUnitConversionFactors = JObject.FromObject(cdalc.GetAllMeterUnitConversionFactors()).ToString(),
                unitConversionFactors = JObject.FromObject(cdalc.GetAllUnitConversionFactors()).ToString(),
                pageState = JObject.FromObject(GetPageStateJson(ActingUser)).ToString()
            });
        }