예제 #1
0
        public string Handle(string ClientIP, string card)
        {
            //

            ////获取当前刷卡器配置
            StepNode current_dev = GetIpStep(ClientIP, 1);
            //StepNode current_last = current_dev.GetLast();

            //刷卡器为第一个步骤
            //if (current_last == null)
            string sResult = "";

            lock (locker)
            {
                //工作人员刷卡
                if (IsWorkCard(card) && current_dev != null)
                {
                    sResult = Pending(ClientIP, card);
                }

                //内镜刷卡
                if (IsMCard(card))
                {
                    //绑卡步骤
                    if (PendingList.ContainsKey(ClientIP))
                    {
                        //string workDev = PendingList[ClientIP].WorkCard;

                        if (BindingCard(ClientIP, card, ref sResult))
                        {
                            //绑卡成功,从绑卡列表中删除
                            PendingList.Remove(ClientIP);
                        }
                    }
                    else if (CardList.ContainsKey(card))  //内镜洗消步骤
                    {
                        if (Step(ClientIP, card, ref sResult))
                        {
                            CardList.Remove(card);
                        }
                        //TaskInfo info = new TaskInfo();
                        //m_updateTaskProc(info);
                    }
                }
            }

            return(sResult);
        }
예제 #2
0
        public bool BindingCard(string ClientIP, string card, ref string sResult)
        {
            bool bConvert = false;

            //获取当前刷卡器的步骤信息

            StepNode curr_node = null;

            if (YesterdayCard.Contains(card))
            {
                curr_node = GetIpStep_yes(ClientIP, 1);
            }
            else
            {
                curr_node = GetIpStep(ClientIP, 1);
            }
            if (curr_node != null)
            {
                //lock (locker)
                {
                    //绑卡过程,内镜卡不在洗消步骤中
                    if (CardList[card] == null)
                    {
                        State mstate = PendingList[ClientIP];
                        mstate.StepTime = curr_node.GetDur();
                        mstate.Binding(card);
                        mstate.UpdateMsgToDB(curr_node);
                        CardList[card] = mstate;
                        bConvert       = true;
                        sResult        = "绑卡成功," + "下一步:" + curr_node.GetNext().GetStepName();;
                    }
                    else
                    {
                        sResult = "内镜卡正在洗消";
                    }
                }
            }


            if (bConvert)
            {
                //更新界面
                TaskInfo info = new TaskInfo(ClientIP, card, PendingList[ClientIP].WorkCard, curr_node.GetDur(), 1, curr_node.GetCleanGroup(), "", bConvert);
                UpdateUIDelegate(info);
            }
            return(bConvert);
        }
예제 #3
0
        public StepNode GetIpStep(string ClientIP, int lastStepNum)
        {
            StepNode current_node = IPlist.GetFirstItem(ClientIP);

            while (current_node != null)
            {
                int stepnum = current_node.GetStepNum();
                if ((stepnum == lastStepNum + 1) || (stepnum == lastStepNum))
                {
                    break;
                }
                else
                {
                    current_node = IPlist.Iterate(ClientIP);
                }
            }
            return(current_node);
        }
예제 #4
0
        public void UpdateMsgToDB(StepNode curr_node, bool bEnd = false)
        {
            //保存数据库
            Clean_RecordList record = new Clean_RecordList();

            record.CleanCard = CardNo;
            record.CleanIp   = ClientIP;
            record.CleanPort = curr_node.GetPort();
            record.MaxNum    = curr_node.GetTotalStepNum();
            record.StartTime = StartTime;
            record.StepTime  = StepTime;
            record.StepNum   = curr_node.GetStepNum();
            record.WorkCard  = WorkCard;
            record.StepName  = curr_node.GetStepName();
            record.EndTime   = StartTime;
            record.Sequence  = id;
            if (bEnd)
            {
                record.EndTime = DateTime.Now;
            }
            DBmanager.Instance.AddQueue(record);
        }
예제 #5
0
 public void SetNext(StepNode Node)
 {
     Next = Node;
 }
예제 #6
0
 public void SetLast(StepNode Node)
 {
     Last = Node;
 }
