Example #1
0
        public ActionResult GetCabinetModel()
        {
            string dbpath = HttpContext.Server.MapPath("~/App_Data/DB/demo.db");

            SqliteHelper.BLL.Cabinet cabintbll = new SqliteHelper.BLL.Cabinet(dbpath);
            var        cabinetModel            = cabintbll.GetModel(1);
            JsonResult js = new JsonResult();

            js = Json(cabinetModel, JsonRequestBehavior.AllowGet);
            return(js);
        }
Example #2
0
        /// <summary>
        /// 获取机柜的容量信息
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCapacityInfo()
        {
            CapacityInfo capacityInfo = new CapacityInfo();
            JsonResult   js           = new JsonResult();
            string       dbpath       = HttpContext.Server.MapPath("~/App_Data/DB/demo.db");

            SqliteHelper.BLL.Cabinet cabintbll = new SqliteHelper.BLL.Cabinet(dbpath);
            var cabinetModel = cabintbll.GetModel(1);

            SqliteHelper.BLL.Asset assetbll = new SqliteHelper.BLL.Asset(dbpath);
            var assetList = assetbll.GetModelList(string.Format("cabinetNo=1 and state in ('1','2')"));
            //层位
            var    usedLayer  = assetList.Sum(m => m.UsedLayer);
            double doubleRate = 100 * usedLayer.Value / cabinetModel.Space.Value;

            capacityInfo.progress1Content = string.Format("{0}% ({1}/{2})", Math.Round(doubleRate, 2), usedLayer, cabinetModel.Space);
            capacityInfo.progress1        = string.Format("{0}%", Math.Round(doubleRate, 2));
            if (doubleRate < 30)
            {
                capacityInfo.ColorStyle1 = "progress-bar progress-bar-success progress-bar-striped";
            }
            else if (doubleRate < 60)
            {
                capacityInfo.ColorStyle1 = "progress-bar progress-bar-info progress-bar-striped";
            }
            else if (doubleRate < 90)
            {
                capacityInfo.ColorStyle1 = "progress-bar progress-bar-warning progress-bar-striped";
            }
            else
            {
                capacityInfo.ColorStyle1 = "progress-bar progress-bar-danger progress-bar-striped";
            }
            //电力
            var usedPower = assetList.Sum(m => m.UsedPower);

            doubleRate = Convert.ToDouble(100 * usedPower.Value / cabinetModel.Power.Value);
            capacityInfo.progress2Content = string.Format("{0}% ({1}/{2})", Math.Round(doubleRate, 2), usedPower, cabinetModel.Power);
            capacityInfo.progress2        = string.Format("{0}%", Math.Round(doubleRate, 2));
            if (doubleRate < 30)
            {
                capacityInfo.ColorStyle2 = "progress-bar progress-bar-success progress-bar-striped";
            }
            else if (doubleRate < 60)
            {
                capacityInfo.ColorStyle2 = "progress-bar progress-bar-info progress-bar-striped";
            }
            else if (doubleRate < 90)
            {
                capacityInfo.ColorStyle2 = "progress-bar progress-bar-warning progress-bar-striped";
            }
            else
            {
                capacityInfo.ColorStyle2 = "progress-bar progress-bar-danger progress-bar-striped";
            }
            //承重
            var usedWeight = assetList.Sum(m => m.UsedWeight);

            doubleRate = Convert.ToDouble(100 * usedWeight.Value / cabinetModel.Weight.Value);
            capacityInfo.progress3Content = string.Format("{0}% ({1}/{2})", Math.Round(doubleRate, 2), usedWeight, cabinetModel.Weight);
            capacityInfo.progress3        = string.Format("{0}%", Math.Round(doubleRate, 2));
            if (doubleRate < 30)
            {
                capacityInfo.ColorStyle3 = "progress-bar progress-bar-success progress-bar-striped";
            }
            else if (doubleRate < 60)
            {
                capacityInfo.ColorStyle3 = "progress-bar progress-bar-info progress-bar-striped";
            }
            else if (doubleRate < 90)
            {
                capacityInfo.ColorStyle3 = "progress-bar progress-bar-warning progress-bar-striped";
            }
            else
            {
                capacityInfo.ColorStyle3 = "progress-bar progress-bar-danger progress-bar-striped";
            }
            //电口
            var usedPowerPort = assetList.Sum(m => m.UsedPowerPort);

            doubleRate = Convert.ToDouble(100 * usedPowerPort.Value / cabinetModel.PowerPort.Value);
            capacityInfo.progress4Content = string.Format("{0}% ({1}/{2})", Math.Round(doubleRate, 2), usedPowerPort, cabinetModel.PowerPort);
            capacityInfo.progress4        = string.Format("{0}%", Math.Round(doubleRate, 2));
            if (doubleRate < 30)
            {
                capacityInfo.ColorStyle4 = "progress-bar progress-bar-success progress-bar-striped";
            }
            else if (doubleRate < 60)
            {
                capacityInfo.ColorStyle4 = "progress-bar progress-bar-info progress-bar-striped";
            }
            else if (doubleRate < 90)
            {
                capacityInfo.ColorStyle4 = "progress-bar progress-bar-warning progress-bar-striped";
            }
            else
            {
                capacityInfo.ColorStyle4 = "progress-bar progress-bar-danger progress-bar-striped";
            }
            //网口
            var usedNetPort = assetList.Sum(m => m.UsedNetPort);

            doubleRate = Convert.ToDouble(100 * usedNetPort.Value / cabinetModel.NetPort.Value);
            capacityInfo.progress5Content = string.Format("{0}% ({1}/{2})", Math.Round(doubleRate, 2), usedNetPort, cabinetModel.NetPort);
            capacityInfo.progress5        = string.Format("{0}%", Math.Round(doubleRate, 2));
            if (doubleRate < 30)
            {
                capacityInfo.ColorStyle5 = "progress-bar progress-bar-success progress-bar-striped";
            }
            else if (doubleRate < 60)
            {
                capacityInfo.ColorStyle5 = "progress-bar progress-bar-info progress-bar-striped";
            }
            else if (doubleRate < 90)
            {
                capacityInfo.ColorStyle5 = "progress-bar progress-bar-warning progress-bar-striped";
            }
            else
            {
                capacityInfo.ColorStyle5 = "progress-bar progress-bar-danger progress-bar-striped";
            }
            js = Json(capacityInfo, JsonRequestBehavior.AllowGet);
            return(js);
        }