コード例 #1
0
 /// <summary>
 /// 清空历史告警---历史告警数据的是否有效字段置为false
 /// add2020-04-10 plq
 /// </summary>
 /// <returns></returns>
 public bool ClearHistoryAlarm()
 {
     using (DataBase db = new DataBase(SqlHelper.MainConnectionString))
     {
         try
         {
             //调用隐式事务 TransactionScope
             using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
             {
                 var oldList = (from s in db.Rfid_AlarmLogInfo
                                select s).ToList();
                 foreach (var info in oldList)
                 {
                     info.ShiFouYouXiao = false;
                 }
                 db.SubmitChanges();
                 ts.Complete(); //提交事务
                 return(true);
             }
         }
         catch (Exception ex)
         {
             LogUtility.Error("DealInnerCommDAL/ClearHistoryAlarm", ex.ToString());
             return(false);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 绑定设备与对应RFID卡
 /// </summary>
 /// <param name="SheBeiID"></param>
 /// <param name="RfidKaHao"></param>
 /// <returns></returns>
 public string BindDevice(string SheBeiID, string RfidKaHao)
 {
     using (DataBase db = new DataBase(SqlHelper.MainConnectionString))
     {
         try
         {
             //调用隐式事务 TransactionScope
             using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
             {
                 var oldInfo = db.FIXED_MatetialInfo.SingleOrDefault <FIXED_MatetialInfo>(s => s.BianMa == SheBeiID);
                 //修改实体属性
                 oldInfo.RFIDKaHao = RfidKaHao; //给对应设备的RFID卡号赋值---即完成卡与设备的绑定
                 //add20200408 plq 判断RFID卡是否已绑定设备,若绑定过,则清空之前绑定设备的RFID卡号
                 var fmInfo = db.FIXED_MatetialInfo.SingleOrDefault <FIXED_MatetialInfo>(s => s.RFIDKaHao == RfidKaHao);
                 if (fmInfo != null)
                 {
                     fmInfo.RFIDKaHao = "";//清空该RFID卡之前绑定设备的RFID卡号字段
                 }
                 db.SubmitChanges();
                 ts.Complete(); //提交事务
                 return("");
             }
         }
         catch (Exception ex)
         {
             LogUtility.Error("RfidRelationDAL/BindDevice", "RFID卡绑定设备出错:" + ex.Message);
             return(ex.Message);
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 新增多条告警数据
 /// </summary>
 /// <param name="ralList"></param>
 /// <returns></returns>
 public bool InsertAllAlarmLog(List <Rfid_AlarmLogInfo> ralList)
 {
     using (DataBase db = new DataBase(SqlHelper.MainConnectionString))
     {
         try
         {
             //调用隐式事务 TransactionScope
             using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
             {
                 //全部插入
                 if (ralList != null)
                 {
                     db.Rfid_AlarmLogInfo.InsertAllOnSubmit(ralList);
                 }
                 db.SubmitChanges();
                 ts.Complete(); //提交事务
                 return(true);
             }
         }
         catch (Exception ex)
         {
             LogUtility.Error("DealInnerCommDAL/InsertAllAlarmLog", ex.ToString());
             return(false);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// 更新告警数据
        /// </summary>
        /// <param name="ralInfo"></param>
        /// <param name="upAdResult"></param>
        /// <returns></returns>
        public bool UpdateAlarmData(Rfid_AlarmLogInfo ralInfo, ref string upAdResult)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(SqlHelper.MainConnectionString))
                {
                    DataBase db      = new DataBase(conn);
                    var      oldInfo = db.Rfid_AlarmLogInfo.SingleOrDefault <Rfid_AlarmLogInfo>(s => s.BianMa == ralInfo.BianMa);

                    //修改实体属性---根据更新类型来对应更新不同字段
                    int typeCode = -1;//更新类型
                    if (!String.IsNullOrEmpty(ralInfo.typeCode))
                    {
                        typeCode = Convert.ToInt32(ralInfo.typeCode);
                    }
                    if (typeCode == (int)Utility.AnchorEnum.ERfid_UpdateAlarmType.更新操作类型) //只更新告警数据中的操作类型字段
                    {                                                                     //更新 操作类型编码
                        oldInfo.CaoZuoLeiXingBianMa = ralInfo.CaoZuoLeiXingBianMa;
                    }
                    else if (typeCode == (int)Utility.AnchorEnum.ERfid_UpdateAlarmType.更新设备及处理状态) //更新告警数据中的设备及处理状态信息
                    {                                                                             //更新设备ID、名称及处理状态
                        oldInfo.SheBeiID             = ralInfo.SheBeiID;
                        oldInfo.SheBeiMingCheng      = ralInfo.SheBeiMingCheng;
                        oldInfo.ChuLiZhuangTaiBianMa = ralInfo.ChuLiZhuangTaiBianMa;
                        oldInfo.ChuLiShiJian         = ralInfo.ChuLiShiJian;
                        oldInfo.CaoZuoRenBianMa      = ralInfo.CaoZuoRenBianMa;
                    }
                    else if (typeCode == (int)Utility.AnchorEnum.ERfid_UpdateAlarmType.更新处理状态) //更新处理状态信息
                    {                                                                          //更新处理状态
                        oldInfo.ChuLiZhuangTaiBianMa = ralInfo.ChuLiZhuangTaiBianMa;
                        oldInfo.ChuLiShiJian         = ralInfo.ChuLiShiJian;
                        oldInfo.CaoZuoRenBianMa      = ralInfo.CaoZuoRenBianMa;
                    }
                    else
                    {
                        upAdResult = "更新告警数据请求的类型编码错误";
                        return(false);
                    }
                    db.SubmitChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                upAdResult = ex.Message;
                LogUtility.Error("RfidGiveAlarmDAL/UpdateAlarmData", "更新告警数据出错:" + ex.Message);
                return(false);
            }
        }
コード例 #5
0
 /// <summary>
 /// 解除绑定
 /// 当前仓库编码置为-1
 /// </summary>
 /// <param name="CangKuID"></param>
 /// <param name="SheBeiBianMa"></param>
 /// <returns></returns>
 public string UnBindStorage(string CangKuID, string SheBeiBianMa)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(SqlHelper.MainConnectionString))
         {
             DataBase db      = new DataBase(conn);
             var      oldInfo = db.FIXED_MatetialInfo.SingleOrDefault <FIXED_MatetialInfo>(s => s.BianMa == SheBeiBianMa);
             //修改实体属性
             oldInfo.DangQianCangKuBianMa = -1; //当前仓库编码赋值为-1,代表解绑
             db.SubmitChanges();
             return("");
         }
     }
     catch (Exception ex)
     {
         LogUtility.Error("RfidRelationDAL/UnBindStorage", "解除设备与仓库的绑定出错:" + ex.Message);
         return(ex.Message);
     }
 }
コード例 #6
0
 /// <summary>
 /// 绑卡设备与对应仓库绑定
 /// </summary>
 /// <param name="RFIDKaHao"></param>
 /// <param name="CangKuID"></param>
 /// <returns></returns>
 public string BindStorage(string SheBeiID, string CangKuID)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(SqlHelper.MainConnectionString))
         {
             DataBase db      = new DataBase(conn);
             var      oldInfo = db.FIXED_MatetialInfo.SingleOrDefault <FIXED_MatetialInfo>(s => s.BianMa == SheBeiID);
             //修改实体属性
             oldInfo.DangQianCangKuBianMa = Convert.ToInt32(CangKuID); //当前仓库编码赋值
             oldInfo.ShiFouDiuShi         = false;                     //绑定关系下 物资不可能为丢失
             db.SubmitChanges();
             return("");
         }
     }
     catch (Exception ex)
     {
         LogUtility.Error("RfidRelationDAL/BindStorage", "绑卡设备与对应仓库绑定出错:" + ex.Message);
         return(ex.Message);
     }
 }
コード例 #7
0
 /// <summary>
 /// 丢失处理
 /// 是否丢失 字段 设为1
 /// 丢失处理逻辑待确认
 /// </summary>
 /// <param name="CangKuID"></param>
 /// <param name="SheBeiBianMa"></param>
 /// <returns></returns>
 public string DealLose(string CangKuID, string SheBeiBianMa)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(SqlHelper.MainConnectionString))
         {
             DataBase db      = new DataBase(conn);
             var      oldInfo = db.FIXED_MatetialInfo.SingleOrDefault <FIXED_MatetialInfo>(s => s.BianMa == SheBeiBianMa);
             //修改实体属性
             oldInfo.ShiFouDiuShi         = true; //是否丢失 设为true
             oldInfo.DangQianCangKuBianMa = -1;   //丢失 物资的当前仓库编码也 设为-1
             //要不要清空RFID卡号---防止RFID卡二次利用时因为设备不为空导致不会走第一次绑定流程
             db.SubmitChanges();
             return("");
         }
     }
     catch (Exception ex)
     {
         LogUtility.Error("RfidRelationDAL/DealLose", "丢失请求出错:" + ex.Message);
         return(ex.Message);
     }
 }
