Beispiel #1
0
 public void ActiveProcessRead(IotCentral iotConfigurations,
                               ProcessReadData.NotificarPuertoDelegate urgencia  = null,
                               ProcessReadData.NotificarPuertoDelegate notificar = null)
 {
     this._activeProcessRead = true;
     this._processReadData   = new ProcessReadData(iotConfigurations, this._writeFunction, urgencia, notificar);
 }
Beispiel #2
0
 public void ChangeConfigurationRead(IotCentral iotConfigurations)
 {
     this._processReadData = new ProcessReadData(iotConfigurations, this._writeFunction);
 }
Beispiel #3
0
        public bool ReadDataText(string textFile, Database db, KQTextFormatInfo textFormat, ref int RecordCount,
                                 ref int RecordIndex, ProcessReadData prog)
        {
            bool ret = false;

            RecordCount = 0;
            RecordIndex = 0;
            StreamReader   sr = null;
            string         line;
            List <TAttLog> logList = new List <TAttLog>();
            List <int>     snList  = new List <int>();
            int            MacSN   = 0;

            try
            {
                sr = new StreamReader(textFile);
                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine();
                    if (line != "")
                    {
                        attLog          = new TAttLog();
                        attLog.ReadMark = Convert.ToByte(line.Substring(0, 2));
                        attLog.CardID   = line.Substring(2, 10);
                        if (line.Length == 45)
                        {
                            attLog.PhyID    = line.Substring(12, 10);
                            attLog.MacTAG   = line.Substring(22, 4);
                            attLog.CardTime = new DateTime(Convert.ToInt16(line.Substring(26, 4)),
                                                           Convert.ToByte(line.Substring(30, 2)), Convert.ToByte(line.Substring(32, 2)),
                                                           Convert.ToByte(line.Substring(34, 2)), Convert.ToByte(line.Substring(36, 2)),
                                                           Convert.ToByte(line.Substring(38, 2)));
                            MacSN = Convert.ToInt32(line.Substring(40, 5));
                        }
                        else
                        {
                            attLog.PhyID    = "";
                            attLog.MacTAG   = "";
                            attLog.CardTime = new DateTime(Convert.ToInt16(line.Substring(12, 4)),
                                                           Convert.ToByte(line.Substring(16, 2)), Convert.ToByte(line.Substring(18, 2)),
                                                           Convert.ToByte(line.Substring(20, 2)), Convert.ToByte(line.Substring(22, 2)),
                                                           Convert.ToByte(line.Substring(24, 2)));
                            MacSN = Convert.ToInt32(line.Substring(26, 5));
                        }
                        logList.Add(attLog);
                        snList.Add(MacSN);
                        RecordCount++;
                    }
                }
                for (int i = 0; i < RecordCount; i++)
                {
                    attLog = logList[i];
                    MacSN  = snList[i];
                    SaveDB(db, attLog, MacSN);
                    RecordIndex = RecordIndex + 1;
                    if (RecordIndex > RecordCount)
                    {
                        RecordIndex = RecordCount;
                    }
                    prog(RecordCount, RecordIndex);
                }
                ret = true;
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
            return(ret);
        }
Beispiel #4
0
        public bool ReadDataUSB(string usbFile, Database db, KQTextFormatInfo textFormat, ref int RecordCount,
                                ref int RecordIndex, ProcessReadData prog)
        {
            bool ret = false;

            RecordCount = 0;
            RecordIndex = 0;
            TRecordCountUSB recCount = new TRecordCountUSB();
            bool            IsBigMac = false;

            try
            {
                ret = DeviceObject.objKS.AttLogCountUSB(IsBigMac, usbFile, ref recCount);
                if (!ret)
                {
                    Pub.MessageBoxShow(Pub.GetResText("", "ErrorKQUSB", ""));
                    return(false);
                }
                if (recCount.MacType != 1)
                {
                    Pub.MessageBoxShow(Pub.GetResText("", "ErrorKQUSBType", ""));
                    return(false);
                }
                RecordCount = recCount.Count;
                int    MacSN    = recCount.MacSN;
                int    CardType = recCount.CardType;
                string MacVer   = recCount.Ver;
                if (RecordCount == 0)
                {
                    ret = true;
                }
                for (int i = 1; i <= recCount.Sector; i++)
                {
                    ret = DeviceObject.objKS.AttLogDataUSB(IsBigMac, MacVer, i, ref logCount);
                    if (ret)
                    {
                        for (int j = 0; j < logCount; j++)
                        {
                            if (RecordIndex >= recCount.Count)
                            {
                                break;
                            }
                            if (DeviceObject.objKS.AttLogDataValue(j, ref attLog))
                            {
                                WriteTextFile(attLog, MacSN);
                                if (textFormat.Allow)
                                {
                                    WriteTextFormat(db, textFormat, attLog, MacSN);
                                }
                                SaveDB(db, attLog, MacSN);
                                if (attLog.IsCount != 0)
                                {
                                    RecordIndex = RecordIndex + 1;
                                }
                                if (RecordIndex > recCount.Count)
                                {
                                    RecordIndex = recCount.Count;
                                }
                                prog(recCount.Count, RecordIndex);
                            }
                        }
                    }
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            return(ret);
        }
Beispiel #5
0
        private bool ReadData(Database db, KQTextFormatInfo textFormat, int MacSN, ref int RecordCount,
                              ref int RecordIndex, bool AutoRetry, ProcessReadData prog, ProcessRealData progReal)
        {
            RecordCount = 0;
            RecordIndex = 0;
            bool         ret      = false;
            TRecordCount recCount = new TRecordCount();

            if (!DeviceObject.objKS.AttLogCount(IsNew, ref recCount))
            {
                return(false);
            }
            RecordCount = recCount.Count;
            if (RecordCount == 0)
            {
                return(true);
            }
            DialogResult result;

            for (int i = 1; i <= recCount.Sector; i++)
            {
RetryReadData:
                if (IsStop)
                {
                    DeviceObject.objKS.Close();
                    break;
                }
                Application.DoEvents();
                ret = DeviceObject.objKS.AttLogData(SystemInfo.DataFilePath, IsNew, i, ref logCount);
                if (!ret)
                {
                    if (AutoRetry)
                    {
                        goto RetryReadData;
                    }
                    result = Pub.MessageBoxQuestion(cap + "\r\n\r\n" + DeviceObject.objKS.ErrMsg + "\r\n\r\n" + msgContinue,
                                                    MessageBoxButtons.AbortRetryIgnore);
                    if (result == DialogResult.Abort)
                    {
                        break;
                    }
                    else if (result == DialogResult.Ignore)
                    {
                        continue;
                    }
                    else
                    {
                        goto RetryReadData;
                    }
                }
                for (int j = 0; j < logCount; j++)
                {
                    if (RecordIndex >= recCount.Count)
                    {
                        break;
                    }
                    if (DeviceObject.objKS.AttLogDataValue(j, ref attLog))
                    {
                        WriteTextFile(attLog, MacSN);
                        if (textFormat.Allow)
                        {
                            WriteTextFormat(db, textFormat, attLog, MacSN);
                        }
                        SaveDB(db, attLog, MacSN);
                        if (attLog.IsCount != 0)
                        {
                            RecordIndex = RecordIndex + 1;
                        }
                        if (RecordIndex > recCount.Count)
                        {
                            RecordIndex = recCount.Count;
                        }
                        if (prog != null)
                        {
                            prog(recCount.Count, RecordIndex);
                        }
                        if (progReal != null)
                        {
                            progReal(attLog, MacSN);
                        }
                    }
                }
            }
            if (ret && IsNew && recCount.Count > 0 && !IsStop)
            {
RetryFlag:
                ret = DeviceObject.objKS.AttLogFlag(recCount.Count);
                if (!ret)
                {
                    if (AutoRetry)
                    {
                        goto RetryFlag;
                    }
                    if (!Pub.MessageBoxShowQuestion(cap + "\r\n\r\n" +
                                                    DeviceObject.objKS.ErrMsg + "\r\n\r\n" + msgContinue))
                    {
                        goto RetryFlag;
                    }
                }
            }
            return(ret);
        }
Beispiel #6
0
 public bool ReadData(Database db, KQTextFormatInfo textFormat, int MacSN, ref int RecordCount,
                      ref int RecordIndex, bool AutoRetry, ProcessReadData prog)
 {
     return(ReadData(db, textFormat, MacSN, ref RecordCount, ref RecordIndex, AutoRetry, prog, null));
 }