Ejemplo n.º 1
0
        public void SaveFaceLog(string LogStr)
        {
            byte[]                              PhotoImage         = null;
            DataTableReader                     dr                 = null;
            int                                 InOutMode          = 0;
            int                                 VerifyStatus       = 0;
            int                                 VerifyType         = 0;
            int                                 DevMode            = 0;
            VerifyPush <VerifyPushInfo>         verifyPush         = null;
            VerifyPush <RemoteOpenDoorPushInfo> remoteOpenDoorPush = null;

            if (LogStr.Contains("RemoteOpenDoorPush"))
            {
                remoteOpenDoorPush = JsonConvert.DeserializeObject <VerifyPush <RemoteOpenDoorPushInfo> >(LogStr);
                MacSN         = remoteOpenDoorPush.info.DeviceID.ToString();
                attLog.Remark = "";
                UInt32 FingerNo = 0;
                attLog          = new TFingerLog();
                attLog.CardID   = FingerNo.ToString("0000000000");
                attLog.CardTime = DateTime.Parse(remoteOpenDoorPush.info.CreateTime);
                attLog.FingerNo = FingerNo;
                VerifyStatus    = 27;
                VerifyType      = remoteOpenDoorPush.info.VerfyType;
            }
            else
            {
                verifyPush    = JsonConvert.DeserializeObject <VerifyPush <VerifyPushInfo> >(LogStr);
                MacSN         = verifyPush.info.DeviceID.ToString();
                attLog.Remark = verifyPush.info.Notes;
                if (verifyPush.info.CustomizeID < 0)
                {
                    verifyPush.info.CustomizeID = 0;
                }
                UInt32 FingerNo = (UInt32)verifyPush.info.CustomizeID;
                attLog                  = new TFingerLog();
                attLog.CardID           = FingerNo.ToString("0000000000");
                attLog.CardTime         = DateTime.Parse(verifyPush.info.CreateTime);
                attLog.FingerNo         = FingerNo;
                attLog.Temperature      = verifyPush.info.Temperature;
                attLog.TemperatureAlarm = verifyPush.info.TemperatureAlarm;
                VerifyType              = verifyPush.info.VerfyType;
                VerifyStatus            = verifyPush.info.VerifyStatus;
                if (verifyPush.SanpPic != null)
                {
                    PhotoImage = Convert.FromBase64String(verifyPush.SanpPic.Replace("data:image/jpeg;base64,", ""));
                }
                else
                {
                    PhotoImage = new byte[0];
                }
            }
            dr = SystemInfo.db.GetDataReader("SELECT * FROM VDI_MacInfo WHERE MacSN='" + MacSN + "'");
            if (dr.Read())
            {
                int.TryParse(dr["InOutMode"].ToString(), out InOutMode);
                int.TryParse(dr["DevModeID"].ToString(), out DevMode);
            }
            dr.Close();
            readData.Sea_SetLogName(attLog, InOutMode, VerifyStatus, VerifyType);
            if (attLog.VerifyMode == 2 || attLog.VerifyMode == 3)
            {
                pidLog.Name  = verifyPush.info.Name;
                pidLog.Time  = attLog.CardTime;
                pidLog.MacSN = MacSN;
                if (verifyPush.info.Gender == 0)
                {
                    pidLog.Gender = Pub.GetResText("Public", "EmpSex0", "");
                }
                else if (verifyPush.info.Gender == 1)
                {
                    pidLog.Gender = Pub.GetResText("Public", "EmpSex1", "");
                }
                else
                {
                    pidLog.Gender = "";
                }
                pidLog.Birthday         = DateTime.Parse(verifyPush.info.Birthday);
                pidLog.CardType         = Pub.GetResText("Public", "LOG_IDCARD", "");
                pidLog.EmpCertNo        = verifyPush.info.IdCard;
                pidLog.EmpAddress       = verifyPush.info.Address;
                pidLog.InOutMode        = attLog.InOutMode;
                pidLog.InOutModeName    = attLog.InOutModeName;
                pidLog.Temperature      = verifyPush.info.Temperature;
                pidLog.TemperatureAlarm = verifyPush.info.TemperatureAlarm;
                pidLog.Nation           = readData.Sea_GetNation(verifyPush.info.Nation);

                readData.SavePID(pidLog, ref GUID);//人证记录表
                if (GUID != "" && PhotoImage != null)
                {
                    readData.SavePIDPhoto(GUID, PhotoImage);
                }
            }
            readData.WriteTextFile(attLog, MacSN);
            if (textFormat.Allow)
            {
                readData.WriteTextFormat(textFormat, attLog, MacSN);
            }
            if (DevMode == 0 || DevMode == 1)
            {
                readData.SaveDB(attLog, MacSN, true, ref GUID);
                if (GUID != "")
                {
                    if (PhotoImage != null)
                    {
                        readData.SaveDBPhoto(GUID, PhotoImage);
                    }
                }
            }

            if (attLog.VerifyMode == 0 || (attLog.VerifyMode != 2 && attLog.VerifyMode != 3))
            {
                attLog.VerifyMode     = attLog.DoorMode;
                attLog.VerifyModeName = attLog.DoorModeName;
            }

            readData.WriteTextFileMJ(attLog, MacSN);
            if (DevMode == 0 || DevMode == 2)
            {
                readData.SaveDBMJ(attLog, MacSN, true, ref GUID);
                if (GUID != "")
                {
                    if (PhotoImage != null)
                    {
                        readData.SaveDBPhotoMJ(GUID, PhotoImage);
                    }
                }
            }
            if (prog != null)
            {
                prog(1, 1, MacSN, attLog, GUID, true);
            }
        }