コード例 #1
0
 public void Update(AscmReadingHead ascmReadingHead)
 {
     //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmReadingHead where id<>" + ascmReadingHead.id + " and docNumber='" + ascmReadingHead.docNumber + "'");
     //if (count == 0)
     //{
     //    using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
     //    {
     //        try
     //        {
     //            YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmReadingHead>(ascmReadingHead);
     //            tx.Commit();//正确执行提交
     //        }
     //        catch (Exception ex)
     //        {
     //            tx.Rollback();//回滚
     //            YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmReadingHead)", ex);
     //            throw ex;
     //        }
     //    }
     //}
     //else
     //{
     //    throw new Exception("已经存在员工编号\"" + ascmReadingHead.name + "\"!");
     //}
 }
コード例 #2
0
 public void Save(AscmReadingHead ascmReadingHead)
 {
     try
     {
         //int count = YnDaoHelper.GetInstance().nHibernateHelper.GetCount("select count(*) from AscmReadingHead where docNumber='" + ascmReadingHead.docNumber + "'");
         //if (count == 0)
         //{
         //    int maxId = YnDaoHelper.GetInstance().nHibernateHelper.GetMaxId("select max(id) from AscmReadingHead");
         //    using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         //    {
         //        try
         //        {
         //            maxId++;
         //            ascmReadingHead.id = maxId;
         //            YnDaoHelper.GetInstance().nHibernateHelper.Save(ascmReadingHead);
         //            tx.Commit();//正确执行提交
         //        }
         //        catch (Exception ex)
         //        {
         //            tx.Rollback();//回滚
         //            throw ex;
         //        }
         //    }
         //}
         //else
         //{
         //    throw new Exception("已经存在员工编号\"" + ascmReadingHead.name + "\"!");
         //}
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("保存失败(Save AscmReadingHead)", ex);
         throw ex;
     }
 }
コード例 #3
0
 public void Delete(AscmReadingHead ascmReadingHead)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete <AscmReadingHead>(ascmReadingHead);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmReadingHead)", ex);
         throw ex;
     }
 }
