コード例 #1
0
ファイル: CardService.cs プロジェクト: dahaideyu/api
        public virtual void SynchronizationCard(string cardId)
        {
            if (Constant.Sysc)
            {
                try
                {
                    var entity = _cardRepository.GetById(cardId);


                    var person = GetPersonByCardId(cardId);
                    if (entity == null || person == null)
                    {
                        return;
                    }

                    var requestXml = GetCardXml(entity, person);
                    Log.Debug(this.GetType().ToString(), requestXml);

                    if (requestXml.IsBlank())
                    {
                        return;
                    }


                    var areaS       = new Lkb.CrkServiceImplService();
                    var responseXml = areaS.insertCrk(requestXml);
                    Log.Debug(this.GetType().ToString(), responseXml);
                    var resultRes = responseXml.Deserial <ResultResponse>();

                    var syncLog = new SyncLogEntity();
                    syncLog.SyncType    = SyncLogEnum.InsertCrk.ToString();
                    syncLog.ResquestXml = requestXml;
                    syncLog.ResponseXml = responseXml;
                    syncLog.SyncTime    = DateTime.Now;
                    syncLog.SyncResult  = 0;
                    syncLog.CommunityId = entity.CommunityUUID;

                    if (resultRes != null && resultRes.Header != null)
                    {
                        var header = resultRes.Header;
                        if (header.RspCode.Equals("0"))
                        {
                            entity.SyncVersion += 1;
                            entity.SyncStatus   = true;
                            _cardRepository.Update(entity);

                            syncLog.SyncResult = 1;
                        }
                    }

                    _syncLogService.InsertSyncLog(syncLog);
                }
                catch (Exception ex)
                {
                    Log.Error(null, ex.Message);
                }
            }
        }
コード例 #2
0
ファイル: PersonService.cs プロジェクト: dahaideyu/api
        private void Synchronization(PersonEntity entity)
        {
            if (Constant.Sysc)
            {
                try
                {
                    var requestXml = GetXml(entity);

                    if (requestXml == null)
                    {
                        return;
                    }

                    Log.Debug(this.GetType().ToString(), requestXml);

                    var areaS       = new Lkb.PersonServiceImplService();
                    var responseXml = areaS.insertPerson(requestXml);

                    Log.Debug(this.GetType().ToString(), responseXml);

                    var syncLog = new SyncLogEntity();
                    syncLog.SyncType    = SyncLogEnum.InsertPerson.ToString();
                    syncLog.ResquestXml = requestXml;
                    syncLog.ResponseXml = responseXml;
                    syncLog.SyncTime    = DateTime.Now;
                    syncLog.SyncResult  = 0;
                    syncLog.CommunityId = entity.CommunityUUID;

                    var resultRes = responseXml.Deserial <ResultResponse>();
                    if (resultRes != null && resultRes.Header != null)
                    {
                        var header = resultRes.Header;
                        if (header.RspCode.Equals("0"))
                        {
                            var entity2 = _personRepository.GetById(entity.PersonUUID);
                            entity2.SyncVersion += 1;
                            entity2.SyncStatus   = true;
                            _personRepository.Update(entity2);

                            syncLog.SyncResult = 1;
                        }
                    }

                    _syncService.InsertSyncLog(syncLog);
                }
                catch (Exception ex)
                {
                    Log.Error(null, ex.Message);
                }
            }
        }
コード例 #3
0
ファイル: DeviceStatusService.cs プロジェクト: dahaideyu/api
        private void Synchronization(DeviceStatusEntity entity)
        {
            if (Constant.Sysc)
            {
                try
                {
                    //同步设备信息是实际上同步的是门,所以要根据设备ID 查找关联的门
                    var door = _doorService.GetDoorByDevice(entity.DeviceUUID);
                    if (door == null)
                    {
                        return;
                    }

                    var requestXml = GetXml(entity, door);
                    Log.Debug(this.GetType().ToString(), requestXml);

                    var areaS       = new Lkb.DeviceStatusServiceImplService();
                    var responseXml = areaS.insertDeviceStatus(requestXml);
                    Log.Debug(this.GetType().ToString(), responseXml);
                    var resultRes = responseXml.Deserial <ResultResponse>();
                    var syncLog   = new SyncLogEntity();
                    syncLog.SyncType    = SyncLogEnum.InsertDeviceStatus.ToString();
                    syncLog.ResquestXml = requestXml;
                    syncLog.ResponseXml = responseXml;
                    syncLog.SyncTime    = DateTime.Now;
                    syncLog.SyncResult  = 0;
                    syncLog.CommunityId = "";//entity.CommunityUUID;

                    if (resultRes != null && resultRes.Header != null)
                    {
                        var header = resultRes.Header;
                        if (header.RspCode.Equals("0"))
                        {
                            var entity2 = _statusRepository.GetById(entity.DeviceUUID);
                            entity2.SyncVersion += 1;
                            entity2.SyncStatus   = true;
                            _statusRepository.Update(entity2);
                            syncLog.SyncResult = 1;
                        }
                    }
                    _syncService.InsertSyncLog(syncLog);
                }
                catch (Exception ex)
                {
                    Log.Error(null, ex.Message);
                }
            }
        }
コード例 #4
0
        private void Synchronization(DeviceAlarmEntity entity)
        {
            if (Constant.Sysc)
            {
                try
                {
                    //同步报警信息的时候需要根据设备ID找到对应的门,这里实际上是门作为设备来处理的
                    var door       = _doorService.GetById(entity.DeviceUUID);
                    var requestXml = GetXml(entity, door);
                    Log.Debug(this.GetType().ToString(), requestXml);

                    var areaS       = new Lkb.DeviceAlarmServiceImplService();
                    var responseXml = areaS.insertDeviceAlarm(requestXml);

                    Log.Debug(this.GetType().ToString(), responseXml);
                    var resultRes = responseXml.Deserial <ResultResponse>();

                    var syncLog = new SyncLogEntity();
                    syncLog.SyncType    = SyncLogEnum.InsertDeviceAlarm.ToString();
                    syncLog.ResquestXml = requestXml;
                    syncLog.ResponseXml = responseXml;
                    syncLog.SyncTime    = DateTime.Now;
                    syncLog.SyncResult  = 0;
                    syncLog.CommunityId = entity.CommunityUUID;

                    if (resultRes != null && resultRes.Header != null)
                    {
                        var header = resultRes.Header;
                        if (header.RspCode.Equals("0"))
                        {
                            var entity2 = _alarmRepository.GetById(entity.AlarmUUID);
                            entity2.SyncVersion += 1;
                            entity2.SyncStatus   = true;
                            _alarmRepository.Update(entity2);
                            syncLog.SyncResult = 1;
                        }
                    }
                    _syncService.InsertSyncLog(syncLog);
                }
                catch (Exception ex)
                {
                    Log.Error(null, ex.Message);
                }
            }
        }