Beispiel #1
0
        /// <summary>
        /// 添加点名表数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool Add(QY_DIANMB model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into QY_DIANMB(");
            strSql.Append("MINGC,DATATIME,DATAVALUE,QY_DIANBMB_FK)");
            strSql.Append(" values (");
            strSql.Append(":MINGC,:DATATIME,:DATAVALUE,:QY_DIANBMB_FK)");
            OracleParameter[] para =
            {
                new OracleParameter(":MINGC",         OracleType.VarChar,   50),
                new OracleParameter(":DATATIME",      OracleType.DateTime),
                new OracleParameter(":DATAVALUE",     OracleType.VarChar,   36),
                new OracleParameter(":QY_DIANBMB_FK", OracleType.VarChar, 36)
            };
            para[0].Value = model.MINGC;
            para[1].Value = model.DATATIME;
            para[2].Value = model.DATAVALUE;
            para[3].Value = model.QY_DIANBMB_FK;
            int row = DbHelperOra.ExecuteSql(strSql.ToString(), para);

            if (row > 0)
            {
                string los = "点名表新增数据: 点名:" + model.MINGC + " " + "时间:" + model.DATATIME + " " + "值:" + model.DATAVALUE + " " + "别名外键:" + model.QY_DIANBMB_FK;
                logs.writelog(los);
                return(true);
            }
            else
            {
                logs.writelog("点名表新增数据失败");
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 数据添加
        /// </summary>
        /// <param name="name">点名</param>
        /// <param name="shuj">数据</param>
        /// <param name="type">1:OPC,0:PI</param>
        /// <returns></returns>
        public bool OPCAdd(string name, string shuj, string type)
        {
            bool result = false;

            try
            {
                string    biemid = GetIDbyBM(name);
                QY_DIANMB model  = new QY_DIANMB();
                model.DATATIME  = DateTime.Now;
                model.DATAVALUE = shuj;
                model.MINGC     = name;
                if (biemid == "")
                {
                    model.QY_DIANBMB_FK = "0";
                }
                model.QY_DIANBMB_FK = biemid;
                //lock
                lock (this)
                {
                    int count = CheckCount(model.DATATIME.ToString("yyyy-MM-dd HH:mm:ss"), model.MINGC, model.DATAVALUE);
                    if (count == 0)
                    {
                        QY_DIANBMB dianbm = GetDataType(name);
                        if (dianbm.DATATYPE == "B")
                        {
                            if (Exists(name))
                            {
                                result = Update(model);
                            }
                            else
                            {
                                result = Add(model);
                            }
                        }
                        if (dianbm.DATATYPE == "S")
                        {
                            result = Add(model);
                        }
                        //if (type == "1") 取煤批次
                        //{
                        //    QUMPCAdd(name, shuj);
                        //}
                        //else
                        //{
                        //    RLPCAdd(name, shuj);
                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                logs.writelog("添加错误" + ex.Message);
                throw;
            }
            return(result);
        }
Beispiel #3
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Update(QY_DIANMB model)
 {
     try
     {
         StringBuilder strSql = new StringBuilder();
         strSql.Append("update qy_dianmb set");
         strSql.Append(" MINGC=:MINGC,");
         strSql.Append(" DATATIME=:DATATIME,");
         strSql.Append(" DATAVALUE=:DATAVALUE");
         strSql.Append(" where QY_DIANBMB_FK=:QY_DIANBMB_FK");
         OracleParameter[] para =
         {
             new OracleParameter(":QY_DIANBMB_FK", OracleType.VarChar,   36),
             new OracleParameter(":MINGC",         OracleType.VarChar,   50),
             new OracleParameter(":DATATIME",      OracleType.DateTime),
             new OracleParameter(":DATAVALUE",     OracleType.VarChar, 36)
         };
         para[0].Value = model.QY_DIANBMB_FK;
         para[1].Value = model.MINGC;
         para[2].Value = model.DATATIME;
         para[3].Value = model.DATAVALUE;
         int rows = DbHelperOra.ExecuteSql(strSql.ToString(), para);
         if (rows > 0)
         {
             string los = "更新点名表数据: 点名:" + model.MINGC + " " + "时间:" + model.DATATIME + " " + "值:" + model.DATAVALUE;
             logs.writelog(los);
             return(true);
         }
         else
         {
             logs.writelog("点名表没有可以更新的数据");
             return(false);
         }
     }
     catch (Exception ex)
     {
         logs.writelog("update点名表出错" + ex.Message);
         throw;
     }
 }