示例#1
0
        internal void init(string filename)
        {
            string xmlContent = string.Empty;

            _filename  = filename;
            xmlContent = File.ReadAllText(filename);

            using (XmlReader reader = XmlReader.Create(new StringReader(xmlContent)))
            {
                reader.ReadToFollowing("Date");
                _date = reader.ReadElementContentAsDateTime();
                reader.ReadToFollowing("ZeroTime");
                _zeroTime = reader.ReadElementContentAsInt();

                int    id;
                string name;
                //int start;
                //int finish;
                int    status;
                int    cardNo;
                int    startNo;
                int    classe;
                string punchesstr;
                int    cardReadId;
                int    cardId;

                while (reader.ReadToFollowing("Runner"))
                {
                    try
                    {
                        reader.ReadToFollowing("Id"); id     = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Name"); name = reader.ReadElementContentAsString();
                        //reader.ReadToFollowing("Start"); start = reader.ReadElementContentAsInt();
                        //reader.ReadToFollowing("Finish"); finish = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Status"); status      = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("CardNo"); cardNo      = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("StartNo"); startNo    = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Class"); classe       = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Punches"); punchesstr = reader.ReadElementContentAsString();
                        reader.ReadToFollowing("ReadId"); cardReadId  = reader.ReadElementContentAsInt();
                        reader.ReadToFollowing("Id"); cardId          = reader.ReadElementContentAsInt();

                        runner r = new runner(id, name, /*start, finish, */ status, cardNo, startNo, classe, punchesstr, cardReadId, cardId, _postes);
                        if (r.Start < _firstStart)
                        {
                            _firstStart = r.Start;
                        }
                        if (r.Finish > _lastFinish)
                        {
                            _lastFinish = r.Finish;
                        }
                        _runners.Add(r);
                    }
                    catch (Exception ex)
                    {
                        dbg = ex.Message;
                    }
                }
            }
            _postes.Sort();
        }
示例#2
0
        private void mainTimer_Tick(object sender, EventArgs e)
        {
            bool done       = false;
            bool isjumpNext = jumpNext;

            while (!done)
            {
                currentTime         = currentTime.AddMilliseconds(speedFactorIncr);// = new DateTime(DateTime.Now.Subtract(refTime).Add(new TimeSpan(startTime.Ticks)).Ticks);
                currentTextBox.Text = currentTime.ToLongTimeString();

                int nowsec = (int)(new TimeSpan(currentTime.Hour, currentTime.Minute, currentTime.Second).TotalSeconds);

                int tickTime = nowsec - _worker.ZeroTime;

                List <object[]> lo = _worker.tick(tickTime);
                if (lo.Count > 0)
                {
                    foreach (object[] oo in lo)
                    {
                        runner r = oo[0] as runner;
                        //oo[0] runner
                        //oo[1] punchesok (si plusieurs)
                        // ou
                        //oo[0] runner   a fini
                        if (oo.Length == 2)
                        {
                            List <int[]> pok = oo[1] as List <int[]>;
                            foreach (int[] p in pok)
                            {
                                // cherchons si ce poste est checké !
                                string info = currentTime.ToLongTimeString() + "\t" + p[0].ToString() + "\t" + r.Name;
                                logFullTextBox.AppendText(info);
                                int index = _checkedRadio.IndexOf(p[0]);
                                if (index >= 0)
                                {
                                    done = true;

                                    int timeCode = (p[1] + _worker.ZeroTime) * 10;
                                    _actionToDo.Enqueue(new object[] { actionType.ePunch, p[0], r.CardNo, timeCode, info + "\t* RADIO *" + Environment.NewLine });
                                    logFullTextBox.AppendText("\t* RADIO *");

                                    //_sender.sendPunch(p[0], r.CardNo, timeCode);
                                    //logTextBox.AppendText(currentTime.ToLongTimeString() + "\t" + p[0].ToString() + "\t" + r.Name + "\t* RADIO *" + Environment.NewLine);
                                }
                                logFullTextBox.AppendText(Environment.NewLine);
                            }
                        }
                        else
                        if (oo.Length == 1)
                        {
                            done = true;
                            //_sender.sendCard(r.CardNo, r.Card.Punches, _worker.ZeroTime);
                            string info = currentTime.ToLongTimeString() + "\t" + r.Name + "\t* FINISH **********" + Environment.NewLine;
                            logFullTextBox.AppendText(info);
                            _actionToDo.Enqueue(new object[] { actionType.eCard, r.CardNo, r.Card.Punches, _worker.ZeroTime, info });
                            //logTextBox.AppendText(currentTime.ToLongTimeString() + "\t" + r.Name + "\t* FINISH *" + Environment.NewLine);
                        }
                    }
                }

                if (currentTime.CompareTo(stopTime) > 0)
                {
                    done = true;
                    stopButton_Click(null, null);
                }
                if (!isjumpNext)
                {
                    done = true;// on attendra la suite
                }
                if (!isjumpNext)
                {
                    Application.DoEvents();
                }
            }
            if (isjumpNext)
            {
                jumpNext = false;
            }
        }