Beispiel #1
0
        /// <summary>
        /// 传入客户端数据版本号,接口判断版本是否过期,如过期则返回异常
        /// 未过期则返回变动的数据及变动类型
        /// 如变动数据量很大可只返回部分数据
        /// </summary>
        /// <returns></returns>
        public InterfaceRet ReadData(string data)
        {
            DataVersion version = Newtonsoft.Json.JsonConvert.DeserializeObject <DataVersion>(data);

            if (ChangeLogNotifyer.CheckVersionExpires(version))
            {
                throw new Exception("数据版本已过期");
            }


            ChangeLogNotifyer logNotifyer = new ChangeLogNotifyer();
            List <ChangeLog>  logs        = new List <ChangeLog>();

            logNotifyer.GetChangeLog(version.Identifier, version.Version + 1, 10, logs);

            SyncObj syncobj;

            List <SyncObj> retList = new List <SyncObj>();

            foreach (var log in logs)
            {
                syncobj = new SyncObj();
                retList.Add(syncobj);
                syncobj.Log = log;

                if (log.ChangeType != ChangeType.ctDel)
                {
                    syncobj.Obj = dbAccess.Get(log.Key);
                }
            }
            _ret.data = retList;
            return(_ret);
        }
Beispiel #2
0
        public static Boolean CheckVersionExpires(DataVersion version)
        {
            int minVersion, maxVersion;

            ChangeLogNotifyer.GetVersionRange(version.Identifier, out minVersion, out maxVersion);
            return(version.Version < minVersion);
        }