Ejemplo n.º 1
0
        public CommandResult Update(DeviceInfo info)
        {

            DeviceInfo original = ProviderFactory.Create<IDeviceInfoProvider>(_RepoUri).GetByID(info.ID).QueryObject;
            if (original != null)
            {
                return ProviderFactory.Create<IDeviceInfoProvider>(_RepoUri).Update(info, original);
            }
            else
            {
                return new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord));
            }
        }
Ejemplo n.º 2
0
 public CommandResult Add(DeviceInfo info)
 {
     string id = ProviderFactory.Create<IStringIDCreater>(_RepoUri).CreateID("0", 4, "Reader");
     if (!string.IsNullOrEmpty(id))
     {
         info.ID = id;
         return ProviderFactory.Create<IDeviceInfoProvider>(_RepoUri).Insert(info);
     }
     else
     {
         return new CommandResult(ResultCode.Fail, "创建ID失败");
     }
 }
Ejemplo n.º 3
0
 public CommandResult Delete(DeviceInfo info)
 {
     return ProviderFactory.Create<IDeviceInfoProvider>(_RepoUri).Delete(info);
 }
  private void GetAttendanceLog(DeviceInfo device, bool onlyLatest)
  {
      ZKFingerKeeper keeper = new ZKFingerKeeper(device);
      FrmProcessing frm = new FrmProcessing();
      Action action = delegate()
      {
          frm.ShowProgress("正在连接考勤机...", 0);
          keeper.Connect();
          if (keeper.IsConnected)
          {
              try
              {
                  //清空控制器
                  frm.ShowProgress("正在获取考勤记录...", 0);
                  DatetimeRange dr = null;
                  if (onlyLatest && device.LastEventDt != null)
                  {
                      dr = new DatetimeRange(device.LastEventDt.Value.AddSeconds(1), new DateTime(2099, 12, 31)); //从最后那个时间开始获取
                  }
                  List<AttendanceLog> logs = keeper.GetAttendanceLogs(dr);
                  if (logs == null || logs.Count == 0)
                  {
                      frm.ShowProgress(string.Empty , 1);
                  }
                  else
                  {
                      frm.ShowProgress(string.Format("获取到 {0} 条考勤记录,正在努力保存考勤记录...", logs.Count), 0.99m);
                      AttendanceLogBLL bll = new AttendanceLogBLL(AppSettings.CurrentSetting.ConnectUri);
                      int count = 0;
                      foreach (AttendanceLog log in logs)
                      {
                          count++;
                          frm.ShowProgress(string.Format("正在保存第 {0} 条记录", count), (decimal)count / logs.Count);
                          CommandResult ret = bll.Add(log);
                      }
                      frm.ShowProgress(string.Empty , 1);
                      device.LastEventDt = logs.Max(it => it.ReadDateTime);
                      (new DeviceInfoBLL(AppSettings.CurrentSetting.ConnectUri)).Update(device);
                  }
              }
              catch (ThreadAbortException)
              {
              }
              catch (Exception ex)
              {
                  LJH.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
              }
              finally
              {
                  keeper.Disconnect();
              }
          }
          else
          {
              frm.ShowProgress("连接设备失败", 1);
          }
      };
      Thread t = new Thread(new ThreadStart(action));
      t.Start();
      frm.ShowDialog();
 }
 protected override Object GetItemFromInput()
 {
     DeviceInfo info;
     if (UpdatingItem == null)
     {
         info = new DeviceInfo();
         info.ForAttendance = true;
         info.GroupID = ParentGroup != null ? ParentGroup.ID : null;
     }
     else
     {
         info = UpdatingItem as DeviceInfo;
     }
     info.Name = txtName.Text;
     info.DeviceType =(DeviceType ) comDeviceType.SelectedIndex ;
     info.Communication = (CommunicationType)comCommunication.SelectedIndex;
     info.Serial = txtSerial.Text;
     if (gpTCPIP.Enabled)
     {
         info.IP = txtIP.IP;
         info.ControlPort = txtPort.IntergerValue;
         info.IPMask = txtIPMask.IP;
         info.Gateway = txtGateway.IP;
     }
     if (gpRS232.Enabled)
     {
         info.Commport = txtCommport.IntergerValue;
         info.Baud = txtBaud.IntergerValue;
         info.Address = txtAddress.IntergerValue;
     }
     info.ForAttendance = chkForAttendance.Checked;
     return info;
 }
Ejemplo n.º 6
0
 public ZKFingerKeeper(LJH.Attendance.Model.DeviceInfo para)
 {
     Parameter = para;
 }