コード例 #1
0
        public static Boolean CheckVersionExpires(DataVersion version)
        {
            int minVersion, maxVersion;

            ChangeLogNotifyer.GetVersionRange(version.Identifier, out minVersion, out maxVersion);
            return(version.Version < minVersion);
        }
コード例 #2
0
ファイル: LCSyncDemo.cs プロジェクト: yaotion/RunSafty_WebAPI
        public InterfaceRet GetNewestVersion(string data)
        {
            _ret.Clear();
            int minVersion, maxVersion;

            ChangeLogNotifyer.GetVersionRange(data, out minVersion, out maxVersion);
            _ret.data = maxVersion;
            return(_ret);
        }
コード例 #3
0
ファイル: LCSyncDemo.cs プロジェクト: yaotion/RunSafty_WebAPI
        /// <summary>
        /// 传入需要更新各类数据的版本号,返回最新版本号或是需要整体更新
        /// 输入参数DataVersion包含客户端数据版本号
        /// 返回DataVersion包含最新版本号
        /// 版本号为0时表示没有变动数据
        /// 版本号为-1时表示版本过期
        /// </summary>
        /// <returns></returns>
        public InterfaceRet ReadDataVersion(string data)
        {
            _ret.Clear();


            List <DataVersion> versions = Newtonsoft.Json.JsonConvert.DeserializeObject <List <DataVersion> >(data);

            int minVersion, maxVersion;


            foreach (var version in versions)
            {
                ChangeLogNotifyer.GetVersionRange(version.Identifier, out minVersion, out maxVersion);

                if (minVersion == 0 && maxVersion == 0)//没有数据变动
                {
                    version.Version = 0;
                }
                else
                if (version.Version < minVersion)    //数据版本过期
                {
                    version.Version = -1;
                }
                else
                if (version.Version > maxVersion)        //异常版本
                {
                    throw new Exception(string.Format("{0} 数据版本{1}大于服务器数据版本{2}", version.Identifier, version.Version, maxVersion));
                }
                else
                {
                    version.Version = maxVersion;
                }
            }

            _ret.data = versions;
            return(_ret);
        }