Example #1
0
        /// <summary>
        /// 同步数据从DB到设备
        /// </summary>
        public static void CopyDataToDev()
        {
            try
            {
                KQInfo DAccess = new KQInfo(Common.GetDataConnection(DataCollection.Config.FRASConnectionString, SND.DA.DataAccessHelper.DataSourceType.SqlClient));
                DataTable dt = DAccess.GetCopyData();
                List<CopyData> list = new List<CopyData>();
                if (dt != null && dt.Rows.Count > 0)
                {

                    foreach (DataRow row in dt.Rows)
                    {
                        int dwFlag = row["flag"] is DBNull ? 0 : System.Convert.ToInt32(row["flag"]);
                        int dwCopyType = System.Convert.ToInt32(row["copyType"]);
                        int dwAntNum = 0;
                        dwAntNum = GetDevNum(dwFlag, dwCopyType);
                        CopyData cdata = new CopyData();
                        cdata.StrDevNum = dwAntNum.ToString();
                        cdata.StrUserId = row["userid"].ToString();
                        cdata.StrUserName = row["username"].ToString();
                        cdata.StrFeaturePath = row["featurePath"].ToString();

                        cdata.StrPicturePath = row["photoPath"].ToString();
                        cdata.StrCardId = row["cardId"].ToString();
                        cdata.StrCopyType = row["copyType"].ToString();
                        cdata.StrFlag = dwFlag.ToString();
                        list.Add(cdata);

                    }
                }

                // 开始同步数据
                foreach (CopyData data in list)
                {

                    if (DataCollection.MachineList.ContainsKey(data.StrDevNum))
                    {
                        EnrollUserEventArgs arg = new EnrollUserEventArgs();
                        arg.UserId = System.Convert.ToInt32(data.StrUserId);
                        arg.UserName = data.StrUserName;
                        arg.strCardNo = string.IsNullOrEmpty(data.StrCardId) ? "0000000000" : data.StrCardId;
                        arg.lPhotoType = 1;

                        arg.strBase64FeatureData = ComFunc.FileToBase64String(ref arg.lFeatureLen, data.StrFeaturePath);
                        arg.strBase64PhotoData = ComFunc.FileToBase64String(ref arg.lPhotoLen, data.StrPicturePath);

                        IMachine m = DataCollection.MachineList[data.StrDevNum];
                        m.EnrollUser(arg);

                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.LogSys("==CopyDataToDev==" + ex.Message);
            }
        }
 public int AddUserToMachine(UserInfo UserInfo)
 {
     if(Machine!=null)
     {
         EnrollUserEventArgs arg = new EnrollUserEventArgs();
         arg.UserId = System.Convert.ToInt32(UserInfo.UserId);
         arg.UserName = UserInfo.UserName;
         arg.UserType = UserInfo.Type;
         arg.CardNo = UserInfo.CardNo == string.Empty ? "0000000000" : UserInfo.CardNo;
         arg.DeptId = System.Convert.ToInt32(UserInfo.DeptId);
         arg.lPhotoType = 0;
         arg.lPhotoLen=0;
         arg.strBase64PhotoData=string.Empty;
         return Machine.ModifyUser(arg);
     }
     return 0;
 }
Example #3
0
 /// <summary>
 /// 修改用户
 /// </summary>
 /// <param name="arg"></param>
 public int ModifyUser(EnrollUserEventArgs arg)
 {
     // 修改用户数据
     return mDevObj.ModifyUser(arg.UserType, arg.UserId, arg.CardNo, 0, arg.UserName, arg.DeptId, 0, 0, arg.lPhotoType, arg.lPhotoLen, arg.strBase64PhotoData);
 }
Example #4
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="arg"></param>
 public void EnrollUser(EnrollUserEventArgs arg)
 {
     // 考勤机初始化
     try
     {
         // 修改用户数据
         int ret = mDevObj.ModifyUser(arg.UserType, arg.UserId, arg.CardNo, 0, arg.UserName, 0, 0, 0, arg.lPhotoType, arg.lPhotoLen, arg.strBase64PhotoData);
         if (ret == 0)
         {
             //修改特征数据
             mDevObj.ModifyUserFeature(arg.UserId, arg.strBase64FeatureData);
         }
     }
     catch (Exception ex)
     {
         mLastError = ex.Message;
     }
 }
Example #5
0
 public int ModifyUser(EnrollUserEventArgs arg)
 {
     return 0;
 }
Example #6
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="arg"></param>
        public void EnrollUser(EnrollUserEventArgs arg)
        {
            USER_INFO userIfo = new USER_INFO();
            userIfo.cardno = arg.CardNo;
            userIfo.deptname = arg.DeptId;
            userIfo.id = arg.UserId;
            userIfo.name = arg.UserName;
            userIfo.photo = arg.strBase64PhotoData;
            userIfo.photolen = arg.lPhotoLen;
            userIfo.phototype = (byte)arg.lPhotoType;
            userIfo.power = 0;
            userIfo.regstatus = 0;
            userIfo.status = 0;
            userIfo.type = (byte)arg.UserType;

            // 修改用户数据
            long ret = mDevObj.DEV_PutUser(mDevHandle, 105, userIfo, false);
            if (ret == 0)
            {
                FEATURE_INFO featuerInfo = new FEATURE_INFO();
                featuerInfo.feature = arg.strBase64FeatureData;
                featuerInfo.featurelen = arg.lFeatureLen;
                featuerInfo.method = 0;
                featuerInfo.version = 0;
                //修改特征数据
                long result = mDevObj.DEV_PutFeature(mDevHandle, 112, arg.UserId, featuerInfo);
            }
        }