Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.clutercapacity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update clutercapacity set ");
            strSql.Append("totalCapacity=@totalCapacity,");
            strSql.Append("usedCapacity=@usedCapacity");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@totalCapacity", MySqlDbType.VarChar, 32),
                new MySqlParameter("@usedCapacity",  MySqlDbType.VarChar, 32),
                new MySqlParameter("@id",            MySqlDbType.Int32, 4)
            };
            parameters[0].Value = model.totalCapacity;
            parameters[1].Value = model.usedCapacity;
            parameters[2].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.clutercapacity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into clutercapacity(");
            strSql.Append("totalCapacity,usedCapacity)");
            strSql.Append(" values (");
            strSql.Append("@totalCapacity,@usedCapacity)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@totalCapacity", MySqlDbType.VarChar, 32),
                new MySqlParameter("@usedCapacity",  MySqlDbType.VarChar, 32)
            };
            parameters[0].Value = model.totalCapacity;
            parameters[1].Value = model.usedCapacity;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 系统的存储状态,当前上传人数,用户姓名和等级显示
        /// </summary>
        public void ShowSystemStatus()
        {
            //上传人数显示
            Maticsoft.BLL.onlinenumber          onlines     = new Maticsoft.BLL.onlinenumber();
            List <Maticsoft.Model.onlinenumber> onlineList1 = onlines.GetModelList("onlinestatus=1");

            //username去重
            for (int i = 0; i < onlineList1.Count; i++)
            {
                for (int j = onlineList1.Count - 1; j > i; j--)
                {
                    if (onlineList1[i].username.Equals(onlineList1[j].username))
                    {
                        onlineList1.RemoveAt(j);
                    }
                }
            }
            labelUpload.Text = "当前有" + onlineList1.Count + "人正在上传数据";
            //系统存储状态显示
            Maticsoft.BLL.clutercapacity   bCluter1 = new Maticsoft.BLL.clutercapacity();
            Maticsoft.Model.clutercapacity mCluter1 = bCluter1.GetModelList("1=1 group by id desc limit 1")[0];
            String total    = mCluter1.totalCapacity;
            String used     = mCluter1.usedCapacity;
            float  totalNum = 1;
            float  usedNum  = 0;

            //将系统总量转换为GB表示,用于计算进度条
            if (total.Contains("TB"))
            {
                String temp = total.Split("TB".ToArray())[0];
                totalNum = float.Parse(temp) * 1024;
            }
            else if (total.Contains("GB"))
            {
                String temp = total.Split("GB".ToArray())[0];
                totalNum = float.Parse(temp);
            }
            //将已使用量转换为GB显示,用于计算进度条比例
            if (used.Contains("TB"))
            {
                String temp = used.Split("TB".ToArray())[0];
                usedNum = float.Parse(temp) * 1024;
            }
            else if (used.Contains("GB"))
            {
                String temp = used.Split("GB".ToArray())[0];
                usedNum = float.Parse(temp);
            }
            processBar_SystemStaus1.Text  = used + "/" + total;
            processBar_SystemStaus1.Value = (usedNum / totalNum) * 100;

            //用户姓名和等级显示
            labelUser.Text = UserInfo.username;
            String userRolle = UserInfo.userRolle;

            Maticsoft.BLL.role   roleB = new Maticsoft.BLL.role();
            Maticsoft.Model.role roleM = roleB.GetModel(Convert.ToInt32(UserInfo.userRolle));
            labelPost.Text = roleM.roleName;
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.clutercapacity DataRowToModel(DataRow row)
 {
     Maticsoft.Model.clutercapacity model = new Maticsoft.Model.clutercapacity();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["totalCapacity"] != null)
         {
             model.totalCapacity = row["totalCapacity"].ToString();
         }
         if (row["usedCapacity"] != null)
         {
             model.usedCapacity = row["usedCapacity"].ToString();
         }
     }
     return(model);
 }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.clutercapacity GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,totalCapacity,usedCapacity from clutercapacity ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Maticsoft.Model.clutercapacity model = new Maticsoft.Model.clutercapacity();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }