예제 #1
0
        private void LoadTextFormat()
        {
            DataTableReader dr = null;

            try
            {
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_000001, new string[] { "112", KQTextFormatInfo.KQ_ConfigID,
                                                                                  KQTextFormatInfo.KQ_TextFormat }));
                if (dr.Read())
                {
                    textFormat = new KQTextFormatInfo(dr["Value"].ToString());
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
        }
예제 #2
0
 public RequestHelper(Database db, HttpListenerRequest request, Label label, ECard78.FingerReadData.ProcessSeaRealData prog, KQTextFormatInfo textFormat)
 {
     this.db         = db;
     this.request    = request;
     this.label      = label;
     this.prog       = prog;
     this.textFormat = textFormat;
 }
예제 #3
0
        private void WriteTextFormat(Database db, KQTextFormatInfo textFormat, TAttLog attLog, int MacSN)
        {
            if (attLog.CardTime == null || attLog.CardTime.ToOADate() == 0)
            {
                return;
            }
            DataTableReader dr      = null;
            string          EmpNo   = "";
            string          EmpName = "";
            bool            IsError = false;

            try
            {
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "106", SystemInfo.CardType.ToString(),
                                                                                  attLog.CardID }));
                if (dr.Read())
                {
                    EmpNo   = dr["EmpNo"].ToString();
                    EmpName = dr["EmpName"].ToString();
                }
            }
            catch (Exception E)
            {
                IsError = true;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (IsError)
            {
                return;
            }
            DateTime t        = Convert.ToDateTime(attLog.CardTime);
            string   fileName = SystemInfo.DataFilePath + "KQ" + t.ToString(SystemInfo.DateFormatLog) + "_Format.txt";
            string   msg      = textFormat.GetKQFormatText(MacSN, EmpNo, EmpName, attLog.CardID, t);

            Pub.WriteTextFile(fileName, msg);
        }
예제 #4
0
        public bool ReadDataReal(string RealData, Database db, KQTextFormatInfo textFormat, int MacSN, string Version,
                                 ref int RecordCount, ref int LogID, ProcessRealData prog)
        {
            bool ret = false;

            RecordCount = 0;
            LogID       = 0;
            try
            {
                ret = DeviceObject.objKS.AttLogDataReal(RealData, Version, ref RecordCount, ref LogID);
                for (int j = 0; j < RecordCount; j++)
                {
                    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)
                        {
                            RecordCount = RecordCount - 1;
                        }
                        if (prog != null)
                        {
                            prog(attLog, MacSN);
                        }
                    }
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            return(ret);
        }
예제 #5
0
 public void Setup(Database db, int port, Label label, KQTextFormatInfo textFormat, ECard78.FingerReadData.ProcessSeaRealData prog)
 {
     try
     {
         this.db         = db;
         this.label      = label;
         this.prog       = prog;
         this.textFormat = textFormat;
         if (port == 0)
         {
             stop = true;
             httpListener.Close();
             return;
         }
         stop = false;
         httpListener.AuthenticationSchemes = AuthenticationSchemes.Anonymous;
         httpListener.Prefixes.Add(string.Format("http://*:{0}/", port));
         httpListener.Start();
         Receive();
     }
     catch
     {
     }
 }
예제 #6
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);
        }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
 public bool ReadData(Database db, KQTextFormatInfo textFormat, int MacSN, ref int RecordCount,
                      ref int RecordIndex, bool AutoRetry, ProcessRealData prog)
 {
     return(ReadData(db, textFormat, MacSN, ref RecordCount, ref RecordIndex, AutoRetry, null, prog));
 }