コード例 #4
0
 public void Delete(int id)
 {
     try
     {
         AscmReadingHead ascmReadingHead = Get(id);
         Delete(ascmReadingHead);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #5
0
        public AscmReadingHead Get(int id)
        {
            AscmReadingHead ascmReadingHead = null;

            try
            {
                ascmReadingHead = YnDaoHelper.GetInstance().nHibernateHelper.Get <AscmReadingHead>(id);
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Get AscmReadingHead)", ex);
                throw ex;
            }
            return(ascmReadingHead);
        }
コード例 #6
0
        private void LoadAscmReadingHead()
        {
            List <AscmReadingHead> listAscmReadingHead = null;

            m_readerWriterLock_readingHead.AcquireReaderLock(10000);
            try
            {
                //listAscmReadingHead = AscmWsInterface.GetInstance().GetAllAscmReadingHeadList();
                listAscmReadingHead = AscmReadingHeadService.GetInstance().GetList(null, null, null, "", "");
                if (listAscmReadingHead != null)
                {
                    listAscmReadingHead = listAscmReadingHead.Where(P => P.ip.Trim() != "0.0.0.0").ToList();
                }
                //
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
            m_readerWriterLock_readingHead.ReleaseReaderLock();
            try
            {
                //增加
                foreach (AscmReadingHead ascmReadingHead in listAscmReadingHead)
                {
                    ReadingHead readingHead = listReadingHead.Find(e => e.ascmReadingHead.id == ascmReadingHead.id);
                    if (readingHead == null)
                    {
                        readingHead = new ReadingHead();
                        readingHead.ascmReadingHead = ascmReadingHead;
                        //readingHead.StartThread();
                        ReadingHeadThreadClass readingHeadThreadClass = new ReadingHeadThreadClass(WriteLogFile, readingHead);
                        //线程终止后不能重启
                        if (readingHead.thread != null)
                        {
                            readingHead.thread.Abort();
                        }


                        //this.AddLog("加载读写器:" + ascmReadingHead.ip);
                        try
                        {
                            //连接
                            //ascmReadingHead.ip = "192.168.1.100";
                            //readingHead.modulerReader = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 16);
                            readingHead.modulerReader        = Reader.Create(ascmReadingHead.ip, ModuleTech.Region.NA, 4);
                            readingHead.moduleTech_isConnect = true;
                            //设置天线
                            int[]          ants = new int[] { 1, 2, 3, 4 };//天线全部是四天线;
                            SimpleReadPlan plan = new SimpleReadPlan(ants);
                            readingHead.modulerReader.ParamSet("ReadPlan", plan);
                            //设置功率
                            List <AntPower> antspwr = new List <AntPower>();
                            antspwr.Add(new AntPower((byte)1, 3000, 3000));
                            antspwr.Add(new AntPower((byte)2, 3000, 3000));
                            antspwr.Add(new AntPower((byte)3, 3000, 3000));
                            antspwr.Add(new AntPower((byte)4, 3000, 3000));
                            readingHead.modulerReader.ParamSet("AntPowerConf", antspwr.ToArray());
                            //设置格式
                            readingHead.modulerReader.ParamSet("Gen2Session", ModuleTech.Gen2.Session.Session1);
                            //设置读取位置
                            EmbededCmdData ecd = new EmbededCmdData(ModuleTech.Gen2.MemBank.EPC, 2, 4);
                            readingHead.modulerReader.ParamSet("EmbededCmdOfInventory", ecd);

                            //开启线程
                            readingHead.thread = new Thread(readingHeadThreadClass.Read);
                            readingHead.thread.IsBackground = true;

                            readingHead.bThread = true;
                            readingHead.thread.Start();

                            listReadingHead.Add(readingHead);
                        }
                        catch (Exception ex)
                        {
                            this.AddLog("加载读写器失败[" + ascmReadingHead.ip + "]:" + ex.Message);
                        }
                    }
                }
                //删除没有的设备或失败的线程
                for (int iReadingHead = listReadingHead.Count - 1; iReadingHead >= 0; iReadingHead--)
                {
                    ReadingHead     readingHead     = listReadingHead[iReadingHead];
                    AscmReadingHead ascmReadingHead = listAscmReadingHead.Find(e => readingHead.ascmReadingHead.id == e.id);
                    if (ascmReadingHead == null || readingHead.thread == null || !readingHead.bThread)
                    {
                        readingHead.StopThread();
                        listReadingHead.RemoveAt(iReadingHead);
                    }
                }
            }
            catch (Exception ex)
            {
                this.AddLog("加载读写器异常:" + ex.Message);
            }
        }
コード例 #7
0
        public void AddForkliftContainerLog(string forkliftRfid, AscmReadingHead ascmReadingHead, AscmForklift ascmForklift, List <string> listRfid, string sessionKey)
        {
            try
            {
                if (listRfid.Count > 0)
                {
                    DateTime dtServer = DateTime.Now;
                    int      times    = 0;
                    //该叉车最后一次读取
                    YnBaseDal.YnPage ynPage = new YnBaseDal.YnPage();
                    ynPage.SetPageSize(1);
                    string sql = "from AscmForkliftContainerLog where passDate='" + dtServer.ToString("yyyy-MM-dd") + "' and forkliftId=" + ascmForklift.id + "";
                    IList <AscmForkliftContainerLog> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmForkliftContainerLog>(sql + " order by times desc", sql, ynPage, sessionKey);
                    if (ilist != null && ilist.Count > 0)
                    {
                        AscmForkliftContainerLog ascmForkliftContainerLog = ilist[0];
                        DateTime dtCreateTime = Convert.ToDateTime(ascmForkliftContainerLog.createTime);
                        TimeSpan ts           = dtServer.Subtract(dtCreateTime);

                        if (ascmForkliftContainerLog.readingHeadId == ascmReadingHead.id)
                        {
                            if (ts.TotalMinutes < 10)//10分钟同一叉车不重复计入
                            {
                                return;
                            }
                            times = ascmForkliftContainerLog.times;
                        }
                    }
                    //开始加入
                    times++;
                    string maxIdKey = YnFrame.Services.YnBillKeyService.GetInstance().GetBillKey("AscmForkliftContainerLog", "", "", 10, listRfid.Count, sessionKey);
                    long   maxId    = Convert.ToInt64(maxIdKey);
                    List <AscmForkliftContainerLog> listAscmForkliftContainerLog = new List <AscmForkliftContainerLog>();
                    foreach (string rfid in listRfid)
                    {
                        AscmForkliftContainerLog ascmForkliftContainerLog = new AscmForkliftContainerLog();
                        ascmForkliftContainerLog.id               = ++maxId;
                        ascmForkliftContainerLog.forkliftId       = ascmForklift.id;
                        ascmForkliftContainerLog.forkliftIdRfidId = forkliftRfid;
                        ascmForkliftContainerLog.containerRfidId  = rfid;
                        ascmForkliftContainerLog.createTime       = dtServer.ToString("yyyy-MM-dd HH:mm");
                        ascmForkliftContainerLog.passDate         = dtServer.ToString("yyyy-MM-dd");
                        ascmForkliftContainerLog.times            = times;
                        ascmForkliftContainerLog.readingHeadId    = ascmReadingHead.id;
                        ascmForkliftContainerLog.readingHeadIp    = ascmReadingHead.ip;
                        ascmForkliftContainerLog.status           = "";
                        listAscmForkliftContainerLog.Add(ascmForkliftContainerLog);
                    }
                    using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession(sessionKey).BeginTransaction())
                    {
                        try
                        {
                            if (listAscmForkliftContainerLog.Count > 0)
                            {
                                YnDaoHelper.GetInstance().nHibernateHelper.SaveList(listAscmForkliftContainerLog, sessionKey);
                            }


                            tx.Commit();//正确执行提交
                        }
                        catch (Exception ex)
                        {
                            tx.Rollback();//回滚
                            throw ex;
                        }
                    }
                    //建立领料员单次领料与领料单的关联
                    AscmWmsMtlRequisitionMainService.GetInstance().WmsStoreIssueCheck(forkliftRfid, times, dtServer.ToString("yyyy-MM-dd HH:mm"), sessionKey);
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("记录日志失败(Find AscmForkliftContainerLog)", ex);
                throw ex;
            }
        }