/// <summary>
        /// 清除Preal信息
        /// </summary>
        /// <param name="id"></param>
        public static void DeletePreal(R_PrealInfo preal)
        {
            RPrealCacheDeleteRequest request = new RPrealCacheDeleteRequest();

            request.PrealInfo = preal;
            rPRealCacheService.DeleteRRealCache(request);
        }
Esempio n. 2
0
        public BasicResponse OldPlsPersonRealSync(OldPlsPersonRealSyncRequest request)
        {
            try
            {
                var req = new RPrealCacheGetAllRequest();
                var res = _RPRealCacheService.GetAllRRealCache(req);
                var allPersonRealCache = res.Data;      //所有人员实时缓存
                var info = request.Info;

                foreach (var item in info)
                {
                    R_PrealInfo personRealCache = new R_PrealInfo();
                    var         ifExist         = false;
                    if (allPersonRealCache != null)
                    {
                        personRealCache = allPersonRealCache.FirstOrDefault(a => a.Yid == item.Yid);
                        if (personRealCache != null)
                        {
                            ifExist = true;
                        }
                    }

                    if (!ifExist)
                    {
                        var req2 = new RPrealCacheAddRequest
                        {
                            PrealInfo = item
                        };
                        _RPRealCacheService.AddRRealCache(req2);
                    }
                    else
                    {
                        if (item.Bh != personRealCache.Bh || item.JobNumber != personRealCache.JobNumber ||
                            item.PersonName != personRealCache.PersonName ||
                            item.Department != personRealCache.Department ||
                            item.Duty != personRealCache.Duty ||
                            item.TypeOfWork != personRealCache.TypeOfWork ||
                            item.CurrentPosition != personRealCache.CurrentPosition ||
                            item.Rtime != personRealCache.Rtime ||
                            item.UpPosition != personRealCache.UpPosition ||
                            item.OnPosition != personRealCache.OnPosition ||
                            item.Ontime != personRealCache.Ontime ||
                            item.Rjsc != personRealCache.Rjsc || item.Bjtype != personRealCache.Bjtype || item.Flag != personRealCache.Flag)
                        {
                            var req2 = new RPrealCacheUpdateRequest
                            {
                                PrealInfo = item
                            };
                            _RPRealCacheService.UpdateRRealCahce(req2);
                        }
                    }
                }

                if (allPersonRealCache != null)
                {
                    for (var i = allPersonRealCache.Count - 1; i >= 0; i--)
                    {
                        var ifExist = info.Any(a => a.Yid == allPersonRealCache[i].Yid);
                        if (!ifExist)
                        {
                            var req3 = new RPrealCacheDeleteRequest
                            {
                                PrealInfo = allPersonRealCache[i]
                            };
                            _RPRealCacheService.DeleteRRealCache(req3);
                        }
                    }
                }

                return(new BasicResponse());
            }
            catch (Exception exc)
            {
                LogHelper.Error(exc.ToString());
                return(new BasicResponse()
                {
                    Code = 101,
                    Message = "同步失败"
                });
            }
        }