コード例 #8
0
        /// <summary>
        /// 新增告警记录数据
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool InsertAlarmLog(Rfid_AlarmLogInfo info)
        {
            using (DataBase db = new DataBase(SqlHelper.MainConnectionString))
            {
                try
                {
                    //向记录表中插入一条数据
                    if (info != null)
                    {
                        db.Rfid_AlarmLogInfo.InsertOnSubmit(info);
                    }

                    //执行更新操作
                    db.SubmitChanges();
                    return(true);
                }
                catch (Exception ex)
                {
                    LogUtility.Error("DealInnerCommDAL/InsertAlarmLog", ex.ToString());
                    return(false);
                }
            }
        }
コード例 #9
0
 /// <summary>
 /// 判断Rfid_AlarmLog表中是否已有重复的告警数据记录,有则更新时间、返回true,没有则返回false。
 /// 暂定 相同操作类型编码、相同设备ID、相同RFID卡号、相同仓库ID、相同读写器ID且处理状态编码为1(未处理)的为重复告警数据
 /// 若有重复数据,则更新其 记录时间 字段,返回true;若没有则返回false
 /// </summary>
 /// <param name="info"></param>
 /// <returns></returns>
 public bool VerifyIsRepeat(Rfid_AlarmLogInfo info, ref string errMsg)
 {
     using (DataBase db = new DataBase(SqlHelper.MainConnectionString))
     {
         try
         {
             int code = (int)Utility.AnchorEnum.ERfid_ProcessingState.未处理; //未处理时的状态编码
             //取出实体
             //var oldInfo = db.Rfid_AlarmLogInfo.SingleOrDefault<Rfid_AlarmLogInfo>(s => s.CaoZuoLeiXingBianMa == info.CaoZuoLeiXingBianMa
             //    && s.SheBeiID == info.SheBeiID && s.RFIDKaHao == info.RFIDKaHao && s.CangKuID == info.CangKuID && s.DuXieQiID == info.DuXieQiID
             //    && s.ChuLiZhuangTaiBianMa == code);
             var oldInfo = (from s in db.Rfid_AlarmLogInfo
                            where s.CaoZuoLeiXingBianMa == info.CaoZuoLeiXingBianMa && s.SheBeiID == info.SheBeiID &&
                            s.RFIDKaHao == info.RFIDKaHao && s.CangKuID == info.CangKuID && s.DuXieQiID == info.DuXieQiID &&
                            s.ChuLiZhuangTaiBianMa == code
                            select s).FirstOrDefault();
             if (oldInfo != null)
             {
                 //oldInfo.JiLuShiJian = info.JiLuShiJian; //更新 记录时间
                 oldInfo.ShiFouYouXiao = info.ShiFouYouXiao; //add2020-04-10 plq 设为有效
                 db.SubmitChanges();                         //保存更新
                 return(true);
             }
             else  //没有重复告警
             {
                 return(false);
             }
         }
         catch (Exception ex)
         {
             errMsg = ex.Message;
             LogUtility.Error("DealInnerCommDAL/VerifyIsRepeat", ex.Message);
             return(false);
         }
     }
 }