Example #1
0
        private bool MJPowerDownload(string MacSN, ref string MacMsg)
        {
            bool ret   = true;
            int  Count = 0;
            List <ExtCmd_USERDOORINFO> uiList = new List <ExtCmd_USERDOORINFO>();

            byte[] byt             = new byte[((int)FKMax.SIZE_USERDOORINFO_V1) + 64];
            ExtCmd_USERDOORINFO ui = new ExtCmd_USERDOORINFO();

            for (int i = 0; i < fingerNoList.Count; i++)
            {
                ui.Init(false, fingerNoList[i]);
                DeviceObject.objFK623.StructToByteArray(ui, byt);
                ret = DeviceObject.objFK623.ExtCommand(byt);
                if (!ret)
                {
                    Count++;
                    if (Count == fingerNoList.Count)
                    {
                        return(MJPowerDownload(MacSN, ref MacMsg, false));
                    }

                    continue;
                }

                ui = (ExtCmd_USERDOORINFO)DeviceObject.objFK623.ByteArrayToStruct(byt, typeof(ExtCmd_USERDOORINFO));
                uiList.Add(ui);
            }
            if (uiList.Count > 0)
            {
                DeviceObject.objFK623.RunCode = (int)FKRun.RUN_SUCCESS;
                ret = true;
                string          sql       = "";
                DataTableReader dr        = null;
                string          SysID     = MacSN.ToString();
                string          EmpNo     = "";
                string          SunID     = "";
                string          MonID     = "";
                string          TueID     = "";
                string          WedID     = "";
                string          ThuID     = "";
                string          FriID     = "";
                string          SatID     = "";
                string          StartDate = "";
                string          EndDate   = "";
                DateTime        dt;
                try
                {
                    for (int i = 0; i < uiList.Count; i++)
                    {
                        ui  = uiList[i];
                        ret = SystemInfo.db.GetEmpNoByFingerNo(ui.UserID, ref EmpNo);
                        if (!ret)
                        {
                            break;
                        }
                        SunID     = ui.WeekPassTime[0].ToString();
                        MonID     = ui.WeekPassTime[1].ToString();
                        TueID     = ui.WeekPassTime[2].ToString();
                        WedID     = ui.WeekPassTime[3].ToString();
                        ThuID     = ui.WeekPassTime[4].ToString();
                        FriID     = ui.WeekPassTime[5].ToString();
                        SatID     = ui.WeekPassTime[6].ToString();
                        StartDate = "NULL";
                        dt        = new DateTime();
                        try
                        {
                            dt        = new DateTime(ui.StartYear, ui.StartMonth, ui.StartDay);
                            StartDate = "'" + dt.ToString(SystemInfo.SQLDateFMT) + "'";
                        }
                        catch
                        {
                        }
                        EndDate = "NULL";
                        try
                        {
                            dt      = new DateTime(ui.EndYear, ui.EndMonth, ui.EndDay);
                            EndDate = "'" + dt.ToString(SystemInfo.SQLDateFMT) + "'";
                        }
                        catch
                        {
                        }
                        dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "503", SysID, EmpNo }));
                        if (dr.Read())
                        {
                            sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "505", SysID, EmpNo, SunID, MonID, TueID, WedID, ThuID,
                                                                              FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate });
                        }
                        else
                        {
                            sql = Pub.GetSQL(DBCode.DB_000300, new string[] { "504", SysID, EmpNo, SunID, MonID, TueID, WedID, ThuID,
                                                                              FriID, SatID, OprtInfo.OprtNo, StartDate, EndDate });
                        }
                        dr.Close();
                        SystemInfo.db.ExecSQL(sql);
                    }
                }
                catch (Exception E)
                {
                    ret = false;
                    Pub.ShowErrorMsg(E);
                }
                finally
                {
                    if (dr != null)
                    {
                        dr.Close();
                    }
                    dr = null;
                }
            }
            return(ret);
        }