예제 #7
0
        public void InitProcedure()
        {
            try
            {
                using (CleanProcedureEntities db = new CleanProcedureEntities())
                {
                    //刷卡器
                    var list = db.Clean_CardDevice.Select(p => p.DevType).Distinct();
                    foreach (var item in list)
                    {
                        var      machinlist = db.Clean_CardDevice.Where(p => p.DevType == item && p.Stopped == false).OrderBy(p => p.StepNumber);
                        StepNode sn         = null;
                        StepNode snLast     = null;

                        foreach (var m in machinlist)
                        {
                            snLast = sn;
                            sn     = new StepNode(m.ClientIP, m);


                            sn.SetLast(snLast);
                            if (snLast != null)
                            {
                                snLast.SetNext(sn);
                            }
                            if (m.DevType.Equals("消毒监控"))
                            {
                                IPlist.Add(m.ClientIP, sn);
                            }
                            if (m.DevType.Equals("隔夜消毒"))
                            {
                                IPlist_yes.Add(m.ClientIP, sn);
                            }
                        }
                    }
                    //人员卡
                    var wlist = from a in db.Clean_Card where a.DevType == "人员" select a.CardNo;
                    Worker.AddRange(wlist.AsEnumerable());

                    //内镜卡
                    var nlist = from c in db.Clean_Card where c.DevType == "镜子" select c;
                    foreach (var item in nlist)
                    {
                        CardList.Add(item.CardNo, null);
                    }
                    State.id = db.Clean_RecordList.Max(p => p.Sequence) + 1;
                    //如果隔夜消毒的内镜不作废,查询昨天消毒未用的内镜卡
                    if (Config_func.GetInstance().LastNight)
                    {
                        //获取昨天使用记录
                        var        uselist = db.CleanCard_UserList.GroupBy(p => p.CleanCard);
                        List <int> seqlist = new List <int>();
                        foreach (var item in uselist)
                        {
                            string             cardname = item.Key;
                            CleanCard_UserList it       = item.OrderBy(p => p.Sequence).LastOrDefault();
                            //昨天 最后的使用记录
                            DateTime time = (DateTime)it.ZuofeiTime;
                            if (time.Date.Equals(DateTime.Today.AddDays(-1)) /*|| it.StartTime.Date.Equals(DateTime.Today)*/)
                            {
                                seqlist.Add(it.Sequence);
                            }
                        }



                        var reclist = db.Clean_RecordList.GroupBy(p => p.CleanCard);

                        foreach (var item in reclist)
                        {
                            string           cardname = item.Key;
                            Clean_RecordList it       = item.OrderBy(p => p.StartTime).LastOrDefault();
                            //昨天的消毒记录
                            if (it.StartTime.Date.Equals(DateTime.Today.AddDays(-1)) && !seqlist.Contains(it.Sequence) /*|| it.StartTime.Date.Equals(DateTime.Today)*/)
                            {
                                //if (it.StepNum < it.MaxNum)//消毒未完成记录
                                //{
                                //    State mState = new State(it.WorkCard,it.CleanIp,it.StepTime);
                                //    mState.Binding(cardname);


                                //    CardList[cardname] = mState;

                                //}
                                YesterdayCard.Add(it.CleanCard);
                            }
                        }
                    }
                }
                DBmanager.Instance.Start();
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(Exception), ex);
            }
        }
예제 #8
0
        //洗消步骤切换
        public bool Step(string ClientIP, string card, ref string sRet)
        {
            sRet = "";
            bool bFinish = false;
            bool bstart  = false;
            //bool bConvert = false;
            DateTime currenttime = DateTime.Now;
            //获取内镜卡上次的刷卡信息
            State mState = CardList[card];

            if (mState == null)
            {
                sRet = "";
                return(false);
            }
            else
            {
                //获取当前刷卡器的步骤信息
                StepNode curr_node = null;
                if (YesterdayCard.Contains(card))
                {
                    curr_node = GetIpStep_yes(ClientIP, mState.StepNum);
                }
                else
                {
                    curr_node = GetIpStep(ClientIP, mState.StepNum);
                }

                //StepNode curr_node = GetIpStep(ClientIP, mState.StepNum);

                if (curr_node == null)
                {
                    sRet = "刷卡步骤不对";
                }
                else
                {
                    StepNode last_node = curr_node.GetLast();

                    if (last_node == null)
                    {
                        string temp = "结束";
                        if (curr_node.GetNext() != null)
                        {
                            temp = curr_node.GetNext().GetStepName();
                        }
                        sRet = "下一步:" + temp;
                    }
                    //不能机洗跳手工
                    else if (last_node.IsMachineWash() && !curr_node.IsMachineWash())
                    {
                        sRet = "不能机洗跳手工";
                    }
                    else
                    {
                        //int stepTime = last_node.GetDur();

                        //  lock (locker)
                        {
                            //当前步骤的上一个刷卡器地址是否相同,即洗消顺序相同
                            if (last_node.StepIp().Equals(mState.ClientIP))
                            {
                                if (curr_node.GetStepNum() == curr_node.GetTotalStepNum())
                                {
                                    mState.UpdateMsgToDB(curr_node, true);

                                    bFinish = true;

                                    sRet = "洗消步骤全部结束";
                                }
                                else if (mState.IsTimeFinish())
                                {
                                    mState.Convert(ClientIP);
                                    mState.StepTime = curr_node.GetDur();
                                    mState.UpdateMsgToDB(curr_node);
                                    bstart = true;
                                    string temp = "结束";
                                    if (curr_node.GetNext() != null)
                                    {
                                        temp = curr_node.GetNext().GetStepName();
                                    }
                                    sRet = "下一步:" + temp;
                                }
                                else
                                {
                                    sRet = "洗消时间未到";
                                }
                            }
                            //else if (curr_node.StepIp().Equals(mState.ClientIP))//结束当前步骤
                            //{


                            //    if (curr_node.GetStepNum() == curr_node.GetTotalStepNum())
                            //    {
                            //        mState.UpdateMsgToDB(curr_node, true);

                            //        bFinish = true;

                            //        sRet = "洗消步骤全部结束";
                            //    }

                            //}
                            else
                            {
                                string temp = "结束";
                                if (curr_node.GetNext() != null)
                                {
                                    temp = curr_node.GetNext().GetStepName();
                                }
                                sRet = "下一步:" + temp;
                            }
                        }
                    }
                }

                TaskInfo info = new TaskInfo(ClientIP, card, mState.WorkCard, curr_node.GetDur(), curr_node.GetStepNum(), curr_node.GetCleanGroup(), sRet, bstart);
                if (bFinish)
                {
                    TaskCallBack(info);
                }
                else
                {
                    UpdateUIDelegate(info);
                }

                return(bFinish);
            }
        }