예제 #10
0
        private void LoadTextFormat()
        {
            DataTableReader dr = null;

            try
            {
                if (!db.IsOpen)
                {
                    db.Open(SystemInfo.ConnStr);
                }
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_000001, new string[] { "112", KQTextFormatInfo.KQ_ConfigID,
                                                                                  KQTextFormatInfo.KQ_TextFormat }));
                if (dr.Read())
                {
                    textFormat = new KQTextFormatInfo(dr["Value"].ToString());
                }
            }
            catch (Exception E)
            {
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            chkAllow.Checked    = textFormat.Allow;
            rbSepNo.Checked     = textFormat.SepFlag == 0;
            rbSepTAB.Checked    = textFormat.SepFlag == 1;
            rbSepCustom.Checked = textFormat.SepFlag == 2;
            if (!rbSepNo.Checked && rbSepTAB.Checked && rbSepCustom.Checked)
            {
                rbSepNo.Checked = true;
            }

            txtSep.Text         = textFormat.SepStr;
            chkMacSN.Checked    = textFormat.MacSNAllow;
            txtMacSN.Text       = textFormat.MacSNLen.ToString();
            txtMacSN.Tag        = textFormat.MacSNOrder;
            chkEmpNo.Checked    = textFormat.EmpNoAllow;
            txtEmpNo.Text       = textFormat.EmpNoLen.ToString();
            txtEmpNo.Tag        = textFormat.EmpNoOrder;
            chkEmpName.Checked  = textFormat.EmpNameAllow;
            txtEmpName.Text     = textFormat.EmpNameLen.ToString();
            txtEmpName.Tag      = textFormat.EmpNameOrder;
            chkCardNo.Checked   = textFormat.CardNoAllow;
            txtCardNo.Text      = textFormat.CardNoLen.ToString();
            txtCardNo.Tag       = textFormat.CardNoOrder;
            chkDataTime.Checked = textFormat.DataTimeAllow;
            txtDataTime.Text    = textFormat.DataTimeFormat;
            txtDataTime.Tag     = textFormat.DataTimeOrder;
            chkOrder.Items.Clear();
            if (textFormat.EmpNoOrder == 0)
            {
                chkOrder.Items.Add(chkEmpNo.Text);
            }
            else if (textFormat.EmpNameOrder == 0)
            {
                chkOrder.Items.Add(chkEmpName.Text);
            }
            else if (textFormat.CardNoOrder == 0)
            {
                chkOrder.Items.Add(chkCardNo.Text);
            }
            else if (textFormat.DataTimeOrder == 0)
            {
                chkOrder.Items.Add(chkDataTime.Text);
            }
            else
            {
                chkOrder.Items.Add(chkMacSN.Text);
            }
            if (textFormat.MacSNOrder == 1)
            {
                chkOrder.Items.Add(chkMacSN.Text);
            }
            else if (textFormat.EmpNoOrder == 1)
            {
                chkOrder.Items.Add(chkEmpNo.Text);
            }
            else if (textFormat.EmpNameOrder == 1)
            {
                chkOrder.Items.Add(chkEmpName.Text);
            }
            else if (textFormat.CardNoOrder == 1)
            {
                chkOrder.Items.Add(chkCardNo.Text);
            }
            else if (textFormat.DataTimeOrder == 1)
            {
                chkOrder.Items.Add(chkDataTime.Text);
            }
            if (textFormat.MacSNOrder == 2)
            {
                chkOrder.Items.Add(chkMacSN.Text);
            }
            else if (textFormat.EmpNoOrder == 2)
            {
                chkOrder.Items.Add(chkEmpNo.Text);
            }
            else if (textFormat.EmpNameOrder == 2)
            {
                chkOrder.Items.Add(chkEmpName.Text);
            }
            else if (textFormat.CardNoOrder == 2)
            {
                chkOrder.Items.Add(chkCardNo.Text);
            }
            else if (textFormat.DataTimeOrder == 2)
            {
                chkOrder.Items.Add(chkDataTime.Text);
            }
            if (textFormat.MacSNOrder == 3)
            {
                chkOrder.Items.Add(chkMacSN.Text);
            }
            else if (textFormat.EmpNoOrder == 3)
            {
                chkOrder.Items.Add(chkEmpNo.Text);
            }
            else if (textFormat.EmpNameOrder == 3)
            {
                chkOrder.Items.Add(chkEmpName.Text);
            }
            else if (textFormat.CardNoOrder == 3)
            {
                chkOrder.Items.Add(chkCardNo.Text);
            }
            else if (textFormat.DataTimeOrder == 3)
            {
                chkOrder.Items.Add(chkDataTime.Text);
            }
            if (textFormat.MacSNOrder == 4)
            {
                chkOrder.Items.Add(chkMacSN.Text);
            }
            else if (textFormat.EmpNoOrder == 4)
            {
                chkOrder.Items.Add(chkEmpNo.Text);
            }
            else if (textFormat.EmpNameOrder == 4)
            {
                chkOrder.Items.Add(chkEmpName.Text);
            }
            else if (textFormat.CardNoOrder == 4)
            {
                chkOrder.Items.Add(chkCardNo.Text);
            }
            else if (textFormat.DataTimeOrder == 4)
            {
                chkOrder.Items.Add(chkDataTime.Text);
            }
        }
예제 #11
0
 private void btnShowFormat_Click(object sender, EventArgs e)
 {
     textFormat     = new KQTextFormatInfo(GetFieldsString());
     txtFormat.Text = textFormat.GetKQFormatText(1, "E0001", "ZhangSan", "1", DateTime.Now);
 }