Example #2
0
        private bool MJPowerUpload(string MacSN, ref string MacMsg)
        {
            bool ret = true;
            List <ExtCmd_USERDOORINFO> uiList            = new List <ExtCmd_USERDOORINFO>();
            List <UserWeekPassTime>    vUserPassTimeList = new List <UserWeekPassTime>();
            UserWeekPassTime           vUserPassTime;
            ExtCmd_USERDOORINFO        ui;
            DataTableReader            dr = null;
            DateTime dt;

            try
            {
                dr = SystemInfo.db.GetDataReader(Pub.GetSQL(DBCode.DB_000300, new string[] { "500", MacSN.ToString() }));
                while (dr.Read())
                {
                    for (int i = 0; i < GUID.Count; i++)
                    {
                        if (GUID[i].Equals(dr["GUID"].ToString()))
                        {
                            ui = new ExtCmd_USERDOORINFO();
                            ui.Init(true, Convert.ToUInt32(dr["FingerNo"].ToString()));
                            ui.WeekPassTime[0] = Convert.ToByte(dr["SunID"].ToString());
                            ui.WeekPassTime[1] = Convert.ToByte(dr["MonID"].ToString());
                            ui.WeekPassTime[2] = Convert.ToByte(dr["TueID"].ToString());
                            ui.WeekPassTime[3] = Convert.ToByte(dr["WedID"].ToString());
                            ui.WeekPassTime[4] = Convert.ToByte(dr["ThuID"].ToString());
                            ui.WeekPassTime[5] = Convert.ToByte(dr["FriID"].ToString());
                            ui.WeekPassTime[6] = Convert.ToByte(dr["SatID"].ToString());
                            vUserPassTime      = new UserWeekPassTime();
                            //无有效期
                            vUserPassTime.Init();
                            vUserPassTime.UserID          = Convert.ToUInt32(dr["FingerNo"].ToString());
                            vUserPassTime.WeekPassTime[0] = Convert.ToByte(dr["SunID"].ToString());
                            vUserPassTime.WeekPassTime[1] = Convert.ToByte(dr["MonID"].ToString());
                            vUserPassTime.WeekPassTime[2] = Convert.ToByte(dr["TueID"].ToString());
                            vUserPassTime.WeekPassTime[3] = Convert.ToByte(dr["WedID"].ToString());
                            vUserPassTime.WeekPassTime[4] = Convert.ToByte(dr["ThuID"].ToString());
                            vUserPassTime.WeekPassTime[5] = Convert.ToByte(dr["FriID"].ToString());
                            vUserPassTime.WeekPassTime[6] = Convert.ToByte(dr["SatID"].ToString());

                            vUserPassTimeList.Add(vUserPassTime);
                            try
                            {
                                dt            = Convert.ToDateTime(dr["StartDate"].ToString());
                                ui.StartYear  = (short)dt.Year;
                                ui.StartMonth = (byte)dt.Month;
                                ui.StartDay   = (byte)dt.Day;
                            }
                            catch
                            {
                            }
                            try
                            {
                                dt          = Convert.ToDateTime(dr["EndDate"].ToString());
                                ui.EndYear  = (short)dt.Year;
                                ui.EndMonth = (byte)dt.Month;
                                ui.EndDay   = (byte)dt.Day;
                            }
                            catch
                            {
                            }
                            uiList.Add(ui);
                        }
                    }
                }
            }
            catch (Exception E)
            {
                ret = false;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (ret && uiList.Count > 0)
            {
                byte[] byt             = new byte[((int)FKMax.SIZE_USERDOORINFO_V1) + 64];
                byte[] bytUserPassTime = new byte[(int)FKMax.SIZE_USER_WEEK_PASS_TIME_STRUCT];
                for (int i = 0; i < uiList.Count; i++)
                {
                    ui = uiList[i];

                    if (ui.EndYear == 0 && ui.StartYear == 0)
                    {
                        DeviceObject.objFK623.StructToByteArray(vUserPassTimeList[i], bytUserPassTime);
                        ret = DeviceObject.objFK623.HS_SetUserWeekPassTime(bytUserPassTime);
                        continue;
                    }

                    if (ui.StartYear == 0)
                    {
                        ui.StartYear = 1900;
                    }


                    DeviceObject.objFK623.StructToByteArray(ui, byt);
                    ret = DeviceObject.objFK623.ExtCommand(byt);
                    if (!ret)
                    {
                        //break;
                        DeviceObject.objFK623.StructToByteArray(vUserPassTimeList[i], bytUserPassTime);
                        ret = DeviceObject.objFK623.HS_SetUserWeekPassTime(bytUserPassTime);
                    }
                }
            }
            return(ret);
        }
Example #3
0
        private bool MJPowerUpload(int MacSN, ref string MacMsg)
        {
            bool ret = true;
            List <ExtCmd_USERDOORINFO> uiList = new List <ExtCmd_USERDOORINFO>();
            ExtCmd_USERDOORINFO        ui;
            DataTableReader            dr = null;
            DateTime dt;

            try
            {
                dr = db.GetDataReader(Pub.GetSQL(DBCode.DB_002001, new string[] { "4000", MacSN.ToString() }));
                while (dr.Read())
                {
                    ui = new ExtCmd_USERDOORINFO();
                    ui.Init(true, Convert.ToUInt32(dr["CardFingerNo"].ToString()));
                    ui.WeekPassTime[0] = Convert.ToByte(dr["SunID"].ToString());
                    ui.WeekPassTime[1] = Convert.ToByte(dr["MonID"].ToString());
                    ui.WeekPassTime[2] = Convert.ToByte(dr["TueID"].ToString());
                    ui.WeekPassTime[3] = Convert.ToByte(dr["WedID"].ToString());
                    ui.WeekPassTime[4] = Convert.ToByte(dr["ThuID"].ToString());
                    ui.WeekPassTime[5] = Convert.ToByte(dr["FriID"].ToString());
                    ui.WeekPassTime[6] = Convert.ToByte(dr["SatID"].ToString());
                    try
                    {
                        dt            = Convert.ToDateTime(dr["StartDate"].ToString());
                        ui.StartYear  = (short)dt.Year;
                        ui.StartMonth = (byte)dt.Month;
                        ui.StartDay   = (byte)dt.Day;
                    }
                    catch
                    {
                    }
                    try
                    {
                        dt          = Convert.ToDateTime(dr["EndDate"].ToString());
                        ui.EndYear  = (short)dt.Year;
                        ui.EndMonth = (byte)dt.Month;
                        ui.EndDay   = (byte)dt.Day;
                    }
                    catch
                    {
                    }
                    uiList.Add(ui);
                }
            }
            catch (Exception E)
            {
                ret = false;
                Pub.ShowErrorMsg(E);
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
                dr = null;
            }
            if (ret && uiList.Count > 0)
            {
                byte[] byt = new byte[((int)FKMax.SIZE_USERDOORINFO_V1) + 64];
                for (int i = 0; i < uiList.Count; i++)
                {
                    ui = uiList[i];
                    DeviceObject.objFK623.StructToByteArray(ui, byt);
                    ret = DeviceObject.objFK623.ExtCommand(byt);
                    if (!ret)
                    {
                        break;
                    }
                }
            }
            return(ret);
        }